[331844] Open Declaration (F3) on "request" identifier in Java code fragments is being handled incorrectly
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/hyperlink/JSPJavaHyperlinkDetector.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/hyperlink/JSPJavaHyperlinkDetector.java
index 846dee2..f4059db 100644
--- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/hyperlink/JSPJavaHyperlinkDetector.java
+++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/hyperlink/JSPJavaHyperlinkDetector.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2007 IBM Corporation and others.
+ * Copyright (c) 2006, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -49,6 +49,7 @@
IHyperlink link = null;
if (region != null) {
// open local variable in the JSP file...
+ boolean isInTranslationCU = false;
if (element instanceof ISourceReference) {
IFile file = null;
int jspOffset = 0;
@@ -79,18 +80,25 @@
// link to local variable definitions
if (element instanceof ILocalVariable) {
range = ((ILocalVariable) element).getNameRange();
+ Object cu = ((ILocalVariable) element).getDeclaringMember().getCompilationUnit();
+ if (cu != null && cu.equals(jspTranslation.getCompilationUnit()))
+ isInTranslationCU = true;
}
// linking to fields of the same compilation unit
else if (element.getElementType() == IJavaElement.FIELD) {
Object cu = ((IField) element).getCompilationUnit();
- if (cu != null && cu.equals(jspTranslation.getCompilationUnit()))
+ if (cu != null && cu.equals(jspTranslation.getCompilationUnit())) {
range = ((ISourceReference) element).getSourceRange();
+ isInTranslationCU = true;
+ }
}
// linking to methods of the same compilation unit
else if (element.getElementType() == IJavaElement.METHOD) {
Object cu = ((IMethod) element).getCompilationUnit();
- if (cu != null && cu.equals(jspTranslation.getCompilationUnit()))
+ if (cu != null && cu.equals(jspTranslation.getCompilationUnit())) {
range = ((ISourceReference) element).getSourceRange();
+ isInTranslationCU = true;
+ }
}
}
@@ -105,7 +113,7 @@
Logger.log(Logger.WARNING_DEBUG, jme.getMessage(), jme);
}
}
- if (link == null) {
+ if (link == null && !isInTranslationCU) { // Don't try to open the translation CU
link = new JSPJavaHyperlink(region, element);
}
}