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 397158
Collapse All | Expand All

(-)a/org.eclipse.jdt.ui.tests.refactoring/resources/UseSupertypeWherePossible/testNew40/in/A.java (+10 lines)
Added Link Here
1
package p;
2
interface I<T> {
3
}
4
class A<E> implements I<E> {
5
}
6
class C11 {
7
    static <T> A<T> m() {
8
        return null;
9
    }
10
}
(-)a/org.eclipse.jdt.ui.tests.refactoring/resources/UseSupertypeWherePossible/testNew40/out/A.java (+10 lines)
Added Link Here
1
package p;
2
interface I<T> {
3
}
4
class A<E> implements I<E> {
5
}
6
class C11 {
7
    static <T> I<T> m() {
8
        return null;
9
    }
10
}
(-)a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/UseSupertypeWherePossibleTests.java (-1 / +6 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Samrat Dhillon <samrat.dhillon@gmail.com> - [use supertype] Inserts incorrect type argument when applied on a generic static method - https://bugs.eclipse.org/397158
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.ui.tests.refactoring;
12
package org.eclipse.jdt.ui.tests.refactoring;
12
13
Lines 272-277 Link Here
272
		//		printTestDisabledMessage("bug 169608");
273
		//		printTestDisabledMessage("bug 169608");
273
		validatePassingTest("C", new String[]{"C"}, "p.B");
274
		validatePassingTest("C", new String[]{"C"}, "p.B");
274
	}
275
	}
276
	
277
	public void testNew40() throws Exception{
278
		validatePassingTest("A", new String[]{"A"}, "p.I", true);
279
	}
275
280
276
	/* i had to rename tests 0-15 because of cvs problems*/
281
	/* i had to rename tests 0-15 because of cvs problems*/
277
282
(-)a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/constraints/SuperTypeRefactoringProcessor.java (-2 / +20 lines)
Lines 8-13 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     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
10
 *     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
11
 *     Samrat Dhillon <samrat.dhillon@gmail.com> -  [use supertype] Inserts incorrect type argument when applied on a generic static method - - https://bugs.eclipse.org/397158
11
 *******************************************************************************/
12
 *******************************************************************************/
12
package org.eclipse.jdt.internal.corext.refactoring.structure.constraints;
13
package org.eclipse.jdt.internal.corext.refactoring.structure.constraints;
13
14
Lines 53-58 Link Here
53
import org.eclipse.jdt.core.JavaCore;
54
import org.eclipse.jdt.core.JavaCore;
54
import org.eclipse.jdt.core.JavaModelException;
55
import org.eclipse.jdt.core.JavaModelException;
55
import org.eclipse.jdt.core.WorkingCopyOwner;
56
import org.eclipse.jdt.core.WorkingCopyOwner;
57
import org.eclipse.jdt.core.dom.AST;
56
import org.eclipse.jdt.core.dom.ASTNode;
58
import org.eclipse.jdt.core.dom.ASTNode;
57
import org.eclipse.jdt.core.dom.ASTParser;
59
import org.eclipse.jdt.core.dom.ASTParser;
58
import org.eclipse.jdt.core.dom.ASTRequestor;
60
import org.eclipse.jdt.core.dom.ASTRequestor;
Lines 68-73 Link Here
68
import org.eclipse.jdt.core.dom.IVariableBinding;
70
import org.eclipse.jdt.core.dom.IVariableBinding;
69
import org.eclipse.jdt.core.dom.MethodDeclaration;
71
import org.eclipse.jdt.core.dom.MethodDeclaration;
70
import org.eclipse.jdt.core.dom.NodeFinder;
72
import org.eclipse.jdt.core.dom.NodeFinder;
73
import org.eclipse.jdt.core.dom.ParameterizedType;
71
import org.eclipse.jdt.core.dom.QualifiedName;
74
import org.eclipse.jdt.core.dom.QualifiedName;
72
import org.eclipse.jdt.core.dom.SimpleName;
75
import org.eclipse.jdt.core.dom.SimpleName;
73
import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
76
import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
Lines 89-94 Link Here
89
import org.eclipse.jdt.internal.corext.codemanipulation.CodeGenerationSettings;
92
import org.eclipse.jdt.internal.corext.codemanipulation.CodeGenerationSettings;
90
import org.eclipse.jdt.internal.corext.codemanipulation.ContextSensitiveImportRewriteContext;
93
import org.eclipse.jdt.internal.corext.codemanipulation.ContextSensitiveImportRewriteContext;
91
import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility;
94
import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility;
95
import org.eclipse.jdt.internal.corext.dom.ASTNodeFactory;
92
import org.eclipse.jdt.internal.corext.dom.ASTNodes;
96
import org.eclipse.jdt.internal.corext.dom.ASTNodes;
93
import org.eclipse.jdt.internal.corext.refactoring.JDTRefactoringDescriptorComment;
97
import org.eclipse.jdt.internal.corext.refactoring.JDTRefactoringDescriptorComment;
94
import org.eclipse.jdt.internal.corext.refactoring.RefactoringCoreMessages;
98
import org.eclipse.jdt.internal.corext.refactoring.RefactoringCoreMessages;
Lines 144-151 Link Here
144
	 */
148
	 */
145
	protected static ASTNode createCorrespondingNode(final CompilationUnitRewrite rewrite, final TType type, ASTNode node) {
149
	protected static ASTNode createCorrespondingNode(final CompilationUnitRewrite rewrite, final TType type, ASTNode node) {
146
		ImportRewrite importRewrite= rewrite.getImportRewrite();
150
		ImportRewrite importRewrite= rewrite.getImportRewrite();
147
		ImportRewriteContext context = new ContextSensitiveImportRewriteContext(node, importRewrite);
151
		ImportRewriteContext context = new ContextSensitiveImportRewriteContext(node, importRewrite);		
148
		return importRewrite.addImportFromSignature(new BindingKey(type.getBindingKey()).toSignature(), rewrite.getAST(), context);
152
		if(type instanceof org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.ParameterizedType && node instanceof ParameterizedType){
153
			AST ast = node.getAST();
154
			Type baseType= ast.newSimpleType(ASTNodeFactory.newName(ast, type.getErasure().getName()));
155
			ParameterizedType paramType= ast.newParameterizedType(baseType);
156
			
157
			ParameterizedType subType = (ParameterizedType) node;
158
			List<Type> typeArgs = subType.typeArguments();
159
			for(Type param: typeArgs){
160
				paramType.typeArguments().add(ast.newSimpleType(ast.newSimpleName(param.toString())));
161
			}
162
			importRewrite.addImportFromSignature(new BindingKey(type.getErasure().getBindingKey()).toSignature(), rewrite.getAST(), context);
163
			return paramType;
164
		}else{
165
			return importRewrite.addImportFromSignature(new BindingKey(type.getBindingKey()).toSignature(), rewrite.getAST(), context);
166
		}
149
	}
167
	}
150
168
151
	/** Should type occurrences on instanceof's also be rewritten? */
169
	/** Should type occurrences on instanceof's also be rewritten? */

Return to bug 397158