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 238624 Details for
Bug 397158
[use supertype] Inserts incorrect type argument when applied on a generic static method
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]
Fix and Test
Bug 397158.patch (text/plain), 6.66 KB, created by
Samrat Dhillon
on 2013-12-31 10:38:47 EST
(
hide
)
Description:
Fix and Test
Filename:
MIME Type:
Creator:
Samrat Dhillon
Created:
2013-12-31 10:38:47 EST
Size:
6.66 KB
patch
obsolete
>diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/UseSupertypeWherePossible/testNew40/in/A.java b/org.eclipse.jdt.ui.tests.refactoring/resources/UseSupertypeWherePossible/testNew40/in/A.java >new file mode 100644 >index 0000000..af3a714 >--- /dev/null >+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/UseSupertypeWherePossible/testNew40/in/A.java >@@ -0,0 +1,10 @@ >+package p; >+interface I<T> { >+} >+class A<E> implements I<E> { >+} >+class C11 { >+ static <T> A<T> m() { >+ return null; >+ } >+} >\ No newline at end of file >diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/UseSupertypeWherePossible/testNew40/out/A.java b/org.eclipse.jdt.ui.tests.refactoring/resources/UseSupertypeWherePossible/testNew40/out/A.java >new file mode 100644 >index 0000000..72cb973 >--- /dev/null >+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/UseSupertypeWherePossible/testNew40/out/A.java >@@ -0,0 +1,10 @@ >+package p; >+interface I<T> { >+} >+class A<E> implements I<E> { >+} >+class C11 { >+ static <T> I<T> m() { >+ return null; >+ } >+} >\ No newline at end of file >diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/UseSupertypeWherePossibleTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/UseSupertypeWherePossibleTests.java >index 31a622b..e140650 100644 >--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/UseSupertypeWherePossibleTests.java >+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/UseSupertypeWherePossibleTests.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2009 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 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Samrat Dhillon <samrat.dhillon@gmail.com> - [use supertype] Inserts incorrect type argument when applied on a generic static method - https://bugs.eclipse.org/397158 > *******************************************************************************/ > package org.eclipse.jdt.ui.tests.refactoring; > >@@ -272,6 +273,10 @@ > // printTestDisabledMessage("bug 169608"); > validatePassingTest("C", new String[]{"C"}, "p.B"); > } >+ >+ public void testNew40() throws Exception{ >+ validatePassingTest("A", new String[]{"A"}, "p.I", true); >+ } > > /* i had to rename tests 0-15 because of cvs problems*/ > >diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/constraints/SuperTypeRefactoringProcessor.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/constraints/SuperTypeRefactoringProcessor.java >index 57c443e..e9a54cb 100644 >--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/constraints/SuperTypeRefactoringProcessor.java >+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/constraints/SuperTypeRefactoringProcessor.java >@@ -8,6 +8,7 @@ > * Contributors: > * IBM Corporation - initial API and implementation > * Stephan Herrmann <stephan@cs.tu-berlin.de> - [refactoring] pull-up with "use the destination type where possible" creates bogus import of nested type - https://bugs.eclipse.org/393932 >+ * Samrat Dhillon <samrat.dhillon@gmail.com> - [use supertype] Inserts incorrect type argument when applied on a generic static method - - https://bugs.eclipse.org/397158 > *******************************************************************************/ > package org.eclipse.jdt.internal.corext.refactoring.structure.constraints; > >@@ -53,6 +54,7 @@ > import org.eclipse.jdt.core.JavaCore; > import org.eclipse.jdt.core.JavaModelException; > import org.eclipse.jdt.core.WorkingCopyOwner; >+import org.eclipse.jdt.core.dom.AST; > import org.eclipse.jdt.core.dom.ASTNode; > import org.eclipse.jdt.core.dom.ASTParser; > import org.eclipse.jdt.core.dom.ASTRequestor; >@@ -68,6 +70,7 @@ > import org.eclipse.jdt.core.dom.IVariableBinding; > import org.eclipse.jdt.core.dom.MethodDeclaration; > import org.eclipse.jdt.core.dom.NodeFinder; >+import org.eclipse.jdt.core.dom.ParameterizedType; > import org.eclipse.jdt.core.dom.QualifiedName; > import org.eclipse.jdt.core.dom.SimpleName; > import org.eclipse.jdt.core.dom.SingleVariableDeclaration; >@@ -89,6 +92,7 @@ > import org.eclipse.jdt.internal.corext.codemanipulation.CodeGenerationSettings; > import org.eclipse.jdt.internal.corext.codemanipulation.ContextSensitiveImportRewriteContext; > import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility; >+import org.eclipse.jdt.internal.corext.dom.ASTNodeFactory; > import org.eclipse.jdt.internal.corext.dom.ASTNodes; > import org.eclipse.jdt.internal.corext.refactoring.JDTRefactoringDescriptorComment; > import org.eclipse.jdt.internal.corext.refactoring.RefactoringCoreMessages; >@@ -144,8 +148,22 @@ > */ > protected static ASTNode createCorrespondingNode(final CompilationUnitRewrite rewrite, final TType type, ASTNode node) { > ImportRewrite importRewrite= rewrite.getImportRewrite(); >- ImportRewriteContext context = new ContextSensitiveImportRewriteContext(node, importRewrite); >- return importRewrite.addImportFromSignature(new BindingKey(type.getBindingKey()).toSignature(), rewrite.getAST(), context); >+ ImportRewriteContext context = new ContextSensitiveImportRewriteContext(node, importRewrite); >+ if(type instanceof org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.ParameterizedType && node instanceof ParameterizedType){ >+ AST ast = node.getAST(); >+ Type baseType= ast.newSimpleType(ASTNodeFactory.newName(ast, type.getErasure().getName())); >+ ParameterizedType paramType= ast.newParameterizedType(baseType); >+ >+ ParameterizedType subType = (ParameterizedType) node; >+ List<Type> typeArgs = subType.typeArguments(); >+ for(Type param: typeArgs){ >+ paramType.typeArguments().add(ast.newSimpleType(ast.newSimpleName(param.toString()))); >+ } >+ importRewrite.addImportFromSignature(new BindingKey(type.getErasure().getBindingKey()).toSignature(), rewrite.getAST(), context); >+ return paramType; >+ }else{ >+ return importRewrite.addImportFromSignature(new BindingKey(type.getBindingKey()).toSignature(), rewrite.getAST(), context); >+ } > } > > /** Should type occurrences on instanceof's also be rewritten? */
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 397158
: 238624