* @since 3.0
*/
protected void updateOccurrenceAnnotations(ITextSelection selection) {// ,
- // CompilationUnit
- // astRoot)
- // {
+ // CompilationUnit
+ // astRoot)
+ // {
if (fOccurrencesFinderJob != null)
fOccurrencesFinderJob.cancel();
fMarkOccurrenceModificationStamp = currentModificationStamp;
}
- if (fMarkOccurrenceTargetRegion == null || fMarkOccurrenceTargetRegion.getLength()==0) {
+ if (fMarkOccurrenceTargetRegion == null || fMarkOccurrenceTargetRegion.getLength() == 0) {
return;
}
Scanner fScanner = new Scanner();
fScanner.setSource(document.get().toCharArray());
fScanner.setPHPMode(false);
+ String wordStr;
char[] word;
- word = document.get(fMarkOccurrenceTargetRegion.getOffset(), fMarkOccurrenceTargetRegion.getLength()).toCharArray();
-
- int fToken = ITerminalSymbols.TokenNameEOF;
- try {
- fToken = fScanner.getNextToken();
- while (fToken != ITerminalSymbols.TokenNameEOF) { // && fToken !=
- // TokenNameERROR) {
- if (fToken == ITerminalSymbols.TokenNameVariable || fToken == ITerminalSymbols.TokenNameIdentifier) {
- // global variable
- if (fScanner.equalsCurrentTokenSource(word)) {
- matches.add(new Region(fScanner.getCurrentTokenStartPosition(), fScanner.getCurrentTokenEndPosition()
- - fScanner.getCurrentTokenStartPosition() + 1));
+ wordStr = document.get(fMarkOccurrenceTargetRegion.getOffset(), fMarkOccurrenceTargetRegion.getLength());
+ if (wordStr != null) {
+ word = wordStr.toCharArray();
+ int fToken = ITerminalSymbols.TokenNameEOF;
+ try {
+ fToken = fScanner.getNextToken();
+ while (fToken != ITerminalSymbols.TokenNameEOF) { // && fToken !=
+ // TokenNameERROR) {
+ if (fToken == ITerminalSymbols.TokenNameVariable || fToken == ITerminalSymbols.TokenNameIdentifier) {
+ // global variable
+ if (fScanner.equalsCurrentTokenSource(word)) {
+ matches.add(new Region(fScanner.getCurrentTokenStartPosition(), fScanner.getCurrentTokenEndPosition()
+ - fScanner.getCurrentTokenStartPosition() + 1));
+ }
}
+ fToken = fScanner.getNextToken();
}
- fToken = fScanner.getNextToken();
+ } catch (InvalidInputException e) {
+ // ignore errors
+ } catch (SyntaxError e) {
+ // ignore errors
}
- } catch (InvalidInputException e) {
- // ignore errors
- } catch (SyntaxError e) {
- // ignore errors
}
-
} catch (BadLocationException e1) {
// ignore errors
} catch (Exception e) {
fPostSelectionListenerWithAST = new ISelectionListenerWithAST() {
public void selectionChanged(IEditorPart part, ITextSelection selection) { // ,
- // CompilationUnit
- // astRoot)
- // {
+ // CompilationUnit
+ // astRoot)
+ // {
updateOccurrenceAnnotations(selection);// , astRoot);
}
};