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

(-)resources/MoveInstanceMethod/canMove/test66/in/A.java (+8 lines)
Added Link Here
1
public class A {
2
	public void foo(java.io.FileNotFoundException arg, B b)
3
			throws java.io.EOFException {
4
	}
5
}
6
7
class B {
8
}
(-)resources/MoveInstanceMethod/canMove/test66/out/A.java (+11 lines)
Added Link Here
1
import java.io.FileNotFoundException;
2
3
public class A {
4
}
5
6
class B {
7
8
	public void foo(FileNotFoundException arg)
9
			throws java.io.EOFException {
10
	}
11
}
(-)test cases/org/eclipse/jdt/ui/tests/refactoring/MoveInstanceMethodTests.java (-1 / +6 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2013 IBM Corporation and others.
2
 * Copyright (c) 2000, 2014 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 563-568 Link Here
563
	public void test65() throws Exception {
563
	public void test65() throws Exception {
564
		helper1(new String[] { "A" }, "A", 3, 17, 3, 18, PARAMETER, "c", false, false);
564
		helper1(new String[] { "A" }, "A", 3, 17, 3, 18, PARAMETER, "c", false, false);
565
	}
565
	}
566
	
567
	// bug 428704
568
	public void test66() throws Exception {
569
		helper1(new String[] { "p1.A"}, "p1.A", 2, 18, 2, 18, PARAMETER, "b", true, true);
570
	}
566
571
567
	// Move mA1 to field fB, do not inline delegator
572
	// Move mA1 to field fB, do not inline delegator
568
	public void test3() throws Exception {
573
	public void test3() throws Exception {
(-)core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/MoveInstanceMethodProcessor.java (-33 / +34 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2013 IBM Corporation and others.
2
 * Copyright (c) 2000, 2014 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 2263-2269 Link Here
2263
	 * @throws CoreException
2263
	 * @throws CoreException
2264
	 *             if an error occurs
2264
	 *             if an error occurs
2265
	 */
2265
	 */
2266
	protected void createMethodCopy(IDocument document, MethodDeclaration declaration, ASTRewrite rewrite, Map<ICompilationUnit, CompilationUnitRewrite> rewrites, Map<IMember, IncomingMemberVisibilityAdjustment> adjustments, RefactoringStatus status, IProgressMonitor monitor) throws CoreException {
2266
	protected void createMethodCopy(IDocument document, MethodDeclaration declaration, ASTRewrite rewrite, Map<ICompilationUnit, CompilationUnitRewrite> rewrites,
2267
			Map<IMember, IncomingMemberVisibilityAdjustment> adjustments, RefactoringStatus status, IProgressMonitor monitor) throws CoreException {
2267
		Assert.isNotNull(document);
2268
		Assert.isNotNull(document);
2268
		Assert.isNotNull(declaration);
2269
		Assert.isNotNull(declaration);
2269
		Assert.isNotNull(rewrite);
2270
		Assert.isNotNull(rewrite);
Lines 2272-2310 Link Here
2272
		Assert.isNotNull(status);
2273
		Assert.isNotNull(status);
2273
		Assert.isNotNull(monitor);
2274
		Assert.isNotNull(monitor);
2274
		final CompilationUnitRewrite rewriter= getCompilationUnitRewrite(rewrites, getTargetType().getCompilationUnit());
2275
		final CompilationUnitRewrite rewriter= getCompilationUnitRewrite(rewrites, getTargetType().getCompilationUnit());
2275
		try {
2276
		rewrite.set(declaration, MethodDeclaration.NAME_PROPERTY, rewrite.getAST().newSimpleName(fMethodName), null);
2276
			rewrite.set(declaration, MethodDeclaration.NAME_PROPERTY, rewrite.getAST().newSimpleName(fMethodName), null);
2277
		boolean same= false;
2277
			boolean same= false;
2278
		final IMethodBinding binding= declaration.resolveBinding();
2278
			final IMethodBinding binding= declaration.resolveBinding();
2279
		if (binding != null) {
2279
			if (binding != null) {
2280
			final ITypeBinding declaring= binding.getDeclaringClass();
2280
				final ITypeBinding declaring= binding.getDeclaringClass();
2281
			if (declaring != null && Bindings.equals(declaring.getPackage(), fTarget.getType().getPackage()))
2281
				if (declaring != null && Bindings.equals(declaring.getPackage(), fTarget.getType().getPackage()))
2282
				same= true;
2282
					same= true;
2283
			final Modifier.ModifierKeyword keyword= same ? null : Modifier.ModifierKeyword.PUBLIC_KEYWORD;
2283
				final Modifier.ModifierKeyword keyword= same ? null : Modifier.ModifierKeyword.PUBLIC_KEYWORD;
2284
			if (MemberVisibilityAdjustor.hasLowerVisibility(binding.getModifiers(), same ? Modifier.NONE : keyword == null ? Modifier.NONE : keyword.toFlagValue())
2284
				if (MemberVisibilityAdjustor.hasLowerVisibility(binding.getModifiers(), same ? Modifier.NONE : keyword == null ? Modifier.NONE : keyword.toFlagValue()) && MemberVisibilityAdjustor.needsVisibilityAdjustments(fMethod, keyword, adjustments)) {
2285
					&& MemberVisibilityAdjustor.needsVisibilityAdjustments(fMethod, keyword, adjustments)) {
2285
					final MemberVisibilityAdjustor.IncomingMemberVisibilityAdjustment adjustment= new MemberVisibilityAdjustor.IncomingMemberVisibilityAdjustment(fMethod, keyword, RefactoringStatus.createStatus(RefactoringStatus.WARNING, Messages.format(RefactoringCoreMessages.MemberVisibilityAdjustor_change_visibility_method_warning, new String[] { MemberVisibilityAdjustor.getLabel(fMethod), MemberVisibilityAdjustor.getLabel(keyword) }), JavaStatusContext.create(fMethod), null, RefactoringStatusEntry.NO_CODE, null));
2286
				final MemberVisibilityAdjustor.IncomingMemberVisibilityAdjustment adjustment= new MemberVisibilityAdjustor.IncomingMemberVisibilityAdjustment(fMethod, keyword,
2286
					ModifierRewrite.create(rewrite, declaration).setVisibility(keyword == null ? Modifier.NONE : keyword.toFlagValue(), null);
2287
						RefactoringStatus.createStatus(
2287
					adjustment.setNeedsRewriting(false);
2288
								RefactoringStatus.WARNING,
2288
					adjustments.put(fMethod, adjustment);
2289
								Messages.format(RefactoringCoreMessages.MemberVisibilityAdjustor_change_visibility_method_warning, new String[] { MemberVisibilityAdjustor.getLabel(fMethod),
2289
				}
2290
										MemberVisibilityAdjustor.getLabel(keyword) }), JavaStatusContext.create(fMethod), null, RefactoringStatusEntry.NO_CODE, null));
2291
				ModifierRewrite.create(rewrite, declaration).setVisibility(keyword == null ? Modifier.NONE : keyword.toFlagValue(), null);
2292
				adjustment.setNeedsRewriting(false);
2293
				adjustments.put(fMethod, adjustment);
2290
			}
2294
			}
2291
			for (IExtendedModifier modifier : (List<IExtendedModifier>) declaration.modifiers()) {
2292
				if (modifier.isAnnotation()) {
2293
					Annotation annotation= (Annotation) modifier;
2294
					ITypeBinding typeBinding= annotation.resolveTypeBinding();
2295
					if (typeBinding != null && typeBinding.getQualifiedName().equals("java.lang.Override")) { //$NON-NLS-1$
2296
						rewrite.remove(annotation, null);
2297
					}
2298
				}
2299
			}
2300
			createMethodArguments(rewrites, rewrite, declaration, adjustments, status);
2301
			createMethodTypeParameters(rewrite, declaration, status);
2302
			createMethodComment(rewrite, declaration);
2303
			createMethodBody(rewriter, rewrite, declaration);
2304
		} finally {
2305
			if (fMethod.getCompilationUnit().equals(getTargetType().getCompilationUnit()))
2306
				rewriter.clearImportRewrites();
2307
		}
2295
		}
2296
		for (IExtendedModifier modifier : (List<IExtendedModifier>) declaration.modifiers()) {
2297
			if (modifier.isAnnotation()) {
2298
				Annotation annotation= (Annotation) modifier;
2299
				ITypeBinding typeBinding= annotation.resolveTypeBinding();
2300
				if (typeBinding != null && typeBinding.getQualifiedName().equals("java.lang.Override")) { //$NON-NLS-1$
2301
					rewrite.remove(annotation, null);
2302
				}
2303
			}
2304
		}
2305
		createMethodArguments(rewrites, rewrite, declaration, adjustments, status);
2306
		createMethodTypeParameters(rewrite, declaration, status);
2307
		createMethodComment(rewrite, declaration);
2308
		createMethodBody(rewriter, rewrite, declaration);
2308
	}
2309
	}
2309
2310
2310
	/**
2311
	/**

Return to bug 428704