Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 189151 Details for
Bug 171019
[javadoc][select] F3 on {@inheritDoc} tag should navigate to target javadoc
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
proposed fix v1.0
patchInheritDoc.txt (text/plain), 8.97 KB, created by
Ayushman Jain
on 2011-02-17 01:30:55 EST
(
hide
)
Description:
proposed fix v1.0
Filename:
MIME Type:
Creator:
Ayushman Jain
Created:
2011-02-17 01:30:55 EST
Size:
8.97 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java,v >retrieving revision 1.158 >diff -u -r1.158 SelectionEngine.java >--- codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java 7 Apr 2010 17:22:33 -0000 1.158 >+++ codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java 16 Feb 2011 18:51:07 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2010 IBM Corporation and others. >+ * Copyright (c) 2000, 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 >@@ -1106,7 +1106,7 @@ > } > this.acceptedAnswer = true; > } else if (binding instanceof MethodBinding) { >- MethodBinding methodBinding = (MethodBinding) binding; >+ MethodBinding methodBinding = getCorrectMethodBinding((MethodBinding) binding); > this.noProposal = false; > > boolean isValuesOrValueOf = false; >@@ -1608,4 +1608,80 @@ > > return false; > } >+ >+ private MethodBinding getCorrectMethodBinding(MethodBinding binding) { >+ if (this.parser.javadocParser instanceof SelectionJavadocParser) { >+ if (((SelectionJavadocParser)this.parser.javadocParser).inheritDocTagSelected){ >+ ReferenceBinding superclass = binding.declaringClass.superclass(); >+ try { >+ MethodBinding res = null; >+ res = findOverriddenMethodInHierarchy(superclass, binding); >+ if (res != null) >+ return res; >+ if (!binding.isConstructor()) { >+ ReferenceBinding[] superInterfaces= binding.declaringClass.superInterfaces(); >+ for (int i= 0; i < superInterfaces.length; i++) { >+ res= findOverriddenMethodInHierarchy(superInterfaces[i], binding); >+ if (res != null) { >+ return res; >+ } >+ } >+ } >+ >+ } catch (JavaModelException e) { >+ return null; >+ } >+ } >+ } >+ return binding; >+ } >+ >+ private MethodBinding findOverriddenMethodInType(ReferenceBinding overriddenType, MethodBinding overriding) throws JavaModelException { >+ if (overriddenType == null) >+ return null; >+ MethodBinding[] overriddenMethods= overriddenType.availableMethods(); >+ LookupEnvironment lookupEnv = this.lookupEnvironment; >+ if (lookupEnv != null && overriddenMethods != null) { >+ for (int i= 0; i < overriddenMethods.length; i++) { >+ if (lookupEnv.methodVerifier().isMethodSubsignature(overriding, overriddenMethods[i])) { >+ return overriddenMethods[i]; >+ } >+ } >+ } >+ return null; >+ } >+ >+ /** >+ * Finds the directly overridden method in a type and its super types. First the super class is examined and then the implemented interfaces. >+ * With generics it is possible that 2 methods in the same type are overidden at the same time. In that case, the first overridden method found is returned. >+ * @param type The type to find methods in >+ * @param overriding The overriding method >+ * @return The first overridden method or <code>null</code> if no method is overridden >+ * @throws JavaModelException >+ */ >+ private MethodBinding findOverriddenMethodInHierarchy(ReferenceBinding type, MethodBinding overriding) throws JavaModelException { >+ if (type == null) >+ return null; >+ MethodBinding method= findOverriddenMethodInType(type, overriding); >+ if (method != null) { >+ return method; >+ } >+ ReferenceBinding superClass= type.superclass(); >+ if (superClass != null) { >+ MethodBinding res= findOverriddenMethodInHierarchy(superClass, overriding); >+ if (res != null) { >+ return res; >+ } >+ } >+ if (!overriding.isConstructor()) { >+ ReferenceBinding[] superInterfaces= type.superInterfaces(); >+ for (int i= 0; i < superInterfaces.length; i++) { >+ MethodBinding res= findOverriddenMethodInHierarchy(superInterfaces[i], overriding); >+ if (res != null) { >+ return res; >+ } >+ } >+ } >+ return method; >+ } > } >Index: codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionJavadoc.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionJavadoc.java,v >retrieving revision 1.7 >diff -u -r1.7 SelectionJavadoc.java >--- codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionJavadoc.java 7 Mar 2009 01:08:06 -0000 1.7 >+++ codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionJavadoc.java 16 Feb 2011 18:51:07 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2009 IBM Corporation and others. >+ * Copyright (c) 2000, 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 >@@ -11,6 +11,7 @@ > package org.eclipse.jdt.internal.codeassist.select; > > import org.eclipse.jdt.internal.compiler.ast.*; >+import org.eclipse.jdt.internal.compiler.impl.ReferenceContext; > import org.eclipse.jdt.internal.compiler.lookup.*; > > /** >@@ -19,9 +20,11 @@ > public class SelectionJavadoc extends Javadoc { > > Expression selectedNode; >+ boolean inheritDocSelected; > > public SelectionJavadoc(int sourceStart, int sourceEnd) { > super(sourceStart, sourceEnd); >+ this.inheritDocSelected = false; > } > > /* (non-Javadoc) >@@ -106,6 +109,11 @@ > binding = this.selectedNode.resolvedType; > } > throw new SelectionNodeFound(binding); >+ } else if (this.inheritDocSelected) { >+ ReferenceContext referenceContext = scope.referenceContext(); >+ if (referenceContext instanceof MethodDeclaration) { >+ throw new SelectionNodeFound(((MethodDeclaration) referenceContext).binding); >+ } > } > } > >Index: codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionJavadocParser.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionJavadocParser.java,v >retrieving revision 1.9 >diff -u -r1.9 SelectionJavadocParser.java >--- codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionJavadocParser.java 7 Mar 2009 01:08:06 -0000 1.9 >+++ codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionJavadocParser.java 16 Feb 2011 18:51:07 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2009 IBM Corporation and others. >+ * Copyright (c) 2000, 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 >@@ -25,12 +25,14 @@ > int selectionStart; > int selectionEnd; > ASTNode selectedNode; >+ public boolean inheritDocTagSelected; > > public SelectionJavadocParser(SelectionParser sourceParser) { > super(sourceParser); > this.shouldReportProblems = false; > this.reportProblems = false; > this.kind = SELECTION_PARSER | TEXT_PARSE; >+ this.inheritDocTagSelected = false; > } > > /* >@@ -186,6 +188,13 @@ > protected void updateDocComment() { > if (this.selectedNode instanceof Expression) { > ((SelectionJavadoc) this.docComment).selectedNode = (Expression) this.selectedNode; >+ } else if (this.inheritDocTagSelected) { >+ ((SelectionJavadoc) this.docComment).inheritDocSelected = true; > } > } >+ >+ protected void parseInheritDocTag() { >+ if (this.tagSourceStart == this.selectionStart && this.tagSourceEnd == this.selectionEnd) >+ this.inheritDocTagSelected = true; >+ } > } >Index: compiler/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java,v >retrieving revision 1.80 >diff -u -r1.80 JavadocParser.java >--- compiler/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java 8 Feb 2011 05:16:20 -0000 1.80 >+++ compiler/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java 16 Feb 2011 18:51:07 -0000 >@@ -568,6 +568,7 @@ > if (this.reportProblems) { > recordInheritedPosition((((long) this.tagSourceStart) << 32) + this.tagSourceEnd); > } >+ parseInheritDocTag(); > break; > default: > valid = false; >@@ -692,6 +693,10 @@ > return valid; > } > >+ protected void parseInheritDocTag() { >+ // do nothing >+ } >+ > /* > * Parse @param tag declaration and flag missing description if corresponding option is enabled > */
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 171019
:
189151
|
189479
|
189586