Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Keller2014-01-20 13:20:15 +0000
committerMarkus Keller2014-02-08 00:15:34 +0000
commitf9694bfb4ba224ca3ff558a3eef89f9433b055e5 (patch)
treedd875fabd98af1c31c9604501cd37c1ac014e6f4
parent815164b3b52c2daf5d745ad9399c77ceb9c881fa (diff)
downloadeclipse.jdt.ui-f9694bfb4ba224ca3ff558a3eef89f9433b055e5.tar.gz
eclipse.jdt.ui-f9694bfb4ba224ca3ff558a3eef89f9433b055e5.tar.xz
eclipse.jdt.ui-f9694bfb4ba224ca3ff558a3eef89f9433b055e5.zip
Bug 407056: [1.8] Support NameQualifiedType AST node
-rw-r--r--org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/dom/ASTNodes.java21
-rw-r--r--org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/PotentialProgrammingProblemsFix.java2
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/flow/FlowAnalyzer.java10
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/CopyQualifiedNameAction.java14
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightings.java142
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ASTResolving.java15
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java4
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavadocHover.java20
8 files changed, 78 insertions, 150 deletions
diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/dom/ASTNodes.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/dom/ASTNodes.java
index 4093289be5..a75006b510 100644
--- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/dom/ASTNodes.java
+++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/dom/ASTNodes.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2014 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
@@ -939,23 +939,6 @@ public class ASTNodes {
}
}
- public static SimpleType getLeftMostSimpleType(QualifiedType type) {
- final SimpleType[] result= new SimpleType[1];
- ASTVisitor visitor= new ASTVisitor() {
- @Override
- public boolean visit(QualifiedType qualifiedType) {
- Type left= qualifiedType.getQualifier();
- if (left instanceof SimpleType)
- result[0]= (SimpleType)left;
- else
- left.accept(this);
- return false;
- }
- };
- type.accept(visitor);
- return result[0];
- }
-
/**
* Returns the topmost ancestor of <code>name</code> that is still a {@link Name}.
* <p>
@@ -963,6 +946,7 @@ public class ASTNodes {
*
* @param name a name node
* @return the topmost name
+ * @see #getNormalizedNode(ASTNode)
*/
public static Name getTopMostName(Name name) {
Name result= name;
@@ -979,6 +963,7 @@ public class ASTNodes {
*
* @param node the starting node, can be <code>null</code>
* @return the topmost type or <code>null</code> if the node is not a descendant of a type node
+ * @see #getNormalizedNode(ASTNode)
*/
public static Type getTopMostType(ASTNode node) {
ASTNode result= null;
diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/PotentialProgrammingProblemsFix.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/PotentialProgrammingProblemsFix.java
index bfade420eb..da2dee3684 100644
--- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/PotentialProgrammingProblemsFix.java
+++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/PotentialProgrammingProblemsFix.java
@@ -391,6 +391,8 @@ public class PotentialProgrammingProblemsFix extends CompilationUnitRewriteOpera
name= ((SimpleType) selection).getName();
} else if (selection instanceof NameQualifiedType) {
name= ((NameQualifiedType) selection).getName();
+ } else if (selection instanceof QualifiedType) {
+ name= ((QualifiedType) selection).getName();
} else if (selection instanceof ParameterizedType) {
final ParameterizedType type= (ParameterizedType) selection;
final Type raw= type.getType();
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/flow/FlowAnalyzer.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/flow/FlowAnalyzer.java
index a2a2fcc90e..cb2e1aee6c 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/flow/FlowAnalyzer.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/flow/FlowAnalyzer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2014 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
@@ -69,6 +69,7 @@ import org.eclipse.jdt.core.dom.MemberValuePair;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.MethodInvocation;
import org.eclipse.jdt.core.dom.Name;
+import org.eclipse.jdt.core.dom.NameQualifiedType;
import org.eclipse.jdt.core.dom.NormalAnnotation;
import org.eclipse.jdt.core.dom.NullLiteral;
import org.eclipse.jdt.core.dom.NumberLiteral;
@@ -725,6 +726,13 @@ abstract class FlowAnalyzer extends GenericVisitor {
}
@Override
+ public void endVisit(NameQualifiedType node) {
+ if (skipNode(node))
+ return;
+ processSequential(node, node.getQualifier(), node.getName());
+ }
+
+ @Override
public void endVisit(NormalAnnotation node) {
if (skipNode(node))
return;
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/CopyQualifiedNameAction.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/CopyQualifiedNameAction.java
index 22938bbe98..b95b3dcacc 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/CopyQualifiedNameAction.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/CopyQualifiedNameAction.java
@@ -67,16 +67,16 @@ import org.eclipse.jdt.core.dom.MemberValuePair;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.MethodInvocation;
import org.eclipse.jdt.core.dom.Name;
-import org.eclipse.jdt.core.dom.NameQualifiedType;
import org.eclipse.jdt.core.dom.NodeFinder;
import org.eclipse.jdt.core.dom.PackageDeclaration;
-import org.eclipse.jdt.core.dom.SimpleType;
import org.eclipse.jdt.core.dom.StructuralPropertyDescriptor;
import org.eclipse.jdt.core.dom.Type;
import org.eclipse.jdt.core.dom.TypeDeclaration;
import org.eclipse.jdt.core.dom.TypeParameter;
import org.eclipse.jdt.core.dom.VariableDeclaration;
+import org.eclipse.jdt.internal.corext.dom.ASTNodes;
+
import org.eclipse.jdt.ui.JavaElementLabels;
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jdt.ui.SharedASTProvider;
@@ -365,12 +365,10 @@ public class CopyQualifiedNameAction extends SelectionDispatchAction {
* @since 3.7
*/
private IBinding getConstructorBindingIfAvailable(Name nameNode) {
- StructuralPropertyDescriptor loc= nameNode.getLocationInParent();
- if (loc == SimpleType.NAME_PROPERTY || loc == NameQualifiedType.NAME_PROPERTY) {
- ASTNode parent= nameNode.getParent();
- loc= parent.getLocationInParent();
- if (loc == ClassInstanceCreation.TYPE_PROPERTY)
- return ((ClassInstanceCreation)parent.getParent()).resolveConstructorBinding();
+ ASTNode type= ASTNodes.getNormalizedNode(nameNode);
+ StructuralPropertyDescriptor loc= type.getLocationInParent();
+ if (loc == ClassInstanceCreation.TYPE_PROPERTY) {
+ return ((ClassInstanceCreation) type.getParent()).resolveConstructorBinding();
}
return null;
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightings.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightings.java
index d669fe188c..ad97386eb3 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightings.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightings.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2014 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
@@ -35,18 +35,18 @@ import org.eclipse.jdt.core.dom.InfixExpression;
import org.eclipse.jdt.core.dom.MemberValuePair;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.Modifier;
+import org.eclipse.jdt.core.dom.NameQualifiedType;
import org.eclipse.jdt.core.dom.ParameterizedType;
import org.eclipse.jdt.core.dom.PrefixExpression;
import org.eclipse.jdt.core.dom.QualifiedName;
-import org.eclipse.jdt.core.dom.QualifiedType;
import org.eclipse.jdt.core.dom.SimpleName;
import org.eclipse.jdt.core.dom.SimpleType;
import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
import org.eclipse.jdt.core.dom.StructuralPropertyDescriptor;
-import org.eclipse.jdt.core.dom.Type;
import org.eclipse.jdt.core.dom.VariableDeclaration;
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
+import org.eclipse.jdt.internal.corext.dom.ASTNodes;
import org.eclipse.jdt.internal.corext.dom.Bindings;
import org.eclipse.jdt.ui.PreferenceConstants;
@@ -480,12 +480,15 @@ public class SemanticHighlightings {
return isAutoUnBoxingExpression((Expression) parent);
}
// B) constructor invocations
- if (desc == SimpleType.NAME_PROPERTY || desc == QualifiedType.NAME_PROPERTY) {
+ if (desc == QualifiedName.NAME_PROPERTY) {
+ node= (Expression) node.getParent();
+ desc= node.getLocationInParent();
+ }
+ if (desc == SimpleType.NAME_PROPERTY || desc == NameQualifiedType.NAME_PROPERTY) {
ASTNode parent= node.getParent();
if (parent != null && parent.getLocationInParent() == ClassInstanceCreation.TYPE_PROPERTY) {
parent= parent.getParent();
- if (parent instanceof Expression)
- return isAutoUnBoxingExpression((Expression) parent);
+ return isAutoUnBoxingExpression((ClassInstanceCreation) parent);
}
}
return false;
@@ -908,54 +911,9 @@ public class SemanticHighlightings {
*/
@Override
public boolean consumes(SemanticToken token) {
- IBinding binding= getMethodBinding(token);
+ IBinding binding= getBinding(token);
return binding != null && binding.getKind() == IBinding.METHOD;
}
-
- /**
- * Extracts the method binding from the token's simple name. The method
- * binding is either the token's binding (if the parent of token is a
- * method call or declaration) or the constructor binding of a class
- * instance creation if the node is the type name of a class instance
- * creation.
- *
- * @param token the token to extract the method binding from
- * @return the corresponding method binding, or <code>null</code>
- */
- private IBinding getMethodBinding(SemanticToken token) {
- IBinding binding= null;
- // work around: https://bugs.eclipse.org/bugs/show_bug.cgi?id=62605
- ASTNode node= token.getNode();
- ASTNode parent= node.getParent();
- while (isTypePath(node, parent)) {
- node= parent;
- parent= parent.getParent();
- }
-
- if (parent != null && node.getLocationInParent() == ClassInstanceCreation.TYPE_PROPERTY)
- binding= ((ClassInstanceCreation) parent).resolveConstructorBinding();
- else
- binding= token.getBinding();
- return binding;
- }
-
- /**
- * Returns <code>true</code> if the given child/parent nodes are valid
- * sub nodes of a <code>Type</code> ASTNode.
- * @param child the child node
- * @param parent the parent node
- * @return <code>true</code> if the nodes may be the sub nodes of a type node, false otherwise
- */
- private boolean isTypePath(ASTNode child, ASTNode parent) {
- if (parent instanceof Type) {
- StructuralPropertyDescriptor location= child.getLocationInParent();
- return location == ParameterizedType.TYPE_PROPERTY || location == SimpleType.NAME_PROPERTY;
- } else if (parent instanceof QualifiedName) {
- StructuralPropertyDescriptor location= child.getLocationInParent();
- return location == QualifiedName.NAME_PROPERTY;
- }
- return false;
- }
}
/**
@@ -1230,7 +1188,7 @@ public class SemanticHighlightings {
*/
@Override
public boolean consumes(SemanticToken token) {
- IBinding binding= getMethodBinding(token);
+ IBinding binding= getBinding(token);
if (binding != null) {
if (binding.isDeprecated())
return true;
@@ -1251,51 +1209,6 @@ public class SemanticHighlightings {
}
return false;
}
-
- /**
- * Extracts the method binding from the token's simple name. The method
- * binding is either the token's binding (if the parent of token is a
- * method call or declaration) or the constructor binding of a class
- * instance creation if the node is the type name of a class instance
- * creation.
- *
- * @param token the token to extract the method binding from
- * @return the corresponding method binding, or <code>null</code>
- */
- private IBinding getMethodBinding(SemanticToken token) {
- IBinding binding= null;
- // work around: https://bugs.eclipse.org/bugs/show_bug.cgi?id=62605
- ASTNode node= token.getNode();
- ASTNode parent= node.getParent();
- while (isTypePath(node, parent)) {
- node= parent;
- parent= parent.getParent();
- }
-
- if (parent != null && node.getLocationInParent() == ClassInstanceCreation.TYPE_PROPERTY)
- binding= ((ClassInstanceCreation) parent).resolveConstructorBinding();
- else
- binding= token.getBinding();
- return binding;
- }
-
- /**
- * Returns <code>true</code> if the given child/parent nodes are valid
- * sub nodes of a <code>Type</code> ASTNode.
- * @param child the child node
- * @param parent the parent node
- * @return <code>true</code> if the nodes may be the sub nodes of a type node, false otherwise
- */
- private boolean isTypePath(ASTNode child, ASTNode parent) {
- if (parent instanceof Type) {
- StructuralPropertyDescriptor location= child.getLocationInParent();
- return location == ParameterizedType.TYPE_PROPERTY || location == SimpleType.NAME_PROPERTY;
- } else if (parent instanceof QualifiedName) {
- StructuralPropertyDescriptor location= child.getLocationInParent();
- return location == QualifiedName.NAME_PROPERTY;
- }
- return false;
- }
}
/**
@@ -2191,9 +2104,9 @@ public class SemanticHighlightings {
String italickey= PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + METHOD + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ITALIC_SUFFIX;
String enabledkey= PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + METHOD + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED_SUFFIX;
- String oldColorkey= PreferenceConstants.EDITOR_JAVA_METHOD_NAME_COLOR;
- String oldBoldkey= PreferenceConstants.EDITOR_JAVA_METHOD_NAME_BOLD;
- String oldItalickey= PreferenceConstants.EDITOR_JAVA_METHOD_NAME_ITALIC;
+ @SuppressWarnings("deprecation") String oldColorkey= PreferenceConstants.EDITOR_JAVA_METHOD_NAME_COLOR;
+ @SuppressWarnings("deprecation") String oldBoldkey= PreferenceConstants.EDITOR_JAVA_METHOD_NAME_BOLD;
+ @SuppressWarnings("deprecation") String oldItalickey= PreferenceConstants.EDITOR_JAVA_METHOD_NAME_ITALIC;
if (conditionalReset(store, oldColorkey, colorkey)
|| conditionalReset(store, oldBoldkey, boldkey)
@@ -2225,11 +2138,11 @@ public class SemanticHighlightings {
String underlineKey= PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + ANNOTATION + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_UNDERLINE_SUFFIX;
String enabledkey= PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + ANNOTATION + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED_SUFFIX;
- String oldColorkey= PreferenceConstants.EDITOR_JAVA_ANNOTATION_COLOR;
- String oldBoldkey= PreferenceConstants.EDITOR_JAVA_ANNOTATION_BOLD;
- String oldItalickey= PreferenceConstants.EDITOR_JAVA_ANNOTATION_ITALIC;
- String oldStrikethroughKey= PreferenceConstants.EDITOR_JAVA_ANNOTATION_STRIKETHROUGH;
- String oldUnderlineKey= PreferenceConstants.EDITOR_JAVA_ANNOTATION_UNDERLINE;
+ @SuppressWarnings("deprecation") String oldColorkey= PreferenceConstants.EDITOR_JAVA_ANNOTATION_COLOR;
+ @SuppressWarnings("deprecation") String oldBoldkey= PreferenceConstants.EDITOR_JAVA_ANNOTATION_BOLD;
+ @SuppressWarnings("deprecation") String oldItalickey= PreferenceConstants.EDITOR_JAVA_ANNOTATION_ITALIC;
+ @SuppressWarnings("deprecation") String oldStrikethroughKey= PreferenceConstants.EDITOR_JAVA_ANNOTATION_STRIKETHROUGH;
+ @SuppressWarnings("deprecation") String oldUnderlineKey= PreferenceConstants.EDITOR_JAVA_ANNOTATION_UNDERLINE;
if (conditionalReset(store, oldColorkey, colorkey)
|| conditionalReset(store, oldBoldkey, boldkey)
@@ -2287,6 +2200,23 @@ public class SemanticHighlightings {
}
/**
+ * Extracts the binding from the token's simple name.
+ * Works around bug 62605 to return the correct constructor binding in a ClassInstanceCreation.
+ *
+ * @param token the token to extract the binding from
+ * @return the token's binding, or <code>null</code>
+ */
+ private static IBinding getBinding(SemanticToken token) {
+ ASTNode node= token.getNode();
+ ASTNode normalized= ASTNodes.getNormalizedNode(node);
+ if (normalized.getLocationInParent() == ClassInstanceCreation.TYPE_PROPERTY) {
+ // work around: https://bugs.eclipse.org/bugs/show_bug.cgi?id=62605
+ return ((ClassInstanceCreation) normalized.getParent()).resolveConstructorBinding();
+ }
+ return token.getBinding();
+ }
+
+ /**
* Do not instantiate
*/
private SemanticHighlightings() {
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ASTResolving.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ASTResolving.java
index 98b4b1bbc7..aef460bce3 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ASTResolving.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ASTResolving.java
@@ -470,6 +470,16 @@ public class ASTResolving {
}
return parentBinding;
}
+ case ASTNode.NAME_QUALIFIED_TYPE: {
+ ITypeBinding parentBinding= getPossibleTypeBinding(parent);
+ if (parentBinding == null || !parentBinding.isMember()) {
+ return null;
+ }
+ if (node.getLocationInParent() == NameQualifiedType.QUALIFIER_PROPERTY) {
+ return parentBinding.getDeclaringClass();
+ }
+ return parentBinding;
+ }
case ASTNode.VARIABLE_DECLARATION_STATEMENT:
return guessVariableType(((VariableDeclarationStatement) parent).fragments());
case ASTNode.FIELD_DECLARATION:
@@ -828,6 +838,11 @@ public class ASTResolving {
return mask & (SimilarElementsRequestor.REF_TYPES);
}
mask&= SimilarElementsRequestor.REF_TYPES;
+ } else if (parent instanceof NameQualifiedType) {
+ if (node.getLocationInParent() == NameQualifiedType.QUALIFIER_PROPERTY) {
+ return mask & (SimilarElementsRequestor.REF_TYPES);
+ }
+ mask&= SimilarElementsRequestor.REF_TYPES;
} else if (parent instanceof ParameterizedType) {
if (node.getLocationInParent() == ParameterizedType.TYPE_ARGUMENTS_PROPERTY) {
return mask & SimilarElementsRequestor.REF_TYPES_AND_VAR;
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java
index 2b2a7df549..8934f6fe27 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java
@@ -850,7 +850,9 @@ public class UnresolvedElementsSubProcessor {
if (proposal instanceof AddImportCorrectionProposal)
proposal.setRelevance(relevance + elements.length + 2);
- if (binding.isParameterizedType() && (node.getParent() instanceof SimpleType || node.getParent() instanceof NameQualifiedType) && !(node.getParent().getParent() instanceof Type)) {
+ if (binding.isParameterizedType()
+ && (node.getParent() instanceof SimpleType || node.getParent() instanceof NameQualifiedType)
+ && !(node.getParent().getParent() instanceof Type)) {
proposals.add(createTypeRefChangeFullProposal(cu, binding, node, relevance + 5));
}
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavadocHover.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavadocHover.java
index 1f97ac931f..f2634d4f17 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavadocHover.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavadocHover.java
@@ -87,14 +87,8 @@ import org.eclipse.jdt.core.dom.IMemberValuePairBinding;
import org.eclipse.jdt.core.dom.IMethodBinding;
import org.eclipse.jdt.core.dom.ITypeBinding;
import org.eclipse.jdt.core.dom.IVariableBinding;
-import org.eclipse.jdt.core.dom.NameQualifiedType;
import org.eclipse.jdt.core.dom.NodeFinder;
-import org.eclipse.jdt.core.dom.ParameterizedType;
-import org.eclipse.jdt.core.dom.QualifiedName;
-import org.eclipse.jdt.core.dom.QualifiedType;
import org.eclipse.jdt.core.dom.SimpleName;
-import org.eclipse.jdt.core.dom.SimpleType;
-import org.eclipse.jdt.core.dom.StructuralPropertyDescriptor;
import org.eclipse.jdt.core.dom.SuperConstructorInvocation;
import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants;
@@ -1044,17 +1038,11 @@ public class JavadocHover extends AbstractJavaEditorTextHover {
private static IBinding resolveBinding(ASTNode node) {
if (node instanceof SimpleName) {
- // workaround for https://bugs.eclipse.org/62605 (constructor name resolves to type, not method)
SimpleName simpleName= (SimpleName) node;
- StructuralPropertyDescriptor loc= simpleName.getLocationInParent();
- while (loc == QualifiedType.NAME_PROPERTY || loc == QualifiedName.NAME_PROPERTY
- || loc == SimpleType.NAME_PROPERTY || loc == NameQualifiedType.NAME_PROPERTY
- || loc == ParameterizedType.TYPE_PROPERTY) {
- node= node.getParent();
- loc= node.getLocationInParent();
- }
- if (loc == ClassInstanceCreation.TYPE_PROPERTY) {
- ClassInstanceCreation cic= (ClassInstanceCreation) node.getParent();
+ // workaround for https://bugs.eclipse.org/62605 (constructor name resolves to type, not method)
+ ASTNode normalized= ASTNodes.getNormalizedNode(simpleName);
+ if (normalized.getLocationInParent() == ClassInstanceCreation.TYPE_PROPERTY) {
+ ClassInstanceCreation cic= (ClassInstanceCreation) normalized.getParent();
IMethodBinding constructorBinding= cic.resolveConstructorBinding();
if (constructorBinding == null)
return null;

Back to the top