use of org.eclipse.core.runtime.IPath in project che by eclipse.
the class RenamePackageChange method createNewPath.
protected IPath createNewPath(IPackageFragment oldPackage) {
IPath oldPackagePath = createPath(oldPackage.getElementName());
IPath newPackagePath = createPath(getNewName(oldPackage));
return oldPackage.getPath().removeLastSegments(oldPackagePath.segmentCount()).append(newPackagePath);
}
use of org.eclipse.core.runtime.IPath in project che by eclipse.
the class ClasspathChange method perform.
@Override
public Change perform(IProgressMonitor pm) throws CoreException {
pm.beginTask(RefactoringCoreMessages.ClasspathChange_progress_message, 1);
try {
if (!JavaConventions.validateClasspath(fProject, fNewClasspath, fOutputLocation).matches(IStatus.ERROR)) {
IClasspathEntry[] oldClasspath = fProject.getRawClasspath();
IPath oldOutputLocation = fProject.getOutputLocation();
fProject.setRawClasspath(fNewClasspath, fOutputLocation, new SubProgressMonitor(pm, 1));
return new ClasspathChange(fProject, oldClasspath, oldOutputLocation);
} else {
return new NullChange();
}
} finally {
pm.done();
}
}
use of org.eclipse.core.runtime.IPath in project che by eclipse.
the class ClasspathChange method removeEntryChange.
public static ClasspathChange removeEntryChange(IJavaProject project, IClasspathEntry entryToRemove) throws JavaModelException {
IClasspathEntry[] rawClasspath = project.getRawClasspath();
ArrayList<IClasspathEntry> newClasspath = new ArrayList<IClasspathEntry>();
for (int i = 0; i < rawClasspath.length; i++) {
IClasspathEntry curr = rawClasspath[i];
if (curr.getEntryKind() != entryToRemove.getEntryKind() || !curr.getPath().equals(entryToRemove.getPath())) {
newClasspath.add(curr);
}
}
IClasspathEntry[] entries = newClasspath.toArray(new IClasspathEntry[newClasspath.size()]);
IPath outputLocation = project.getOutputLocation();
return newChange(project, entries, outputLocation);
}
use of org.eclipse.core.runtime.IPath in project che by eclipse.
the class RefactoringFileBuffers method acquire.
/**
* Connects to and acquires a text file buffer for the specified compilation unit.
* <p>
* All text file buffers acquired by a call to {@link RefactoringFileBuffers#acquire(ICompilationUnit)}
* must be released using {@link RefactoringFileBuffers#release(ICompilationUnit)}.
* </p>
*
* @param unit the compilation unit to acquire a text file buffer for
* @return the text file buffer, or <code>null</code> if no buffer could be acquired
* @throws CoreException if no buffer could be acquired
*/
public static ITextFileBuffer acquire(final ICompilationUnit unit) throws CoreException {
Assert.isNotNull(unit);
final IResource resource = unit.getResource();
if (resource != null && resource.getType() == IResource.FILE) {
final IPath path = resource.getFullPath();
FileBuffers.getTextFileBufferManager().connect(path, LocationKind.IFILE, new NullProgressMonitor());
return FileBuffers.getTextFileBufferManager().getTextFileBuffer(path, LocationKind.IFILE);
}
return null;
}
use of org.eclipse.core.runtime.IPath in project che by eclipse.
the class JavaElementLabelComposer method appendVariableLabel.
private boolean appendVariableLabel(IPackageFragmentRoot root, long flags) {
try {
IClasspathEntry rawEntry = root.getRawClasspathEntry();
if (rawEntry.getEntryKind() == IClasspathEntry.CPE_VARIABLE) {
IClasspathEntry entry = JavaModelUtil.getClasspathEntry(root);
if (entry.getReferencingEntry() != null) {
// not the variable entry itself, but a referenced entry
return false;
}
IPath path = rawEntry.getPath().makeRelative();
if (getFlag(flags, JavaElementLabels.REFERENCED_ROOT_POST_QUALIFIED)) {
int segements = path.segmentCount();
if (segements > 0) {
fBuffer.append(path.segment(segements - 1));
if (segements > 1) {
int offset = fBuffer.length();
fBuffer.append(JavaElementLabels.CONCAT_STRING);
fBuffer.append(path.removeLastSegments(1).toOSString());
if (getFlag(flags, JavaElementLabels.COLORIZE)) {
fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE);
}
}
} else {
fBuffer.append(path.toString());
}
} else {
fBuffer.append(path.toString());
}
int offset = fBuffer.length();
fBuffer.append(JavaElementLabels.CONCAT_STRING);
if (root.isExternal())
fBuffer.append(root.getPath().toOSString());
else
fBuffer.append(root.getPath().makeRelative().toString());
if (getFlag(flags, JavaElementLabels.COLORIZE)) {
fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE);
}
return true;
}
} catch (JavaModelException e) {
// problems with class path, ignore (bug 202792)
return false;
}
return false;
}
Aggregations