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());

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值