use of org.eclipse.core.runtime.IStatus in project che by eclipse.
the class ReorgCorrectionsSubProcessor method canModifyAccessRules.
private static boolean canModifyAccessRules(IBinding binding) {
IJavaElement element = binding.getJavaElement();
if (element == null)
return false;
IPackageFragmentRoot root = JavaModelUtil.getPackageFragmentRoot(element);
if (root == null)
return false;
try {
IClasspathEntry classpathEntry = root.getRawClasspathEntry();
if (classpathEntry == null)
return false;
if (classpathEntry.getEntryKind() == IClasspathEntry.CPE_LIBRARY)
return true;
if (classpathEntry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
ClasspathContainerInitializer classpathContainerInitializer = JavaCore.getClasspathContainerInitializer(classpathEntry.getPath().segment(0));
IStatus status = classpathContainerInitializer.getAccessRulesStatus(classpathEntry.getPath(), root.getJavaProject());
return status.isOK();
}
} catch (JavaModelException e) {
return false;
}
return false;
}
use of org.eclipse.core.runtime.IStatus in project che by eclipse.
the class ImportOperation method getRejectedFiles.
/**
* Returns the rejected files based on the given multi status.
*
* @param multiStatus multi status to use to determine file rejection
* @param files source files
* @return list of rejected files as absolute paths. Object type IPath.
*/
ArrayList getRejectedFiles(IStatus multiStatus, IFile[] files) {
ArrayList filteredFiles = new ArrayList();
IStatus[] status = multiStatus.getChildren();
for (int i = 0; i < status.length; i++) {
if (status[i].isOK() == false) {
errorTable.add(status[i]);
filteredFiles.add(files[i].getFullPath());
}
}
return filteredFiles;
}
use of org.eclipse.core.runtime.IStatus in project che by eclipse.
the class JavaConventions method validateClassFileName.
/**
* Validate the given .class file name for the given source and compliance levels.
* <p>
* A .class file name must obey the following rules:
* <ul>
* <li> it must not be null
* <li> it must include the <code>".class"</code> suffix
* <li> its prefix must be a valid identifier
* <li> it must not contain any characters or substrings that are not valid
* on the file system on which workspace root is located.
* </ul>
* </p>
* @param name the name of a .class file
* @param sourceLevel the source level
* @param complianceLevel the compliance level
* @return a status object with code <code>IStatus.OK</code> if
* the given name is valid as a .class file name, otherwise a status
* object indicating what is wrong with the name
* @since 3.3
*/
public static IStatus validateClassFileName(String name, String sourceLevel, String complianceLevel) {
if (name == null) {
return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Messages.convention_classFile_nullName, null);
}
if (!org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(name)) {
return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Messages.convention_classFile_notClassFileName, null);
}
String identifier;
int index;
index = name.lastIndexOf('.');
if (index == -1) {
return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Messages.convention_classFile_notClassFileName, null);
}
identifier = name.substring(0, index);
// the package-level spec (replaces package.html)
if (!identifier.equals(PACKAGE_INFO)) {
IStatus status = validateIdentifier(identifier, sourceLevel, complianceLevel);
if (!status.isOK()) {
return status;
}
}
// }
return JavaModelStatus.VERIFIED_OK;
}
use of org.eclipse.core.runtime.IStatus in project che by eclipse.
the class DeltaProcessingState method saveExternalLibTimeStamps.
public void saveExternalLibTimeStamps() throws CoreException {
if (this.externalTimeStamps == null)
return;
// cleanup to avoid any leak ( https://bugs.eclipse.org/bugs/show_bug.cgi?id=244849 )
HashSet toRemove = new HashSet();
if (this.roots != null) {
Enumeration keys = this.externalTimeStamps.keys();
while (keys.hasMoreElements()) {
Object key = keys.nextElement();
if (this.roots.get(key) == null) {
toRemove.add(key);
}
}
}
File timestamps = getTimeStampsFile();
DataOutputStream out = null;
try {
out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(timestamps)));
out.writeInt(this.externalTimeStamps.size() - toRemove.size());
Iterator entries = this.externalTimeStamps.entrySet().iterator();
while (entries.hasNext()) {
Map.Entry entry = (Map.Entry) entries.next();
IPath key = (IPath) entry.getKey();
if (!toRemove.contains(key)) {
out.writeUTF(key.toPortableString());
Long timestamp = (Long) entry.getValue();
out.writeLong(timestamp.longValue());
}
}
} catch (IOException e) {
//$NON-NLS-1$
IStatus status = new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, IStatus.ERROR, "Problems while saving timestamps", e);
throw new CoreException(status);
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
// nothing we can do: ignore
}
}
}
}
use of org.eclipse.core.runtime.IStatus in project che by eclipse.
the class ResourceChangeChecker method createFrom.
private static RefactoringStatus createFrom(IStatus status) {
if (status.isOK())
return new RefactoringStatus();
if (!status.isMultiStatus()) {
switch(status.getSeverity()) {
case IStatus.OK:
return new RefactoringStatus();
case IStatus.INFO:
return RefactoringStatus.createInfoStatus(status.getMessage());
case IStatus.WARNING:
return RefactoringStatus.createWarningStatus(status.getMessage());
case IStatus.ERROR:
return RefactoringStatus.createErrorStatus(status.getMessage());
case IStatus.CANCEL:
return RefactoringStatus.createFatalErrorStatus(status.getMessage());
default:
return RefactoringStatus.createFatalErrorStatus(status.getMessage());
}
} else {
IStatus[] children = status.getChildren();
RefactoringStatus result = new RefactoringStatus();
for (int i = 0; i < children.length; i++) {
result.merge(createFrom(children[i]));
}
return result;
}
}
Aggregations