Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManju Mathew2014-01-07 15:32:17 +0000
committerMarkus Keller2014-02-07 18:09:18 +0000
commit815164b3b52c2daf5d745ad9399c77ceb9c881fa (patch)
treebcda43e7d05b10e41e6ce076ca424dfa823e2fa6
parent53aff5697113c2cb278f2a7db29a45b7b95f5818 (diff)
downloadeclipse.jdt.ui-815164b3b52c2daf5d745ad9399c77ceb9c881fa.tar.gz
eclipse.jdt.ui-815164b3b52c2daf5d745ad9399c77ceb9c881fa.tar.xz
eclipse.jdt.ui-815164b3b52c2daf5d745ad9399c77ceb9c881fa.zip
Bug 407056: [1.8] Support NameQualifiedType AST node
-rw-r--r--org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/PotentialProgrammingProblemsFix.java14
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/CopyQualifiedNameAction.java9
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/OccurrencesFinder.java10
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ASTResolving.java6
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java9
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ModifierCorrectionSubProcessor.java10
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java38
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/TypeMismatchSubProcessor.java23
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java21
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavadocHover.java11
10 files changed, 109 insertions, 42 deletions
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..bfade420eb 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, 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
* 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.NameQualifiedType;
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 NameQualifiedType) {
+ name= ((NameQualifiedType) 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 NameQualifiedType)
+ name= ((NameQualifiedType) 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..22938bbe98 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, 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
* 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
*******************************************************************************/
@@ -63,6 +67,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.NodeFinder;
import org.eclipse.jdt.core.dom.PackageDeclaration;
import org.eclipse.jdt.core.dom.SimpleType;
@@ -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 == NameQualifiedType.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..9ac34baf45 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, 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
* 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
*******************************************************************************/
@@ -31,6 +35,7 @@ import org.eclipse.jdt.core.dom.ImportDeclaration;
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.NameQualifiedType;
import org.eclipse.jdt.core.dom.NodeFinder;
import org.eclipse.jdt.core.dom.ParameterizedType;
import org.eclipse.jdt.core.dom.PostfixExpression;
@@ -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 NameQualifiedType) {
+ Name name= ((NameQualifiedType) 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 6e778a0542..98b4b1bbc7 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
@@ -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
@@ -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.NameQualifiedType;
import org.eclipse.jdt.core.dom.ParameterizedType;
import org.eclipse.jdt.core.dom.PrefixExpression;
import org.eclipse.jdt.core.dom.PrimitiveType;
@@ -407,7 +408,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 == NameQualifiedType.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 cd9e66ec2d..b6fb481428 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
@@ -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
@@ -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.NameQualifiedType;
import org.eclipse.jdt.core.dom.ParameterizedType;
import org.eclipse.jdt.core.dom.ParenthesizedExpression;
import org.eclipse.jdt.core.dom.PrefixExpression;
@@ -1436,10 +1437,14 @@ public class LocalCorrectionsSubProcessor {
Name node= null;
if (selectedNode instanceof SimpleType) {
node= ((SimpleType) selectedNode).getName();
+ } else if (selectedNode instanceof NameQualifiedType) {
+ node= ((NameQualifiedType) selectedNode).getName();
} else if (selectedNode instanceof ArrayType) {
Type elementType= ((ArrayType) selectedNode).getElementType();
if (elementType.isSimpleType()) {
node= ((SimpleType) elementType).getName();
+ } else if (elementType.isNameQualifiedType()) {
+ node= ((NameQualifiedType) elementType).getName();
} else {
return;
}
@@ -1463,7 +1468,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 NameQualifiedType) && !(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 a2a7eb12fd..8ff6da4d6e 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
@@ -1,10 +1,14 @@
/*******************************************************************************
- * 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
* 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@innoopract.com> - [quick fix] 'Remove invalid modifiers' does not appear for enums and annotations - https://bugs.eclipse.org/bugs/show_bug.cgi?id=110589
@@ -54,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.NameQualifiedType;
import org.eclipse.jdt.core.dom.Modifier.ModifierKeyword;
import org.eclipse.jdt.core.dom.QualifiedName;
import org.eclipse.jdt.core.dom.ReturnStatement;
@@ -127,6 +132,9 @@ public class ModifierCorrectionSubProcessor {
case ASTNode.SIMPLE_TYPE:
binding= ((SimpleType) selectedNode).resolveBinding();
break;
+ case ASTNode.NAME_QUALIFIED_TYPE:
+ binding= ((NameQualifiedType) 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 dd69a69f98..e25aaf5989 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.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.NameQualifiedType;
import org.eclipse.jdt.core.dom.NumberLiteral;
import org.eclipse.jdt.core.dom.ParameterizedType;
import org.eclipse.jdt.core.dom.ParenthesizedExpression;
@@ -698,8 +699,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() == NameQualifiedType.NAME_PROPERTY) {
+ ASTNode type= name.getParent();
if (type.getLocationInParent() == ParameterizedType.TYPE_PROPERTY) {
createdType= (ParameterizedType) type.getParent();
if (createdType.getLocationInParent() != ClassInstanceCreation.TYPE_PROPERTY) {
@@ -1468,7 +1470,7 @@ public class QuickAssistProcessor implements IQuickAssistProcessor {
}
Type type= catchClause.getException().getType();
- if (!type.isSimpleType() && !type.isUnionType()) {
+ if (!type.isSimpleType() && !type.isUnionType() && !type.isNameQualifiedType()) {
return false;
}
@@ -1484,12 +1486,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 NameQualifiedType) {
+ selectedMultiCatchType= (NameQualifiedType) parent;
}
}
@@ -1509,12 +1513,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 NameQualifiedType))
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);
@@ -1550,7 +1554,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);
@@ -1617,12 +1621,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 NameQualifiedType) {
+ selectedMultiCatchType= (Type) parent;
}
}
@@ -1690,12 +1694,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 NameQualifiedType) {
+ selectedMultiCatchType= (Type) parent;
}
}
if (selectedMultiCatchType != null)
@@ -1781,12 +1785,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 NameQualifiedType) {
+ 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..6d59bd4e68 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
@@ -1,10 +1,14 @@
/*******************************************************************************
- * 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
* 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.NameQualifiedType;
import org.eclipse.jdt.core.dom.SimpleName;
import org.eclipse.jdt.core.dom.SimpleType;
import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
@@ -455,11 +460,17 @@ 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 NameQualifiedType) {
+ simpleName= ((NameQualifiedType) 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));
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 3b340a2949..2b2a7df549 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
@@ -1,10 +1,14 @@
/*******************************************************************************
- * 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
* 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
* Renaud Waldura &lt;renaud+eclipse@waldura.com&gt; - New class/interface with wizard
@@ -95,6 +99,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.NameQualifiedType;
import org.eclipse.jdt.core.dom.NormalAnnotation;
import org.eclipse.jdt.core.dom.ParenthesizedExpression;
import org.eclipse.jdt.core.dom.QualifiedName;
@@ -211,7 +216,7 @@ public class UnresolvedElementsSubProcessor {
node= null;
}
}
- } else if (parent instanceof SimpleType) {
+ } else if (parent instanceof SimpleType || parent instanceof NameQualifiedType) {
suggestVariableProposals= false;
typeKind= SimilarElementsRequestor.REF_TYPES_AND_VAR;
} else if (parent instanceof QualifiedName) {
@@ -225,7 +230,7 @@ public class UnresolvedElementsSubProcessor {
while (outerParent instanceof QualifiedName) {
outerParent= outerParent.getParent();
}
- if (outerParent instanceof SimpleType) {
+ if (outerParent instanceof SimpleType || outerParent instanceof NameQualifiedType) {
typeKind= SimilarElementsRequestor.REF_TYPES;
suggestVariableProposals= false;
}
@@ -249,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 NameQualifiedType) {
typeKind= SimilarElementsRequestor.REF_TYPES;
suggestVariableProposals= false;
}
@@ -609,10 +614,14 @@ public class UnresolvedElementsSubProcessor {
Name node= null;
if (selectedNode instanceof SimpleType) {
node= ((SimpleType) selectedNode).getName();
+ } else if (selectedNode instanceof NameQualifiedType) {
+ node= ((NameQualifiedType) selectedNode).getName();
} else if (selectedNode instanceof ArrayType) {
Type elementType= ((ArrayType) selectedNode).getElementType();
if (elementType.isSimpleType()) {
node= ((SimpleType) elementType).getName();
+ } else if (elementType.isNameQualifiedType()) {
+ node= ((NameQualifiedType) elementType).getName();
} else {
return;
}
@@ -641,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() == NameQualifiedType.NAME_PROPERTY)) {
ASTNode type= selectedNode.getParent();
if (type.getLocationInParent() == SingleVariableDeclaration.TYPE_PROPERTY) {
SingleVariableDeclaration svd= (SingleVariableDeclaration) type.getParent();
@@ -841,7 +850,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 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 b0e49f9c82..1f97ac931f 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
@@ -1,10 +1,14 @@
/*******************************************************************************
- * 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
* 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
* Genady Beryozkin <eclipse@genady.org> - [hovering] tooltip for constant string does not show constant value - https://bugs.eclipse.org/bugs/show_bug.cgi?id=85382
@@ -83,6 +87,7 @@ 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;
@@ -1042,7 +1047,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 == NameQualifiedType.NAME_PROPERTY
+ || loc == ParameterizedType.TYPE_PROPERTY) {
node= node.getParent();
loc= node.getLocationInParent();
}

Back to the top