[Title] WTP : fixed bugs for Open Declaration.
authorSujin Kim <sujin921.kim@samsung.com>
Fri, 15 Mar 2013 09:02:20 +0000 (18:02 +0900)
committerSujin Kim <sujin921.kim@samsung.com>
Fri, 15 Mar 2013 09:02:20 +0000 (18:02 +0900)
[Desc.] fixed bugs for highlighting of Declaration in <script> tag on
HTML file.
[Issue] REDMINE-8591

org.eclipse.wst.jsdt.web.ui.patch/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/JSDTHyperlinkDetector.java
org.eclipse.wst.jsdt.web.ui.patch/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/WorkspaceFileHyperlink.java

index 2193098..debd073 100644 (file)
@@ -30,6 +30,7 @@ import org.eclipse.wst.jsdt.core.IFunction;
 import org.eclipse.wst.jsdt.core.IJavaScriptElement;
 import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
 import org.eclipse.wst.jsdt.core.ILocalVariable;
+import org.eclipse.wst.jsdt.core.IMember;
 import org.eclipse.wst.jsdt.core.ISourceRange;
 import org.eclipse.wst.jsdt.core.ISourceReference;
 import org.eclipse.wst.jsdt.core.JavaScriptModelException;
@@ -113,14 +114,18 @@ public class JSDTHyperlinkDetector extends AbstractHyperlinkDetector {
                                                else if (element.getElementType() == IJavaScriptElement.FIELD) {
                                                        Object cu = ((IField) element).getJavaScriptUnit();
                                                        if (cu != null && cu.equals(jspTranslation.getCompilationUnit())) {
-                                                               range = ((ISourceReference) element).getSourceRange();
+                                                               // Fixed bug for RM 8591
+                                                               // range = ((ISourceReference) element).getSourceRange();
+                                                               range = ((IMember) element).getNameRange();
                                                        }
                                                }
                                                // linking to methods of the same compilation unit
                                                else if (element.getElementType() == IJavaScriptElement.METHOD) {
                                                        Object cu = ((IFunction) element).getJavaScriptUnit();
                                                        if (cu != null && cu.equals(jspTranslation.getCompilationUnit())) {
-                                                               range = ((ISourceReference) element).getSourceRange();
+                                                               // Fixed bug for RM 8591
+                                                               // range = ((ISourceReference) element).getSourceRange();
+                                                               range = ((IMember) element).getNameRange();
                                                        }
                                                }
                                        }
index ea48fbb..da1ee7c 100644 (file)
@@ -22,6 +22,7 @@ import org.eclipse.ui.ide.IDE;
 import org.eclipse.ui.texteditor.ITextEditor;
 import org.eclipse.wst.html.ui.internal.HTMLUIMessages;
 import org.eclipse.wst.jsdt.web.ui.internal.Logger;
+import org.eclipse.wst.sse.ui.StructuredTextEditor;
 
 class WorkspaceFileHyperlink implements IHyperlink {
        // copies of this class exist in:
@@ -76,8 +77,15 @@ class WorkspaceFileHyperlink implements IHyperlink {
                                IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
                                IEditorPart editor = IDE.openEditor(page, fFile, true);
                                // highlight range in editor if possible
+                               
+                               // Fixed bug for RM 8591
                                if (fHighlightRange != null && editor instanceof ITextEditor) {
                                        ((ITextEditor) editor).selectAndReveal(fHighlightRange.getOffset(), fHighlightRange.getLength());
+                               } else {
+                                       Object ste = editor.getAdapter(StructuredTextEditor.class);
+                                       if (fHighlightRange != null && ste instanceof ITextEditor) {
+                                               ((ITextEditor) ste).selectAndReveal(fHighlightRange.getOffset(), fHighlightRange.getLength());
+                                       }
                                }
                        } catch (PartInitException pie) {
                                Logger.log(Logger.WARNING_DEBUG, pie.getMessage(), pie);