1 8 9 package org.netbeans.modules.tasklist.checkstyle; 10 11 import javax.swing.text.BadLocationException ; 12 import javax.swing.text.Document ; 13 import javax.swing.text.Element ; 14 import org.openide.ErrorManager; 15 16 21 public final class InsertFinalVariableKeywordSuggestionPerformer extends AbstractSuggestionPerformer{ 22 23 24 public InsertFinalVariableKeywordSuggestionPerformer( 25 final Document doc, 26 final int lineno, 27 final int column) { 28 29 super(doc,lineno,column); 30 } 31 32 protected void performImpl(final int docPosition) throws BadLocationException { 33 34 final Element elm = getElement(doc, lineno-1); 35 if (elm == null) { 36 ErrorManager.getDefault().log(ErrorManager.USER, "getElement was null"); 37 return; 38 } 39 40 int wsStart = docPosition - 2; 41 try { 42 while( !Character.isJavaIdentifierPart( doc.getText(wsStart,1).charAt(0) ) ){ 44 --wsStart; 45 } 46 while( Character.isJavaIdentifierStart( doc.getText(wsStart,1).charAt(0) ) ){ 48 --wsStart; 49 } 50 } catch (BadLocationException ex) { 51 ErrorManager.getDefault().notify(ErrorManager.WARNING, ex); 52 } 53 doc.insertString(wsStart+1 ,"final ",null); 54 } 55 56 } 57 | Popular Tags |