Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 232819 Details for
Bug 407056
[1.8] Support PackageQualifiedType AST node
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
WIP Patch
eclipse.jdt.ui.4thJune.patch (text/plain), 49.70 KB, created by
Martin Mathew
on 2013-06-27 00:55:59 EDT
(
hide
)
Description:
WIP Patch
Filename:
MIME Type:
Creator:
Martin Mathew
Created:
2013-06-27 00:55:59 EDT
Size:
49.70 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.ui.tests.refactoring >diff --git test cases/org/eclipse/jdt/ui/tests/refactoring/Java18Setup.java test cases/org/eclipse/jdt/ui/tests/refactoring/Java18Setup.java >new file mode 100644 >index 0000000..e79d402 >--- /dev/null >+++ test cases/org/eclipse/jdt/ui/tests/refactoring/Java18Setup.java >@@ -0,0 +1,39 @@ >+/******************************************************************************* >+ * Copyright (c) 2013 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * This is an implementation of an early-draft specification developed under the Java Community Process (JCP) and >+ * is made available for testing and evaluation purposes only. >+ * The code is not compatible with any specification of the JCP. >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.ui.tests.refactoring; >+ >+import junit.framework.Test; >+ >+import org.eclipse.jdt.testplugin.JavaProjectHelper; >+ >+import org.eclipse.core.runtime.CoreException; >+ >+import org.eclipse.jdt.core.IJavaProject; >+import org.eclipse.jdt.core.IPackageFragmentRoot; >+ >+public class Java18Setup extends RefactoringTestSetup { >+ >+ public Java18Setup(Test test) { >+ super(test); >+ } >+ >+ /* >+ * @see org.eclipse.jdt.ui.tests.refactoring.RefactoringTestSetup#addRTJar(org.eclipse.jdt.core.IJavaProject) >+ */ >+ @Override >+ protected IPackageFragmentRoot addRTJar(IJavaProject project) throws CoreException { >+ return JavaProjectHelper.addRTJar18(project); >+ } >+} >diff --git test cases/org/eclipse/jdt/ui/tests/refactoring/ReceiverParameterTests18.java test cases/org/eclipse/jdt/ui/tests/refactoring/ReceiverParameterTests18.java >new file mode 100644 >index 0000000..b0e9def >--- /dev/null >+++ test cases/org/eclipse/jdt/ui/tests/refactoring/ReceiverParameterTests18.java >@@ -0,0 +1,450 @@ >+/******************************************************************************* >+ * Copyright (c) 2013 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * This is an implementation of an early-draft specification developed under the Java Community Process (JCP) and >+ * is made available for testing and evaluation purposes only. >+ * The code is not compatible with any specification of the JCP. >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.ui.tests.refactoring; >+ >+import java.util.Arrays; >+import java.util.Hashtable; >+import java.util.List; >+ >+import junit.framework.Test; >+import junit.framework.TestSuite; >+ >+import org.eclipse.jdt.testplugin.TestOptions; >+ >+import org.eclipse.core.runtime.Assert; >+import org.eclipse.core.runtime.NullProgressMonitor; >+ >+import org.eclipse.ltk.core.refactoring.Refactoring; >+import org.eclipse.ltk.core.refactoring.RefactoringStatus; >+import org.eclipse.ltk.core.refactoring.participants.MoveRefactoring; >+import org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring; >+ >+import org.eclipse.jdt.core.ICompilationUnit; >+import org.eclipse.jdt.core.IField; >+import org.eclipse.jdt.core.IJavaElement; >+import org.eclipse.jdt.core.IJavaProject; >+import org.eclipse.jdt.core.IMember; >+import org.eclipse.jdt.core.IMethod; >+import org.eclipse.jdt.core.IPackageFragment; >+import org.eclipse.jdt.core.IType; >+import org.eclipse.jdt.core.JavaCore; >+import org.eclipse.jdt.core.JavaModelException; >+import org.eclipse.jdt.core.dom.IVariableBinding; >+import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants; >+ >+import org.eclipse.jdt.internal.corext.codemanipulation.CodeGenerationSettings; >+import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility; >+import org.eclipse.jdt.internal.corext.refactoring.RefactoringAvailabilityTester; >+import org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceProcessor; >+import org.eclipse.jdt.internal.corext.refactoring.structure.ExtractSupertypeProcessor; >+import org.eclipse.jdt.internal.corext.refactoring.structure.MoveInnerToTopRefactoring; >+import org.eclipse.jdt.internal.corext.refactoring.structure.MoveInstanceMethodProcessor; >+import org.eclipse.jdt.internal.corext.refactoring.structure.PullUpRefactoringProcessor; >+import org.eclipse.jdt.internal.corext.refactoring.structure.PushDownRefactoringProcessor; >+import org.eclipse.jdt.internal.corext.refactoring.structure.PushDownRefactoringProcessor.MemberActionInfo; >+import org.eclipse.jdt.internal.corext.refactoring.util.JavaElementUtil; >+import org.eclipse.jdt.internal.corext.template.java.CodeTemplateContextType; >+ >+import org.eclipse.jdt.internal.ui.preferences.JavaPreferencesSettings; >+ >+public class ReceiverParameterTests18 extends RefactoringTest { >+ >+ private static final Class clazz= ReceiverParameterTests18.class; >+ >+ private static final String REFACTORING_PATH= "ReceiverParameter/"; >+ >+ private Hashtable fOldOptions; >+ >+ public ReceiverParameterTests18(String name) { >+ super(name); >+ } >+ >+ public static Test suite() { >+ return new Java18Setup(new TestSuite(clazz)); >+ } >+ >+ public static Test setUpTest(Test someTest) { >+ return new Java18Setup(someTest); >+ } >+ >+ @Override >+ protected void setUp() throws Exception { >+ super.setUp(); >+ StubUtility.setCodeTemplate(CodeTemplateContextType.NEWTYPE_ID, >+ "${package_declaration}" + >+ System.getProperty("line.separator", "\n") + >+ "${" + CodeTemplateContextType.TYPE_COMMENT + "}" + >+ System.getProperty("line.separator", "\n") + >+ "${type_declaration}", null); >+ >+ StubUtility.setCodeTemplate(CodeTemplateContextType.TYPECOMMENT_ID, "/** typecomment template*/", null); >+ >+ fOldOptions= JavaCore.getOptions(); >+ >+ Hashtable options= TestOptions.getDefaultOptions(); >+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR, DefaultCodeFormatterConstants.TRUE); >+ options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1"); >+ options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); >+ >+ JavaCore.setOptions(options); >+ } >+ >+ @Override >+ protected void tearDown() throws Exception { >+ super.tearDown(); >+ JavaCore.setOptions(fOldOptions); >+ fOldOptions= null; >+ } >+ >+ @Override >+ protected String getRefactoringPath() { >+ return REFACTORING_PATH; >+ } >+ >+ private static PullUpRefactoringProcessor createPullUpRefactoringProcessor(IMember[] methods) throws JavaModelException { >+ IJavaProject project= null; >+ if (methods != null && methods.length > 0) >+ project= methods[0].getJavaProject(); >+ if (RefactoringAvailabilityTester.isPullUpAvailable(methods)) { >+ PullUpRefactoringProcessor processor= new PullUpRefactoringProcessor(methods, JavaPreferencesSettings.getCodeGenerationSettings(project)); >+ new ProcessorBasedRefactoring(processor); >+ return processor; >+ } >+ return null; >+ } >+ >+ private static ExtractSupertypeProcessor createExtractSuperclassRefactoringProcessor(IMember[] members) throws JavaModelException { >+ IJavaProject project= null; >+ if (members != null && members.length > 0) >+ project= members[0].getJavaProject(); >+ if (RefactoringAvailabilityTester.isExtractSupertypeAvailable(members)) { >+ final CodeGenerationSettings settings= JavaPreferencesSettings.getCodeGenerationSettings(project); >+ settings.createComments= false; >+ ExtractSupertypeProcessor processor= new ExtractSupertypeProcessor(members, settings); >+ new ProcessorBasedRefactoring(processor); >+ return processor; >+ } >+ return null; >+ } >+ >+ private IPackageFragment getPackage(String name) throws JavaModelException { >+ if ("p".equals(name)) >+ return getPackageP(); >+ IPackageFragment pack= getRoot().getPackageFragment(name); >+ if (pack.exists()) >+ return pack; >+ return getRoot().createPackageFragment(name, false, new NullProgressMonitor()); >+ } >+ >+ private static String getTopLevelTypeName(String typeQualifiedTyperName) { >+ int dotIndex= typeQualifiedTyperName.indexOf('.'); >+ if (dotIndex == -1) >+ return typeQualifiedTyperName; >+ return typeQualifiedTyperName.substring(0, dotIndex); >+ } >+ >+ private void prepareForInputCheck(PushDownRefactoringProcessor processor, IMethod[] selectedMethods, IField[] selectedFields, String[] namesOfMethodsToPullUp, >+ String[][] signaturesOfMethodsToPullUp, String[] namesOfFieldsToPullUp, String[] namesOfMethodsToDeclareAbstract, String[][] signaturesOfMethodsToDeclareAbstract) { >+ IMethod[] methodsToPushDown= findMethods(selectedMethods, namesOfMethodsToPullUp, signaturesOfMethodsToPullUp); >+ IField[] fieldsToPushDown= findFields(selectedFields, namesOfFieldsToPullUp); >+ List membersToPushDown= Arrays.asList(merge(methodsToPushDown, fieldsToPushDown)); >+ List methodsToDeclareAbstract= Arrays.asList(findMethods(selectedMethods, namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract)); >+ >+ MemberActionInfo[] infos= processor.getMemberActionInfos(); >+ for (int i= 0; i < infos.length; i++) { >+ if (membersToPushDown.contains(infos[i].getMember())) { >+ infos[i].setAction(MemberActionInfo.PUSH_DOWN_ACTION); >+ assertTrue(!methodsToDeclareAbstract.contains(infos[i].getMember())); >+ } >+ if (methodsToDeclareAbstract.contains(infos[i].getMember())) { >+ infos[i].setAction(MemberActionInfo.PUSH_ABSTRACT_ACTION); >+ assertTrue(!membersToPushDown.contains(infos[i].getMember())); >+ } >+ } >+ } >+ >+ /** >+ * Tests "Pull Up" method refactoring involving receiver parameter. >+ * >+ * @throws Exception any exception thrown from this test case >+ */ >+ public void testPullUp() throws Exception { >+ String[] methodNames= new String[] { "foo1", "foo2" }; >+ String[][] signatures= new String[][] { new String[0], new String[] { "QString;" } }; >+ boolean deleteAllInSourceType= true; >+ boolean deleteAllMatchingMethods= false; >+ ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); >+ IType type= getType(cu, "B"); >+ IMethod[] methods= getMethods(type, methodNames, signatures); >+ >+ PullUpRefactoringProcessor processor= createPullUpRefactoringProcessor(methods); >+ Refactoring ref= processor.getRefactoring(); >+ >+ assertTrue("activation", ref.checkInitialConditions(new NullProgressMonitor()).isOK()); >+ >+ IType[] possibleClasses= processor.getCandidateTypes(new RefactoringStatus(), new NullProgressMonitor()); >+ assertTrue("No possible class found!", possibleClasses.length > 0); >+ processor.setDestinationType(processor.getCandidateTypes(new RefactoringStatus(), new NullProgressMonitor())[possibleClasses.length - 1 - 0]); >+ >+ if (deleteAllInSourceType) >+ processor.setDeletedMethods(methods); >+ if (deleteAllMatchingMethods) { >+ List l= Arrays.asList(JavaElementUtil.getElementsOfType(processor.getMatchingElements(new NullProgressMonitor(), false), IJavaElement.METHOD)); >+ processor.setDeletedMethods((IMethod[])l.toArray(new IMethod[l.size()])); >+ } >+ >+ RefactoringStatus checkInputResult= ref.checkFinalConditions(new NullProgressMonitor()); >+ assertTrue("precondition was supposed to pass", !checkInputResult.hasError()); >+ performChange(ref, false); >+ >+ String expected= getFileContents(getOutputTestFileName("A")); >+ String actual= cu.getSource(); >+ assertEqualLines(expected, actual); >+ } >+ >+ /** >+ * Tests "Push Down" method refactoring involving receiver parameter. >+ * >+ * @throws Exception any exception thrown from this test case >+ */ >+ public void testPushDown() throws Exception { >+ String[] namesOfMethodsToPushDown= { "foo1", "foo2" }; >+ String[][] signaturesOfMethodsToPushDown= { new String[0], new String[] { "QString;" } }; >+ String[] selectedFieldNames= {}; >+ String[] namesOfFieldsToPushDown= {}; >+ String[] namesOfMethodsToDeclareAbstract= {}; >+ String[][] signaturesOfMethodsToDeclareAbstract= {}; >+ >+ >+ ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A"); >+ >+ IType type= getType(cuA, "A"); >+ IMethod[] selectedMethods= getMethods(type, namesOfMethodsToPushDown, signaturesOfMethodsToPushDown); >+ IField[] selectedFields= getFields(type, selectedFieldNames); >+ IMember[] selectedMembers= merge(selectedFields, selectedMethods); >+ >+ assertTrue(RefactoringAvailabilityTester.isPushDownAvailable(selectedMembers)); >+ PushDownRefactoringProcessor processor= new PushDownRefactoringProcessor(selectedMembers); >+ Refactoring ref= new ProcessorBasedRefactoring(processor); >+ >+ assertTrue("activation", ref.checkInitialConditions(new NullProgressMonitor()).isOK()); >+ >+ prepareForInputCheck(processor, selectedMethods, selectedFields, namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, namesOfFieldsToPushDown, namesOfMethodsToDeclareAbstract, >+ signaturesOfMethodsToDeclareAbstract); >+ >+ RefactoringStatus checkInputResult= ref.checkFinalConditions(new NullProgressMonitor()); >+ assertTrue("precondition was supposed to pass but got " + checkInputResult.toString(), !checkInputResult.hasError()); >+ performChange(ref, false); >+ >+ String expected= getFileContents(getOutputTestFileName("A")); >+ String actual= cuA.getSource(); >+ assertEqualLines("A.java", expected, actual); >+ >+ } >+ >+ /** >+ * Tests "Move" method refactoring involving receiver parameter. >+ * >+ * @throws Exception any exception thrown from this test case >+ */ >+ public void testMove() throws Exception { >+ String[] cuQNames= new String[] { "p1.A", "p2.B" }; >+ String selectionCuQName= "p1.A"; >+ boolean inlineDelegator= false; >+ boolean removeDelegator= false; >+ int selectionCuIndex= -1; >+ for (int i= 0; i < cuQNames.length; i++) >+ if (cuQNames[i] == null || selectionCuQName.equals(cuQNames[i])) >+ selectionCuIndex= i; >+ Assert.isTrue(selectionCuIndex != -1, "parameter selectionCuQName must match some String in cuQNames."); >+ ICompilationUnit cuA= createCUfromTestFile(getPackage("p1"), "A"); >+ ICompilationUnit cuB= createCUfromTestFile(getPackage("p1"), "B"); >+ >+ int offset= cuA.getSource().indexOf("mA1(@NonNull A this, B b)"); >+ IJavaElement[] codeSelect= cuA.codeSelect(offset, 3); >+ assertTrue(codeSelect.length > 0); >+ assertTrue(codeSelect[0] instanceof IMethod); >+ IMethod method= (IMethod)codeSelect[0]; >+ MoveInstanceMethodProcessor processor= new MoveInstanceMethodProcessor(method, JavaPreferencesSettings.getCodeGenerationSettings(cuA.getJavaProject())); >+ Refactoring ref= new MoveRefactoring(processor); >+ >+ assertNotNull("refactoring should be created", ref); >+ RefactoringStatus preconditionResult= ref.checkInitialConditions(new NullProgressMonitor()); >+ >+ assertTrue("activation was supposed to be successful", preconditionResult.isOK()); >+ >+ IVariableBinding target= null; >+ IVariableBinding[] targets= processor.getPossibleTargets(); >+ for (int i= 0; i < targets.length; i++) { >+ IVariableBinding candidate= targets[i]; >+ if (candidate.getName().equals("b")) { >+ target= candidate; >+ break; >+ } >+ } >+ assertNotNull("Expected new target not available.", target); >+ processor.setTarget(target); >+ >+ processor.setInlineDelegator(inlineDelegator); >+ processor.setRemoveDelegator(removeDelegator); >+ processor.setDeprecateDelegates(false); >+ processor.setMethodName("mA1Moved"); >+ >+ preconditionResult.merge(ref.checkFinalConditions(new NullProgressMonitor())); >+ >+ assertTrue("precondition was supposed to pass", !preconditionResult.hasError()); >+ >+ performChange(ref, false); >+ >+ String outputTestFileName= getOutputTestFileName("A"); >+ assertEqualLines("Incorrect inline in " + outputTestFileName, getFileContents(outputTestFileName), cuA.getSource()); >+ >+ >+ outputTestFileName= getOutputTestFileName("B"); >+ assertEqualLines("Incorrect inline in " + outputTestFileName, getFileContents(outputTestFileName), cuB.getSource()); >+ >+ } >+ >+ /** >+ * Tests "Move Type to New File" refactoring involving receiver parameter. >+ * >+ * @throws Exception any exception thrown from this test case >+ */ >+ public void testMoveType2File() throws Exception { >+ String parentClassName= "A"; >+ String enclosingInstanceName= "Inner"; >+ String[] cuNames= new String[] { "A" }; >+ String[] packageNames= new String[] { "p" }; >+ String packageName= "p"; >+ IType parentClas= getType(createCUfromTestFile(getPackage(packageName), parentClassName), parentClassName); >+ IType clas= parentClas.getType(enclosingInstanceName); >+ >+ assertTrue("should be enabled", RefactoringAvailabilityTester.isMoveInnerAvailable(clas)); >+ MoveInnerToTopRefactoring ref= ((RefactoringAvailabilityTester.isMoveInnerAvailable(clas)) ? new MoveInnerToTopRefactoring(clas, JavaPreferencesSettings.getCodeGenerationSettings(clas >+ .getJavaProject())) : null); >+ RefactoringStatus preconditionResult= ref.checkInitialConditions(new NullProgressMonitor()); >+ assertTrue("activation was supposed to be successful" + preconditionResult.toString(), preconditionResult.isOK()); >+ >+ assertEquals("reference creation possible", true, ref.isCreatingInstanceFieldPossible()); >+ assertEquals("reference creation mandatory", false, ref.isCreatingInstanceFieldMandatory()); >+ if (ref.isCreatingInstanceFieldPossible() && !ref.isCreatingInstanceFieldMandatory()) >+ ref.setCreateInstanceField(false); >+ ref.setEnclosingInstanceName(enclosingInstanceName); >+ assertTrue("name should be ok ", ref.checkEnclosingInstanceName(enclosingInstanceName).isOK()); >+ ref.setMarkInstanceFieldAsFinal(false); >+ ICompilationUnit[] cus= new ICompilationUnit[cuNames.length]; >+ for (int i= 0; i < cuNames.length; i++) { >+ if (cuNames[i].equals(clas.getCompilationUnit().findPrimaryType().getElementName())) >+ cus[i]= clas.getCompilationUnit(); >+ else >+ cus[i]= createCUfromTestFile(getPackage(packageNames[i]), cuNames[i]); >+ } >+ >+ RefactoringStatus checkInputResult= ref.checkFinalConditions(new NullProgressMonitor()); >+ assertTrue("precondition was supposed to pass", !checkInputResult.hasError()); >+ performChange(ref, false); >+ >+ for (int i= 0; i < cus.length; i++) { >+ String actual= cus[i].getSource(); >+ String expected= getFileContents(getOutputTestFileName(cuNames[i])); >+ assertEqualLines(cus[i].getElementName(), expected, actual); >+ } >+ ICompilationUnit newCu= clas.getPackageFragment().getCompilationUnit(enclosingInstanceName + ".java"); >+ String expected= getFileContents(getOutputTestFileName(enclosingInstanceName)); >+ String actual= newCu.getSource(); >+ assertEqualLines("new Cu:", expected, actual); >+ >+ } >+ >+ /** >+ * Tests "Extract Interface" refactoring involving receiver parameter. >+ * >+ * @throws Exception any exception thrown from this test case >+ */ >+ public void testExtractInterface() throws Exception { >+ String className= "A"; >+ String newInterfaceName= "I"; >+ >+ IType clas= getType(createCUfromTestFile(getPackageP(), getTopLevelTypeName(className)), className); >+ ICompilationUnit cu= clas.getCompilationUnit(); >+ IPackageFragment pack= (IPackageFragment)cu.getParent(); >+ >+ ExtractInterfaceProcessor processor= new ExtractInterfaceProcessor(clas, JavaPreferencesSettings.getCodeGenerationSettings(clas.getJavaProject())); >+ Refactoring ref= new ProcessorBasedRefactoring(processor); >+ >+ processor.setTypeName(newInterfaceName); >+ assertEquals("interface name should be accepted", RefactoringStatus.OK, processor.checkTypeName(newInterfaceName).getSeverity()); >+ >+ processor.setExtractedMembers(processor.getExtractableMembers()); >+ processor.setReplace(true); >+ processor.setAnnotations(false); >+ assertEquals("was supposed to pass", null, performRefactoring(ref)); >+ assertEqualLines("incorrect changes in " + className, >+ getFileContents(getOutputTestFileName(className)), >+ cu.getSource()); >+ >+ ICompilationUnit interfaceCu= pack.getCompilationUnit(newInterfaceName + ".java"); >+ assertEqualLines("incorrect interface created", >+ getFileContents(getOutputTestFileName(newInterfaceName)), >+ interfaceCu.getSource()); >+ } >+ >+ /** >+ * Tests "Extract Superclass" refactoring involving receiver parameter. >+ * >+ * @throws Exception any exception thrown from this test case >+ */ >+ public void testExtractSuperclass() throws Exception { >+ String[] methodNames= new String[] { "foo1", "foo2" }; >+ String[][] signatures= new String[][] { new String[0], new String[] { "QString;" } }; >+ boolean replaceOccurences= true; >+ >+ >+ ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); >+ IType type= getType(cu, "A"); >+ IMethod[] methods= getMethods(type, methodNames, signatures); >+ >+ ExtractSupertypeProcessor processor= createExtractSuperclassRefactoringProcessor(methods); >+ Refactoring refactoring= processor.getRefactoring(); >+ processor.setMembersToMove(methods); >+ >+ assertTrue("activation", refactoring.checkInitialConditions(new NullProgressMonitor()).isOK()); >+ >+ processor.setTypesToExtract(new IType[] { type }); >+ processor.setTypeName("B"); >+ processor.setCreateMethodStubs(true); >+ processor.setInstanceOf(false); >+ processor.setReplace(replaceOccurences); >+ processor.setDeletedMethods(methods); >+ >+ RefactoringStatus status= refactoring.checkFinalConditions(new NullProgressMonitor()); >+ assertTrue("precondition was supposed to pass", !status.hasError()); >+ performChange(refactoring, false); >+ >+ String expected= getFileContents(getOutputTestFileName("A")); >+ String actual= cu.getSource(); >+ assertEqualLines(expected, actual); >+ >+ expected= getFileContents(getOutputTestFileName("B")); >+ ICompilationUnit unit= getPackageP().getCompilationUnit("B.java"); >+ if (!unit.exists()) >+ assertTrue("extracted compilation unit does not exist", false); >+ actual= unit.getBuffer().getContents(); >+ assertEqualLines(expected, actual); >+ >+ >+ } >+ >+} >#P org.eclipse.jdt.ui.tests >diff --git test plugin/org/eclipse/jdt/testplugin/JavaProjectHelper.java test plugin/org/eclipse/jdt/testplugin/JavaProjectHelper.java >index 79369bb..28334b7 100644 >--- test plugin/org/eclipse/jdt/testplugin/JavaProjectHelper.java >+++ test plugin/org/eclipse/jdt/testplugin/JavaProjectHelper.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2012 IBM Corporation and others. >+ * Copyright (c) 2000, 2013 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -78,15 +78,19 @@ > /** > * @deprecated use {@link #RT_STUBS_15} > */ >+ @Deprecated > public static final IPath RT_STUBS_13= new Path("testresources/rtstubs.jar"); > /** > * @deprecated use {@link #JUNIT_SRC_381} > */ >+ @Deprecated > public static final IPath JUNIT_SRC= new Path("testresources/junit37-noUI-src.zip"); > > public static final IPath RT_STUBS_15= new Path("testresources/rtstubs15.jar"); > public static final IPath RT_STUBS_16= new Path("testresources/rtstubs16.jar"); > public static final IPath RT_STUBS_17= new Path("testresources/rtstubs17.jar"); >+ >+ public static final IPath RT_STUBS_18= new Path("testresources/rtstubs18.jar"); > public static final IPath JUNIT_SRC_381= new Path("testresources/junit381-noUI-src.zip"); > public static final String JUNIT_SRC_ENCODING= "ISO-8859-1"; > >@@ -645,6 +649,13 @@ > return addLibrary(jproject, rtJarPath[0], rtJarPath[1], rtJarPath[2]); > } > >+ >+ public static IPackageFragmentRoot addRTJar18(IJavaProject jproject) throws CoreException { >+ IPath[] rtJarPath= findRtJar(RT_STUBS_18); >+ set17CompilerOptions(jproject); >+ return addLibrary(jproject, rtJarPath[0], rtJarPath[1], rtJarPath[2]); >+ } >+ > /** > * Adds a variable entry with source attachment to a IJavaProject. > * Can return null if variable can not be resolved. >@@ -848,5 +859,6 @@ > while (display.readAndDispatch()) { /*loop*/ } > } > } >+ > } > >#P org.eclipse.jdt.ui >diff --git core extension/org/eclipse/jdt/internal/corext/dom/ASTNodes.java core extension/org/eclipse/jdt/internal/corext/dom/ASTNodes.java >index e26d81c..0129930 100644 >--- core extension/org/eclipse/jdt/internal/corext/dom/ASTNodes.java >+++ core extension/org/eclipse/jdt/internal/corext/dom/ASTNodes.java >@@ -4,6 +4,10 @@ > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at > * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * This is an implementation of an early-draft specification developed under the Java >+ * Community Process (JCP) and is made available for testing and evaluation purposes >+ * only. The code is not compatible with any specification of the JCP. > * > * Contributors: > * IBM Corporation - initial API and implementation >@@ -70,6 +74,7 @@ > import org.eclipse.jdt.core.dom.Modifier; > import org.eclipse.jdt.core.dom.Name; > import org.eclipse.jdt.core.dom.NodeFinder; >+import org.eclipse.jdt.core.dom.PackageQualifiedType; > import org.eclipse.jdt.core.dom.ParameterizedType; > import org.eclipse.jdt.core.dom.ParenthesizedExpression; > import org.eclipse.jdt.core.dom.PrimitiveType; >@@ -574,7 +579,8 @@ > } > // normalize type > if (QualifiedType.NAME_PROPERTY.equals(current.getLocationInParent()) || >- SimpleType.NAME_PROPERTY.equals(current.getLocationInParent())) { >+ SimpleType.NAME_PROPERTY.equals(current.getLocationInParent()) || >+ PackageQualifiedType.NAME_PROPERTY.equals(current.getLocationInParent())) { > current= current.getParent(); > } > // normalize parameterized types >@@ -965,7 +971,7 @@ > /** > * Escapes a string value to a literal that can be used in Java source. > * >- * @param stringValue the string value >+ * @param stringValue the string value > * @return the escaped string > * @see StringLiteral#getEscapedValue() > */ >diff --git core extension/org/eclipse/jdt/internal/corext/fix/PotentialProgrammingProblemsFix.java core extension/org/eclipse/jdt/internal/corext/fix/PotentialProgrammingProblemsFix.java >index dd34f48..70f98d0 100644 >--- core extension/org/eclipse/jdt/internal/corext/fix/PotentialProgrammingProblemsFix.java >+++ core extension/org/eclipse/jdt/internal/corext/fix/PotentialProgrammingProblemsFix.java >@@ -1,9 +1,13 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2011 IBM Corporation and others. >+ * Copyright (c) 2000, 2013 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at > * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * This is an implementation of an early-draft specification developed under the Java >+ * Community Process (JCP) and is made available for testing and evaluation purposes >+ * only. The code is not compatible with any specification of the JCP. > * > * Contributors: > * IBM Corporation - initial API and implementation >@@ -47,6 +51,7 @@ > import org.eclipse.jdt.core.dom.IBinding; > import org.eclipse.jdt.core.dom.ITypeBinding; > import org.eclipse.jdt.core.dom.Name; >+import org.eclipse.jdt.core.dom.PackageQualifiedType; > import org.eclipse.jdt.core.dom.ParameterizedType; > import org.eclipse.jdt.core.dom.QualifiedName; > import org.eclipse.jdt.core.dom.QualifiedType; >@@ -385,11 +390,15 @@ > if (selection instanceof SimpleType) { > final SimpleType type= (SimpleType) selection; > name= type.getName(); >+ } else if (selection instanceof PackageQualifiedType) { >+ name= ((PackageQualifiedType) selection).getName(); > } else if (selection instanceof ParameterizedType) { > final ParameterizedType type= (ParameterizedType) selection; > final Type raw= type.getType(); > if (raw instanceof SimpleType) > name= ((SimpleType) raw).getName(); >+ else if (raw instanceof PackageQualifiedType) >+ name= ((PackageQualifiedType) raw).getName(); > else if (raw instanceof QualifiedType) > name= ((QualifiedType) raw).getName(); > } else if (selection instanceof Name) { >diff --git core refactoring/org/eclipse/jdt/internal/corext/refactoring/nls/NLSHintHelper.java core refactoring/org/eclipse/jdt/internal/corext/refactoring/nls/NLSHintHelper.java >index 4e875b8..ccdf1c5 100644 >--- core refactoring/org/eclipse/jdt/internal/corext/refactoring/nls/NLSHintHelper.java >+++ core refactoring/org/eclipse/jdt/internal/corext/refactoring/nls/NLSHintHelper.java >@@ -1,9 +1,13 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2011 IBM Corporation and others. >+ * Copyright (c) 2000, 2013 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at > * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * This is an implementation of an early-draft specification developed under the Java >+ * Community Process (JCP) and is made available for testing and evaluation purposes >+ * only. The code is not compatible with any specification of the JCP. > * > * Contributors: > * IBM Corporation - initial API and implementation >@@ -57,8 +61,8 @@ > import org.eclipse.jdt.core.dom.NodeFinder; > import org.eclipse.jdt.core.dom.QualifiedName; > import org.eclipse.jdt.core.dom.SimpleName; >-import org.eclipse.jdt.core.dom.SimpleType; > import org.eclipse.jdt.core.dom.StringLiteral; >+import org.eclipse.jdt.core.dom.Type; > import org.eclipse.jdt.core.dom.TypeLiteral; > import org.eclipse.jdt.core.dom.VariableDeclarationFragment; > >@@ -281,7 +285,7 @@ > MethodInvocation methInvocation= (MethodInvocation)initializer; > Expression exp= methInvocation.getExpression(); > if ((exp != null) && (exp instanceof TypeLiteral)) { >- SimpleType simple= (SimpleType)((TypeLiteral) exp).getType(); >+ Type simple= ((TypeLiteral) exp).getType(); > ITypeBinding typeBinding= simple.resolveBinding(); > if (typeBinding != null) > return typeBinding.getQualifiedName(); >diff --git ui/org/eclipse/jdt/internal/ui/actions/CopyQualifiedNameAction.java ui/org/eclipse/jdt/internal/ui/actions/CopyQualifiedNameAction.java >index 85e0681..feeb4a6 100644 >--- ui/org/eclipse/jdt/internal/ui/actions/CopyQualifiedNameAction.java >+++ ui/org/eclipse/jdt/internal/ui/actions/CopyQualifiedNameAction.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2011 IBM Corporation and others. >+ * Copyright (c) 2000, 2013 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -65,6 +65,7 @@ > import org.eclipse.jdt.core.dom.Name; > import org.eclipse.jdt.core.dom.NodeFinder; > import org.eclipse.jdt.core.dom.PackageDeclaration; >+import org.eclipse.jdt.core.dom.PackageQualifiedType; > import org.eclipse.jdt.core.dom.SimpleType; > import org.eclipse.jdt.core.dom.StructuralPropertyDescriptor; > import org.eclipse.jdt.core.dom.Type; >@@ -366,6 +367,11 @@ > loc= parent.getLocationInParent(); > if (loc == ClassInstanceCreation.TYPE_PROPERTY) > return ((ClassInstanceCreation)parent.getParent()).resolveConstructorBinding(); >+ } else if (loc == PackageQualifiedType.NAME_PROPERTY) { >+ ASTNode parent= nameNode.getParent(); >+ loc= parent.getLocationInParent(); >+ if (loc == ClassInstanceCreation.TYPE_PROPERTY) >+ return ((ClassInstanceCreation) parent.getParent()).resolveConstructorBinding(); > } > return null; > } >diff --git ui/org/eclipse/jdt/internal/ui/search/OccurrencesFinder.java ui/org/eclipse/jdt/internal/ui/search/OccurrencesFinder.java >index 0e2e520..c4f6be7 100644 >--- ui/org/eclipse/jdt/internal/ui/search/OccurrencesFinder.java >+++ ui/org/eclipse/jdt/internal/ui/search/OccurrencesFinder.java >@@ -1,10 +1,14 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2011 IBM Corporation and others. >+ * Copyright (c) 2000, 2013 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at > * http://www.eclipse.org/legal/epl-v10.html > * >+ * This is an implementation of an early-draft specification developed under the Java >+ * Community Process (JCP) and is made available for testing and evaluation purposes >+ * only. The code is not compatible with any specification of the JCP. >+ * > * Contributors: > * IBM Corporation - initial API and implementation > *******************************************************************************/ >@@ -32,6 +36,7 @@ > import org.eclipse.jdt.core.dom.Modifier; > import org.eclipse.jdt.core.dom.Name; > import org.eclipse.jdt.core.dom.NodeFinder; >+import org.eclipse.jdt.core.dom.PackageQualifiedType; > import org.eclipse.jdt.core.dom.ParameterizedType; > import org.eclipse.jdt.core.dom.PostfixExpression; > import org.eclipse.jdt.core.dom.PrefixExpression; >@@ -187,6 +192,9 @@ > if (name instanceof QualifiedName) > name= ((QualifiedName)name).getName(); > addUsage(name, node.resolveConstructorBinding()); >+ } else if (type instanceof PackageQualifiedType) { >+ Name name= ((PackageQualifiedType) type).getName(); >+ addUsage(name, node.resolveConstructorBinding()); > } > return super.visit(node); > } >diff --git ui/org/eclipse/jdt/internal/ui/text/correction/ASTResolving.java ui/org/eclipse/jdt/internal/ui/text/correction/ASTResolving.java >index db17f58..3130454 100644 >--- ui/org/eclipse/jdt/internal/ui/text/correction/ASTResolving.java >+++ ui/org/eclipse/jdt/internal/ui/text/correction/ASTResolving.java >@@ -5,6 +5,10 @@ > * which accompanies this distribution, and is available at > * http://www.eclipse.org/legal/epl-v10.html > * >+ * This is an implementation of an early-draft specification developed under the Java >+ * Community Process (JCP) and is made available for testing and evaluation purposes >+ * only. The code is not compatible with any specification of the JCP. >+ * > * Contributors: > * IBM Corporation - initial API and implementation > *******************************************************************************/ >@@ -54,6 +58,7 @@ > import org.eclipse.jdt.core.dom.MethodInvocation; > import org.eclipse.jdt.core.dom.Modifier; > import org.eclipse.jdt.core.dom.Name; >+import org.eclipse.jdt.core.dom.PackageQualifiedType; > import org.eclipse.jdt.core.dom.ParameterizedType; > import org.eclipse.jdt.core.dom.PrefixExpression; > import org.eclipse.jdt.core.dom.PrimitiveType; >@@ -403,7 +408,7 @@ > if (locationInParent == QualifiedName.QUALIFIER_PROPERTY) { > return null; // can't guess type for X.A > } >- if (locationInParent == SimpleType.NAME_PROPERTY) { >+ if (locationInParent == SimpleType.NAME_PROPERTY || locationInParent == PackageQualifiedType.NAME_PROPERTY) { > node= node.getParent(); > } > ITypeBinding binding= Bindings.normalizeTypeBinding(getPossibleTypeBinding(node)); >@@ -854,7 +859,7 @@ > kind= SimilarElementsRequestor.INTERFACES; > break; > case ASTNode.METHOD_DECLARATION: >- if (node.getLocationInParent() == MethodDeclaration.THROWN_EXCEPTIONS_PROPERTY) { >+ if (node.getLocationInParent() == MethodDeclaration.THROWN_EXCEPTION_TYPES_PROPERTY) { > kind= SimilarElementsRequestor.CLASSES; > } else if (node.getLocationInParent() == MethodDeclaration.RETURN_TYPE2_PROPERTY) { > kind= SimilarElementsRequestor.ALL_TYPES | SimilarElementsRequestor.VOIDTYPE; >diff --git ui/org/eclipse/jdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java ui/org/eclipse/jdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java >index 2cf0228..866828c 100644 >--- ui/org/eclipse/jdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java >+++ ui/org/eclipse/jdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java >@@ -5,6 +5,10 @@ > * which accompanies this distribution, and is available at > * http://www.eclipse.org/legal/epl-v10.html > * >+ * This is an implementation of an early-draft specification developed under the Java >+ * Community Process (JCP) and is made available for testing and evaluation purposes >+ * only. The code is not compatible with any specification of the JCP. >+ * > * Contributors: > * IBM Corporation - initial API and implementation > * Renaud Waldura <renaud+eclipse@waldura.com> - Access to static proposal >@@ -76,6 +80,7 @@ > import org.eclipse.jdt.core.dom.MethodInvocation; > import org.eclipse.jdt.core.dom.Modifier; > import org.eclipse.jdt.core.dom.Name; >+import org.eclipse.jdt.core.dom.PackageQualifiedType; > import org.eclipse.jdt.core.dom.ParameterizedType; > import org.eclipse.jdt.core.dom.ParenthesizedExpression; > import org.eclipse.jdt.core.dom.PrefixExpression; >@@ -406,12 +411,12 @@ > } > uncaughtExceptions= unhandledExceptions.toArray(new ITypeBinding[unhandledExceptions.size()]); > >- List<Name> exceptions= methodDecl.thrownExceptions(); >+ List<Type> exceptions= methodDecl.thrownExceptionTypes(); > int nExistingExceptions= exceptions.size(); > ChangeDescription[] desc= new ChangeDescription[nExistingExceptions + uncaughtExceptions.length]; > for (int i= 0; i < exceptions.size(); i++) { >- Name elem= exceptions.get(i); >- if (isSubtype(elem.resolveTypeBinding(), uncaughtExceptions)) { >+ Type elem= exceptions.get(i); >+ if (isSubtype(elem.resolveBinding(), uncaughtExceptions)) { > desc[i]= new RemoveDescription(); > } > } >@@ -751,7 +756,7 @@ > MethodDeclaration decl= (MethodDeclaration) selectedNode.getParent(); > IMethodBinding binding= decl.resolveBinding(); > if (binding != null) { >- List<Name> thrownExceptions= decl.thrownExceptions(); >+ List<Type> thrownExceptions= decl.thrownExceptionTypes(); > int index= thrownExceptions.indexOf(selectedNode); > if (index == -1) { > return; >@@ -1431,6 +1436,8 @@ > Name node= null; > if (selectedNode instanceof SimpleType) { > node= ((SimpleType) selectedNode).getName(); >+ } else if (selectedNode instanceof PackageQualifiedType) { >+ node= ((PackageQualifiedType) selectedNode).getName(); > } else if (selectedNode instanceof ArrayType) { > Type elementType= ((ArrayType) selectedNode).getElementType(); > if (elementType.isSimpleType()) { >@@ -1458,7 +1465,7 @@ > simpleBinding= simpleBinding.getTypeDeclaration(); > > if (!simpleBinding.isRecovered()) { >- if (binding.isParameterizedType() && node.getParent() instanceof SimpleType && !(node.getParent().getParent() instanceof Type)) { >+ if (binding.isParameterizedType() && (node.getParent() instanceof SimpleType || node.getParent() instanceof PackageQualifiedType) && !(node.getParent().getParent() instanceof Type)) { > proposals.add(UnresolvedElementsSubProcessor.createTypeRefChangeFullProposal(cu, binding, node, IProposalRelevance.TYPE_ARGUMENTS_FROM_CONTEXT)); > } > } >diff --git ui/org/eclipse/jdt/internal/ui/text/correction/ModifierCorrectionSubProcessor.java ui/org/eclipse/jdt/internal/ui/text/correction/ModifierCorrectionSubProcessor.java >index a2a7eb1..c743e70 100644 >--- ui/org/eclipse/jdt/internal/ui/text/correction/ModifierCorrectionSubProcessor.java >+++ ui/org/eclipse/jdt/internal/ui/text/correction/ModifierCorrectionSubProcessor.java >@@ -5,6 +5,10 @@ > * which accompanies this distribution, and is available at > * http://www.eclipse.org/legal/epl-v10.html > * >+ * This is an implementation of an early-draft specification developed under the Java >+ * Community Process (JCP) and is made available for testing and evaluation purposes >+ * only. The code is not compatible with any specification of the JCP. >+ * > * Contributors: > * IBM Corporation - initial API and implementation > * Benjamin Muskalla <bmuskalla@innoopract.com> - [quick fix] 'Remove invalid modifiers' does not appear for enums and annotations - https://bugs.eclipse.org/bugs/show_bug.cgi?id=110589 >@@ -54,6 +58,7 @@ > import org.eclipse.jdt.core.dom.MethodDeclaration; > import org.eclipse.jdt.core.dom.MethodInvocation; > import org.eclipse.jdt.core.dom.Modifier; >+import org.eclipse.jdt.core.dom.PackageQualifiedType; > import org.eclipse.jdt.core.dom.Modifier.ModifierKeyword; > import org.eclipse.jdt.core.dom.QualifiedName; > import org.eclipse.jdt.core.dom.ReturnStatement; >@@ -127,6 +132,9 @@ > case ASTNode.SIMPLE_TYPE: > binding= ((SimpleType) selectedNode).resolveBinding(); > break; >+ case ASTNode.PACKAGE_QUALIFIED_TYPE: >+ binding= ((PackageQualifiedType) selectedNode).resolveBinding(); >+ break; > case ASTNode.METHOD_INVOCATION: > binding= ((MethodInvocation) selectedNode).getName().resolveBinding(); > break; >diff --git ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java >index 346512a..9bbb12a 100644 >--- ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java >+++ ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java >@@ -5,6 +5,10 @@ > * which accompanies this distribution, and is available at > * http://www.eclipse.org/legal/epl-v10.html > * >+ * This is an implementation of an early-draft specification developed under the Java >+ * Community Process (JCP) and is made available for testing and evaluation purposes >+ * only. The code is not compatible with any specification of the JCP. >+ * > * Contributors: > * IBM Corporation - initial API and implementation > * Sebastian Davids <sdavids@gmx.de> - Bug 37432 getInvertEqualsProposal >@@ -78,6 +82,7 @@ > import org.eclipse.jdt.core.dom.Modifier; > import org.eclipse.jdt.core.dom.Name; > import org.eclipse.jdt.core.dom.NumberLiteral; >+import org.eclipse.jdt.core.dom.PackageQualifiedType; > import org.eclipse.jdt.core.dom.ParameterizedType; > import org.eclipse.jdt.core.dom.ParenthesizedExpression; > import org.eclipse.jdt.core.dom.PostfixExpression; >@@ -501,8 +506,8 @@ > > if (node instanceof Name) { > Name name= ASTNodes.getTopMostName((Name) node); >- if (name.getLocationInParent() == SimpleType.NAME_PROPERTY) { >- SimpleType type= (SimpleType) name.getParent(); >+ if (name.getLocationInParent() == SimpleType.NAME_PROPERTY || name.getLocationInParent() == PackageQualifiedType.NAME_PROPERTY) { >+ ASTNode type= name.getParent(); > if (type.getLocationInParent() == ParameterizedType.TYPE_PROPERTY) { > createdType= (ParameterizedType) type.getParent(); > if (createdType.getLocationInParent() != ClassInstanceCreation.TYPE_PROPERTY) { >@@ -1268,7 +1273,7 @@ > } > > Type type= catchClause.getException().getType(); >- if (!type.isSimpleType() && !type.isUnionType()) { >+ if (!type.isSimpleType() && !type.isUnionType() && !type.isPackageQualifiedType()) { > return false; > } > >@@ -1309,7 +1314,7 @@ > UnionType unionType= (UnionType) type; > List<Type> types= unionType.types(); > for (Type elementType : types) { >- if (!(elementType instanceof SimpleType)) >+ if (!(elementType instanceof SimpleType || elementType instanceof PackageQualifiedType)) > return false; > addExceptionToThrows(ast, methodDeclaration, rewrite, (SimpleType) elementType); > } >@@ -1495,6 +1500,7 @@ > if (type1.isUnionType() && covering instanceof Name) { > Name topMostName= ASTNodes.getTopMostName((Name) covering); > ASTNode parent= topMostName.getParent(); >+ // TODO handle PQT > if (parent instanceof SimpleType) { > selectedMultiCatchType= (SimpleType) parent; > } >diff --git ui/org/eclipse/jdt/internal/ui/text/correction/TypeMismatchSubProcessor.java ui/org/eclipse/jdt/internal/ui/text/correction/TypeMismatchSubProcessor.java >index f904ad5..65cbef7 100644 >--- ui/org/eclipse/jdt/internal/ui/text/correction/TypeMismatchSubProcessor.java >+++ ui/org/eclipse/jdt/internal/ui/text/correction/TypeMismatchSubProcessor.java >@@ -5,6 +5,10 @@ > * which accompanies this distribution, and is available at > * http://www.eclipse.org/legal/epl-v10.html > * >+ * This is an implementation of an early-draft specification developed under the Java >+ * Community Process (JCP) and is made available for testing and evaluation purposes >+ * only. The code is not compatible with any specification of the JCP. >+ * > * Contributors: > * IBM Corporation - initial API and implementation > * Benjamin Muskalla <bmuskalla@eclipsesource.com> - [quick fix] proposes wrong cast from Object to primitive int - https://bugs.eclipse.org/bugs/show_bug.cgi?id=100593 >@@ -39,6 +43,7 @@ > import org.eclipse.jdt.core.dom.MemberValuePair; > import org.eclipse.jdt.core.dom.MethodDeclaration; > import org.eclipse.jdt.core.dom.Name; >+import org.eclipse.jdt.core.dom.PackageQualifiedType; > import org.eclipse.jdt.core.dom.SimpleName; > import org.eclipse.jdt.core.dom.SimpleType; > import org.eclipse.jdt.core.dom.SingleMemberAnnotation; >@@ -455,16 +460,22 @@ > SingleVariableDeclaration parameter= forStatement.getParameter(); > > ICompilationUnit cu= context.getCompilationUnit(); >- if (parameter.getName().getLength() == 0 >- && parameter.getType() instanceof SimpleType) { >- SimpleType type= (SimpleType) parameter.getType(); >- if (type.getName() instanceof SimpleName) { >- SimpleName simpleName= (SimpleName) type.getName(); >+ if (parameter.getName().getLength() == 0) { >+ SimpleName simpleName= null; >+ if (parameter.getType() instanceof SimpleType) { >+ SimpleType type= (SimpleType) parameter.getType(); >+ if (type.getName() instanceof SimpleName) { >+ simpleName= (SimpleName) type.getName(); >+ } >+ } else if (parameter.getType() instanceof PackageQualifiedType) { >+ simpleName= ((PackageQualifiedType) parameter.getType()).getName(); >+ } >+ if (simpleName != null) { > String name= simpleName.getIdentifier(); > int relevance= StubUtility.hasLocalVariableName(cu.getJavaProject(), name) ? 10 : 7; > String label= Messages.format(CorrectionMessages.TypeMismatchSubProcessor_create_loop_variable_description, BasicElementLabels.getJavaElementName(name)); > Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_LOCAL); >- >+ > proposals.add(new NewVariableCorrectionProposal(label, cu, NewVariableCorrectionProposal.LOCAL, simpleName, null, relevance, image)); > return; > } >diff --git ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java >index 2dcf18c..773a23c 100644 >--- ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java >+++ ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java >@@ -5,6 +5,10 @@ > * which accompanies this distribution, and is available at > * http://www.eclipse.org/legal/epl-v10.html > * >+ * This is an implementation of an early-draft specification developed under the Java >+ * Community Process (JCP) and is made available for testing and evaluation purposes >+ * only. The code is not compatible with any specification of the JCP. >+ * > * Contributors: > * IBM Corporation - initial API and implementation > * Renaud Waldura <renaud+eclipse@waldura.com> - New class/interface with wizard >@@ -96,6 +100,7 @@ > import org.eclipse.jdt.core.dom.Modifier; > import org.eclipse.jdt.core.dom.Name; > import org.eclipse.jdt.core.dom.NormalAnnotation; >+import org.eclipse.jdt.core.dom.PackageQualifiedType; > import org.eclipse.jdt.core.dom.ParenthesizedExpression; > import org.eclipse.jdt.core.dom.QualifiedName; > import org.eclipse.jdt.core.dom.SimpleName; >@@ -211,7 +216,8 @@ > node= null; > } > } >- } else if (parent instanceof SimpleType) { >+ } >+ else if (parent instanceof SimpleType || parent instanceof PackageQualifiedType) { > suggestVariableProposals= false; > typeKind= SimilarElementsRequestor.REF_TYPES_AND_VAR; > } else if (parent instanceof QualifiedName) { >@@ -225,7 +231,7 @@ > while (outerParent instanceof QualifiedName) { > outerParent= outerParent.getParent(); > } >- if (outerParent instanceof SimpleType) { >+ if (outerParent instanceof SimpleType || outerParent instanceof PackageQualifiedType) { > typeKind= SimilarElementsRequestor.REF_TYPES; > suggestVariableProposals= false; > } >@@ -249,7 +255,7 @@ > typeKind= SimilarElementsRequestor.REF_TYPES; > suggestVariableProposals= node.isSimpleName(); > } >- if (selectedNode.getParent() instanceof SimpleType) { >+ if (selectedNode.getParent() instanceof SimpleType || selectedNode.getParent() instanceof PackageQualifiedType) { > typeKind= SimilarElementsRequestor.REF_TYPES; > suggestVariableProposals= false; > } >@@ -609,6 +615,8 @@ > Name node= null; > if (selectedNode instanceof SimpleType) { > node= ((SimpleType) selectedNode).getName(); >+ } else if (selectedNode instanceof PackageQualifiedType) { >+ node= ((PackageQualifiedType) selectedNode).getName(); > } else if (selectedNode instanceof ArrayType) { > Type elementType= ((ArrayType) selectedNode).getElementType(); > if (elementType.isSimpleType()) { >@@ -641,7 +649,7 @@ > } > > private static void addEnhancedForWithoutTypeProposals(ICompilationUnit cu, ASTNode selectedNode, Collection<ICommandAccess> proposals) { >- if (selectedNode instanceof SimpleName && selectedNode.getLocationInParent() == SimpleType.NAME_PROPERTY) { >+ if (selectedNode instanceof SimpleName && (selectedNode.getLocationInParent() == SimpleType.NAME_PROPERTY || selectedNode.getLocationInParent() == PackageQualifiedType.NAME_PROPERTY)) { > ASTNode type= selectedNode.getParent(); > if (type.getLocationInParent() == SingleVariableDeclaration.TYPE_PROPERTY) { > SingleVariableDeclaration svd= (SingleVariableDeclaration) type.getParent(); >@@ -840,7 +848,7 @@ > if (proposal instanceof AddImportCorrectionProposal) > proposal.setRelevance(relevance + elements.length + 2); > >- if (binding.isParameterizedType() && node.getParent() instanceof SimpleType && !(node.getParent().getParent() instanceof Type)) { >+ if (binding.isParameterizedType() && (node.getParent() instanceof SimpleType || node.getParent() instanceof PackageQualifiedType) && !(node.getParent().getParent() instanceof Type)) { > proposals.add(createTypeRefChangeFullProposal(cu, binding, node, relevance + 5)); > } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 407056
:
232819
|
236994
|
238708