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/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, 2014 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.NameQualifiedType;
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 NameQualifiedType) {
393
			name= ((NameQualifiedType) 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 NameQualifiedType)
400
				name= ((NameQualifiedType) 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, 2014 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 63-68 Link Here
63
import org.eclipse.jdt.core.dom.MethodDeclaration;
67
import org.eclipse.jdt.core.dom.MethodDeclaration;
64
import org.eclipse.jdt.core.dom.MethodInvocation;
68
import org.eclipse.jdt.core.dom.MethodInvocation;
65
import org.eclipse.jdt.core.dom.Name;
69
import org.eclipse.jdt.core.dom.Name;
70
import org.eclipse.jdt.core.dom.NameQualifiedType;
66
import org.eclipse.jdt.core.dom.NodeFinder;
71
import org.eclipse.jdt.core.dom.NodeFinder;
67
import org.eclipse.jdt.core.dom.PackageDeclaration;
72
import org.eclipse.jdt.core.dom.PackageDeclaration;
68
import org.eclipse.jdt.core.dom.SimpleType;
73
import org.eclipse.jdt.core.dom.SimpleType;
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 == NameQualifiedType.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, 2014 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 31-36 Link Here
31
import org.eclipse.jdt.core.dom.MethodInvocation;
35
import org.eclipse.jdt.core.dom.MethodInvocation;
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;
38
import org.eclipse.jdt.core.dom.NameQualifiedType;
34
import org.eclipse.jdt.core.dom.NodeFinder;
39
import org.eclipse.jdt.core.dom.NodeFinder;
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;
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 NameQualifiedType) {
196
			Name name= ((NameQualifiedType) 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 (-2 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2013 IBM Corporation and others.
2
 * Copyright (c) 2000, 2014 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
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.NameQualifiedType;
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 == NameQualifiedType.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 (-2 / +7 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2013 IBM Corporation and others.
2
 * Copyright (c) 2000, 2014 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
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.NameQualifiedType;
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 NameQualifiedType) {
1441
			node= ((NameQualifiedType) 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.isNameQualifiedType()) {
1447
				node= ((NameQualifiedType) 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 NameQualifiedType) && !(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 (-1 / +9 lines)
Lines 1-10 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2013 IBM Corporation and others.
2
 * Copyright (c) 2000, 2014 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
 *     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.NameQualifiedType;
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.NAME_QUALIFIED_TYPE:
136
				binding= ((NameQualifiedType) 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 (-18 / +22 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2013 IBM Corporation and others.
2
 * Copyright (c) 2000, 2014 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
Lines 82-87 Link Here
82
import org.eclipse.jdt.core.dom.MethodInvocation;
82
import org.eclipse.jdt.core.dom.MethodInvocation;
83
import org.eclipse.jdt.core.dom.Modifier;
83
import org.eclipse.jdt.core.dom.Modifier;
84
import org.eclipse.jdt.core.dom.Name;
84
import org.eclipse.jdt.core.dom.Name;
85
import org.eclipse.jdt.core.dom.NameQualifiedType;
85
import org.eclipse.jdt.core.dom.NumberLiteral;
86
import org.eclipse.jdt.core.dom.NumberLiteral;
86
import org.eclipse.jdt.core.dom.ParameterizedType;
87
import org.eclipse.jdt.core.dom.ParameterizedType;
87
import org.eclipse.jdt.core.dom.ParenthesizedExpression;
88
import org.eclipse.jdt.core.dom.ParenthesizedExpression;
Lines 579-586 Link Here
579
		
580
		
580
		if (node instanceof Name) {
581
		if (node instanceof Name) {
581
			Name name= ASTNodes.getTopMostName((Name) node);
582
			Name name= ASTNodes.getTopMostName((Name) node);
582
			if (name.getLocationInParent() == SimpleType.NAME_PROPERTY) {
583
			if (name.getLocationInParent() == SimpleType.NAME_PROPERTY ||
583
				SimpleType type= (SimpleType) name.getParent();
584
					name.getLocationInParent() == NameQualifiedType.NAME_PROPERTY) {
585
				ASTNode type= name.getParent();
584
				if (type.getLocationInParent() == ParameterizedType.TYPE_PROPERTY) {
586
				if (type.getLocationInParent() == ParameterizedType.TYPE_PROPERTY) {
585
					createdType= (ParameterizedType) type.getParent();
587
					createdType= (ParameterizedType) type.getParent();
586
					if (createdType.getLocationInParent() != ClassInstanceCreation.TYPE_PROPERTY) {
588
					if (createdType.getLocationInParent() != ClassInstanceCreation.TYPE_PROPERTY) {
Lines 1349-1355 Link Here
1349
		}
1351
		}
1350
1352
1351
		Type type= catchClause.getException().getType();
1353
		Type type= catchClause.getException().getType();
1352
		if (!type.isSimpleType() && !type.isUnionType()) {
1354
		if (!type.isSimpleType() && !type.isUnionType() && !type.isNameQualifiedType()) {
1353
			return false;
1355
			return false;
1354
		}
1356
		}
1355
1357
Lines 1365-1376 Link Here
1365
		AST ast= bodyDeclaration.getAST();
1367
		AST ast= bodyDeclaration.getAST();
1366
		Image image= JavaPluginImages.get(JavaPluginImages.IMG_OBJS_EXCEPTION);
1368
		Image image= JavaPluginImages.get(JavaPluginImages.IMG_OBJS_EXCEPTION);
1367
1369
1368
		SimpleType selectedMultiCatchType= null;
1370
		Type selectedMultiCatchType= null;
1369
		if (type.isUnionType() && node instanceof Name) {
1371
		if (type.isUnionType() && node instanceof Name) {
1370
			Name topMostName= ASTNodes.getTopMostName((Name) node);
1372
			Name topMostName= ASTNodes.getTopMostName((Name) node);
1371
			ASTNode parent= topMostName.getParent();
1373
			ASTNode parent= topMostName.getParent();
1372
			if (parent instanceof SimpleType) {
1374
			if (parent instanceof SimpleType) {
1373
				selectedMultiCatchType= (SimpleType) parent;
1375
				selectedMultiCatchType= (SimpleType) parent;
1376
			} else if (parent instanceof NameQualifiedType) {
1377
				selectedMultiCatchType= (NameQualifiedType) parent;
1374
			}
1378
			}
1375
		}
1379
		}
1376
1380
Lines 1390-1401 Link Here
1390
					UnionType unionType= (UnionType) type;
1394
					UnionType unionType= (UnionType) type;
1391
					List<Type> types= unionType.types();
1395
					List<Type> types= unionType.types();
1392
					for (Type elementType : types) {
1396
					for (Type elementType : types) {
1393
						if (!(elementType instanceof SimpleType))
1397
						if (!(elementType instanceof SimpleType || elementType instanceof NameQualifiedType))
1394
							return false;
1398
							return false;
1395
						addExceptionToThrows(ast, methodDeclaration, rewrite, (SimpleType) elementType);
1399
						addExceptionToThrows(ast, methodDeclaration, rewrite, elementType);
1396
					}
1400
					}
1397
				} else {
1401
				} else {
1398
					addExceptionToThrows(ast, methodDeclaration, rewrite, (SimpleType) type);
1402
					addExceptionToThrows(ast, methodDeclaration, rewrite, type);
1399
				}
1403
				}
1400
				String label= CorrectionMessages.QuickAssistProcessor_catchclausetothrows_description;
1404
				String label= CorrectionMessages.QuickAssistProcessor_catchclausetothrows_description;
1401
				ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, IProposalRelevance.REPLACE_CATCH_CLAUSE_WITH_THROWS, image);
1405
				ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, IProposalRelevance.REPLACE_CATCH_CLAUSE_WITH_THROWS, image);
Lines 1431-1437 Link Here
1431
		}
1435
		}
1432
	}
1436
	}
1433
1437
1434
	private static void addExceptionToThrows(AST ast, MethodDeclaration methodDeclaration, ASTRewrite rewrite, SimpleType type2) {
1438
	private static void addExceptionToThrows(AST ast, MethodDeclaration methodDeclaration, ASTRewrite rewrite, Type type2) {
1435
		ITypeBinding binding= type2.resolveBinding();
1439
		ITypeBinding binding= type2.resolveBinding();
1436
		if (binding == null || isNotYetThrown(binding, methodDeclaration.thrownExceptionTypes())) {
1440
		if (binding == null || isNotYetThrown(binding, methodDeclaration.thrownExceptionTypes())) {
1437
			Type newType= (Type) ASTNode.copySubtree(ast, type2);
1441
			Type newType= (Type) ASTNode.copySubtree(ast, type2);
Lines 1498-1509 Link Here
1498
			return false;
1502
			return false;
1499
		}
1503
		}
1500
1504
1501
		SimpleType selectedMultiCatchType= null;
1505
		Type selectedMultiCatchType= null;
1502
		if (type.isUnionType() && node instanceof Name) {
1506
		if (type.isUnionType() && node instanceof Name) {
1503
			Name topMostName= ASTNodes.getTopMostName((Name) node);
1507
			Name topMostName= ASTNodes.getTopMostName((Name) node);
1504
			ASTNode parent= topMostName.getParent();
1508
			ASTNode parent= topMostName.getParent();
1505
			if (parent instanceof SimpleType) {
1509
			if (parent instanceof SimpleType || parent instanceof NameQualifiedType) {
1506
				selectedMultiCatchType= (SimpleType) parent;
1510
				selectedMultiCatchType= (Type) parent;
1507
			}
1511
			}
1508
		}
1512
		}
1509
1513
Lines 1571-1582 Link Here
1571
		}
1575
		}
1572
1576
1573
		Type type1= catchClause.getException().getType();
1577
		Type type1= catchClause.getException().getType();
1574
		SimpleType selectedMultiCatchType= null;
1578
		Type selectedMultiCatchType= null;
1575
		if (type1.isUnionType() && covering instanceof Name) {
1579
		if (type1.isUnionType() && covering instanceof Name) {
1576
			Name topMostName= ASTNodes.getTopMostName((Name) covering);
1580
			Name topMostName= ASTNodes.getTopMostName((Name) covering);
1577
			ASTNode parent= topMostName.getParent();
1581
			ASTNode parent= topMostName.getParent();
1578
			if (parent instanceof SimpleType) {
1582
			if (parent instanceof SimpleType || parent instanceof NameQualifiedType) {
1579
				selectedMultiCatchType= (SimpleType) parent;
1583
				selectedMultiCatchType= (Type) parent;
1580
			}
1584
			}
1581
		}
1585
		}
1582
		if (selectedMultiCatchType != null)
1586
		if (selectedMultiCatchType != null)
Lines 1662-1673 Link Here
1662
		}
1666
		}
1663
1667
1664
		Type type1= catchClause.getException().getType();
1668
		Type type1= catchClause.getException().getType();
1665
		SimpleType selectedMultiCatchType= null;
1669
		Type selectedMultiCatchType= null;
1666
		if (type1.isUnionType() && covering instanceof Name) {
1670
		if (type1.isUnionType() && covering instanceof Name) {
1667
			Name topMostName= ASTNodes.getTopMostName((Name) covering);
1671
			Name topMostName= ASTNodes.getTopMostName((Name) covering);
1668
			ASTNode parent= topMostName.getParent();
1672
			ASTNode parent= topMostName.getParent();
1669
			if (parent instanceof SimpleType) {
1673
			if (parent instanceof SimpleType || parent instanceof NameQualifiedType) {
1670
				selectedMultiCatchType= (SimpleType) parent;
1674
				selectedMultiCatchType= (Type) parent;
1671
			}
1675
			}
1672
		}
1676
		}
1673
		if (selectedMultiCatchType != null)
1677
		if (selectedMultiCatchType != null)
(-)ui/org/eclipse/jdt/internal/ui/text/correction/TypeMismatchSubProcessor.java (-6 / +17 lines)
Lines 1-10 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2013 IBM Corporation and others.
2
 * Copyright (c) 2000, 2014 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
 *     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.NameQualifiedType;
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-465 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 NameQualifiedType) {
471
				simpleName= ((NameQualifiedType) 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));
(-)ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java (-6 / +15 lines)
Lines 1-10 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2013 IBM Corporation and others.
2
 * Copyright (c) 2000, 2014 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
 *     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 95-100 Link Here
95
import org.eclipse.jdt.core.dom.MethodInvocation;
99
import org.eclipse.jdt.core.dom.MethodInvocation;
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;
102
import org.eclipse.jdt.core.dom.NameQualifiedType;
98
import org.eclipse.jdt.core.dom.NormalAnnotation;
103
import org.eclipse.jdt.core.dom.NormalAnnotation;
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;
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 NameQualifiedType) {
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 NameQualifiedType) {
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 NameQualifiedType) {
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 NameQualifiedType) {
618
			node= ((NameQualifiedType) 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.isNameQualifiedType()) {
624
				node= ((NameQualifiedType) 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() == NameQualifiedType.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 841-847 Link Here
841
				if (proposal instanceof AddImportCorrectionProposal)
850
				if (proposal instanceof AddImportCorrectionProposal)
842
					proposal.setRelevance(relevance + elements.length + 2);
851
					proposal.setRelevance(relevance + elements.length + 2);
843
852
844
				if (binding.isParameterizedType() && node.getParent() instanceof SimpleType && !(node.getParent().getParent() instanceof Type)) {
853
				if (binding.isParameterizedType() && (node.getParent() instanceof SimpleType || node.getParent() instanceof NameQualifiedType) && !(node.getParent().getParent() instanceof Type)) {
845
					proposals.add(createTypeRefChangeFullProposal(cu, binding, node, relevance + 5));
854
					proposals.add(createTypeRefChangeFullProposal(cu, binding, node, relevance + 5));
846
				}
855
				}
847
			}
856
			}
(-)ui/org/eclipse/jdt/internal/ui/text/java/hover/JavadocHover.java (-2 / +9 lines)
Lines 1-10 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2013 IBM Corporation and others.
2
 * Copyright (c) 2000, 2014 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
 *     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
14
 *     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
Lines 83-88 Link Here
83
import org.eclipse.jdt.core.dom.IMethodBinding;
87
import org.eclipse.jdt.core.dom.IMethodBinding;
84
import org.eclipse.jdt.core.dom.ITypeBinding;
88
import org.eclipse.jdt.core.dom.ITypeBinding;
85
import org.eclipse.jdt.core.dom.IVariableBinding;
89
import org.eclipse.jdt.core.dom.IVariableBinding;
90
import org.eclipse.jdt.core.dom.NameQualifiedType;
86
import org.eclipse.jdt.core.dom.NodeFinder;
91
import org.eclipse.jdt.core.dom.NodeFinder;
87
import org.eclipse.jdt.core.dom.ParameterizedType;
92
import org.eclipse.jdt.core.dom.ParameterizedType;
88
import org.eclipse.jdt.core.dom.QualifiedName;
93
import org.eclipse.jdt.core.dom.QualifiedName;
Lines 1042-1048 Link Here
1042
			// workaround for https://bugs.eclipse.org/62605 (constructor name resolves to type, not method)
1047
			// workaround for https://bugs.eclipse.org/62605 (constructor name resolves to type, not method)
1043
			SimpleName simpleName= (SimpleName) node;
1048
			SimpleName simpleName= (SimpleName) node;
1044
			StructuralPropertyDescriptor loc= simpleName.getLocationInParent();
1049
			StructuralPropertyDescriptor loc= simpleName.getLocationInParent();
1045
			while (loc == QualifiedType.NAME_PROPERTY || loc == QualifiedName.NAME_PROPERTY|| loc == SimpleType.NAME_PROPERTY || loc == ParameterizedType.TYPE_PROPERTY) {
1050
			while (loc == QualifiedType.NAME_PROPERTY || loc == QualifiedName.NAME_PROPERTY
1051
					|| loc == SimpleType.NAME_PROPERTY || loc == NameQualifiedType.NAME_PROPERTY
1052
					|| loc == ParameterizedType.TYPE_PROPERTY) {
1046
				node= node.getParent();
1053
				node= node.getParent();
1047
				loc= node.getLocationInParent();
1054
				loc= node.getLocationInParent();
1048
			}
1055
			}

Return to bug 407056