메소드를 인라인해야 할 때 Refactor->Inine
을 사용할 수 있습니다.
JDT/LTK를 사용하여 프로그래밍 방식으로 인라인 리팩터링을 실행하는 방법은 무엇입니까?
이 내가 노력 코드 골격
// 1. Get ICompiationUnit for type "smcho.Hello"
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject project = root.getProject("Hello");
project.open(null /* IProgressMonitor */);
IJavaProject javaProject = JavaCore.create(project);
IType itype = javaProject.findType("smcho.Hello");
org.eclipse.jdt.core.ICompilationUnit icu = itype.getCompilationUnit();
// 2. Contribution and Description creation
RefactoringContribution contribution = RefactoringCore.getRefactoringContribution(IJavaRefactorings.INLINE_METHOD);
InlineMethodDescriptor descriptor = (InlineMethodDescriptor) contribution.createDescriptor();
descriptor.setProject(icu.getResource().getProject().getName());
// 3. executing the refactoring
RefactoringStatus status = new RefactoringStatus();
try {
Refactoring refactoring = descriptor.createRefactoring(status);
IProgressMonitor monitor = new NullProgressMonitor();
refactoring.checkInitialConditions(monitor);
refactoring.checkFinalConditions(monitor);
Change change = refactoring.createChange(monitor);
change.perform(monitor);
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
, 나는이 오류 나는 내가 API에 리팩토링 방법 이름을 제공 할 필요가 있다고 생각
org.eclipse.core.runtime.CoreException: The refactoring script argument 'input' is missing
in the refactoring script.
을 얻었다. 코드에서 무엇이 잘못 되었을까요?
- 당신은 인라인 될 것입니다 메소드의 이름을 알게되면
, 당신의 코드를 사용할 수 있습니다. – prosseek