diff options
author | Manju Mathew | 2013-10-30 09:55:43 +0000 |
---|---|---|
committer | Manju Mathew | 2013-10-30 09:55:43 +0000 |
commit | c3d931e71ca517a0a7edb143def3ab7321aa5ac0 (patch) | |
tree | 461e7c16d19aa99e5d3b1bb9a16609bc5c4f1d8b | |
parent | 15d4811e3fc0484d08c6a610fe081f96865a08ef (diff) | |
download | eclipse.jdt.ui-c3d931e71ca517a0a7edb143def3ab7321aa5ac0.tar.gz eclipse.jdt.ui-c3d931e71ca517a0a7edb143def3ab7321aa5ac0.tar.xz eclipse.jdt.ui-c3d931e71ca517a0a7edb143def3ab7321aa5ac0.zip |
Fix for bug 407056: [1.8] Support PackageQualifiedType AST node
11 files changed, 96 insertions, 39 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 ac58bb32cb..def46ea2c2 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 @@ -652,8 +652,10 @@ public class ASTNodes { current= current.getParent(); } // normalize type - if (QualifiedType.NAME_PROPERTY.equals(current.getLocationInParent()) || - SimpleType.NAME_PROPERTY.equals(current.getLocationInParent())) { + StructuralPropertyDescriptor locationInParent= current.getLocationInParent(); + if (QualifiedType.NAME_PROPERTY.equals(locationInParent) || + SimpleType.NAME_PROPERTY.equals(locationInParent) || + PackageQualifiedType.NAME_PROPERTY.equals(locationInParent)) { current= current.getParent(); } // normalize parameterized types 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 dd34f48eb4..4c61c24dfe 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 @@ -1,10 +1,14 @@ /******************************************************************************* - * Copyright (c) 2000, 2011 IBM Corporation and others. + * Copyright (c) 2000, 2013 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 * http://www.eclipse.org/legal/epl-v10.html * + * This is an implementation of an early-draft specification developed under the Java + * Community Process (JCP) and is made available for testing and evaluation purposes + * only. The code is not compatible with any specification of the JCP. + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -47,6 +51,7 @@ import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jdt.core.dom.IBinding; import org.eclipse.jdt.core.dom.ITypeBinding; import org.eclipse.jdt.core.dom.Name; +import org.eclipse.jdt.core.dom.PackageQualifiedType; import org.eclipse.jdt.core.dom.ParameterizedType; import org.eclipse.jdt.core.dom.QualifiedName; import org.eclipse.jdt.core.dom.QualifiedType; @@ -383,13 +388,16 @@ public class PotentialProgrammingProblemsFix extends CompilationUnitRewriteOpera Name name= null; if (selection instanceof SimpleType) { - final SimpleType type= (SimpleType) selection; - name= type.getName(); + name= ((SimpleType) selection).getName(); + } else if (selection instanceof PackageQualifiedType) { + name= ((PackageQualifiedType) selection).getName(); } else if (selection instanceof ParameterizedType) { final ParameterizedType type= (ParameterizedType) selection; final Type raw= type.getType(); if (raw instanceof SimpleType) name= ((SimpleType) raw).getName(); + else if (raw instanceof PackageQualifiedType) + name= ((PackageQualifiedType) raw).getName(); else if (raw instanceof QualifiedType) name= ((QualifiedType) raw).getName(); } else if (selection instanceof Name) { 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 85e068123e..80f6c5cb2c 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 @@ -1,10 +1,14 @@ /******************************************************************************* - * Copyright (c) 2000, 2011 IBM Corporation and others. + * Copyright (c) 2000, 2013 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 * http://www.eclipse.org/legal/epl-v10.html * + * This is an implementation of an early-draft specification developed under the Java + * Community Process (JCP) and is made available for testing and evaluation purposes + * only. The code is not compatible with any specification of the JCP. + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -65,6 +69,7 @@ import org.eclipse.jdt.core.dom.MethodInvocation; import org.eclipse.jdt.core.dom.Name; import org.eclipse.jdt.core.dom.NodeFinder; import org.eclipse.jdt.core.dom.PackageDeclaration; +import org.eclipse.jdt.core.dom.PackageQualifiedType; import org.eclipse.jdt.core.dom.SimpleType; import org.eclipse.jdt.core.dom.StructuralPropertyDescriptor; import org.eclipse.jdt.core.dom.Type; @@ -361,7 +366,7 @@ public class CopyQualifiedNameAction extends SelectionDispatchAction { */ private IBinding getConstructorBindingIfAvailable(Name nameNode) { StructuralPropertyDescriptor loc= nameNode.getLocationInParent(); - if (loc == SimpleType.NAME_PROPERTY) { + if (loc == SimpleType.NAME_PROPERTY || loc == PackageQualifiedType.NAME_PROPERTY) { ASTNode parent= nameNode.getParent(); loc= parent.getLocationInParent(); if (loc == ClassInstanceCreation.TYPE_PROPERTY) diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/OccurrencesFinder.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/OccurrencesFinder.java index 0e2e520a9a..c4f6be7bc2 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/OccurrencesFinder.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/OccurrencesFinder.java @@ -1,10 +1,14 @@ /******************************************************************************* - * Copyright (c) 2000, 2011 IBM Corporation and others. + * Copyright (c) 2000, 2013 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 * http://www.eclipse.org/legal/epl-v10.html * + * This is an implementation of an early-draft specification developed under the Java + * Community Process (JCP) and is made available for testing and evaluation purposes + * only. The code is not compatible with any specification of the JCP. + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -32,6 +36,7 @@ import org.eclipse.jdt.core.dom.MethodInvocation; import org.eclipse.jdt.core.dom.Modifier; import org.eclipse.jdt.core.dom.Name; import org.eclipse.jdt.core.dom.NodeFinder; +import org.eclipse.jdt.core.dom.PackageQualifiedType; import org.eclipse.jdt.core.dom.ParameterizedType; import org.eclipse.jdt.core.dom.PostfixExpression; import org.eclipse.jdt.core.dom.PrefixExpression; @@ -187,6 +192,9 @@ public class OccurrencesFinder extends ASTVisitor implements IOccurrencesFinder if (name instanceof QualifiedName) name= ((QualifiedName)name).getName(); addUsage(name, node.resolveConstructorBinding()); + } else if (type instanceof PackageQualifiedType) { + Name name= ((PackageQualifiedType) type).getName(); + addUsage(name, node.resolveConstructorBinding()); } return super.visit(node); } 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 23ddcd867c..f46c7d33bc 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 @@ -59,6 +59,7 @@ import org.eclipse.jdt.core.dom.MethodDeclaration; import org.eclipse.jdt.core.dom.MethodInvocation; import org.eclipse.jdt.core.dom.Modifier; import org.eclipse.jdt.core.dom.Name; +import org.eclipse.jdt.core.dom.PackageQualifiedType; import org.eclipse.jdt.core.dom.ParameterizedType; import org.eclipse.jdt.core.dom.PrefixExpression; import org.eclipse.jdt.core.dom.PrimitiveType; @@ -414,7 +415,8 @@ public class ASTResolving { if (locationInParent == QualifiedName.QUALIFIER_PROPERTY) { return null; // can't guess type for X.A } - if (locationInParent == SimpleType.NAME_PROPERTY) { + if (locationInParent == SimpleType.NAME_PROPERTY || + locationInParent == PackageQualifiedType.NAME_PROPERTY) { node= node.getParent(); } ITypeBinding binding= Bindings.normalizeTypeBinding(getPossibleTypeBinding(node)); diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java index f8974192f5..aff8612f08 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java @@ -80,6 +80,7 @@ import org.eclipse.jdt.core.dom.MethodDeclaration; import org.eclipse.jdt.core.dom.MethodInvocation; import org.eclipse.jdt.core.dom.Modifier; import org.eclipse.jdt.core.dom.Name; +import org.eclipse.jdt.core.dom.PackageQualifiedType; import org.eclipse.jdt.core.dom.ParameterizedType; import org.eclipse.jdt.core.dom.ParenthesizedExpression; import org.eclipse.jdt.core.dom.PrefixExpression; @@ -1437,10 +1438,14 @@ public class LocalCorrectionsSubProcessor { Name node= null; if (selectedNode instanceof SimpleType) { node= ((SimpleType) selectedNode).getName(); + } else if (selectedNode instanceof PackageQualifiedType) { + node= ((PackageQualifiedType) selectedNode).getName(); } else if (selectedNode instanceof ArrayType) { Type elementType= ((ArrayType) selectedNode).getElementType(); if (elementType.isSimpleType()) { node= ((SimpleType) elementType).getName(); + } else if (elementType.isPackageQualifiedType()) { + node= ((PackageQualifiedType) elementType).getName(); } else { return; } @@ -1464,7 +1469,7 @@ public class LocalCorrectionsSubProcessor { simpleBinding= simpleBinding.getTypeDeclaration(); if (!simpleBinding.isRecovered()) { - if (binding.isParameterizedType() && node.getParent() instanceof SimpleType && !(node.getParent().getParent() instanceof Type)) { + if (binding.isParameterizedType() && (node.getParent() instanceof SimpleType || node.getParent() instanceof PackageQualifiedType) && !(node.getParent().getParent() instanceof Type)) { proposals.add(UnresolvedElementsSubProcessor.createTypeRefChangeFullProposal(cu, binding, node, IProposalRelevance.TYPE_ARGUMENTS_FROM_CONTEXT)); } } diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ModifierCorrectionSubProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ModifierCorrectionSubProcessor.java index 28b8b8038c..bd7227bdfc 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ModifierCorrectionSubProcessor.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ModifierCorrectionSubProcessor.java @@ -58,6 +58,7 @@ import org.eclipse.jdt.core.dom.Javadoc; import org.eclipse.jdt.core.dom.MethodDeclaration; import org.eclipse.jdt.core.dom.MethodInvocation; import org.eclipse.jdt.core.dom.Modifier; +import org.eclipse.jdt.core.dom.PackageQualifiedType; import org.eclipse.jdt.core.dom.Modifier.ModifierKeyword; import org.eclipse.jdt.core.dom.QualifiedName; import org.eclipse.jdt.core.dom.ReturnStatement; @@ -131,6 +132,9 @@ public class ModifierCorrectionSubProcessor { case ASTNode.SIMPLE_TYPE: binding= ((SimpleType) selectedNode).resolveBinding(); break; + case ASTNode.PACKAGE_QUALIFIED_TYPE: + binding= ((PackageQualifiedType) selectedNode).resolveBinding(); + break; case ASTNode.METHOD_INVOCATION: binding= ((MethodInvocation) selectedNode).getName().resolveBinding(); break; diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java index 3fa637f258..89ff1c9c31 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java @@ -82,6 +82,7 @@ import org.eclipse.jdt.core.dom.MethodInvocation; import org.eclipse.jdt.core.dom.Modifier; import org.eclipse.jdt.core.dom.Name; import org.eclipse.jdt.core.dom.NumberLiteral; +import org.eclipse.jdt.core.dom.PackageQualifiedType; import org.eclipse.jdt.core.dom.ParameterizedType; import org.eclipse.jdt.core.dom.ParenthesizedExpression; import org.eclipse.jdt.core.dom.PostfixExpression; @@ -506,8 +507,9 @@ public class QuickAssistProcessor implements IQuickAssistProcessor { if (node instanceof Name) { Name name= ASTNodes.getTopMostName((Name) node); - if (name.getLocationInParent() == SimpleType.NAME_PROPERTY) { - SimpleType type= (SimpleType) name.getParent(); + if (name.getLocationInParent() == SimpleType.NAME_PROPERTY || + name.getLocationInParent() == PackageQualifiedType.NAME_PROPERTY) { + ASTNode type= name.getParent(); if (type.getLocationInParent() == ParameterizedType.TYPE_PROPERTY) { createdType= (ParameterizedType) type.getParent(); if (createdType.getLocationInParent() != ClassInstanceCreation.TYPE_PROPERTY) { @@ -1276,7 +1278,7 @@ public class QuickAssistProcessor implements IQuickAssistProcessor { } Type type= catchClause.getException().getType(); - if (!type.isSimpleType() && !type.isUnionType()) { + if (!type.isSimpleType() && !type.isUnionType() && !type.isPackageQualifiedType()) { return false; } @@ -1292,12 +1294,14 @@ public class QuickAssistProcessor implements IQuickAssistProcessor { AST ast= bodyDeclaration.getAST(); Image image= JavaPluginImages.get(JavaPluginImages.IMG_OBJS_EXCEPTION); - SimpleType selectedMultiCatchType= null; + Type selectedMultiCatchType= null; if (type.isUnionType() && node instanceof Name) { Name topMostName= ASTNodes.getTopMostName((Name) node); ASTNode parent= topMostName.getParent(); if (parent instanceof SimpleType) { selectedMultiCatchType= (SimpleType) parent; + } else if (parent instanceof PackageQualifiedType) { + selectedMultiCatchType= (PackageQualifiedType) parent; } } @@ -1317,12 +1321,12 @@ public class QuickAssistProcessor implements IQuickAssistProcessor { UnionType unionType= (UnionType) type; List<Type> types= unionType.types(); for (Type elementType : types) { - if (!(elementType instanceof SimpleType)) + if (!(elementType instanceof SimpleType || elementType instanceof PackageQualifiedType)) return false; - addExceptionToThrows(ast, methodDeclaration, rewrite, (SimpleType) elementType); + addExceptionToThrows(ast, methodDeclaration, rewrite, elementType); } } else { - addExceptionToThrows(ast, methodDeclaration, rewrite, (SimpleType) type); + addExceptionToThrows(ast, methodDeclaration, rewrite, type); } String label= CorrectionMessages.QuickAssistProcessor_catchclausetothrows_description; ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, IProposalRelevance.REPLACE_CATCH_CLAUSE_WITH_THROWS, image); @@ -1358,7 +1362,7 @@ public class QuickAssistProcessor implements IQuickAssistProcessor { } } - private static void addExceptionToThrows(AST ast, MethodDeclaration methodDeclaration, ASTRewrite rewrite, SimpleType type2) { + private static void addExceptionToThrows(AST ast, MethodDeclaration methodDeclaration, ASTRewrite rewrite, Type type2) { ITypeBinding binding= type2.resolveBinding(); if (binding == null || isNotYetThrown(binding, methodDeclaration.thrownExceptionTypes())) { Type newType= (Type) ASTNode.copySubtree(ast, type2); @@ -1425,12 +1429,12 @@ public class QuickAssistProcessor implements IQuickAssistProcessor { return false; } - SimpleType selectedMultiCatchType= null; + Type selectedMultiCatchType= null; if (type.isUnionType() && node instanceof Name) { Name topMostName= ASTNodes.getTopMostName((Name) node); ASTNode parent= topMostName.getParent(); - if (parent instanceof SimpleType) { - selectedMultiCatchType= (SimpleType) parent; + if (parent instanceof SimpleType || parent instanceof PackageQualifiedType) { + selectedMultiCatchType= (Type) parent; } } @@ -1498,12 +1502,12 @@ public class QuickAssistProcessor implements IQuickAssistProcessor { } Type type1= catchClause.getException().getType(); - SimpleType selectedMultiCatchType= null; + Type selectedMultiCatchType= null; if (type1.isUnionType() && covering instanceof Name) { Name topMostName= ASTNodes.getTopMostName((Name) covering); ASTNode parent= topMostName.getParent(); - if (parent instanceof SimpleType) { - selectedMultiCatchType= (SimpleType) parent; + if (parent instanceof SimpleType || parent instanceof PackageQualifiedType) { + selectedMultiCatchType= (Type) parent; } } if (selectedMultiCatchType != null) @@ -1589,12 +1593,12 @@ public class QuickAssistProcessor implements IQuickAssistProcessor { } Type type1= catchClause.getException().getType(); - SimpleType selectedMultiCatchType= null; + Type selectedMultiCatchType= null; if (type1.isUnionType() && covering instanceof Name) { Name topMostName= ASTNodes.getTopMostName((Name) covering); ASTNode parent= topMostName.getParent(); - if (parent instanceof SimpleType) { - selectedMultiCatchType= (SimpleType) parent; + if (parent instanceof SimpleType || parent instanceof PackageQualifiedType) { + selectedMultiCatchType= (Type) parent; } } if (selectedMultiCatchType != null) diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/TypeMismatchSubProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/TypeMismatchSubProcessor.java index f904ad5b0b..65cbef78b9 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/TypeMismatchSubProcessor.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/TypeMismatchSubProcessor.java @@ -5,6 +5,10 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * + * This is an implementation of an early-draft specification developed under the Java + * Community Process (JCP) and is made available for testing and evaluation purposes + * only. The code is not compatible with any specification of the JCP. + * * Contributors: * IBM Corporation - initial API and implementation * Benjamin Muskalla <bmuskalla@eclipsesource.com> - [quick fix] proposes wrong cast from Object to primitive int - https://bugs.eclipse.org/bugs/show_bug.cgi?id=100593 @@ -39,6 +43,7 @@ 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.Name; +import org.eclipse.jdt.core.dom.PackageQualifiedType; import org.eclipse.jdt.core.dom.SimpleName; import org.eclipse.jdt.core.dom.SimpleType; import org.eclipse.jdt.core.dom.SingleMemberAnnotation; @@ -455,16 +460,22 @@ public class TypeMismatchSubProcessor { SingleVariableDeclaration parameter= forStatement.getParameter(); ICompilationUnit cu= context.getCompilationUnit(); - if (parameter.getName().getLength() == 0 - && parameter.getType() instanceof SimpleType) { - SimpleType type= (SimpleType) parameter.getType(); - if (type.getName() instanceof SimpleName) { - SimpleName simpleName= (SimpleName) type.getName(); + if (parameter.getName().getLength() == 0) { + SimpleName simpleName= null; + if (parameter.getType() instanceof SimpleType) { + SimpleType type= (SimpleType) parameter.getType(); + if (type.getName() instanceof SimpleName) { + simpleName= (SimpleName) type.getName(); + } + } else if (parameter.getType() instanceof PackageQualifiedType) { + simpleName= ((PackageQualifiedType) parameter.getType()).getName(); + } + if (simpleName != null) { String name= simpleName.getIdentifier(); int relevance= StubUtility.hasLocalVariableName(cu.getJavaProject(), name) ? 10 : 7; String label= Messages.format(CorrectionMessages.TypeMismatchSubProcessor_create_loop_variable_description, BasicElementLabels.getJavaElementName(name)); Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_LOCAL); - + proposals.add(new NewVariableCorrectionProposal(label, cu, NewVariableCorrectionProposal.LOCAL, simpleName, null, relevance, image)); return; } 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 a76e5c1ef9..cf09db33f3 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 @@ -100,6 +100,7 @@ import org.eclipse.jdt.core.dom.MethodInvocation; import org.eclipse.jdt.core.dom.Modifier; import org.eclipse.jdt.core.dom.Name; import org.eclipse.jdt.core.dom.NormalAnnotation; +import org.eclipse.jdt.core.dom.PackageQualifiedType; import org.eclipse.jdt.core.dom.ParenthesizedExpression; import org.eclipse.jdt.core.dom.QualifiedName; import org.eclipse.jdt.core.dom.SimpleName; @@ -215,7 +216,7 @@ public class UnresolvedElementsSubProcessor { node= null; } } - } else if (parent instanceof SimpleType) { + } else if (parent instanceof SimpleType || parent instanceof PackageQualifiedType) { suggestVariableProposals= false; typeKind= SimilarElementsRequestor.REF_TYPES_AND_VAR; } else if (parent instanceof QualifiedName) { @@ -229,7 +230,7 @@ public class UnresolvedElementsSubProcessor { while (outerParent instanceof QualifiedName) { outerParent= outerParent.getParent(); } - if (outerParent instanceof SimpleType) { + if (outerParent instanceof SimpleType || outerParent instanceof PackageQualifiedType) { typeKind= SimilarElementsRequestor.REF_TYPES; suggestVariableProposals= false; } @@ -253,7 +254,7 @@ public class UnresolvedElementsSubProcessor { typeKind= SimilarElementsRequestor.REF_TYPES; suggestVariableProposals= node.isSimpleName(); } - if (selectedNode.getParent() instanceof SimpleType) { + if (selectedNode.getParent() instanceof SimpleType || selectedNode.getParent() instanceof PackageQualifiedType) { typeKind= SimilarElementsRequestor.REF_TYPES; suggestVariableProposals= false; } @@ -613,10 +614,14 @@ public class UnresolvedElementsSubProcessor { Name node= null; if (selectedNode instanceof SimpleType) { node= ((SimpleType) selectedNode).getName(); + } else if (selectedNode instanceof PackageQualifiedType) { + node= ((PackageQualifiedType) selectedNode).getName(); } else if (selectedNode instanceof ArrayType) { Type elementType= ((ArrayType) selectedNode).getElementType(); if (elementType.isSimpleType()) { node= ((SimpleType) elementType).getName(); + } else if (elementType.isPackageQualifiedType()) { + node= ((PackageQualifiedType) elementType).getName(); } else { return; } @@ -645,7 +650,7 @@ public class UnresolvedElementsSubProcessor { } private static void addEnhancedForWithoutTypeProposals(ICompilationUnit cu, ASTNode selectedNode, Collection<ICommandAccess> proposals) { - if (selectedNode instanceof SimpleName && selectedNode.getLocationInParent() == SimpleType.NAME_PROPERTY) { + if (selectedNode instanceof SimpleName && (selectedNode.getLocationInParent() == SimpleType.NAME_PROPERTY || selectedNode.getLocationInParent() == PackageQualifiedType.NAME_PROPERTY)) { ASTNode type= selectedNode.getParent(); if (type.getLocationInParent() == SingleVariableDeclaration.TYPE_PROPERTY) { SingleVariableDeclaration svd= (SingleVariableDeclaration) type.getParent(); @@ -844,7 +849,7 @@ public class UnresolvedElementsSubProcessor { if (proposal instanceof AddImportCorrectionProposal) proposal.setRelevance(relevance + elements.length + 2); - if (binding.isParameterizedType() && node.getParent() instanceof SimpleType && !(node.getParent().getParent() instanceof Type)) { + if (binding.isParameterizedType() && (node.getParent() instanceof SimpleType || node.getParent() instanceof PackageQualifiedType) && !(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 b0e49f9c82..8c6c54b778 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 @@ -84,6 +84,7 @@ 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.NodeFinder; +import org.eclipse.jdt.core.dom.PackageQualifiedType; import org.eclipse.jdt.core.dom.ParameterizedType; import org.eclipse.jdt.core.dom.QualifiedName; import org.eclipse.jdt.core.dom.QualifiedType; @@ -1042,7 +1043,9 @@ public class JavadocHover extends AbstractJavaEditorTextHover { // 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 == ParameterizedType.TYPE_PROPERTY) { + while (loc == QualifiedType.NAME_PROPERTY || loc == QualifiedName.NAME_PROPERTY + || loc == SimpleType.NAME_PROPERTY || loc == PackageQualifiedType.NAME_PROPERTY + || loc == ParameterizedType.TYPE_PROPERTY) { node= node.getParent(); loc= node.getLocationInParent(); } |