use of org.eclipse.core.runtime.IPath in project che by eclipse.
the class RefactoringSession method prepareRenamePackageChange.
private void prepareRenamePackageChange(List<ChangeInfo> changesInfo, ChangeInfo changeInfo, Change ch) {
changeInfo.setName(ChangeInfo.ChangeName.RENAME_PACKAGE);
RenamePackageChange renameChange = (RenamePackageChange) ch;
IPath oldPackageName = new Path(renameChange.getOldName().replace('.', IPath.SEPARATOR));
IPath newPackageName = new Path(renameChange.getNewName().replace('.', IPath.SEPARATOR));
changeInfo.setOldPath(renameChange.getResourcePath().removeLastSegments(oldPackageName.segmentCount()).append(newPackageName).toString());
changeInfo.setPath(renameChange.getResourcePath().toString());
Set<IResource> compilationUnits = renameChange.getFCompilationUnitStamps().keySet();
for (IResource iResource : compilationUnits) {
ChangeInfo change = DtoFactory.newDto(ChangeInfo.class);
change.setName(ChangeInfo.ChangeName.UPDATE);
IPath fullPathOldPath = iResource.getFullPath();
IPath newPath = renameChange.getResourcePath().append(fullPathOldPath.toFile().getName());
change.setOldPath(fullPathOldPath.toString());
change.setPath(newPath.toString());
changesInfo.add(change);
}
}
use of org.eclipse.core.runtime.IPath in project che by eclipse.
the class WorkspaceTest method testSingleProjectClasspath.
@Test
public void testSingleProjectClasspath() throws Exception {
String pom = "<groupId>test</groupId>" + "<artifactId>testArtifact</artifactId>" + "<version>42</version>" + "<dependencies>" + " <dependency>" + " <groupId>junit</groupId>" + " <artifactId>junit</artifactId>" + " <version>4.12</version>" + " </dependency>" + "</dependencies>";
createTestProject("test", pom);
IProject test = ResourcesPlugin.getWorkspace().getRoot().getProject("test");
mavenWorkspace.update(Collections.singletonList(test));
mavenWorkspace.waitForUpdate();
JavaProject javaProject = (JavaProject) JavaCore.create(test);
IClasspathEntry[] classpath = javaProject.getResolvedClasspath();
assertThat(classpath).onProperty("path").is(new Condition<Object[]>() {
@Override
public boolean matches(Object[] value) {
return Stream.of(value).filter(o -> {
if (o instanceof IPath) {
return ((IPath) o).lastSegment().endsWith("junit-4.12.jar");
}
return false;
}).findFirst().isPresent();
}
});
}
use of org.eclipse.core.runtime.IPath in project che by eclipse.
the class WorkspaceTest method testShouldContainsCustomTestSourceDirectory.
@Test
public void testShouldContainsCustomTestSourceDirectory() throws Exception {
String pom = "<groupId>test</groupId>" + "<artifactId>testArtifact</artifactId>" + "<version>42</version>" + "<dependencies>" + " <dependency>" + " <groupId>junit</groupId>" + " <artifactId>junit</artifactId>" + " <version>4.12</version>" + " </dependency>" + "</dependencies>" + "<build>" + "<testSourceDirectory>/mytest</testSourceDirectory>" + "</build>";
createTestProject("test", pom);
IProject test = ResourcesPlugin.getWorkspace().getRoot().getProject("test");
mavenWorkspace.update(Collections.singletonList(test));
mavenWorkspace.waitForUpdate();
JavaProject javaProject = (JavaProject) JavaCore.create(test);
IClasspathEntry[] classpath = javaProject.getResolvedClasspath();
assertThat(classpath).onProperty("path").is(new Condition<Object[]>() {
@Override
public boolean matches(Object[] value) {
return Stream.of(value).filter(o -> {
if (o instanceof IPath) {
return ((IPath) o).toOSString().endsWith("test");
}
return false;
}).findFirst().isPresent();
}
});
}
use of org.eclipse.core.runtime.IPath in project che by eclipse.
the class Checks method checkCompilationUnitNewName.
/**
* Returns OK status if the new name is OK, i.e. when no file with that name exists.
* The name of the given CU is not OK.
*
* @param cu CU to rename
* @param newBareName the new name of the CU (without extension)
* @return the status: FATAL if the CU already exists, OK if OK
*/
public static RefactoringStatus checkCompilationUnitNewName(ICompilationUnit cu, String newBareName) {
String newCUName = JavaModelUtil.getRenamedCUName(cu, newBareName);
IPath renamedResourcePath = cu.getParent().getPath().append(newCUName);
if (resourceExists(renamedResourcePath))
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.Checks_cu_name_used, BasicElementLabels.getResourceName(newCUName)));
else
return new RefactoringStatus();
}
use of org.eclipse.core.runtime.IPath in project che by eclipse.
the class MultiStateTextFileChange method acquireDocument.
/**
* Acquires a document from the file buffer manager.
*
* @param monitor
* the progress monitor to use
* @return the document
* @throws CoreException if the document could not successfully be acquired
*/
private IDocument acquireDocument(final IProgressMonitor monitor) throws CoreException {
if (fCount > 0)
return fBuffer.getDocument();
final ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager();
final IPath path = fFile.getFullPath();
manager.connect(path, LocationKind.IFILE, monitor);
fCount++;
fBuffer = manager.getTextFileBuffer(path, LocationKind.IFILE);
final IDocument document = fBuffer.getDocument();
fContentStamp = ContentStamps.get(fFile, document);
return document;
}
Aggregations