removeAnnotations(myAnnotations.keySet());
}
RutaSelectionParser parser = new RutaSelectionParser();
ISourceModule unit = (ISourceModule) getInputModelElement();
ModuleDeclaration parsed = parser.parse(unit);
ISourceViewer sourceViewer = getSourceViewer();
StyledText styledText = sourceViewer.getTextWidget();
int caret = 0;
if (sourceViewer instanceof ITextViewerExtension5) {
ITextViewerExtension5 extension = (ITextViewerExtension5) sourceViewer;
caret = extension.widgetOffset2ModelOffset(styledText.getCaretOffset());
} else {
int offset = sourceViewer.getVisibleRegion().getOffset();
caret = offset + styledText.getCaretOffset();
}
RutaReferenceVisitor visitor1 = new RutaReferenceVisitor(caret);
ASTNode node = null;
try {
parsed.traverse(visitor1);
} catch (Exception e) {
}
node = visitor1.getResult();
if (node == null) {
RutaReferenceDeclarationVisitor visitor2 = new RutaReferenceDeclarationVisitor(
caret);
try {
parsed.traverse(visitor2);
} catch (Exception e) {
}
node = visitor2.getResult();
}
if (node != null) {
ReferenceFinder refFinder = new ReferenceFinder(node);
try {
parsed.traverse(refFinder);
} catch (Exception e) {
}
List<ASTNode> result = refFinder.getResult();
myAnnotations = new HashMap<Annotation, Position>(result.size());
for (ASTNode each : result) {