Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 407056 | Differences between
and this patch

Collapse All | Expand All

(-)core extension/org/eclipse/jdt/internal/corext/dom/ASTNodes.java (-2 / +4 lines)
Lines 650-657 Link Here
650
			current= current.getParent();
650
			current= current.getParent();
651
		}
651
		}
652
		// normalize type
652
		// normalize type
653
		if (QualifiedType.NAME_PROPERTY.equals(current.getLocationInParent()) ||
653
		StructuralPropertyDescriptor locationInParent= current.getLocationInParent();
654
			SimpleType.NAME_PROPERTY.equals(current.getLocationInParent())) {
654
		if (QualifiedType.NAME_PROPERTY.equals(locationInParent) ||
655
				SimpleType.NAME_PROPERTY.equals(locationInParent) ||
656
				PackageQualifiedType.NAME_PROPERTY.equals(locationInParent)) {
655
			current= current.getParent();
657
			current= current.getParent();
656
		}
658
		}
657
		// normalize parameterized types
659
		// normalize parameterized types
(-)core extension/org/eclipse/jdt/internal/corext/fix/PotentialProgrammingProblemsFix.java (-3 / +11 lines)
Lines 1-9 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
2
 * Copyright (c) 2000, 2013 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * This is an implementation of an early-draft specification developed under the Java
9
 * Community Process (JCP) and is made available for testing and evaluation purposes
10
 * only. The code is not compatible with any specification of the JCP.
7
 *
11
 *
8
 * Contributors:
12
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
13
 *     IBM Corporation - initial API and implementation
Lines 47-52 Link Here
47
import org.eclipse.jdt.core.dom.IBinding;
51
import org.eclipse.jdt.core.dom.IBinding;
48
import org.eclipse.jdt.core.dom.ITypeBinding;
52
import org.eclipse.jdt.core.dom.ITypeBinding;
49
import org.eclipse.jdt.core.dom.Name;
53
import org.eclipse.jdt.core.dom.Name;
54
import org.eclipse.jdt.core.dom.PackageQualifiedType;
50
import org.eclipse.jdt.core.dom.ParameterizedType;
55
import org.eclipse.jdt.core.dom.ParameterizedType;
51
import org.eclipse.jdt.core.dom.QualifiedName;
56
import org.eclipse.jdt.core.dom.QualifiedName;
52
import org.eclipse.jdt.core.dom.QualifiedType;
57
import org.eclipse.jdt.core.dom.QualifiedType;
Lines 383-395 Link Here
383
388
384
		Name name= null;
389
		Name name= null;
385
		if (selection instanceof SimpleType) {
390
		if (selection instanceof SimpleType) {
386
			final SimpleType type= (SimpleType) selection;
391
			name= ((SimpleType) selection).getName();
387
			name= type.getName();
392
		} else if (selection instanceof PackageQualifiedType) {
393
			name= ((PackageQualifiedType) selection).getName();
388
		} else if (selection instanceof ParameterizedType) {
394
		} else if (selection instanceof ParameterizedType) {
389
			final ParameterizedType type= (ParameterizedType) selection;
395
			final ParameterizedType type= (ParameterizedType) selection;
390
			final Type raw= type.getType();
396
			final Type raw= type.getType();
391
			if (raw instanceof SimpleType)
397
			if (raw instanceof SimpleType)
392
				name= ((SimpleType) raw).getName();
398
				name= ((SimpleType) raw).getName();
399
			else if (raw instanceof PackageQualifiedType)
400
				name= ((PackageQualifiedType) raw).getName();
393
			else if (raw instanceof QualifiedType)
401
			else if (raw instanceof QualifiedType)
394
				name= ((QualifiedType) raw).getName();
402
				name= ((QualifiedType) raw).getName();
395
		} else if (selection instanceof Name) {
403
		} else if (selection instanceof Name) {
(-)ui/org/eclipse/jdt/internal/ui/actions/CopyQualifiedNameAction.java (-2 / +7 lines)
Lines 1-10 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
2
 * Copyright (c) 2000, 2013 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
7
 *
8
 * This is an implementation of an early-draft specification developed under the Java
9
 * Community Process (JCP) and is made available for testing and evaluation purposes
10
 * only. The code is not compatible with any specification of the JCP.
11
 * 
8
 * Contributors:
12
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
13
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
14
 *******************************************************************************/
Lines 65-70 Link Here
65
import org.eclipse.jdt.core.dom.Name;
69
import org.eclipse.jdt.core.dom.Name;
66
import org.eclipse.jdt.core.dom.NodeFinder;
70
import org.eclipse.jdt.core.dom.NodeFinder;
67
import org.eclipse.jdt.core.dom.PackageDeclaration;
71
import org.eclipse.jdt.core.dom.PackageDeclaration;
72
import org.eclipse.jdt.core.dom.PackageQualifiedType;
68
import org.eclipse.jdt.core.dom.SimpleType;
73
import org.eclipse.jdt.core.dom.SimpleType;
69
import org.eclipse.jdt.core.dom.StructuralPropertyDescriptor;
74
import org.eclipse.jdt.core.dom.StructuralPropertyDescriptor;
70
import org.eclipse.jdt.core.dom.Type;
75
import org.eclipse.jdt.core.dom.Type;
Lines 361-367 Link Here
361
	 */
366
	 */
362
	private IBinding getConstructorBindingIfAvailable(Name nameNode) {
367
	private IBinding getConstructorBindingIfAvailable(Name nameNode) {
363
		StructuralPropertyDescriptor loc= nameNode.getLocationInParent();
368
		StructuralPropertyDescriptor loc= nameNode.getLocationInParent();
364
		if (loc == SimpleType.NAME_PROPERTY) {
369
		if (loc == SimpleType.NAME_PROPERTY || loc == PackageQualifiedType.NAME_PROPERTY) {
365
			ASTNode parent= nameNode.getParent();
370
			ASTNode parent= nameNode.getParent();
366
			loc= parent.getLocationInParent();
371
			loc= parent.getLocationInParent();
367
			if (loc == ClassInstanceCreation.TYPE_PROPERTY)
372
			if (loc == ClassInstanceCreation.TYPE_PROPERTY)
(-)ui/org/eclipse/jdt/internal/ui/search/OccurrencesFinder.java (-1 / +9 lines)
Lines 1-10 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
2
 * Copyright (c) 2000, 2013 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
7
 *
8
 * This is an implementation of an early-draft specification developed under the Java
9
 * Community Process (JCP) and is made available for testing and evaluation purposes
10
 * only. The code is not compatible with any specification of the JCP.
11
 * 
8
 * Contributors:
12
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
13
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
14
 *******************************************************************************/
Lines 32-37 Link Here
32
import org.eclipse.jdt.core.dom.Modifier;
36
import org.eclipse.jdt.core.dom.Modifier;
33
import org.eclipse.jdt.core.dom.Name;
37
import org.eclipse.jdt.core.dom.Name;
34
import org.eclipse.jdt.core.dom.NodeFinder;
38
import org.eclipse.jdt.core.dom.NodeFinder;
39
import org.eclipse.jdt.core.dom.PackageQualifiedType;
35
import org.eclipse.jdt.core.dom.ParameterizedType;
40
import org.eclipse.jdt.core.dom.ParameterizedType;
36
import org.eclipse.jdt.core.dom.PostfixExpression;
41
import org.eclipse.jdt.core.dom.PostfixExpression;
37
import org.eclipse.jdt.core.dom.PrefixExpression;
42
import org.eclipse.jdt.core.dom.PrefixExpression;
Lines 187-192 Link Here
187
			if (name instanceof QualifiedName)
192
			if (name instanceof QualifiedName)
188
				name= ((QualifiedName)name).getName();
193
				name= ((QualifiedName)name).getName();
189
			addUsage(name, node.resolveConstructorBinding());
194
			addUsage(name, node.resolveConstructorBinding());
195
		} else if (type instanceof PackageQualifiedType) {
196
			Name name= ((PackageQualifiedType) type).getName();
197
			addUsage(name, node.resolveConstructorBinding());
190
		}
198
		}
191
		return super.visit(node);
199
		return super.visit(node);
192
	}
200
	}
(-)ui/org/eclipse/jdt/internal/ui/text/correction/ASTResolving.java (-1 / +3 lines)
Lines 59-64 Link Here
59
import org.eclipse.jdt.core.dom.MethodInvocation;
59
import org.eclipse.jdt.core.dom.MethodInvocation;
60
import org.eclipse.jdt.core.dom.Modifier;
60
import org.eclipse.jdt.core.dom.Modifier;
61
import org.eclipse.jdt.core.dom.Name;
61
import org.eclipse.jdt.core.dom.Name;
62
import org.eclipse.jdt.core.dom.PackageQualifiedType;
62
import org.eclipse.jdt.core.dom.ParameterizedType;
63
import org.eclipse.jdt.core.dom.ParameterizedType;
63
import org.eclipse.jdt.core.dom.PrefixExpression;
64
import org.eclipse.jdt.core.dom.PrefixExpression;
64
import org.eclipse.jdt.core.dom.PrimitiveType;
65
import org.eclipse.jdt.core.dom.PrimitiveType;
Lines 407-413 Link Here
407
    	if (locationInParent == QualifiedName.QUALIFIER_PROPERTY) {
408
    	if (locationInParent == QualifiedName.QUALIFIER_PROPERTY) {
408
    		return null; // can't guess type for X.A
409
    		return null; // can't guess type for X.A
409
    	}
410
    	}
410
    	if (locationInParent == SimpleType.NAME_PROPERTY) {
411
		if (locationInParent == SimpleType.NAME_PROPERTY ||
412
				locationInParent == PackageQualifiedType.NAME_PROPERTY) {
411
    		node= node.getParent();
413
    		node= node.getParent();
412
    	}
414
    	}
413
    	ITypeBinding binding= Bindings.normalizeTypeBinding(getPossibleTypeBinding(node));
415
    	ITypeBinding binding= Bindings.normalizeTypeBinding(getPossibleTypeBinding(node));
(-)ui/org/eclipse/jdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java (-1 / +6 lines)
Lines 80-85 Link Here
80
import org.eclipse.jdt.core.dom.MethodInvocation;
80
import org.eclipse.jdt.core.dom.MethodInvocation;
81
import org.eclipse.jdt.core.dom.Modifier;
81
import org.eclipse.jdt.core.dom.Modifier;
82
import org.eclipse.jdt.core.dom.Name;
82
import org.eclipse.jdt.core.dom.Name;
83
import org.eclipse.jdt.core.dom.PackageQualifiedType;
83
import org.eclipse.jdt.core.dom.ParameterizedType;
84
import org.eclipse.jdt.core.dom.ParameterizedType;
84
import org.eclipse.jdt.core.dom.ParenthesizedExpression;
85
import org.eclipse.jdt.core.dom.ParenthesizedExpression;
85
import org.eclipse.jdt.core.dom.PrefixExpression;
86
import org.eclipse.jdt.core.dom.PrefixExpression;
Lines 1436-1445 Link Here
1436
		Name node= null;
1437
		Name node= null;
1437
		if (selectedNode instanceof SimpleType) {
1438
		if (selectedNode instanceof SimpleType) {
1438
			node= ((SimpleType) selectedNode).getName();
1439
			node= ((SimpleType) selectedNode).getName();
1440
		} else if (selectedNode instanceof PackageQualifiedType) {
1441
			node= ((PackageQualifiedType) selectedNode).getName();
1439
		} else if (selectedNode instanceof ArrayType) {
1442
		} else if (selectedNode instanceof ArrayType) {
1440
			Type elementType= ((ArrayType) selectedNode).getElementType();
1443
			Type elementType= ((ArrayType) selectedNode).getElementType();
1441
			if (elementType.isSimpleType()) {
1444
			if (elementType.isSimpleType()) {
1442
				node= ((SimpleType) elementType).getName();
1445
				node= ((SimpleType) elementType).getName();
1446
			} else if (elementType.isPackageQualifiedType()) {
1447
				node= ((PackageQualifiedType) elementType).getName();
1443
			} else {
1448
			} else {
1444
				return;
1449
				return;
1445
			}
1450
			}
Lines 1463-1469 Link Here
1463
			simpleBinding= simpleBinding.getTypeDeclaration();
1468
			simpleBinding= simpleBinding.getTypeDeclaration();
1464
		
1469
		
1465
			if (!simpleBinding.isRecovered()) {
1470
			if (!simpleBinding.isRecovered()) {
1466
				if (binding.isParameterizedType() && node.getParent() instanceof SimpleType && !(node.getParent().getParent() instanceof Type)) {
1471
				if (binding.isParameterizedType() && (node.getParent() instanceof SimpleType || node.getParent() instanceof PackageQualifiedType) && !(node.getParent().getParent() instanceof Type)) {
1467
					proposals.add(UnresolvedElementsSubProcessor.createTypeRefChangeFullProposal(cu, binding, node, IProposalRelevance.TYPE_ARGUMENTS_FROM_CONTEXT));
1472
					proposals.add(UnresolvedElementsSubProcessor.createTypeRefChangeFullProposal(cu, binding, node, IProposalRelevance.TYPE_ARGUMENTS_FROM_CONTEXT));
1468
				}
1473
				}
1469
			}
1474
			}
(-)ui/org/eclipse/jdt/internal/ui/text/correction/ModifierCorrectionSubProcessor.java (+8 lines)
Lines 5-10 Link Here
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
7
 *
8
 * This is an implementation of an early-draft specification developed under the Java
9
 * Community Process (JCP) and is made available for testing and evaluation purposes
10
 * only. The code is not compatible with any specification of the JCP.
11
 * 
8
 * Contributors:
12
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
13
 *     IBM Corporation - initial API and implementation
10
 *     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
14
 *     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
Lines 54-59 Link Here
54
import org.eclipse.jdt.core.dom.MethodDeclaration;
58
import org.eclipse.jdt.core.dom.MethodDeclaration;
55
import org.eclipse.jdt.core.dom.MethodInvocation;
59
import org.eclipse.jdt.core.dom.MethodInvocation;
56
import org.eclipse.jdt.core.dom.Modifier;
60
import org.eclipse.jdt.core.dom.Modifier;
61
import org.eclipse.jdt.core.dom.PackageQualifiedType;
57
import org.eclipse.jdt.core.dom.Modifier.ModifierKeyword;
62
import org.eclipse.jdt.core.dom.Modifier.ModifierKeyword;
58
import org.eclipse.jdt.core.dom.QualifiedName;
63
import org.eclipse.jdt.core.dom.QualifiedName;
59
import org.eclipse.jdt.core.dom.ReturnStatement;
64
import org.eclipse.jdt.core.dom.ReturnStatement;
Lines 127-132 Link Here
127
			case ASTNode.SIMPLE_TYPE:
132
			case ASTNode.SIMPLE_TYPE:
128
				binding= ((SimpleType) selectedNode).resolveBinding();
133
				binding= ((SimpleType) selectedNode).resolveBinding();
129
				break;
134
				break;
135
			case ASTNode.PACKAGE_QUALIFIED_TYPE:
136
				binding= ((PackageQualifiedType) selectedNode).resolveBinding();
137
				break;
130
			case ASTNode.METHOD_INVOCATION:
138
			case ASTNode.METHOD_INVOCATION:
131
				binding= ((MethodInvocation) selectedNode).getName().resolveBinding();
139
				binding= ((MethodInvocation) selectedNode).getName().resolveBinding();
132
				break;
140
				break;
(-)ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java (-17 / +21 lines)
Lines 82-87 Link Here
82
import org.eclipse.jdt.core.dom.Modifier;
82
import org.eclipse.jdt.core.dom.Modifier;
83
import org.eclipse.jdt.core.dom.Name;
83
import org.eclipse.jdt.core.dom.Name;
84
import org.eclipse.jdt.core.dom.NumberLiteral;
84
import org.eclipse.jdt.core.dom.NumberLiteral;
85
import org.eclipse.jdt.core.dom.PackageQualifiedType;
85
import org.eclipse.jdt.core.dom.ParameterizedType;
86
import org.eclipse.jdt.core.dom.ParameterizedType;
86
import org.eclipse.jdt.core.dom.ParenthesizedExpression;
87
import org.eclipse.jdt.core.dom.ParenthesizedExpression;
87
import org.eclipse.jdt.core.dom.PostfixExpression;
88
import org.eclipse.jdt.core.dom.PostfixExpression;
Lines 505-512 Link Here
505
		
506
		
506
		if (node instanceof Name) {
507
		if (node instanceof Name) {
507
			Name name= ASTNodes.getTopMostName((Name) node);
508
			Name name= ASTNodes.getTopMostName((Name) node);
508
			if (name.getLocationInParent() == SimpleType.NAME_PROPERTY) {
509
			if (name.getLocationInParent() == SimpleType.NAME_PROPERTY ||
509
				SimpleType type= (SimpleType) name.getParent();
510
					name.getLocationInParent() == PackageQualifiedType.NAME_PROPERTY) {
511
				ASTNode type= name.getParent();
510
				if (type.getLocationInParent() == ParameterizedType.TYPE_PROPERTY) {
512
				if (type.getLocationInParent() == ParameterizedType.TYPE_PROPERTY) {
511
					createdType= (ParameterizedType) type.getParent();
513
					createdType= (ParameterizedType) type.getParent();
512
					if (createdType.getLocationInParent() != ClassInstanceCreation.TYPE_PROPERTY) {
514
					if (createdType.getLocationInParent() != ClassInstanceCreation.TYPE_PROPERTY) {
Lines 1275-1281 Link Here
1275
		}
1277
		}
1276
1278
1277
		Type type= catchClause.getException().getType();
1279
		Type type= catchClause.getException().getType();
1278
		if (!type.isSimpleType() && !type.isUnionType()) {
1280
		if (!type.isSimpleType() && !type.isUnionType() && !type.isPackageQualifiedType()) {
1279
			return false;
1281
			return false;
1280
		}
1282
		}
1281
1283
Lines 1291-1302 Link Here
1291
		AST ast= bodyDeclaration.getAST();
1293
		AST ast= bodyDeclaration.getAST();
1292
		Image image= JavaPluginImages.get(JavaPluginImages.IMG_OBJS_EXCEPTION);
1294
		Image image= JavaPluginImages.get(JavaPluginImages.IMG_OBJS_EXCEPTION);
1293
1295
1294
		SimpleType selectedMultiCatchType= null;
1296
		Type selectedMultiCatchType= null;
1295
		if (type.isUnionType() && node instanceof Name) {
1297
		if (type.isUnionType() && node instanceof Name) {
1296
			Name topMostName= ASTNodes.getTopMostName((Name) node);
1298
			Name topMostName= ASTNodes.getTopMostName((Name) node);
1297
			ASTNode parent= topMostName.getParent();
1299
			ASTNode parent= topMostName.getParent();
1298
			if (parent instanceof SimpleType) {
1300
			if (parent instanceof SimpleType) {
1299
				selectedMultiCatchType= (SimpleType) parent;
1301
				selectedMultiCatchType= (SimpleType) parent;
1302
			} else if (parent instanceof PackageQualifiedType) {
1303
				selectedMultiCatchType= (PackageQualifiedType) parent;
1300
			}
1304
			}
1301
		}
1305
		}
1302
1306
Lines 1316-1327 Link Here
1316
					UnionType unionType= (UnionType) type;
1320
					UnionType unionType= (UnionType) type;
1317
					List<Type> types= unionType.types();
1321
					List<Type> types= unionType.types();
1318
					for (Type elementType : types) {
1322
					for (Type elementType : types) {
1319
						if (!(elementType instanceof SimpleType))
1323
						if (!(elementType instanceof SimpleType || elementType instanceof PackageQualifiedType))
1320
							return false;
1324
							return false;
1321
						addExceptionToThrows(ast, methodDeclaration, rewrite, (SimpleType) elementType);
1325
						addExceptionToThrows(ast, methodDeclaration, rewrite, elementType);
1322
					}
1326
					}
1323
				} else {
1327
				} else {
1324
					addExceptionToThrows(ast, methodDeclaration, rewrite, (SimpleType) type);
1328
					addExceptionToThrows(ast, methodDeclaration, rewrite, type);
1325
				}
1329
				}
1326
				String label= CorrectionMessages.QuickAssistProcessor_catchclausetothrows_description;
1330
				String label= CorrectionMessages.QuickAssistProcessor_catchclausetothrows_description;
1327
				ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, IProposalRelevance.REPLACE_CATCH_CLAUSE_WITH_THROWS, image);
1331
				ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, IProposalRelevance.REPLACE_CATCH_CLAUSE_WITH_THROWS, image);
Lines 1357-1363 Link Here
1357
		}
1361
		}
1358
	}
1362
	}
1359
1363
1360
	private static void addExceptionToThrows(AST ast, MethodDeclaration methodDeclaration, ASTRewrite rewrite, SimpleType type2) {
1364
	private static void addExceptionToThrows(AST ast, MethodDeclaration methodDeclaration, ASTRewrite rewrite, Type type2) {
1361
		ITypeBinding binding= type2.resolveBinding();
1365
		ITypeBinding binding= type2.resolveBinding();
1362
		if (binding == null || isNotYetThrown(binding, methodDeclaration.thrownExceptionTypes())) {
1366
		if (binding == null || isNotYetThrown(binding, methodDeclaration.thrownExceptionTypes())) {
1363
			Type newType= (Type) ASTNode.copySubtree(ast, type2);
1367
			Type newType= (Type) ASTNode.copySubtree(ast, type2);
Lines 1424-1435 Link Here
1424
			return false;
1428
			return false;
1425
		}
1429
		}
1426
1430
1427
		SimpleType selectedMultiCatchType= null;
1431
		Type selectedMultiCatchType= null;
1428
		if (type.isUnionType() && node instanceof Name) {
1432
		if (type.isUnionType() && node instanceof Name) {
1429
			Name topMostName= ASTNodes.getTopMostName((Name) node);
1433
			Name topMostName= ASTNodes.getTopMostName((Name) node);
1430
			ASTNode parent= topMostName.getParent();
1434
			ASTNode parent= topMostName.getParent();
1431
			if (parent instanceof SimpleType) {
1435
			if (parent instanceof SimpleType || parent instanceof PackageQualifiedType) {
1432
				selectedMultiCatchType= (SimpleType) parent;
1436
				selectedMultiCatchType= (Type) parent;
1433
			}
1437
			}
1434
		}
1438
		}
1435
1439
Lines 1497-1508 Link Here
1497
		}
1501
		}
1498
1502
1499
		Type type1= catchClause.getException().getType();
1503
		Type type1= catchClause.getException().getType();
1500
		SimpleType selectedMultiCatchType= null;
1504
		Type selectedMultiCatchType= null;
1501
		if (type1.isUnionType() && covering instanceof Name) {
1505
		if (type1.isUnionType() && covering instanceof Name) {
1502
			Name topMostName= ASTNodes.getTopMostName((Name) covering);
1506
			Name topMostName= ASTNodes.getTopMostName((Name) covering);
1503
			ASTNode parent= topMostName.getParent();
1507
			ASTNode parent= topMostName.getParent();
1504
			if (parent instanceof SimpleType) {
1508
			if (parent instanceof SimpleType || parent instanceof PackageQualifiedType) {
1505
				selectedMultiCatchType= (SimpleType) parent;
1509
				selectedMultiCatchType= (Type) parent;
1506
			}
1510
			}
1507
		}
1511
		}
1508
		if (selectedMultiCatchType != null)
1512
		if (selectedMultiCatchType != null)
Lines 1588-1599 Link Here
1588
		}
1592
		}
1589
1593
1590
		Type type1= catchClause.getException().getType();
1594
		Type type1= catchClause.getException().getType();
1591
		SimpleType selectedMultiCatchType= null;
1595
		Type selectedMultiCatchType= null;
1592
		if (type1.isUnionType() && covering instanceof Name) {
1596
		if (type1.isUnionType() && covering instanceof Name) {
1593
			Name topMostName= ASTNodes.getTopMostName((Name) covering);
1597
			Name topMostName= ASTNodes.getTopMostName((Name) covering);
1594
			ASTNode parent= topMostName.getParent();
1598
			ASTNode parent= topMostName.getParent();
1595
			if (parent instanceof SimpleType) {
1599
			if (parent instanceof SimpleType || parent instanceof PackageQualifiedType) {
1596
				selectedMultiCatchType= (SimpleType) parent;
1600
				selectedMultiCatchType= (Type) parent;
1597
			}
1601
			}
1598
		}
1602
		}
1599
		if (selectedMultiCatchType != null)
1603
		if (selectedMultiCatchType != null)
(-)ui/org/eclipse/jdt/internal/ui/text/correction/TypeMismatchSubProcessor.java (-6 / +17 lines)
Lines 5-10 Link Here
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
7
 *
8
 * This is an implementation of an early-draft specification developed under the Java
9
 * Community Process (JCP) and is made available for testing and evaluation purposes
10
 * only. The code is not compatible with any specification of the JCP.
11
 * 
8
 * Contributors:
12
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
13
 *     IBM Corporation - initial API and implementation
10
 *     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
14
 *     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
Lines 39-44 Link Here
39
import org.eclipse.jdt.core.dom.MemberValuePair;
43
import org.eclipse.jdt.core.dom.MemberValuePair;
40
import org.eclipse.jdt.core.dom.MethodDeclaration;
44
import org.eclipse.jdt.core.dom.MethodDeclaration;
41
import org.eclipse.jdt.core.dom.Name;
45
import org.eclipse.jdt.core.dom.Name;
46
import org.eclipse.jdt.core.dom.PackageQualifiedType;
42
import org.eclipse.jdt.core.dom.SimpleName;
47
import org.eclipse.jdt.core.dom.SimpleName;
43
import org.eclipse.jdt.core.dom.SimpleType;
48
import org.eclipse.jdt.core.dom.SimpleType;
44
import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
49
import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
Lines 455-470 Link Here
455
		SingleVariableDeclaration parameter= forStatement.getParameter();
460
		SingleVariableDeclaration parameter= forStatement.getParameter();
456
461
457
		ICompilationUnit cu= context.getCompilationUnit();
462
		ICompilationUnit cu= context.getCompilationUnit();
458
		if (parameter.getName().getLength() == 0
463
		if (parameter.getName().getLength() == 0) {
459
				&& parameter.getType() instanceof SimpleType) {
464
			SimpleName simpleName= null;
460
			SimpleType type= (SimpleType) parameter.getType();
465
			if (parameter.getType() instanceof SimpleType) {
461
			if (type.getName() instanceof SimpleName) {
466
				SimpleType type= (SimpleType) parameter.getType();
462
				SimpleName simpleName= (SimpleName) type.getName();
467
				if (type.getName() instanceof SimpleName) {
468
					simpleName= (SimpleName) type.getName();
469
				}
470
			} else if (parameter.getType() instanceof PackageQualifiedType) {
471
				simpleName= ((PackageQualifiedType) parameter.getType()).getName();
472
			}
473
			if (simpleName != null) {
463
				String name= simpleName.getIdentifier();
474
				String name= simpleName.getIdentifier();
464
				int relevance= StubUtility.hasLocalVariableName(cu.getJavaProject(), name) ? 10 : 7;
475
				int relevance= StubUtility.hasLocalVariableName(cu.getJavaProject(), name) ? 10 : 7;
465
				String label= Messages.format(CorrectionMessages.TypeMismatchSubProcessor_create_loop_variable_description, BasicElementLabels.getJavaElementName(name));
476
				String label= Messages.format(CorrectionMessages.TypeMismatchSubProcessor_create_loop_variable_description, BasicElementLabels.getJavaElementName(name));
466
				Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_LOCAL);
477
				Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_LOCAL);
467
				
478
468
				proposals.add(new NewVariableCorrectionProposal(label, cu, NewVariableCorrectionProposal.LOCAL, simpleName, null, relevance, image));
479
				proposals.add(new NewVariableCorrectionProposal(label, cu, NewVariableCorrectionProposal.LOCAL, simpleName, null, relevance, image));
469
				return;
480
				return;
470
			}
481
			}
(-)ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java (-5 / +14 lines)
Lines 5-10 Link Here
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
7
 *
8
 * This is an implementation of an early-draft specification developed under the Java
9
 * Community Process (JCP) and is made available for testing and evaluation purposes
10
 * only. The code is not compatible with any specification of the JCP.
11
 * 
8
 * Contributors:
12
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
13
 *     IBM Corporation - initial API and implementation
10
 *     Renaud Waldura &lt;renaud+eclipse@waldura.com&gt; - New class/interface with wizard
14
 *     Renaud Waldura &lt;renaud+eclipse@waldura.com&gt; - New class/interface with wizard
Lines 96-101 Link Here
96
import org.eclipse.jdt.core.dom.Modifier;
100
import org.eclipse.jdt.core.dom.Modifier;
97
import org.eclipse.jdt.core.dom.Name;
101
import org.eclipse.jdt.core.dom.Name;
98
import org.eclipse.jdt.core.dom.NormalAnnotation;
102
import org.eclipse.jdt.core.dom.NormalAnnotation;
103
import org.eclipse.jdt.core.dom.PackageQualifiedType;
99
import org.eclipse.jdt.core.dom.ParenthesizedExpression;
104
import org.eclipse.jdt.core.dom.ParenthesizedExpression;
100
import org.eclipse.jdt.core.dom.QualifiedName;
105
import org.eclipse.jdt.core.dom.QualifiedName;
101
import org.eclipse.jdt.core.dom.SimpleName;
106
import org.eclipse.jdt.core.dom.SimpleName;
Lines 211-217 Link Here
211
							node= null;
216
							node= null;
212
						}
217
						}
213
					}
218
					}
214
				} else if (parent instanceof SimpleType) {
219
				} else if (parent instanceof SimpleType || parent instanceof PackageQualifiedType) {
215
					suggestVariableProposals= false;
220
					suggestVariableProposals= false;
216
					typeKind= SimilarElementsRequestor.REF_TYPES_AND_VAR;
221
					typeKind= SimilarElementsRequestor.REF_TYPES_AND_VAR;
217
				} else if (parent instanceof QualifiedName) {
222
				} else if (parent instanceof QualifiedName) {
Lines 225-231 Link Here
225
					while (outerParent instanceof QualifiedName) {
230
					while (outerParent instanceof QualifiedName) {
226
						outerParent= outerParent.getParent();
231
						outerParent= outerParent.getParent();
227
					}
232
					}
228
					if (outerParent instanceof SimpleType) {
233
					if (outerParent instanceof SimpleType || outerParent instanceof PackageQualifiedType) {
229
						typeKind= SimilarElementsRequestor.REF_TYPES;
234
						typeKind= SimilarElementsRequestor.REF_TYPES;
230
						suggestVariableProposals= false;
235
						suggestVariableProposals= false;
231
					}
236
					}
Lines 249-255 Link Here
249
					typeKind= SimilarElementsRequestor.REF_TYPES;
254
					typeKind= SimilarElementsRequestor.REF_TYPES;
250
					suggestVariableProposals= node.isSimpleName();
255
					suggestVariableProposals= node.isSimpleName();
251
				}
256
				}
252
				if (selectedNode.getParent() instanceof SimpleType) {
257
				if (selectedNode.getParent() instanceof SimpleType || selectedNode.getParent() instanceof PackageQualifiedType) {
253
					typeKind= SimilarElementsRequestor.REF_TYPES;
258
					typeKind= SimilarElementsRequestor.REF_TYPES;
254
					suggestVariableProposals= false;
259
					suggestVariableProposals= false;
255
				}
260
				}
Lines 609-618 Link Here
609
		Name node= null;
614
		Name node= null;
610
		if (selectedNode instanceof SimpleType) {
615
		if (selectedNode instanceof SimpleType) {
611
			node= ((SimpleType) selectedNode).getName();
616
			node= ((SimpleType) selectedNode).getName();
617
		} else if (selectedNode instanceof PackageQualifiedType) {
618
			node= ((PackageQualifiedType) selectedNode).getName();
612
		} else if (selectedNode instanceof ArrayType) {
619
		} else if (selectedNode instanceof ArrayType) {
613
			Type elementType= ((ArrayType) selectedNode).getElementType();
620
			Type elementType= ((ArrayType) selectedNode).getElementType();
614
			if (elementType.isSimpleType()) {
621
			if (elementType.isSimpleType()) {
615
				node= ((SimpleType) elementType).getName();
622
				node= ((SimpleType) elementType).getName();
623
			} else if (elementType.isPackageQualifiedType()) {
624
				node= ((PackageQualifiedType) elementType).getName();
616
			} else {
625
			} else {
617
				return;
626
				return;
618
			}
627
			}
Lines 641-647 Link Here
641
	}
650
	}
642
651
643
	private static void addEnhancedForWithoutTypeProposals(ICompilationUnit cu, ASTNode selectedNode, Collection<ICommandAccess> proposals) {
652
	private static void addEnhancedForWithoutTypeProposals(ICompilationUnit cu, ASTNode selectedNode, Collection<ICommandAccess> proposals) {
644
		if (selectedNode instanceof SimpleName && selectedNode.getLocationInParent() == SimpleType.NAME_PROPERTY) {
653
		if (selectedNode instanceof SimpleName && (selectedNode.getLocationInParent() == SimpleType.NAME_PROPERTY || selectedNode.getLocationInParent() == PackageQualifiedType.NAME_PROPERTY)) {
645
			ASTNode type= selectedNode.getParent();
654
			ASTNode type= selectedNode.getParent();
646
			if (type.getLocationInParent() == SingleVariableDeclaration.TYPE_PROPERTY) {
655
			if (type.getLocationInParent() == SingleVariableDeclaration.TYPE_PROPERTY) {
647
				SingleVariableDeclaration svd= (SingleVariableDeclaration) type.getParent();
656
				SingleVariableDeclaration svd= (SingleVariableDeclaration) type.getParent();
Lines 840-846 Link Here
840
				if (proposal instanceof AddImportCorrectionProposal)
849
				if (proposal instanceof AddImportCorrectionProposal)
841
					proposal.setRelevance(relevance + elements.length + 2);
850
					proposal.setRelevance(relevance + elements.length + 2);
842
851
843
				if (binding.isParameterizedType() && node.getParent() instanceof SimpleType && !(node.getParent().getParent() instanceof Type)) {
852
				if (binding.isParameterizedType() && (node.getParent() instanceof SimpleType || node.getParent() instanceof PackageQualifiedType) && !(node.getParent().getParent() instanceof Type)) {
844
					proposals.add(createTypeRefChangeFullProposal(cu, binding, node, relevance + 5));
853
					proposals.add(createTypeRefChangeFullProposal(cu, binding, node, relevance + 5));
845
				}
854
				}
846
			}
855
			}
(-)ui/org/eclipse/jdt/internal/ui/text/java/hover/JavadocHover.java (-1 / +4 lines)
Lines 84-89 Link Here
84
import org.eclipse.jdt.core.dom.ITypeBinding;
84
import org.eclipse.jdt.core.dom.ITypeBinding;
85
import org.eclipse.jdt.core.dom.IVariableBinding;
85
import org.eclipse.jdt.core.dom.IVariableBinding;
86
import org.eclipse.jdt.core.dom.NodeFinder;
86
import org.eclipse.jdt.core.dom.NodeFinder;
87
import org.eclipse.jdt.core.dom.PackageQualifiedType;
87
import org.eclipse.jdt.core.dom.ParameterizedType;
88
import org.eclipse.jdt.core.dom.ParameterizedType;
88
import org.eclipse.jdt.core.dom.QualifiedName;
89
import org.eclipse.jdt.core.dom.QualifiedName;
89
import org.eclipse.jdt.core.dom.QualifiedType;
90
import org.eclipse.jdt.core.dom.QualifiedType;
Lines 1042-1048 Link Here
1042
			// workaround for https://bugs.eclipse.org/62605 (constructor name resolves to type, not method)
1043
			// workaround for https://bugs.eclipse.org/62605 (constructor name resolves to type, not method)
1043
			SimpleName simpleName= (SimpleName) node;
1044
			SimpleName simpleName= (SimpleName) node;
1044
			StructuralPropertyDescriptor loc= simpleName.getLocationInParent();
1045
			StructuralPropertyDescriptor loc= simpleName.getLocationInParent();
1045
			while (loc == QualifiedType.NAME_PROPERTY || loc == QualifiedName.NAME_PROPERTY|| loc == SimpleType.NAME_PROPERTY || loc == ParameterizedType.TYPE_PROPERTY) {
1046
			while (loc == QualifiedType.NAME_PROPERTY || loc == QualifiedName.NAME_PROPERTY
1047
					|| loc == SimpleType.NAME_PROPERTY || loc == PackageQualifiedType.NAME_PROPERTY
1048
					|| loc == ParameterizedType.TYPE_PROPERTY) {
1046
				node= node.getParent();
1049
				node= node.getParent();
1047
				loc= node.getLocationInParent();
1050
				loc= node.getLocationInParent();
1048
			}
1051
			}

Return to bug 407056