当前位置: 首页>>代码示例>>Java>>正文


Java Refactoring.checkInitialConditions方法代码示例

本文整理汇总了Java中org.eclipse.ltk.core.refactoring.Refactoring.checkInitialConditions方法的典型用法代码示例。如果您正苦于以下问题:Java Refactoring.checkInitialConditions方法的具体用法?Java Refactoring.checkInitialConditions怎么用?Java Refactoring.checkInitialConditions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.ltk.core.refactoring.Refactoring的用法示例。


在下文中一共展示了Refactoring.checkInitialConditions方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: helperPass

import org.eclipse.ltk.core.refactoring.Refactoring; //导入方法依赖的package包/类
private void helperPass(ICompilationUnit cu, IMethod[] methods, boolean testCompilation)
		throws JavaModelException, CoreException, Exception, IOException {
	Refactoring refactoring = getRefactoring(methods);

	RefactoringStatus initialStatus = refactoring.checkInitialConditions(new NullProgressMonitor());
	getLogger().info("Initial status: " + initialStatus);

	RefactoringStatus finalStatus = refactoring.checkFinalConditions(new NullProgressMonitor());
	getLogger().info("Final status: " + finalStatus);

	assertTrue("Precondition was supposed to pass.", initialStatus.isOK() && finalStatus.isOK());
	performChange(refactoring, false);

	String outputTestFileName = getOutputTestFileName("A");
	String actual = cu.getSource();

	if (testCompilation)
		assertTrue("Actual output should compile.", compiles(actual));

	if (this.replaceExpectedWithActual)
		setFileContents(outputTestFileName, actual);

	String expected = getFileContents(outputTestFileName);
	assertEqualLines(expected, actual);
}
 
开发者ID:ponder-lab,项目名称:Common-Eclipse-Java-Refactoring-Framework,代码行数:26,代码来源:RefactoringTest.java

示例2: renameVariable

import org.eclipse.ltk.core.refactoring.Refactoring; //导入方法依赖的package包/类
public static void renameVariable(String task, IJavaElement element, String new_name) {
    RefactoringStatus status = new RefactoringStatus();

    RefactoringContribution contrib = RefactoringCore
            .getRefactoringContribution(IJavaRefactorings.RENAME_LOCAL_VARIABLE);
    RenameJavaElementDescriptor rnDesc = (RenameJavaElementDescriptor) contrib.createDescriptor();
    rnDesc.setFlags(JavaRefactoringDescriptor.JAR_MIGRATION | JavaRefactoringDescriptor.JAR_REFACTORING);
    rnDesc.setProject(element.getJavaProject().getProject().getName());
    rnDesc.setUpdateReferences(true);
    rnDesc.setJavaElement(element);
    rnDesc.setNewName(new_name);

    Refactoring ref;
    try {
        ref = rnDesc.createRefactoring(status);
        ref.checkInitialConditions(NULL_MON);
        ref.checkFinalConditions(NULL_MON);

        Change change = ref.createChange(NULL_MON);
        change.perform(NULL_MON);
    } catch (CoreException e) {
        e.printStackTrace();
    }

}
 
开发者ID:Flamefire,项目名称:ImportSmaliVarNames,代码行数:26,代码来源:RefactoringHelper.java

示例3: assertFailedPrecondition

import org.eclipse.ltk.core.refactoring.Refactoring; //导入方法依赖的package包/类
protected void assertFailedPrecondition(IMethod... methods) throws CoreException {
	Refactoring refactoring = getRefactoring(methods);

	RefactoringStatus initialStatus = refactoring.checkInitialConditions(new NullProgressMonitor());
	getLogger().info("Initial status: " + initialStatus);

	RefactoringStatus finalStatus = refactoring.checkFinalConditions(new NullProgressMonitor());
	getLogger().info("Final status: " + finalStatus);

	assertFailedPrecondition(initialStatus, finalStatus);
}
 
开发者ID:ponder-lab,项目名称:Common-Eclipse-Java-Refactoring-Framework,代码行数:12,代码来源:RefactoringTest.java

示例4: helperPassNoFatal

import org.eclipse.ltk.core.refactoring.Refactoring; //导入方法依赖的package包/类
/**
 * Test methods in two classes, namely, A and B, with no fatal errors.
 */
protected void helperPassNoFatal(String[] methodNames1, String[][] signatures1, String[] methodNames2,
		String[][] signatures2) throws Exception {
	ICompilationUnit cu = createCUfromTestFile(getPackageP(), "A");
	IType type = getType(cu, "A");
	Set<IMethod> methodSet = new LinkedHashSet<>();
	Collections.addAll(methodSet, getMethods(type, methodNames1, signatures1));

	type = getType(cu, "B");
	Collections.addAll(methodSet, getMethods(type, methodNames2, signatures2));

	Refactoring refactoring = getRefactoring(methodSet.toArray(new IMethod[methodSet.size()]));

	RefactoringStatus initialStatus = refactoring.checkInitialConditions(new NullProgressMonitor());
	getLogger().info("Initial status: " + initialStatus);

	RefactoringStatus finalStatus = refactoring.checkFinalConditions(new NullProgressMonitor());
	getLogger().info("Final status: " + finalStatus);

	assertTrue("Precondition was supposed to pass.",
			!initialStatus.hasFatalError() && !finalStatus.hasFatalError());
	performChange(refactoring, false);

	String outputTestFileName = getOutputTestFileName("A");
	String actual = cu.getSource();
	assertTrue("Actual output should compile.", compiles(actual));

	if (this.replaceExpectedWithActual)
		setFileContents(outputTestFileName, actual);

	String expected = getFileContents(outputTestFileName);
	assertEqualLines(expected, actual);
}
 
开发者ID:ponder-lab,项目名称:Common-Eclipse-Java-Refactoring-Framework,代码行数:36,代码来源:RefactoringTest.java


注:本文中的org.eclipse.ltk.core.refactoring.Refactoring.checkInitialConditions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。