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

(-)test (+39 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2013 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * This is an implementation of an early-draft specification developed under the Java Community Process (JCP) and
9
 * is made available for testing and evaluation purposes only.
10
 * The code is not compatible with any specification of the JCP.
11
 * 
12
 * Contributors:
13
 *     IBM Corporation - initial API and implementation
14
 *******************************************************************************/
15
package org.eclipse.jdt.ui.tests.refactoring;
16
17
import junit.framework.Test;
18
19
import org.eclipse.jdt.testplugin.JavaProjectHelper;
20
21
import org.eclipse.core.runtime.CoreException;
22
23
import org.eclipse.jdt.core.IJavaProject;
24
import org.eclipse.jdt.core.IPackageFragmentRoot;
25
26
public class Java18Setup extends RefactoringTestSetup {
27
28
	public Java18Setup(Test test) {
29
		super(test);
30
	}
31
32
	/*
33
	 * @see org.eclipse.jdt.ui.tests.refactoring.RefactoringTestSetup#addRTJar(org.eclipse.jdt.core.IJavaProject)
34
	 */
35
	@Override
36
	protected IPackageFragmentRoot addRTJar(IJavaProject project) throws CoreException {
37
		return JavaProjectHelper.addRTJar18(project);
38
	}
39
}
(-)test (+450 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2013 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * This is an implementation of an early-draft specification developed under the Java Community Process (JCP) and
9
 * is made available for testing and evaluation purposes only.
10
 * The code is not compatible with any specification of the JCP.
11
 * 
12
 * Contributors:
13
 *     IBM Corporation - initial API and implementation
14
 *******************************************************************************/
15
package org.eclipse.jdt.ui.tests.refactoring;
16
17
import java.util.Arrays;
18
import java.util.Hashtable;
19
import java.util.List;
20
21
import junit.framework.Test;
22
import junit.framework.TestSuite;
23
24
import org.eclipse.jdt.testplugin.TestOptions;
25
26
import org.eclipse.core.runtime.Assert;
27
import org.eclipse.core.runtime.NullProgressMonitor;
28
29
import org.eclipse.ltk.core.refactoring.Refactoring;
30
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
31
import org.eclipse.ltk.core.refactoring.participants.MoveRefactoring;
32
import org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring;
33
34
import org.eclipse.jdt.core.ICompilationUnit;
35
import org.eclipse.jdt.core.IField;
36
import org.eclipse.jdt.core.IJavaElement;
37
import org.eclipse.jdt.core.IJavaProject;
38
import org.eclipse.jdt.core.IMember;
39
import org.eclipse.jdt.core.IMethod;
40
import org.eclipse.jdt.core.IPackageFragment;
41
import org.eclipse.jdt.core.IType;
42
import org.eclipse.jdt.core.JavaCore;
43
import org.eclipse.jdt.core.JavaModelException;
44
import org.eclipse.jdt.core.dom.IVariableBinding;
45
import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants;
46
47
import org.eclipse.jdt.internal.corext.codemanipulation.CodeGenerationSettings;
48
import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility;
49
import org.eclipse.jdt.internal.corext.refactoring.RefactoringAvailabilityTester;
50
import org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceProcessor;
51
import org.eclipse.jdt.internal.corext.refactoring.structure.ExtractSupertypeProcessor;
52
import org.eclipse.jdt.internal.corext.refactoring.structure.MoveInnerToTopRefactoring;
53
import org.eclipse.jdt.internal.corext.refactoring.structure.MoveInstanceMethodProcessor;
54
import org.eclipse.jdt.internal.corext.refactoring.structure.PullUpRefactoringProcessor;
55
import org.eclipse.jdt.internal.corext.refactoring.structure.PushDownRefactoringProcessor;
56
import org.eclipse.jdt.internal.corext.refactoring.structure.PushDownRefactoringProcessor.MemberActionInfo;
57
import org.eclipse.jdt.internal.corext.refactoring.util.JavaElementUtil;
58
import org.eclipse.jdt.internal.corext.template.java.CodeTemplateContextType;
59
60
import org.eclipse.jdt.internal.ui.preferences.JavaPreferencesSettings;
61
62
public class ReceiverParameterTests18 extends RefactoringTest {
63
64
	private static final Class clazz= ReceiverParameterTests18.class;
65
66
	private static final String REFACTORING_PATH= "ReceiverParameter/";
67
68
	private Hashtable fOldOptions;
69
70
	public ReceiverParameterTests18(String name) {
71
		super(name);
72
	}
73
74
	public static Test suite() {
75
		return new Java18Setup(new TestSuite(clazz));
76
	}
77
78
	public static Test setUpTest(Test someTest) {
79
		return new Java18Setup(someTest);
80
	}
81
82
	@Override
83
	protected void setUp() throws Exception {
84
		super.setUp();
85
		StubUtility.setCodeTemplate(CodeTemplateContextType.NEWTYPE_ID,
86
				"${package_declaration}" +
87
						System.getProperty("line.separator", "\n") +
88
						"${" + CodeTemplateContextType.TYPE_COMMENT + "}" +
89
						System.getProperty("line.separator", "\n") +
90
						"${type_declaration}", null);
91
92
		StubUtility.setCodeTemplate(CodeTemplateContextType.TYPECOMMENT_ID, "/** typecomment template*/", null);
93
94
		fOldOptions= JavaCore.getOptions();
95
96
		Hashtable options= TestOptions.getDefaultOptions();
97
		options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR, DefaultCodeFormatterConstants.TRUE);
98
		options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1");
99
		options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB);
100
101
		JavaCore.setOptions(options);
102
	}
103
104
	@Override
105
	protected void tearDown() throws Exception {
106
		super.tearDown();
107
		JavaCore.setOptions(fOldOptions);
108
		fOldOptions= null;
109
	}
110
111
	@Override
112
	protected String getRefactoringPath() {
113
		return REFACTORING_PATH;
114
	}
115
116
	private static PullUpRefactoringProcessor createPullUpRefactoringProcessor(IMember[] methods) throws JavaModelException {
117
		IJavaProject project= null;
118
		if (methods != null && methods.length > 0)
119
			project= methods[0].getJavaProject();
120
		if (RefactoringAvailabilityTester.isPullUpAvailable(methods)) {
121
			PullUpRefactoringProcessor processor= new PullUpRefactoringProcessor(methods, JavaPreferencesSettings.getCodeGenerationSettings(project));
122
			new ProcessorBasedRefactoring(processor);
123
			return processor;
124
		}
125
		return null;
126
	}
127
128
	private static ExtractSupertypeProcessor createExtractSuperclassRefactoringProcessor(IMember[] members) throws JavaModelException {
129
		IJavaProject project= null;
130
		if (members != null && members.length > 0)
131
			project= members[0].getJavaProject();
132
		if (RefactoringAvailabilityTester.isExtractSupertypeAvailable(members)) {
133
			final CodeGenerationSettings settings= JavaPreferencesSettings.getCodeGenerationSettings(project);
134
			settings.createComments= false;
135
			ExtractSupertypeProcessor processor= new ExtractSupertypeProcessor(members, settings);
136
			new ProcessorBasedRefactoring(processor);
137
			return processor;
138
		}
139
		return null;
140
	}
141
142
	private IPackageFragment getPackage(String name) throws JavaModelException {
143
		if ("p".equals(name))
144
			return getPackageP();
145
		IPackageFragment pack= getRoot().getPackageFragment(name);
146
		if (pack.exists())
147
			return pack;
148
		return getRoot().createPackageFragment(name, false, new NullProgressMonitor());
149
	}
150
151
	private static String getTopLevelTypeName(String typeQualifiedTyperName) {
152
		int dotIndex= typeQualifiedTyperName.indexOf('.');
153
		if (dotIndex == -1)
154
			return typeQualifiedTyperName;
155
		return typeQualifiedTyperName.substring(0, dotIndex);
156
	}
157
	
158
	private void prepareForInputCheck(PushDownRefactoringProcessor processor, IMethod[] selectedMethods, IField[] selectedFields, String[] namesOfMethodsToPullUp,
159
			String[][] signaturesOfMethodsToPullUp, String[] namesOfFieldsToPullUp, String[] namesOfMethodsToDeclareAbstract, String[][] signaturesOfMethodsToDeclareAbstract) {
160
		IMethod[] methodsToPushDown= findMethods(selectedMethods, namesOfMethodsToPullUp, signaturesOfMethodsToPullUp);
161
		IField[] fieldsToPushDown= findFields(selectedFields, namesOfFieldsToPullUp);
162
		List membersToPushDown= Arrays.asList(merge(methodsToPushDown, fieldsToPushDown));
163
		List methodsToDeclareAbstract= Arrays.asList(findMethods(selectedMethods, namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract));
164
165
		MemberActionInfo[] infos= processor.getMemberActionInfos();
166
		for (int i= 0; i < infos.length; i++) {
167
			if (membersToPushDown.contains(infos[i].getMember())) {
168
				infos[i].setAction(MemberActionInfo.PUSH_DOWN_ACTION);
169
				assertTrue(!methodsToDeclareAbstract.contains(infos[i].getMember()));
170
			}
171
			if (methodsToDeclareAbstract.contains(infos[i].getMember())) {
172
				infos[i].setAction(MemberActionInfo.PUSH_ABSTRACT_ACTION);
173
				assertTrue(!membersToPushDown.contains(infos[i].getMember()));
174
			}
175
		}
176
	}
177
178
	/**
179
	 * Tests "Pull Up" method refactoring involving receiver parameter.
180
	 * 
181
	 * @throws Exception any exception thrown from this test case
182
	 */
183
	public void testPullUp() throws Exception {
184
		String[] methodNames= new String[] { "foo1", "foo2" };
185
		String[][] signatures= new String[][] { new String[0], new String[] { "QString;" } };
186
		boolean deleteAllInSourceType= true;
187
		boolean deleteAllMatchingMethods= false;
188
		ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
189
		IType type= getType(cu, "B");
190
		IMethod[] methods= getMethods(type, methodNames, signatures);
191
192
		PullUpRefactoringProcessor processor= createPullUpRefactoringProcessor(methods);
193
		Refactoring ref= processor.getRefactoring();
194
195
		assertTrue("activation", ref.checkInitialConditions(new NullProgressMonitor()).isOK());
196
197
		IType[] possibleClasses= processor.getCandidateTypes(new RefactoringStatus(), new NullProgressMonitor());
198
		assertTrue("No possible class found!", possibleClasses.length > 0);
199
		processor.setDestinationType(processor.getCandidateTypes(new RefactoringStatus(), new NullProgressMonitor())[possibleClasses.length - 1 - 0]);
200
201
		if (deleteAllInSourceType)
202
			processor.setDeletedMethods(methods);
203
		if (deleteAllMatchingMethods) {
204
			List l= Arrays.asList(JavaElementUtil.getElementsOfType(processor.getMatchingElements(new NullProgressMonitor(), false), IJavaElement.METHOD));
205
			processor.setDeletedMethods((IMethod[])l.toArray(new IMethod[l.size()]));
206
		}
207
208
		RefactoringStatus checkInputResult= ref.checkFinalConditions(new NullProgressMonitor());
209
		assertTrue("precondition was supposed to pass", !checkInputResult.hasError());
210
		performChange(ref, false);
211
212
		String expected= getFileContents(getOutputTestFileName("A"));
213
		String actual= cu.getSource();
214
		assertEqualLines(expected, actual);
215
	}
216
217
	/**
218
	 * Tests "Push Down" method refactoring involving receiver parameter.
219
	 * 
220
	 * @throws Exception any exception thrown from this test case
221
	 */
222
	public void testPushDown() throws Exception {
223
		String[] namesOfMethodsToPushDown= { "foo1", "foo2" };
224
		String[][] signaturesOfMethodsToPushDown= { new String[0], new String[] { "QString;" } };
225
		String[] selectedFieldNames= {};
226
		String[] namesOfFieldsToPushDown= {};
227
		String[] namesOfMethodsToDeclareAbstract= {};
228
		String[][] signaturesOfMethodsToDeclareAbstract= {};
229
230
231
		ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A");
232
233
		IType type= getType(cuA, "A");
234
		IMethod[] selectedMethods= getMethods(type, namesOfMethodsToPushDown, signaturesOfMethodsToPushDown);
235
		IField[] selectedFields= getFields(type, selectedFieldNames);
236
		IMember[] selectedMembers= merge(selectedFields, selectedMethods);
237
238
		assertTrue(RefactoringAvailabilityTester.isPushDownAvailable(selectedMembers));
239
		PushDownRefactoringProcessor processor= new PushDownRefactoringProcessor(selectedMembers);
240
		Refactoring ref= new ProcessorBasedRefactoring(processor);
241
242
		assertTrue("activation", ref.checkInitialConditions(new NullProgressMonitor()).isOK());
243
244
		prepareForInputCheck(processor, selectedMethods, selectedFields, namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, namesOfFieldsToPushDown, namesOfMethodsToDeclareAbstract,
245
				signaturesOfMethodsToDeclareAbstract);
246
247
		RefactoringStatus checkInputResult= ref.checkFinalConditions(new NullProgressMonitor());
248
		assertTrue("precondition was supposed to pass but got " + checkInputResult.toString(), !checkInputResult.hasError());
249
		performChange(ref, false);
250
251
		String expected= getFileContents(getOutputTestFileName("A"));
252
		String actual= cuA.getSource();
253
		assertEqualLines("A.java", expected, actual);
254
255
	}
256
257
	/**
258
	 * Tests "Move" method refactoring involving receiver parameter.
259
	 * 
260
	 * @throws Exception any exception thrown from this test case
261
	 */
262
	public void testMove() throws Exception {
263
		String[] cuQNames= new String[] { "p1.A", "p2.B" };
264
		String selectionCuQName= "p1.A";
265
		boolean inlineDelegator= false;
266
		boolean removeDelegator= false;
267
		int selectionCuIndex= -1;
268
		for (int i= 0; i < cuQNames.length; i++)
269
			if (cuQNames[i] == null || selectionCuQName.equals(cuQNames[i]))
270
				selectionCuIndex= i;
271
		Assert.isTrue(selectionCuIndex != -1, "parameter selectionCuQName must match some String in cuQNames.");
272
		ICompilationUnit cuA= createCUfromTestFile(getPackage("p1"), "A");
273
		ICompilationUnit cuB= createCUfromTestFile(getPackage("p1"), "B");
274
275
		int offset= cuA.getSource().indexOf("mA1(@NonNull A this, B b)");
276
		IJavaElement[] codeSelect= cuA.codeSelect(offset, 3);
277
		assertTrue(codeSelect.length > 0);
278
		assertTrue(codeSelect[0] instanceof IMethod);
279
		IMethod method= (IMethod)codeSelect[0];
280
		MoveInstanceMethodProcessor processor= new MoveInstanceMethodProcessor(method, JavaPreferencesSettings.getCodeGenerationSettings(cuA.getJavaProject()));
281
		Refactoring ref= new MoveRefactoring(processor);
282
283
		assertNotNull("refactoring should be created", ref);
284
		RefactoringStatus preconditionResult= ref.checkInitialConditions(new NullProgressMonitor());
285
286
		assertTrue("activation was supposed to be successful", preconditionResult.isOK());
287
288
		IVariableBinding target= null;
289
		IVariableBinding[] targets= processor.getPossibleTargets();
290
		for (int i= 0; i < targets.length; i++) {
291
			IVariableBinding candidate= targets[i];
292
			if (candidate.getName().equals("b")) {
293
				target= candidate;
294
				break;
295
			}
296
		}
297
		assertNotNull("Expected new target not available.", target);
298
		processor.setTarget(target);
299
300
		processor.setInlineDelegator(inlineDelegator);
301
		processor.setRemoveDelegator(removeDelegator);
302
		processor.setDeprecateDelegates(false);
303
		processor.setMethodName("mA1Moved");
304
305
		preconditionResult.merge(ref.checkFinalConditions(new NullProgressMonitor()));
306
307
		assertTrue("precondition was supposed to pass", !preconditionResult.hasError());
308
309
		performChange(ref, false);
310
311
		String outputTestFileName= getOutputTestFileName("A");
312
		assertEqualLines("Incorrect inline in " + outputTestFileName, getFileContents(outputTestFileName), cuA.getSource());
313
314
315
		outputTestFileName= getOutputTestFileName("B");
316
		assertEqualLines("Incorrect inline in " + outputTestFileName, getFileContents(outputTestFileName), cuB.getSource());
317
318
	}
319
320
	/**
321
	 * Tests "Move Type to New File" refactoring involving receiver parameter.
322
	 * 
323
	 * @throws Exception any exception thrown from this test case
324
	 */
325
	public void testMoveType2File() throws Exception {
326
		String parentClassName= "A";
327
		String enclosingInstanceName= "Inner";
328
		String[] cuNames= new String[] { "A" };
329
		String[] packageNames= new String[] { "p" };
330
		String packageName= "p";
331
		IType parentClas= getType(createCUfromTestFile(getPackage(packageName), parentClassName), parentClassName);
332
		IType clas= parentClas.getType(enclosingInstanceName);
333
334
		assertTrue("should be enabled", RefactoringAvailabilityTester.isMoveInnerAvailable(clas));
335
		MoveInnerToTopRefactoring ref= ((RefactoringAvailabilityTester.isMoveInnerAvailable(clas)) ? new MoveInnerToTopRefactoring(clas, JavaPreferencesSettings.getCodeGenerationSettings(clas
336
				.getJavaProject())) : null);
337
		RefactoringStatus preconditionResult= ref.checkInitialConditions(new NullProgressMonitor());
338
		assertTrue("activation was supposed to be successful" + preconditionResult.toString(), preconditionResult.isOK());
339
340
		assertEquals("reference creation possible", true, ref.isCreatingInstanceFieldPossible());
341
		assertEquals("reference creation mandatory", false, ref.isCreatingInstanceFieldMandatory());
342
		if (ref.isCreatingInstanceFieldPossible() && !ref.isCreatingInstanceFieldMandatory())
343
			ref.setCreateInstanceField(false);
344
		ref.setEnclosingInstanceName(enclosingInstanceName);
345
		assertTrue("name should be ok ", ref.checkEnclosingInstanceName(enclosingInstanceName).isOK());
346
		ref.setMarkInstanceFieldAsFinal(false);
347
		ICompilationUnit[] cus= new ICompilationUnit[cuNames.length];
348
		for (int i= 0; i < cuNames.length; i++) {
349
			if (cuNames[i].equals(clas.getCompilationUnit().findPrimaryType().getElementName()))
350
				cus[i]= clas.getCompilationUnit();
351
			else
352
				cus[i]= createCUfromTestFile(getPackage(packageNames[i]), cuNames[i]);
353
		}
354
355
		RefactoringStatus checkInputResult= ref.checkFinalConditions(new NullProgressMonitor());
356
		assertTrue("precondition was supposed to pass", !checkInputResult.hasError());
357
		performChange(ref, false);
358
359
		for (int i= 0; i < cus.length; i++) {
360
			String actual= cus[i].getSource();
361
			String expected= getFileContents(getOutputTestFileName(cuNames[i]));
362
			assertEqualLines(cus[i].getElementName(), expected, actual);
363
		}
364
		ICompilationUnit newCu= clas.getPackageFragment().getCompilationUnit(enclosingInstanceName + ".java");
365
		String expected= getFileContents(getOutputTestFileName(enclosingInstanceName));
366
		String actual= newCu.getSource();
367
		assertEqualLines("new Cu:", expected, actual);
368
369
	}
370
371
	/**
372
	 * Tests "Extract Interface" refactoring involving receiver parameter.
373
	 * 
374
	 * @throws Exception any exception thrown from this test case
375
	 */
376
	public void testExtractInterface() throws Exception {
377
		String className= "A";
378
		String newInterfaceName= "I";
379
380
		IType clas= getType(createCUfromTestFile(getPackageP(), getTopLevelTypeName(className)), className);
381
		ICompilationUnit cu= clas.getCompilationUnit();
382
		IPackageFragment pack= (IPackageFragment)cu.getParent();
383
384
		ExtractInterfaceProcessor processor= new ExtractInterfaceProcessor(clas, JavaPreferencesSettings.getCodeGenerationSettings(clas.getJavaProject()));
385
		Refactoring ref= new ProcessorBasedRefactoring(processor);
386
387
		processor.setTypeName(newInterfaceName);
388
		assertEquals("interface name should be accepted", RefactoringStatus.OK, processor.checkTypeName(newInterfaceName).getSeverity());
389
390
		processor.setExtractedMembers(processor.getExtractableMembers());
391
		processor.setReplace(true);
392
		processor.setAnnotations(false);
393
		assertEquals("was supposed to pass", null, performRefactoring(ref));
394
		assertEqualLines("incorrect changes in " + className,
395
				getFileContents(getOutputTestFileName(className)),
396
				cu.getSource());
397
398
		ICompilationUnit interfaceCu= pack.getCompilationUnit(newInterfaceName + ".java");
399
		assertEqualLines("incorrect interface created",
400
				getFileContents(getOutputTestFileName(newInterfaceName)),
401
				interfaceCu.getSource());
402
	}
403
404
	/**
405
	 * Tests "Extract Superclass" refactoring involving receiver parameter.
406
	 * 
407
	 * @throws Exception any exception thrown from this test case
408
	 */
409
	public void testExtractSuperclass() throws Exception {
410
		String[] methodNames= new String[] { "foo1", "foo2" };
411
		String[][] signatures= new String[][] { new String[0], new String[] { "QString;" } };
412
		boolean replaceOccurences= true;
413
414
415
		ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
416
		IType type= getType(cu, "A");
417
		IMethod[] methods= getMethods(type, methodNames, signatures);
418
419
		ExtractSupertypeProcessor processor= createExtractSuperclassRefactoringProcessor(methods);
420
		Refactoring refactoring= processor.getRefactoring();
421
		processor.setMembersToMove(methods);
422
423
		assertTrue("activation", refactoring.checkInitialConditions(new NullProgressMonitor()).isOK());
424
425
		processor.setTypesToExtract(new IType[] { type });
426
		processor.setTypeName("B");
427
		processor.setCreateMethodStubs(true);
428
		processor.setInstanceOf(false);
429
		processor.setReplace(replaceOccurences);
430
		processor.setDeletedMethods(methods);
431
432
		RefactoringStatus status= refactoring.checkFinalConditions(new NullProgressMonitor());
433
		assertTrue("precondition was supposed to pass", !status.hasError());
434
		performChange(refactoring, false);
435
436
		String expected= getFileContents(getOutputTestFileName("A"));
437
		String actual= cu.getSource();
438
		assertEqualLines(expected, actual);
439
440
		expected= getFileContents(getOutputTestFileName("B"));
441
		ICompilationUnit unit= getPackageP().getCompilationUnit("B.java");
442
		if (!unit.exists())
443
			assertTrue("extracted compilation unit does not exist", false);
444
		actual= unit.getBuffer().getContents();
445
		assertEqualLines(expected, actual);
446
447
448
	}
449
450
}
(-)test plugin/org/eclipse/jdt/testplugin/JavaProjectHelper.java (-1 / +13 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2012 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
Lines 78-92 Link Here
78
	/**
78
	/**
79
	 * @deprecated use {@link #RT_STUBS_15}
79
	 * @deprecated use {@link #RT_STUBS_15}
80
	 */
80
	 */
81
	@Deprecated
81
	public static final IPath RT_STUBS_13= new Path("testresources/rtstubs.jar");
82
	public static final IPath RT_STUBS_13= new Path("testresources/rtstubs.jar");
82
	/**
83
	/**
83
	 * @deprecated use {@link #JUNIT_SRC_381}
84
	 * @deprecated use {@link #JUNIT_SRC_381}
84
	 */
85
	 */
86
	@Deprecated
85
	public static final IPath JUNIT_SRC= new Path("testresources/junit37-noUI-src.zip");
87
	public static final IPath JUNIT_SRC= new Path("testresources/junit37-noUI-src.zip");
86
88
87
	public static final IPath RT_STUBS_15= new Path("testresources/rtstubs15.jar");
89
	public static final IPath RT_STUBS_15= new Path("testresources/rtstubs15.jar");
88
	public static final IPath RT_STUBS_16= new Path("testresources/rtstubs16.jar");
90
	public static final IPath RT_STUBS_16= new Path("testresources/rtstubs16.jar");
89
	public static final IPath RT_STUBS_17= new Path("testresources/rtstubs17.jar");
91
	public static final IPath RT_STUBS_17= new Path("testresources/rtstubs17.jar");
92
93
	public static final IPath RT_STUBS_18= new Path("testresources/rtstubs18.jar");
90
	public static final IPath JUNIT_SRC_381= new Path("testresources/junit381-noUI-src.zip");
94
	public static final IPath JUNIT_SRC_381= new Path("testresources/junit381-noUI-src.zip");
91
	public static final String JUNIT_SRC_ENCODING= "ISO-8859-1";
95
	public static final String JUNIT_SRC_ENCODING= "ISO-8859-1";
92
96
Lines 645-650 Link Here
645
		return addLibrary(jproject, rtJarPath[0], rtJarPath[1], rtJarPath[2]);
649
		return addLibrary(jproject, rtJarPath[0], rtJarPath[1], rtJarPath[2]);
646
	}
650
	}
647
651
652
653
	public static IPackageFragmentRoot addRTJar18(IJavaProject jproject) throws CoreException {
654
		IPath[] rtJarPath= findRtJar(RT_STUBS_18);
655
		set17CompilerOptions(jproject);
656
		return addLibrary(jproject, rtJarPath[0], rtJarPath[1], rtJarPath[2]);
657
	}
658
648
	/**
659
	/**
649
	 * Adds a variable entry with source attachment to a IJavaProject.
660
	 * Adds a variable entry with source attachment to a IJavaProject.
650
	 * Can return null if variable can not be resolved.
661
	 * Can return null if variable can not be resolved.
Lines 848-852 Link Here
848
			while (display.readAndDispatch()) { /*loop*/ }
859
			while (display.readAndDispatch()) { /*loop*/ }
849
		}
860
		}
850
	}
861
	}
862
851
}
863
}
852
864
(-)core extension/org/eclipse/jdt/internal/corext/dom/ASTNodes.java (-2 / +8 lines)
Lines 4-9 Link Here
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 70-75 Link Here
70
import org.eclipse.jdt.core.dom.Modifier;
74
import org.eclipse.jdt.core.dom.Modifier;
71
import org.eclipse.jdt.core.dom.Name;
75
import org.eclipse.jdt.core.dom.Name;
72
import org.eclipse.jdt.core.dom.NodeFinder;
76
import org.eclipse.jdt.core.dom.NodeFinder;
77
import org.eclipse.jdt.core.dom.PackageQualifiedType;
73
import org.eclipse.jdt.core.dom.ParameterizedType;
78
import org.eclipse.jdt.core.dom.ParameterizedType;
74
import org.eclipse.jdt.core.dom.ParenthesizedExpression;
79
import org.eclipse.jdt.core.dom.ParenthesizedExpression;
75
import org.eclipse.jdt.core.dom.PrimitiveType;
80
import org.eclipse.jdt.core.dom.PrimitiveType;
Lines 574-580 Link Here
574
		}
579
		}
575
		// normalize type
580
		// normalize type
576
		if (QualifiedType.NAME_PROPERTY.equals(current.getLocationInParent()) ||
581
		if (QualifiedType.NAME_PROPERTY.equals(current.getLocationInParent()) ||
577
			SimpleType.NAME_PROPERTY.equals(current.getLocationInParent())) {
582
				SimpleType.NAME_PROPERTY.equals(current.getLocationInParent()) ||
583
				PackageQualifiedType.NAME_PROPERTY.equals(current.getLocationInParent())) {
578
			current= current.getParent();
584
			current= current.getParent();
579
		}
585
		}
580
		// normalize parameterized types
586
		// normalize parameterized types
Lines 965-971 Link Here
965
	/**
971
	/**
966
	 * Escapes a string value to a literal that can be used in Java source.
972
	 * Escapes a string value to a literal that can be used in Java source.
967
	 * 
973
	 * 
968
	 * @param stringValue the string value 
974
	 * @param stringValue the string value
969
	 * @return the escaped string
975
	 * @return the escaped string
970
	 * @see StringLiteral#getEscapedValue()
976
	 * @see StringLiteral#getEscapedValue()
971
	 */
977
	 */
(-)core extension/org/eclipse/jdt/internal/corext/fix/PotentialProgrammingProblemsFix.java (-1 / +10 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 385-395 Link Here
385
		if (selection instanceof SimpleType) {
390
		if (selection instanceof SimpleType) {
386
			final SimpleType type= (SimpleType) selection;
391
			final SimpleType type= (SimpleType) selection;
387
			name= type.getName();
392
			name= type.getName();
393
		} else if (selection instanceof PackageQualifiedType) {
394
			name= ((PackageQualifiedType) selection).getName();
388
		} else if (selection instanceof ParameterizedType) {
395
		} else if (selection instanceof ParameterizedType) {
389
			final ParameterizedType type= (ParameterizedType) selection;
396
			final ParameterizedType type= (ParameterizedType) selection;
390
			final Type raw= type.getType();
397
			final Type raw= type.getType();
391
			if (raw instanceof SimpleType)
398
			if (raw instanceof SimpleType)
392
				name= ((SimpleType) raw).getName();
399
				name= ((SimpleType) raw).getName();
400
			else if (raw instanceof PackageQualifiedType)
401
				name= ((PackageQualifiedType) raw).getName();
393
			else if (raw instanceof QualifiedType)
402
			else if (raw instanceof QualifiedType)
394
				name= ((QualifiedType) raw).getName();
403
				name= ((QualifiedType) raw).getName();
395
		} else if (selection instanceof Name) {
404
		} else if (selection instanceof Name) {
(-)core refactoring/org/eclipse/jdt/internal/corext/refactoring/nls/NLSHintHelper.java (-3 / +7 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 57-64 Link Here
57
import org.eclipse.jdt.core.dom.NodeFinder;
61
import org.eclipse.jdt.core.dom.NodeFinder;
58
import org.eclipse.jdt.core.dom.QualifiedName;
62
import org.eclipse.jdt.core.dom.QualifiedName;
59
import org.eclipse.jdt.core.dom.SimpleName;
63
import org.eclipse.jdt.core.dom.SimpleName;
60
import org.eclipse.jdt.core.dom.SimpleType;
61
import org.eclipse.jdt.core.dom.StringLiteral;
64
import org.eclipse.jdt.core.dom.StringLiteral;
65
import org.eclipse.jdt.core.dom.Type;
62
import org.eclipse.jdt.core.dom.TypeLiteral;
66
import org.eclipse.jdt.core.dom.TypeLiteral;
63
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
67
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
64
68
Lines 281-287 Link Here
281
					MethodInvocation methInvocation= (MethodInvocation)initializer;
285
					MethodInvocation methInvocation= (MethodInvocation)initializer;
282
					Expression exp= methInvocation.getExpression();
286
					Expression exp= methInvocation.getExpression();
283
					if ((exp != null) && (exp instanceof TypeLiteral)) {
287
					if ((exp != null) && (exp instanceof TypeLiteral)) {
284
						SimpleType simple= (SimpleType)((TypeLiteral) exp).getType();
288
						Type simple= ((TypeLiteral) exp).getType();
285
						ITypeBinding typeBinding= simple.resolveBinding();
289
						ITypeBinding typeBinding= simple.resolveBinding();
286
						if (typeBinding != null)
290
						if (typeBinding != null)
287
							return typeBinding.getQualifiedName();
291
							return typeBinding.getQualifiedName();
(-)ui/org/eclipse/jdt/internal/ui/actions/CopyQualifiedNameAction.java (-1 / +7 lines)
Lines 1-5 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
Lines 65-70 Link Here
65
import org.eclipse.jdt.core.dom.Name;
65
import org.eclipse.jdt.core.dom.Name;
66
import org.eclipse.jdt.core.dom.NodeFinder;
66
import org.eclipse.jdt.core.dom.NodeFinder;
67
import org.eclipse.jdt.core.dom.PackageDeclaration;
67
import org.eclipse.jdt.core.dom.PackageDeclaration;
68
import org.eclipse.jdt.core.dom.PackageQualifiedType;
68
import org.eclipse.jdt.core.dom.SimpleType;
69
import org.eclipse.jdt.core.dom.SimpleType;
69
import org.eclipse.jdt.core.dom.StructuralPropertyDescriptor;
70
import org.eclipse.jdt.core.dom.StructuralPropertyDescriptor;
70
import org.eclipse.jdt.core.dom.Type;
71
import org.eclipse.jdt.core.dom.Type;
Lines 366-371 Link Here
366
			loc= parent.getLocationInParent();
367
			loc= parent.getLocationInParent();
367
			if (loc == ClassInstanceCreation.TYPE_PROPERTY)
368
			if (loc == ClassInstanceCreation.TYPE_PROPERTY)
368
				return ((ClassInstanceCreation)parent.getParent()).resolveConstructorBinding();
369
				return ((ClassInstanceCreation)parent.getParent()).resolveConstructorBinding();
370
		} else if (loc == PackageQualifiedType.NAME_PROPERTY) {
371
			ASTNode parent= nameNode.getParent();
372
			loc= parent.getLocationInParent();
373
			if (loc == ClassInstanceCreation.TYPE_PROPERTY)
374
				return ((ClassInstanceCreation) parent.getParent()).resolveConstructorBinding();
369
		}
375
		}
370
		return null;
376
		return null;
371
	}
377
	}
(-)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 (-2 / +7 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
 *******************************************************************************/
14
 *******************************************************************************/
Lines 54-59 Link Here
54
import org.eclipse.jdt.core.dom.MethodInvocation;
58
import org.eclipse.jdt.core.dom.MethodInvocation;
55
import org.eclipse.jdt.core.dom.Modifier;
59
import org.eclipse.jdt.core.dom.Modifier;
56
import org.eclipse.jdt.core.dom.Name;
60
import org.eclipse.jdt.core.dom.Name;
61
import org.eclipse.jdt.core.dom.PackageQualifiedType;
57
import org.eclipse.jdt.core.dom.ParameterizedType;
62
import org.eclipse.jdt.core.dom.ParameterizedType;
58
import org.eclipse.jdt.core.dom.PrefixExpression;
63
import org.eclipse.jdt.core.dom.PrefixExpression;
59
import org.eclipse.jdt.core.dom.PrimitiveType;
64
import org.eclipse.jdt.core.dom.PrimitiveType;
Lines 403-409 Link Here
403
    	if (locationInParent == QualifiedName.QUALIFIER_PROPERTY) {
408
    	if (locationInParent == QualifiedName.QUALIFIER_PROPERTY) {
404
    		return null; // can't guess type for X.A
409
    		return null; // can't guess type for X.A
405
    	}
410
    	}
406
    	if (locationInParent == SimpleType.NAME_PROPERTY) {
411
		if (locationInParent == SimpleType.NAME_PROPERTY || locationInParent == PackageQualifiedType.NAME_PROPERTY) {
407
    		node= node.getParent();
412
    		node= node.getParent();
408
    	}
413
    	}
409
    	ITypeBinding binding= Bindings.normalizeTypeBinding(getPossibleTypeBinding(node));
414
    	ITypeBinding binding= Bindings.normalizeTypeBinding(getPossibleTypeBinding(node));
Lines 854-860 Link Here
854
				kind= SimilarElementsRequestor.INTERFACES;
859
				kind= SimilarElementsRequestor.INTERFACES;
855
				break;
860
				break;
856
			case ASTNode.METHOD_DECLARATION:
861
			case ASTNode.METHOD_DECLARATION:
857
				if (node.getLocationInParent() == MethodDeclaration.THROWN_EXCEPTIONS_PROPERTY) {
862
				if (node.getLocationInParent() == MethodDeclaration.THROWN_EXCEPTION_TYPES_PROPERTY) {
858
					kind= SimilarElementsRequestor.CLASSES;
863
					kind= SimilarElementsRequestor.CLASSES;
859
				} else if (node.getLocationInParent() == MethodDeclaration.RETURN_TYPE2_PROPERTY) {
864
				} else if (node.getLocationInParent() == MethodDeclaration.RETURN_TYPE2_PROPERTY) {
860
					kind= SimilarElementsRequestor.ALL_TYPES | SimilarElementsRequestor.VOIDTYPE;
865
					kind= SimilarElementsRequestor.ALL_TYPES | SimilarElementsRequestor.VOIDTYPE;
(-)ui/org/eclipse/jdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java (-5 / +12 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; - Access to static proposal
14
 *     Renaud Waldura &lt;renaud+eclipse@waldura.com&gt; - Access to static proposal
Lines 76-81 Link Here
76
import org.eclipse.jdt.core.dom.MethodInvocation;
80
import org.eclipse.jdt.core.dom.MethodInvocation;
77
import org.eclipse.jdt.core.dom.Modifier;
81
import org.eclipse.jdt.core.dom.Modifier;
78
import org.eclipse.jdt.core.dom.Name;
82
import org.eclipse.jdt.core.dom.Name;
83
import org.eclipse.jdt.core.dom.PackageQualifiedType;
79
import org.eclipse.jdt.core.dom.ParameterizedType;
84
import org.eclipse.jdt.core.dom.ParameterizedType;
80
import org.eclipse.jdt.core.dom.ParenthesizedExpression;
85
import org.eclipse.jdt.core.dom.ParenthesizedExpression;
81
import org.eclipse.jdt.core.dom.PrefixExpression;
86
import org.eclipse.jdt.core.dom.PrefixExpression;
Lines 406-417 Link Here
406
				}
411
				}
407
				uncaughtExceptions= unhandledExceptions.toArray(new ITypeBinding[unhandledExceptions.size()]);
412
				uncaughtExceptions= unhandledExceptions.toArray(new ITypeBinding[unhandledExceptions.size()]);
408
413
409
				List<Name> exceptions= methodDecl.thrownExceptions();
414
				List<Type> exceptions= methodDecl.thrownExceptionTypes();
410
				int nExistingExceptions= exceptions.size();
415
				int nExistingExceptions= exceptions.size();
411
				ChangeDescription[] desc= new ChangeDescription[nExistingExceptions + uncaughtExceptions.length];
416
				ChangeDescription[] desc= new ChangeDescription[nExistingExceptions + uncaughtExceptions.length];
412
				for (int i= 0; i < exceptions.size(); i++) {
417
				for (int i= 0; i < exceptions.size(); i++) {
413
					Name elem= exceptions.get(i);
418
					Type elem= exceptions.get(i);
414
					if (isSubtype(elem.resolveTypeBinding(), uncaughtExceptions)) {
419
					if (isSubtype(elem.resolveBinding(), uncaughtExceptions)) {
415
						desc[i]= new RemoveDescription();
420
						desc[i]= new RemoveDescription();
416
					}
421
					}
417
				}
422
				}
Lines 751-757 Link Here
751
		MethodDeclaration decl= (MethodDeclaration) selectedNode.getParent();
756
		MethodDeclaration decl= (MethodDeclaration) selectedNode.getParent();
752
		IMethodBinding binding= decl.resolveBinding();
757
		IMethodBinding binding= decl.resolveBinding();
753
		if (binding != null) {
758
		if (binding != null) {
754
			List<Name> thrownExceptions= decl.thrownExceptions();
759
			List<Type> thrownExceptions= decl.thrownExceptionTypes();
755
			int index= thrownExceptions.indexOf(selectedNode);
760
			int index= thrownExceptions.indexOf(selectedNode);
756
			if (index == -1) {
761
			if (index == -1) {
757
				return;
762
				return;
Lines 1431-1436 Link Here
1431
		Name node= null;
1436
		Name node= null;
1432
		if (selectedNode instanceof SimpleType) {
1437
		if (selectedNode instanceof SimpleType) {
1433
			node= ((SimpleType) selectedNode).getName();
1438
			node= ((SimpleType) selectedNode).getName();
1439
		} else if (selectedNode instanceof PackageQualifiedType) {
1440
			node= ((PackageQualifiedType) selectedNode).getName();
1434
		} else if (selectedNode instanceof ArrayType) {
1441
		} else if (selectedNode instanceof ArrayType) {
1435
			Type elementType= ((ArrayType) selectedNode).getElementType();
1442
			Type elementType= ((ArrayType) selectedNode).getElementType();
1436
			if (elementType.isSimpleType()) {
1443
			if (elementType.isSimpleType()) {
Lines 1458-1464 Link Here
1458
			simpleBinding= simpleBinding.getTypeDeclaration();
1465
			simpleBinding= simpleBinding.getTypeDeclaration();
1459
		
1466
		
1460
			if (!simpleBinding.isRecovered()) {
1467
			if (!simpleBinding.isRecovered()) {
1461
				if (binding.isParameterizedType() && node.getParent() instanceof SimpleType && !(node.getParent().getParent() instanceof Type)) {
1468
				if (binding.isParameterizedType() && (node.getParent() instanceof SimpleType || node.getParent() instanceof PackageQualifiedType) && !(node.getParent().getParent() instanceof Type)) {
1462
					proposals.add(UnresolvedElementsSubProcessor.createTypeRefChangeFullProposal(cu, binding, node, IProposalRelevance.TYPE_ARGUMENTS_FROM_CONTEXT));
1469
					proposals.add(UnresolvedElementsSubProcessor.createTypeRefChangeFullProposal(cu, binding, node, IProposalRelevance.TYPE_ARGUMENTS_FROM_CONTEXT));
1463
				}
1470
				}
1464
			}
1471
			}
(-)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 (-4 / +10 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
 *     Sebastian Davids <sdavids@gmx.de> - Bug 37432 getInvertEqualsProposal
14
 *     Sebastian Davids <sdavids@gmx.de> - Bug 37432 getInvertEqualsProposal
Lines 78-83 Link Here
78
import org.eclipse.jdt.core.dom.Modifier;
82
import org.eclipse.jdt.core.dom.Modifier;
79
import org.eclipse.jdt.core.dom.Name;
83
import org.eclipse.jdt.core.dom.Name;
80
import org.eclipse.jdt.core.dom.NumberLiteral;
84
import org.eclipse.jdt.core.dom.NumberLiteral;
85
import org.eclipse.jdt.core.dom.PackageQualifiedType;
81
import org.eclipse.jdt.core.dom.ParameterizedType;
86
import org.eclipse.jdt.core.dom.ParameterizedType;
82
import org.eclipse.jdt.core.dom.ParenthesizedExpression;
87
import org.eclipse.jdt.core.dom.ParenthesizedExpression;
83
import org.eclipse.jdt.core.dom.PostfixExpression;
88
import org.eclipse.jdt.core.dom.PostfixExpression;
Lines 501-508 Link Here
501
		
506
		
502
		if (node instanceof Name) {
507
		if (node instanceof Name) {
503
			Name name= ASTNodes.getTopMostName((Name) node);
508
			Name name= ASTNodes.getTopMostName((Name) node);
504
			if (name.getLocationInParent() == SimpleType.NAME_PROPERTY) {
509
			if (name.getLocationInParent() == SimpleType.NAME_PROPERTY || name.getLocationInParent() == PackageQualifiedType.NAME_PROPERTY) {
505
				SimpleType type= (SimpleType) name.getParent();
510
				ASTNode type= name.getParent();
506
				if (type.getLocationInParent() == ParameterizedType.TYPE_PROPERTY) {
511
				if (type.getLocationInParent() == ParameterizedType.TYPE_PROPERTY) {
507
					createdType= (ParameterizedType) type.getParent();
512
					createdType= (ParameterizedType) type.getParent();
508
					if (createdType.getLocationInParent() != ClassInstanceCreation.TYPE_PROPERTY) {
513
					if (createdType.getLocationInParent() != ClassInstanceCreation.TYPE_PROPERTY) {
Lines 1268-1274 Link Here
1268
		}
1273
		}
1269
1274
1270
		Type type= catchClause.getException().getType();
1275
		Type type= catchClause.getException().getType();
1271
		if (!type.isSimpleType() && !type.isUnionType()) {
1276
		if (!type.isSimpleType() && !type.isUnionType() && !type.isPackageQualifiedType()) {
1272
			return false;
1277
			return false;
1273
		}
1278
		}
1274
1279
Lines 1309-1315 Link Here
1309
					UnionType unionType= (UnionType) type;
1314
					UnionType unionType= (UnionType) type;
1310
					List<Type> types= unionType.types();
1315
					List<Type> types= unionType.types();
1311
					for (Type elementType : types) {
1316
					for (Type elementType : types) {
1312
						if (!(elementType instanceof SimpleType))
1317
						if (!(elementType instanceof SimpleType || elementType instanceof PackageQualifiedType))
1313
							return false;
1318
							return false;
1314
						addExceptionToThrows(ast, methodDeclaration, rewrite, (SimpleType) elementType);
1319
						addExceptionToThrows(ast, methodDeclaration, rewrite, (SimpleType) elementType);
1315
					}
1320
					}
Lines 1495-1500 Link Here
1495
		if (type1.isUnionType() && covering instanceof Name) {
1500
		if (type1.isUnionType() && covering instanceof Name) {
1496
			Name topMostName= ASTNodes.getTopMostName((Name) covering);
1501
			Name topMostName= ASTNodes.getTopMostName((Name) covering);
1497
			ASTNode parent= topMostName.getParent();
1502
			ASTNode parent= topMostName.getParent();
1503
			// TODO handle PQT
1498
			if (parent instanceof SimpleType) {
1504
			if (parent instanceof SimpleType) {
1499
				selectedMultiCatchType= (SimpleType) parent;
1505
				selectedMultiCatchType= (SimpleType) parent;
1500
			}
1506
			}
(-)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 / +13 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
				}
220
				else if (parent instanceof SimpleType || parent instanceof PackageQualifiedType) {
215
					suggestVariableProposals= false;
221
					suggestVariableProposals= false;
216
					typeKind= SimilarElementsRequestor.REF_TYPES_AND_VAR;
222
					typeKind= SimilarElementsRequestor.REF_TYPES_AND_VAR;
217
				} else if (parent instanceof QualifiedName) {
223
				} else if (parent instanceof QualifiedName) {
Lines 225-231 Link Here
225
					while (outerParent instanceof QualifiedName) {
231
					while (outerParent instanceof QualifiedName) {
226
						outerParent= outerParent.getParent();
232
						outerParent= outerParent.getParent();
227
					}
233
					}
228
					if (outerParent instanceof SimpleType) {
234
					if (outerParent instanceof SimpleType || outerParent instanceof PackageQualifiedType) {
229
						typeKind= SimilarElementsRequestor.REF_TYPES;
235
						typeKind= SimilarElementsRequestor.REF_TYPES;
230
						suggestVariableProposals= false;
236
						suggestVariableProposals= false;
231
					}
237
					}
Lines 249-255 Link Here
249
					typeKind= SimilarElementsRequestor.REF_TYPES;
255
					typeKind= SimilarElementsRequestor.REF_TYPES;
250
					suggestVariableProposals= node.isSimpleName();
256
					suggestVariableProposals= node.isSimpleName();
251
				}
257
				}
252
				if (selectedNode.getParent() instanceof SimpleType) {
258
				if (selectedNode.getParent() instanceof SimpleType || selectedNode.getParent() instanceof PackageQualifiedType) {
253
					typeKind= SimilarElementsRequestor.REF_TYPES;
259
					typeKind= SimilarElementsRequestor.REF_TYPES;
254
					suggestVariableProposals= false;
260
					suggestVariableProposals= false;
255
				}
261
				}
Lines 609-614 Link Here
609
		Name node= null;
615
		Name node= null;
610
		if (selectedNode instanceof SimpleType) {
616
		if (selectedNode instanceof SimpleType) {
611
			node= ((SimpleType) selectedNode).getName();
617
			node= ((SimpleType) selectedNode).getName();
618
		} else if (selectedNode instanceof PackageQualifiedType) {
619
			node= ((PackageQualifiedType) selectedNode).getName();
612
		} else if (selectedNode instanceof ArrayType) {
620
		} else if (selectedNode instanceof ArrayType) {
613
			Type elementType= ((ArrayType) selectedNode).getElementType();
621
			Type elementType= ((ArrayType) selectedNode).getElementType();
614
			if (elementType.isSimpleType()) {
622
			if (elementType.isSimpleType()) {
Lines 641-647 Link Here
641
	}
649
	}
642
650
643
	private static void addEnhancedForWithoutTypeProposals(ICompilationUnit cu, ASTNode selectedNode, Collection<ICommandAccess> proposals) {
651
	private static void addEnhancedForWithoutTypeProposals(ICompilationUnit cu, ASTNode selectedNode, Collection<ICommandAccess> proposals) {
644
		if (selectedNode instanceof SimpleName && selectedNode.getLocationInParent() == SimpleType.NAME_PROPERTY) {
652
		if (selectedNode instanceof SimpleName && (selectedNode.getLocationInParent() == SimpleType.NAME_PROPERTY || selectedNode.getLocationInParent() == PackageQualifiedType.NAME_PROPERTY)) {
645
			ASTNode type= selectedNode.getParent();
653
			ASTNode type= selectedNode.getParent();
646
			if (type.getLocationInParent() == SingleVariableDeclaration.TYPE_PROPERTY) {
654
			if (type.getLocationInParent() == SingleVariableDeclaration.TYPE_PROPERTY) {
647
				SingleVariableDeclaration svd= (SingleVariableDeclaration) type.getParent();
655
				SingleVariableDeclaration svd= (SingleVariableDeclaration) type.getParent();
Lines 840-846 Link Here
840
				if (proposal instanceof AddImportCorrectionProposal)
848
				if (proposal instanceof AddImportCorrectionProposal)
841
					proposal.setRelevance(relevance + elements.length + 2);
849
					proposal.setRelevance(relevance + elements.length + 2);
842
850
843
				if (binding.isParameterizedType() && node.getParent() instanceof SimpleType && !(node.getParent().getParent() instanceof Type)) {
851
				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));
852
					proposals.add(createTypeRefChangeFullProposal(cu, binding, node, relevance + 5));
845
				}
853
				}
846
			}
854
			}

Return to bug 407056