Java Code Examples for org.eclipse.core.resources.IFile#delete()

The following examples show how to use org.eclipse.core.resources.IFile#delete() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * handle the resources.
 * 
 * @param resource
 * @exception CoreException
 */
public boolean visit( IResource resource ) throws CoreException
{
	if ( resource instanceof IFile )
	{
		IFile file = (IFile) resource;
		if ( file == null || files == null )
			return true;

		Iterator<String> it = files.iterator( );
		while ( it.hasNext( ) )
		{
			String name = it.next( );
			if ( name != null && file.getName( ).startsWith( name ) )
			{
				file.delete( true, monitor );
				break;
			}
		}
	}
	return true;
}
 
Example 2
@Test
public void testPublishWar_childModulePublished() throws CoreException {
  IFile war = project.getFile("my-app.war");
  IFolder unzipped = project.getFolder("unzipped");
  IFolder tempDirectory = project.getFolder("temp");
  try {
    WarPublisher.publishWar(project, war.getLocation(), tempDirectory.getLocation(), monitor);

    ZipUtil.unzip(war.getLocation().toFile(), unzipped.getLocation().toFile(), monitor);
    unzipped.refreshLocal(IResource.DEPTH_INFINITE, monitor);
    for (String childModule : getExpectedChildModuleNames()) {
      assertTrue(unzipped.getFile("WEB-INF/lib/" + childModule).exists());
    }
  } finally {
    war.delete(true, monitor);
    unzipped.delete(true, monitor);
    tempDirectory.delete(true, monitor);
  }
}
 
Example 3
private void importIcons(final File tmpDir) {
    final File[] files = tmpDir.listFiles(imageFileFilter);
    if (files != null) {
        final IRepositoryStore defStore = getDefinitionStore();
        for (final File iconFile : files) {
            final IFolder folder = defStore.getResource();
            final IFile file = folder.getFile(iconFile.getName());
            try {
                if (file.exists() && FileActionDialog.confirmDeletionQuestion(iconFile.getName())) {
                    file.delete(true, Repository.NULL_PROGRESS_MONITOR);
                }
                file.create(new FileInputStream(iconFile), true, Repository.NULL_PROGRESS_MONITOR);
            } catch (final Exception e) {
                BonitaStudioLog.error(e);
            }
        }
    }
}
 
Example 4
@Test
public void testDefaultConfiguration() throws Exception {
	IJavaProject project = createJavaProject("foo");
	addNature(project.getProject(), XtextProjectHelper.NATURE_ID);
	IFolder folder = project.getProject().getFolder("src");
	IFile file = folder.getFile("Foo" + F_EXT);
	file.create(new StringInputStream("object Foo"), true, monitor());
	build();
	IFile generatedFile = project.getProject().getFile("./src-gen/Foo.txt");
	assertTrue(generatedFile.exists());
	assertTrue(generatedFile.isDerived());
	assertTrue(generatedFile.findMarkers(DerivedResourceMarkers.MARKER_ID, false, IResource.DEPTH_ZERO).length == 1);
	assertEquals("object Foo", readFile(generatedFile).trim());
	file.setContents(new StringInputStream("object Bar"), true, true, monitor());
	build();
	assertFalse(generatedFile.exists());
	generatedFile = project.getProject().getFile("./src-gen/Bar.txt");
	assertTrue(generatedFile.exists());
	assertTrue(generatedFile.isDerived());
	assertTrue(generatedFile.findMarkers(DerivedResourceMarkers.MARKER_ID, false, IResource.DEPTH_ZERO).length == 1);
	assertEquals("object Bar", readFile(generatedFile).trim());
	file.delete(true, monitor());
	build();
	assertFalse(generatedFile.exists());
}
 
Example 5
@Test public void testDeleteFile() throws Exception {
	IJavaProject project = createJavaProject("foo");
	addNature(project.getProject(), XtextProjectHelper.NATURE_ID);
	IFolder folder = project.getProject().getFolder("src");
	IFile file = folder.getFile("Foo" + F_EXT);
	file.create(new StringInputStream("object Foo"), true, monitor());
	build();
	assertTrue(indexContainsElement(file.getFullPath().toString(), "Foo"));
	assertEquals(1, countResourcesInIndex());

	getBuilderState().addListener(this);
	file.delete(true, monitor());
	build();
	assertEquals(1, getEvents().get(0).getDeltas().size());
	assertNull(getEvents().get(0).getDeltas().get(0).getNew());
	assertEquals(0, countResourcesInIndex());
}
 
Example 6
public static IFile copyFileToWorkspace(Plugin srcPlugin,
		String srcFilePath, IFile destFile) throws IOException,
		CoreException {
	Bundle bundle = srcPlugin.getBundle();
	URL bundleUrl = bundle.getResource(srcFilePath);
	URL fileUrl = FileLocator.toFileURL(bundleUrl);
	InputStream openStream = new BufferedInputStream(fileUrl.openStream());
	if (destFile.exists()) {
		destFile.delete(true, null);
	}
	destFile.create(openStream, true, null);
	return destFile;
}
 
Example 7
@Test
public void testRemoveGpeRuntimeAndFacets_metadataFileDoesNotExist() throws CoreException {
  IFile metadataFile =
      gpeProject.getFile(".settings/org.eclipse.wst.common.project.facet.core.xml");
  metadataFile.delete(true, monitor);
  assertFalse(metadataFile.exists());

  IFacetedProject facetedProject = ProjectFacetsManager.create(gpeProject);
  assertFalse(GpeMigrator.removeGpeRuntimeAndFacets(facetedProject));
}
 
Example 8
private void createProjectImpl(ProjectResource projRoot, IProject newProject){
	try {
		for(Object obj : selectContentProvider.getChildren(projRoot)){
			if (obj instanceof ProjectResource) {
				ProjectResource proResource = (ProjectResource) obj;
				// 如果没有选中,那么不进行导入操作
				if (!selectElementTree.getChecked(proResource)) {
					continue;
				}
				
				if (proResource.isFolder()) {
					// 如果是文件夹,则创建
					IFolder childFolder = newProject.getFolder(proResource.getLabel());
					if (!childFolder.exists()) {
						childFolder.create(true, true, null);
					}
					createCurProjectResource(proResource, childFolder);
				}else {
					// 如果是文件,则判断是否需要覆盖,若是,则直接覆盖
					if (proResource.isNeedCover()) {
						IFile iFile = newProject.getFile(proResource.getLabel());
						InputStream inputStream = proResource.getInputStream();
						if (inputStream != null) {
							if (iFile.exists()) {
								closeOpenedFile(iFile);
								iFile.delete(true, null);
							}
							iFile.create(inputStream, true, null);
						}
					}
				}
			}
		}
	} catch (Exception e) {
		e.printStackTrace();
		disposeImg();
		LOGGER.error(Messages.getString("importProjectWizardPage.LOGG.importEroor"), e);
	}
	
}
 
Example 9
/**
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=400193
 */
@Test
public void testSourceRelativeOutput() throws Exception {
	IProject project = testHelper.getProject();
	String srcFolder = "/foo/bar/bug";
	JavaProjectSetupUtil.addSourceFolder(JavaCore.create(project), srcFolder);

	String path = srcFolder + "/Foo.xtend";
	String fullFileName = project.getName() + path;
	IFile sourceFile = testHelper.createFileImpl(fullFileName, "class Foo {}");
	assertTrue(sourceFile.exists());
	waitForBuild();

	IFile generatedFile = project.getFile("foo/bar/xtend-gen/Foo.java");
	assertTrue(generatedFile.exists());
	IFile traceFile = testHelper.getProject().getFile("foo/bar/xtend-gen/.Foo.java._trace");
	assertTrue(traceFile.exists());
	IFile classFile = testHelper.getProject().getFile("/bin/Foo.class");
	assertTrue(classFile.exists());
	
	List<IPath> traceFiles = traceMarkers.findTraceFiles(sourceFile);
	assertTrue(traceFiles.contains(traceFile.getFullPath()));


	sourceFile.delete(false, new NullProgressMonitor());
	waitForBuild();
	assertFalse(generatedFile.exists());
	assertFalse(traceFile.exists());
}
 
Example 10
@Override
public void deleteFile(String fileName) {
	try {
		IFile file = root.getFile(new Path(fileName));
		file.delete(true, new NullProgressMonitor());
	} catch (CoreException e) {
		throw new RuntimeException(e);
	}
}
 
Example 11
protected void testDeleteDeletedDerivedResource(IContainer output) {
	try {
		File outputDirectory = output.getLocation().toFile();
		int expectedSize = 0;
		if (outputDirectory.exists()) {
			expectedSize = outputDirectory.list().length;
		}
		IFile sourceFile = createFile(project.getFile(("src/Foo" + F_EXT)).getFullPath(), "object Foo");
		build();
		Assert.assertNotEquals(expectedSize, outputDirectory.list().length);
		IFile file = output.getFile(new Path("Foo.txt"));
		file.refreshLocal(0, null);
		Assert.assertTrue(isSynchronized(file));
		new WorkspaceJob("file.delete") {
			@Override
			public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
				Assert.assertTrue(file.getLocation().toFile().delete());
				Assert.assertFalse(isSynchronized(file));
				return Status.OK_STATUS;
			}
		}.run(monitor());
		sourceFile.delete(false, monitor());
		build();
		Assert.assertEquals(expectedSize, outputDirectory.list().length);
	} catch (CoreException e) {
		throw Exceptions.sneakyThrow(e);
	}
}
 
Example 12
/**
 * Moves a file to the output directory with a new name.
 * 
 * @param project the current project
 * @param sourceFile output file to be moved
 * @param destDir the destination directory of the file
 * @param destName the new name of the file
 * @param monitor progress monitor
 * @throws CoreException if an error occurs
 * @return file in the new location
 */
private static IFile moveFile(IProject project, IFile sourceFile,
		IContainer destContainer, String destName,
		IProgressMonitor monitor) throws CoreException {
	if (sourceFile != null && sourceFile.exists() && destName != null) {
	    final IPath destRelPath = new Path(destName);
        final IFile dest = destContainer.getFile(destRelPath);

        if (dest.exists()) {
            File outFile = new File(sourceFile.getLocationURI());
            File destFile = new File(dest.getLocationURI());
            try {
                // Try to move the content instead of deleting the old file
                // and replace it by the new one. This is better for some
                // viewers like Sumatrapdf
                FileOutputStream out = new FileOutputStream(destFile);
                out.getChannel().tryLock();
                BufferedInputStream in = new BufferedInputStream(new FileInputStream(outFile));

                byte[] buf = new byte[4096];
                int l;
                while ((l = in.read(buf)) != -1) {
                    out.write(buf, 0, l);
                }
                in.close();
                out.close();
                sourceFile.delete(true, monitor);
            } catch (IOException e) {
                // try to delete and move the file
                dest.delete(true, monitor);
                sourceFile.move(dest.getFullPath(), true, monitor);
            }
        }
        else {
            // move the file
            sourceFile.move(dest.getFullPath(), true, monitor);
        }
        monitor.worked(1);
        return dest;
    }
	else {
	    return null;
	}
}
 
Example 13
@Override
public void process ( final String phase, final IFolder baseDir, final IProgressMonitor monitor, final Map<String, String> properties ) throws Exception
{
    if ( phase != null && !"process".equals ( phase ) )
    {
        return;
    }

    final String name = makeName ();

    final IFolder output = baseDir.getFolder ( new Path ( name ) );
    output.create ( true, true, null );

    final IFile exporterFile = output.getFile ( "exporter.xml" ); //$NON-NLS-1$
    final IFile propFile = output.getFile ( "application.properties" ); //$NON-NLS-1$

    final DocumentRoot root = ExporterFactory.eINSTANCE.createDocumentRoot ();

    final ConfigurationType cfg = ExporterFactory.eINSTANCE.createConfigurationType ();
    root.setConfiguration ( cfg );

    final HiveType hive = ExporterFactory.eINSTANCE.createHiveType ();
    cfg.getHive ().add ( hive );
    hive.setRef ( getHiveId () );

    final HiveConfigurationType hiveCfg = ExporterFactory.eINSTANCE.createHiveConfigurationType ();
    hive.setConfiguration ( hiveCfg );

    addConfiguration ( hiveCfg );

    for ( final Endpoint ep : this.driver.getEndpoints () )
    {
        addEndpoint ( hive, ep );
    }

    // write exporter file
    new ModelWriter ( root ).store ( URI.createPlatformResourceURI ( exporterFile.getFullPath ().toString (), true ) );
    exporterFile.refreshLocal ( 1, monitor );

    // write application properties
    if ( propFile.exists () )
    {
        propFile.delete ( true, monitor );
    }
    final Properties p = new Properties ();
    fillProperties ( p );
    if ( !p.isEmpty () )
    {
        try (FileOutputStream fos = new FileOutputStream ( propFile.getRawLocation ().toOSString () ))
        {
            p.store ( fos, "Created by the Eclipse SCADA world generator" );
        }
        propFile.refreshLocal ( 1, monitor );
    }
}
 
Example 14
@Test
public void renameUsedType_4() {
  try {
    try {
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("package foo;");
      _builder.newLine();
      _builder.newLine();
      _builder.append("public class Foo {");
      _builder.newLine();
      _builder.newLine();
      _builder.append("\t");
      _builder.append("public static void foo(int i) {}");
      _builder.newLine();
      _builder.newLine();
      _builder.append("}");
      _builder.newLine();
      this.testHelper.createFile("foo/Foo.java", _builder.toString());
      StringConcatenation _builder_1 = new StringConcatenation();
      _builder_1.append("package bar");
      _builder_1.newLine();
      _builder_1.newLine();
      _builder_1.append("import static extension foo.Foo.foo");
      _builder_1.newLine();
      _builder_1.newLine();
      _builder_1.append("class Bar {");
      _builder_1.newLine();
      _builder_1.newLine();
      _builder_1.append("\t");
      _builder_1.append("def bar() {");
      _builder_1.newLine();
      _builder_1.append("\t\t");
      _builder_1.append("1.foo");
      _builder_1.newLine();
      _builder_1.append("\t");
      _builder_1.append("}");
      _builder_1.newLine();
      _builder_1.newLine();
      _builder_1.append("}");
      _builder_1.newLine();
      final IFile xtendFile = this.testHelper.createFile("bar/Bar.xtend", _builder_1.toString());
      this.renameJavaElement(this.findJavaType("foo.Foo"), "NewFoo");
      StringConcatenation _builder_2 = new StringConcatenation();
      _builder_2.append("package bar");
      _builder_2.newLine();
      _builder_2.newLine();
      _builder_2.append("import static extension foo.NewFoo.foo");
      _builder_2.newLine();
      _builder_2.newLine();
      _builder_2.append("class Bar {");
      _builder_2.newLine();
      _builder_2.newLine();
      _builder_2.append("\t");
      _builder_2.append("def bar() {");
      _builder_2.newLine();
      _builder_2.append("\t\t");
      _builder_2.append("1.foo");
      _builder_2.newLine();
      _builder_2.append("\t");
      _builder_2.append("}");
      _builder_2.newLine();
      _builder_2.newLine();
      _builder_2.append("}");
      _builder_2.newLine();
      this.fileAsserts.assertFileContains(xtendFile, _builder_2.toString());
    } finally {
      IFile _file = this.testHelper.getProject().getFile("src/foo/NewFoo.java");
      NullProgressMonitor _nullProgressMonitor = new NullProgressMonitor();
      _file.delete(true, _nullProgressMonitor);
    }
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 15
/**
 * @throws CoreException
 *             if something unexpected happens during resource access
 * @throws IOException
 *             if serialization of the trace data fails
 * @since 2.3
 */
protected void updateTraceInformation(IFile traceFile, CharSequence contents, boolean derived)
		throws CoreException, IOException {
	if (contents instanceof ITraceRegionProvider) {
		try {
			AbstractTraceRegion traceRegion = ((ITraceRegionProvider) contents).getTraceRegion();
			if (sourceTraces == null) {
				sourceTraces = HashMultimap.create();
			}
			IPath tracePath = traceFile.getFullPath();
			Iterator<AbstractTraceRegion> iterator = traceRegion.treeIterator();
			while (iterator.hasNext()) {
				AbstractTraceRegion region = iterator.next();
				for (ILocationData location : region.getAssociatedLocations()) {
					SourceRelativeURI path = location.getSrcRelativePath();
					if (path != null) {
						sourceTraces.put(path, tracePath);
					}
				}
			}
			class AccessibleOutputStream extends ByteArrayOutputStream {
				byte[] internalBuffer() {
					return buf;
				}

				int internalLength() {
					return count;
				}
			}
			AccessibleOutputStream data = new AccessibleOutputStream();
			traceSerializer.writeTraceRegionTo(traceRegion, data);
			// avoid copying the byte array
			InputStream input = new ByteArrayInputStream(data.internalBuffer(), 0, data.internalLength());
			if (traceFile.exists()) {
				traceFile.setContents(input, true, false, monitor);
			} else {
				traceFile.create(input, true, monitor);
			}
			setDerived(traceFile, derived);
			return;
		} catch (TraceNotFoundException e) {
			// ok
		}
	}
	if (traceFile.exists()) {
		traceFile.delete(IResource.FORCE, monitor);
	}
}
 
Example 16
@Ignore
@Test
public void renameUsedType_2() {
  try {
    try {
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("package foo;");
      _builder.newLine();
      _builder.newLine();
      _builder.append("public class Foo {");
      _builder.newLine();
      _builder.newLine();
      _builder.append("\t");
      _builder.append("public static class Inner {}");
      _builder.newLine();
      _builder.newLine();
      _builder.append("}");
      _builder.newLine();
      this.testHelper.createFile("foo/Foo.java", _builder.toString());
      StringConcatenation _builder_1 = new StringConcatenation();
      _builder_1.append("package bar");
      _builder_1.newLine();
      _builder_1.newLine();
      _builder_1.append("import foo.Foo.*");
      _builder_1.newLine();
      _builder_1.newLine();
      _builder_1.append("class Bar extends Inner {}");
      _builder_1.newLine();
      final IFile xtendFile = this.testHelper.createFile("bar/Bar.xtend", _builder_1.toString());
      this.renameJavaElement(this.findJavaType("foo.Foo"), "NewFoo");
      StringConcatenation _builder_2 = new StringConcatenation();
      _builder_2.append("package bar");
      _builder_2.newLine();
      _builder_2.newLine();
      _builder_2.append("import foo.NewFoo.*");
      _builder_2.newLine();
      _builder_2.newLine();
      _builder_2.append("class Bar extends Inner {}");
      _builder_2.newLine();
      this.fileAsserts.assertFileContains(xtendFile, _builder_2.toString());
    } finally {
      IFile _file = this.testHelper.getProject().getFile("src/foo/NewFoo.java");
      NullProgressMonitor _nullProgressMonitor = new NullProgressMonitor();
      _file.delete(true, _nullProgressMonitor);
    }
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 17
@Ignore
@Test
public void renameUnusedType_2() {
  try {
    try {
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("package foo;");
      _builder.newLine();
      _builder.newLine();
      _builder.append("public class Foo {}");
      _builder.newLine();
      this.testHelper.createFile("foo/Foo.java", _builder.toString());
      StringConcatenation _builder_1 = new StringConcatenation();
      _builder_1.append("package bar");
      _builder_1.newLine();
      _builder_1.newLine();
      _builder_1.append("import foo.Foo.*");
      _builder_1.newLine();
      _builder_1.newLine();
      _builder_1.append("class Bar {}");
      _builder_1.newLine();
      final IFile xtendFile = this.testHelper.createFile("bar/Bar.xtend", _builder_1.toString());
      this.renameJavaElement(this.findJavaType("foo.Foo"), "NewFoo");
      StringConcatenation _builder_2 = new StringConcatenation();
      _builder_2.append("package bar");
      _builder_2.newLine();
      _builder_2.newLine();
      _builder_2.append("import foo.NewFoo.*");
      _builder_2.newLine();
      _builder_2.newLine();
      _builder_2.append("class Bar {}");
      _builder_2.newLine();
      this.fileAsserts.assertFileContains(xtendFile, _builder_2.toString());
    } finally {
      IFile _file = this.testHelper.getProject().getFile("src/foo/NewFoo.java");
      NullProgressMonitor _nullProgressMonitor = new NullProgressMonitor();
      _file.delete(true, _nullProgressMonitor);
    }
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 18
Source Project: Pydev   File: TddTestWorkbench.java    License: Eclipse Public License 1.0 4 votes vote down vote up
private void checkCreateNewModuleWithClass2()
        throws CoreException, BadLocationException, MisconfigurationException {
    String mod1Contents;
    TddCodeGenerationQuickFixParticipant quickFix;
    PySelection ps;
    List<ICompletionProposalHandle> props;
    IFile mod2 = initFile.getParent().getParent().getParent().getFile(new Path("newpack2/module_new.py"));
    final List<PyEdit> pyEditCreated = new ArrayList<PyEdit>();
    ICallbackListener<PyEdit> listener = new ICallbackListener<PyEdit>() {

        @Override
        public Object call(PyEdit obj) {
            pyEditCreated.add(obj);
            return null;
        }
    };
    PyEdit.onPyEditCreated.registerListener(listener);

    try {
        goToManual(AnalysisRequestsTestWorkbench.TIME_FOR_ANALYSIS); //give it a bit more time...
        mod1Contents = "" +
                "from newpack2.module_new import Foo";
        setContentsAndWaitReparseAndError(mod1Contents);

        quickFix = new TddCodeGenerationQuickFixParticipant();
        int offset = mod1Contents.length();
        ps = new PySelection(editor.getDocument(), offset);
        assertTrue(quickFix.isValid(ps, "", editor, offset));
        props = waitForQuickFixProps(quickFix, ps, offset);

        assertTrue(!mod2.exists());
        findCompletion(props, "Create Foo class at new module newpack2.module_new").apply(
                editor.getISourceViewer(), '\n', 0, offset);
        assertTrue("Expected: " + mod2 +
                " to exist.", mod2.exists());

        assertEquals(1, pyEditCreated.size());

    } finally {
        for (PyEdit edit : pyEditCreated) {
            edit.close(false);
        }
        PyEdit.onPyEditCreated.unregisterListener(listener);
        mod2.delete(true, null);
    }
}
 
Example 19
@Test
public void renameUnusedType_6() {
  try {
    try {
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("package foo;");
      _builder.newLine();
      _builder.newLine();
      _builder.append("public class Foo {");
      _builder.newLine();
      _builder.newLine();
      _builder.append("\t");
      _builder.append("public static void foo() {}");
      _builder.newLine();
      _builder.newLine();
      _builder.append("}");
      _builder.newLine();
      this.testHelper.createFile("foo/Foo.java", _builder.toString());
      StringConcatenation _builder_1 = new StringConcatenation();
      _builder_1.append("package bar");
      _builder_1.newLine();
      _builder_1.newLine();
      _builder_1.append("import static extension foo.Foo.*");
      _builder_1.newLine();
      _builder_1.newLine();
      _builder_1.append("class Bar {}");
      _builder_1.newLine();
      final IFile xtendFile = this.testHelper.createFile("bar/Bar.xtend", _builder_1.toString());
      this.renameJavaElement(this.findJavaType("foo.Foo"), "NewFoo");
      StringConcatenation _builder_2 = new StringConcatenation();
      _builder_2.append("package bar");
      _builder_2.newLine();
      _builder_2.newLine();
      _builder_2.append("import static extension foo.NewFoo.*");
      _builder_2.newLine();
      _builder_2.newLine();
      _builder_2.append("class Bar {}");
      _builder_2.newLine();
      this.fileAsserts.assertFileContains(xtendFile, _builder_2.toString());
    } finally {
      IFile _file = this.testHelper.getProject().getFile("src/foo/NewFoo.java");
      NullProgressMonitor _nullProgressMonitor = new NullProgressMonitor();
      _file.delete(true, _nullProgressMonitor);
    }
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 20
@Test
public void renameUnusedType() {
  try {
    try {
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("package foo;");
      _builder.newLine();
      _builder.newLine();
      _builder.append("public class Foo {}");
      _builder.newLine();
      this.testHelper.createFile("foo/Foo.java", _builder.toString());
      StringConcatenation _builder_1 = new StringConcatenation();
      _builder_1.append("package bar");
      _builder_1.newLine();
      _builder_1.newLine();
      _builder_1.append("import foo.Foo");
      _builder_1.newLine();
      _builder_1.newLine();
      _builder_1.append("class Bar {}");
      _builder_1.newLine();
      final IFile xtendFile = this.testHelper.createFile("bar/Bar.xtend", _builder_1.toString());
      this.renameJavaElement(this.findJavaType("foo.Foo"), "NewFoo");
      StringConcatenation _builder_2 = new StringConcatenation();
      _builder_2.append("package bar");
      _builder_2.newLine();
      _builder_2.newLine();
      _builder_2.append("import foo.NewFoo");
      _builder_2.newLine();
      _builder_2.newLine();
      _builder_2.append("class Bar {}");
      _builder_2.newLine();
      this.fileAsserts.assertFileContains(xtendFile, _builder_2.toString());
    } finally {
      IFile _file = this.testHelper.getProject().getFile("src/foo/NewFoo.java");
      NullProgressMonitor _nullProgressMonitor = new NullProgressMonitor();
      _file.delete(true, _nullProgressMonitor);
    }
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}