Project: JDT
Bug 376779 [navigation] JavaElementHyperlinkDetector#detectHyperlinks(..) is wasting time
Reported: 2012-04-13 15:35:12 | Status: resolved fixed

Navigation via Ctrl+Hyperlinks is very slow in medium-sized classes, e.g. LocalCorrectionsSubProcessor. When I hold Ctrl and move the mouse, I see update times of almost a second. Most of the time is wasted in repeated calls to JavaElementHyperlinkDetector#detectHyperlinks(..). The two major factors are: 1. All 4 subclasses of JavaElementHyperlinkDetector perform ICodeAssist#codeSelect(..) again on the same element. 2. ICodeAssist#codeSelect(..) is already quite slow, since it often has to compile large parts of the AST and resolve many bindings (I think not using star imports adds to this). We should consider adding a wrapper around calls to codeSelect and first see if we already have a shared AST available for free. If we find a SimpleName without recovered/malformed parents, we should just use resolveBinding().getJavaElement() and keep codeSelect as a fallback.

Files changed in fix:
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementHyperlinkDetector.java