Young87

当前位置:首页 >个人收藏

java中move用法_Java IFile.move方法代碼示例

import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類

/**

*

* 01. Class0 uses Class1 in require statement and in isa function

* 02. Class1 file is renamed

* 05. Class0 should get error marker at require statement and at isa function

* 06. Class1 is renamed back

* 07. Class0 should have no error markers

*/

//@formatter:on

@Test

public void testSuperClassRenamed() throws Exception {

logger.info("BuilderParticipantPluginUITest.testSuperClassRenamed");

// create project and test files

final IProject project = createJSProject("testSuperClassRenamed");

IFolder folder = configureProjectWithXtext(project);

IFolder moduleFolder = createFolder(folder, InheritanceTestFiles.inheritanceModule());

IFile parentFile = createTestFile(moduleFolder, "Parent", InheritanceTestFiles.Parent());

assertMarkers("Parent file should have no errors", parentFile, 0);

IFile childFile = createTestFile(moduleFolder, "Child", InheritanceTestFiles.Child());

assertMarkers("Child file should have no errors", childFile, 0);

// open editors of test files

IWorkbenchPage page = getActivePage();

XtextEditor parentFileXtextEditor = openAndGetXtextEditor(parentFile, page);

List> errors = getEditorErrors(parentFileXtextEditor);

assertEquals("Editor of parent should have no errors", 0, errors.size());

XtextEditor childFileXtextEditor = openAndGetXtextEditor(childFile, page);

errors = getEditorErrors(childFileXtextEditor);

assertEquals("Editor of child should have no errors", 0, errors.size());

parentFileXtextEditor.close(true);

parentFile.move(new Path("Parent2" + F_EXT), true, true, monitor());

moduleFolder.refreshLocal(IResource.DEPTH_INFINITE, monitor());

waitForAutoBuild();

waitForUpdateEditorJob();

assertFalse("Parent.n4js doesn't exist anymore", moduleFolder.getFile(new Path("Parent" + F_EXT)).exists());

IFile movedParentFile = moduleFolder.getFile("Parent2" + F_EXT);

assertTrue("Parent2.n4js does exist", movedParentFile.exists());

errors = getEditorErrors(childFileXtextEditor);

assertEquals("Editor of child should have got error markers", 3, errors.size());

movedParentFile.move(new Path("Parent" + F_EXT), true, true, monitor());

moduleFolder.refreshLocal(IResource.DEPTH_INFINITE, monitor());

waitForAutoBuild();

waitForUpdateEditorJob();

assertTrue("Parent.n4js does exist", moduleFolder.getFile(new Path("Parent" + F_EXT)).exists());

errors = getEditorErrors(childFileXtextEditor);

assertEquals("Editor of child should have no errors", 0, errors.size());

}

除特别声明,本站所有文章均为原创,如需转载请以超级链接形式注明出处:SmartCat's Blog

上一篇: 如何用 Python 实现 QQ 消息自动回复?

下一篇: python打包exe——pyinstaller遇到的那些坑及解决办法

精华推荐