[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools.jdt] Inline Refactoring - checkOverridden

In the class

	org.eclipse.jdt.internal.corext.refactoring.code.InlineMethodRefactoring

there is a method

private void checkOverridden(RefactoringStatus status, IProgressMonitor pm) throws JavaModelException {

where there is a check	

checkSuperClasses(status, method, hierarchy.getAllSuperclasses(type), new SubProgressMonitor(pm, 1));

and I was wondering if anyone could tell me why this check is here?


The reason that I am asking is that I have the following code:

	1.	public class TestClass {
	2.		public static void main(String[] args) {
	3.			SubClass subClass = new SubClass();		
	4.			subClass.method();		
	5.		}
	6.	}
	7.
	8.	class SubClass extends BaseClass {
	9.		public void method() {
	10.			newMethod();
	11.		}
	12.	}
	13.
	14.	abstract class BaseClass {
	15.		public abstract void method();
	16.
	17.		public void newMethod() {
	18.			System.out.println("BaseClass::newMethod()");
	19.		}
	20.	}

where I wish to "Inline" the call on line (4.)

	subClass.method();
	
in order to produce the result

	subClass.newMethod();
	
but the check

checkSuperClasses(status, method, hierarchy.getAllSuperclasses(type), new SubProgressMonitor(pm, 1));

prevents this refactoring from occurring.



Does anyone know the reason the "Inline" refactoring is not allowed in these circumstances?


I'm guessing that there are some case where carrying out this refactoring would be "dangerous"? But I can't see how it would be in my particular case.


Any help greatly appreciated,

Thanks,

Máirtín


----- (Code without line numbers)

public class CustomerClass {
	public static void main(String[] args) {
		SubClass subClass = new SubClass();		
		subClass.method();		
	}
}

class SubClass extends BaseClass {
	public void method() {
		newMethod();
	}
}

abstract class BaseClass {
	public abstract void method();

	public void newMethod() {
		System.out.println("BaseClass::newMethod()");
	}
}