Java 类org.eclipse.jdt.core.IJavaModelStatus 实例源码

项目:che    文件:JavaModelManager.java   
private ClasspathChange setClasspath(
    IClasspathEntry[] newRawClasspath,
    IClasspathEntry[] referencedEntries,
    IPath newOutputLocation,
    IJavaModelStatus newRawClasspathStatus,
    IClasspathEntry[] newResolvedClasspath,
    Map newRootPathToRawEntries,
    Map newRootPathToResolvedEntries,
    IJavaModelStatus newUnresolvedEntryStatus,
    boolean addClasspathChange) {
  ClasspathChange classpathChange = addClasspathChange ? addClasspathChange() : null;

  if (referencedEntries != null) this.referencedEntries = referencedEntries;
  if (this.referencedEntries == null) this.referencedEntries = ClasspathEntry.NO_ENTRIES;
  this.rawClasspath = newRawClasspath;
  this.outputLocation = newOutputLocation;
  this.rawClasspathStatus = newRawClasspathStatus;
  this.resolvedClasspath = newResolvedClasspath;
  this.rootPathToRawEntries = newRootPathToRawEntries;
  this.rootPathToResolvedEntries = newRootPathToResolvedEntries;
  this.unresolvedEntryStatus = newUnresolvedEntryStatus;
  this.javadocCache = new LRUCache(JAVADOC_CACHE_INITIAL_SIZE);

  return classpathChange;
}
项目:che    文件:JavaModelManager.java   
public synchronized ClasspathChange setRawClasspath(
    IClasspathEntry[] newRawClasspath,
    IClasspathEntry[] referencedEntries,
    IPath newOutputLocation,
    IJavaModelStatus newRawClasspathStatus) {
  this.rawTimeStamp++;
  return setClasspath(
      newRawClasspath,
      referencedEntries,
      newOutputLocation,
      newRawClasspathStatus,
      null /*resolved classpath*/,
      null /*root to raw map*/,
      null /*root to resolved map*/,
      null /*unresolved status*/,
      true /*add classpath
           change*/);
}
项目:che    文件:JavaModelManager.java   
public ClasspathChange setResolvedClasspath(
    IClasspathEntry[] newResolvedClasspath,
    Map newRootPathToRawEntries,
    Map newRootPathToResolvedEntries,
    IJavaModelStatus newUnresolvedEntryStatus,
    int timeStamp,
    boolean addClasspathChange) {
  return setResolvedClasspath(
      newResolvedClasspath,
      null,
      newRootPathToRawEntries,
      newRootPathToResolvedEntries,
      newUnresolvedEntryStatus,
      timeStamp,
      addClasspathChange);
}
项目:che    文件:JavaModelManager.java   
public synchronized ClasspathChange setResolvedClasspath(
    IClasspathEntry[] newResolvedClasspath,
    IClasspathEntry[] referencedEntries,
    Map newRootPathToRawEntries,
    Map newRootPathToResolvedEntries,
    IJavaModelStatus newUnresolvedEntryStatus,
    int timeStamp,
    boolean addClasspathChange) {
  if (this.rawTimeStamp != timeStamp) return null;
  return setClasspath(
      this.rawClasspath,
      referencedEntries,
      this.outputLocation,
      this.rawClasspathStatus,
      newResolvedClasspath,
      newRootPathToRawEntries,
      newRootPathToResolvedEntries,
      newUnresolvedEntryStatus,
      addClasspathChange);
}
项目:che    文件:ClasspathEntry.java   
private static IJavaModelStatus validateLibraryContents(
    IPath path, IJavaProject project, String entryPathMsg) {
  JavaModelManager manager = JavaModelManager.getJavaModelManager();
  try {
    manager.verifyArchiveContent(path);
  } catch (CoreException e) {
    if (e.getStatus().getMessage() == Messages.status_IOException) {
      return new JavaModelStatus(
          IJavaModelStatusConstants.INVALID_CLASSPATH,
          Messages.bind(
              Messages.classpath_archiveReadError,
              new String[] {entryPathMsg, project.getElementName()}));
    }
  }
  return JavaModelStatus.VERIFIED_OK;
}
项目:Eclipse-Postfix-Code-Completion    文件:ClasspathModifier.java   
public static void commitClassPath(List<CPListElement> newEntries, IJavaProject project, IProgressMonitor monitor) throws JavaModelException {
    if (monitor == null)
        monitor= new NullProgressMonitor();

    monitor.beginTask("", 2); //$NON-NLS-1$

    try {
        IClasspathEntry[] entries= convert(newEntries);
        IPath outputLocation= project.getOutputLocation();

        IJavaModelStatus status= JavaConventions.validateClasspath(project, entries, outputLocation);
        if (!status.isOK())
            throw new JavaModelException(status);

        BuildPathSupport.setEEComplianceOptions(project, newEntries);
        project.setRawClasspath(entries, outputLocation, new SubProgressMonitor(monitor, 2));
    } finally {
        monitor.done();
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:ClasspathModifier.java   
public static void commitClassPath(CPJavaProject cpProject, IProgressMonitor monitor) throws JavaModelException {
if (monitor == null)
    monitor= new NullProgressMonitor();

monitor.beginTask("", 2); //$NON-NLS-1$

try {
    List<CPListElement> cpListElements= cpProject.getCPListElements();
    IClasspathEntry[] entries= convert(cpListElements);
    IPath outputLocation= cpProject.getDefaultOutputLocation();

    IJavaProject javaProject= cpProject.getJavaProject();
    IJavaModelStatus status= JavaConventions.validateClasspath(javaProject, entries, outputLocation);
    if (!status.isOK())
        throw new JavaModelException(status);

    BuildPathSupport.setEEComplianceOptions(javaProject, cpListElements);
    javaProject.setRawClasspath(entries, outputLocation, new SubProgressMonitor(monitor, 2));
} finally {
    monitor.done();
}
  }
项目:Eclipse-Postfix-Code-Completion    文件:BuildPathsBlock.java   
private void updateBuildPathStatus() {
    List<CPListElement> elements= fClassPathList.getElements();
    IClasspathEntry[] entries= new IClasspathEntry[elements.size()];

    for (int i= elements.size()-1 ; i >= 0 ; i--) {
        CPListElement currElement= elements.get(i);
        entries[i]= currElement.getClasspathEntry();
    }

    IJavaModelStatus status= JavaConventions.validateClasspath(fCurrJProject, entries, fOutputLocationPath);
    if (!status.isOK()) {
        fBuildPathStatus.setError(status.getMessage());
        return;
    }
    fBuildPathStatus.setOK();
}
项目:Eclipse-Postfix-Code-Completion    文件:CreateMethodOperation.java   
/**
 * @see CreateTypeMemberOperation#verifyNameCollision
 */
protected IJavaModelStatus verifyNameCollision() {
    if (this.createdNode != null) {
        IType type = getType();
        String name;
        if (((MethodDeclaration) this.createdNode).isConstructor())
            name = type.getElementName();
        else
            name = getASTNodeName();
        String[] types = convertASTMethodTypesToSignatures();
        if (type.getMethod(name, types).exists()) {
            return new JavaModelStatus(
                IJavaModelStatusConstants.NAME_COLLISION,
                Messages.bind(Messages.status_nameCollision, name));
        }
    }
    return JavaModelStatus.VERIFIED_OK;
}
项目:Eclipse-Postfix-Code-Completion    文件:CreateTypeMemberOperation.java   
/**
 * Possible failures: <ul>
 *  <li>NO_ELEMENTS_TO_PROCESS - the parent element supplied to the operation is
 *      <code>null</code>.
 *  <li>INVALID_CONTENTS - The source is <code>null</code> or has serious syntax errors.
  * <li>NAME_COLLISION - A name collision occurred in the destination
 * </ul>
 */
public IJavaModelStatus verify() {
    IJavaModelStatus status = super.verify();
    if (!status.isOK()) {
        return status;
    }
    if (this.source == null) {
        return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CONTENTS);
    }
    if (!this.force) {
        //check for name collisions
        try {
            ICompilationUnit cu = getCompilationUnit();
            generateElementAST(null, cu);
        } catch (JavaModelException jme) {
            return jme.getJavaModelStatus();
        }
        return verifyNameCollision();
    }

    return JavaModelStatus.VERIFIED_OK;
}
项目:Eclipse-Postfix-Code-Completion    文件:CreateTypeOperation.java   
/**
 * @see CreateTypeMemberOperation#verifyNameCollision
 */
protected IJavaModelStatus verifyNameCollision() {
    IJavaElement parent = getParentElement();
    switch (parent.getElementType()) {
        case IJavaElement.COMPILATION_UNIT:
            String typeName = getASTNodeName();
            if (((ICompilationUnit) parent).getType(typeName).exists()) {
                return new JavaModelStatus(
                    IJavaModelStatusConstants.NAME_COLLISION,
                    Messages.bind(Messages.status_nameCollision, typeName));
            }
            break;
        case IJavaElement.TYPE:
            typeName = getASTNodeName();
            if (((IType) parent).getType(typeName).exists()) {
                return new JavaModelStatus(
                    IJavaModelStatusConstants.NAME_COLLISION,
                    Messages.bind(Messages.status_nameCollision, typeName));
            }
            break;
        // Note: creating local/anonymous type is not supported
    }
    return JavaModelStatus.VERIFIED_OK;
}
项目:Eclipse-Postfix-Code-Completion    文件:CreateElementInCUOperation.java   
/**
 * Possible failures: <ul>
 *  <li>NO_ELEMENTS_TO_PROCESS - the compilation unit supplied to the operation is
 *      <code>null</code>.
 *  <li>INVALID_NAME - no name, a name was null or not a valid
 *      import declaration name.
 *  <li>INVALID_SIBLING - the sibling provided for positioning is not valid.
 * </ul>
 * @see IJavaModelStatus
 * @see org.eclipse.jdt.core.JavaConventions
 */
public IJavaModelStatus verify() {
    if (getParentElement() == null) {
        return new JavaModelStatus(IJavaModelStatusConstants.NO_ELEMENTS_TO_PROCESS);
    }
    if (this.anchorElement != null) {
        IJavaElement domPresentParent = this.anchorElement.getParent();
        if (domPresentParent.getElementType() == IJavaElement.IMPORT_CONTAINER) {
            domPresentParent = domPresentParent.getParent();
        }
        if (!domPresentParent.equals(getParentElement())) {
            return new JavaModelStatus(IJavaModelStatusConstants.INVALID_SIBLING, this.anchorElement);
        }
    }
    return JavaModelStatus.VERIFIED_OK;
}
项目:Eclipse-Postfix-Code-Completion    文件:ClasspathEntry.java   
/**
 * Returns a Java model status describing the problem related to this classpath entry if any,
 * a status object with code <code>IStatus.OK</code> if the entry is fine (that is, if the
 * given classpath entry denotes a valid element to be referenced onto a classpath).
 *
 * @param project the given java project
 * @param entry the given classpath entry
 * @param checkSourceAttachment a flag to determine if source attachment should be checked
 * @param referredByContainer flag indicating whether the given entry is referred by a classpath container
 * @return a java model status describing the problem related to this classpath entry if any, a status object with code <code>IStatus.OK</code> if the entry is fine
 */
public static IJavaModelStatus validateClasspathEntry(IJavaProject project, IClasspathEntry entry, boolean checkSourceAttachment, boolean referredByContainer){
    if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
        JavaModelManager.getJavaModelManager().removeFromInvalidArchiveCache(entry.getPath());
    }
    IJavaModelStatus status = validateClasspathEntry(project, entry, null, checkSourceAttachment, referredByContainer);
    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=171136 and https://bugs.eclipse.org/bugs/show_bug.cgi?id=300136
    // Ignore class path errors from optional entries.
    int statusCode = status.getCode();
    if ( (statusCode == IJavaModelStatusConstants.INVALID_CLASSPATH || 
            statusCode == IJavaModelStatusConstants.CP_CONTAINER_PATH_UNBOUND ||
            statusCode == IJavaModelStatusConstants.CP_VARIABLE_PATH_UNBOUND ||
            statusCode == IJavaModelStatusConstants.INVALID_PATH) &&
            ((ClasspathEntry) entry).isOptional())
        return JavaModelStatus.VERIFIED_OK;
    return status;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ClasspathModifier.java   
public static void commitClassPath(List<CPListElement> newEntries, IJavaProject project, IProgressMonitor monitor) throws JavaModelException {
    if (monitor == null)
        monitor= new NullProgressMonitor();

    monitor.beginTask("", 2); //$NON-NLS-1$

    try {
        IClasspathEntry[] entries= convert(newEntries);
        IPath outputLocation= project.getOutputLocation();

        IJavaModelStatus status= JavaConventions.validateClasspath(project, entries, outputLocation);
        if (!status.isOK())
            throw new JavaModelException(status);

        BuildPathSupport.setEEComplianceOptions(project, newEntries);
        project.setRawClasspath(entries, outputLocation, new SubProgressMonitor(monitor, 2));
    } finally {
        monitor.done();
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ClasspathModifier.java   
public static void commitClassPath(CPJavaProject cpProject, IProgressMonitor monitor) throws JavaModelException {
if (monitor == null)
    monitor= new NullProgressMonitor();

monitor.beginTask("", 2); //$NON-NLS-1$

try {
    List<CPListElement> cpListElements= cpProject.getCPListElements();
    IClasspathEntry[] entries= convert(cpListElements);
    IPath outputLocation= cpProject.getDefaultOutputLocation();

    IJavaProject javaProject= cpProject.getJavaProject();
    IJavaModelStatus status= JavaConventions.validateClasspath(javaProject, entries, outputLocation);
    if (!status.isOK())
        throw new JavaModelException(status);

    BuildPathSupport.setEEComplianceOptions(javaProject, cpListElements);
    javaProject.setRawClasspath(entries, outputLocation, new SubProgressMonitor(monitor, 2));
} finally {
    monitor.done();
}
  }
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:BuildPathsBlock.java   
private void updateBuildPathStatus() {
    List<CPListElement> elements= fClassPathList.getElements();
    IClasspathEntry[] entries= new IClasspathEntry[elements.size()];

    for (int i= elements.size()-1 ; i >= 0 ; i--) {
        CPListElement currElement= elements.get(i);
        entries[i]= currElement.getClasspathEntry();
    }

    IJavaModelStatus status= JavaConventions.validateClasspath(fCurrJProject, entries, fOutputLocationPath);
    if (!status.isOK()) {
        fBuildPathStatus.setError(status.getMessage());
        return;
    }
    fBuildPathStatus.setOK();
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:CreateMethodOperation.java   
/**
 * @see CreateTypeMemberOperation#verifyNameCollision
 */
protected IJavaModelStatus verifyNameCollision() {
    if (this.createdNode != null) {
        IType type = getType();
        String name;
        if (((MethodDeclaration) this.createdNode).isConstructor())
            name = type.getElementName();
        else
            name = getASTNodeName();
        String[] types = convertASTMethodTypesToSignatures();
        if (type.getMethod(name, types).exists()) {
            return new JavaModelStatus(
                IJavaModelStatusConstants.NAME_COLLISION,
                Messages.bind(Messages.status_nameCollision, name));
        }
    }
    return JavaModelStatus.VERIFIED_OK;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:CreateTypeMemberOperation.java   
/**
 * Possible failures: <ul>
 *  <li>NO_ELEMENTS_TO_PROCESS - the parent element supplied to the operation is
 *      <code>null</code>.
 *  <li>INVALID_CONTENTS - The source is <code>null</code> or has serious syntax errors.
  * <li>NAME_COLLISION - A name collision occurred in the destination
 * </ul>
 */
public IJavaModelStatus verify() {
    IJavaModelStatus status = super.verify();
    if (!status.isOK()) {
        return status;
    }
    if (this.source == null) {
        return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CONTENTS);
    }
    if (!this.force) {
        //check for name collisions
        try {
            ICompilationUnit cu = getCompilationUnit();
            generateElementAST(null, cu);
        } catch (JavaModelException jme) {
            return jme.getJavaModelStatus();
        }
        return verifyNameCollision();
    }

    return JavaModelStatus.VERIFIED_OK;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:CreateTypeOperation.java   
/**
 * @see CreateTypeMemberOperation#verifyNameCollision
 */
protected IJavaModelStatus verifyNameCollision() {
    IJavaElement parent = getParentElement();
    switch (parent.getElementType()) {
        case IJavaElement.COMPILATION_UNIT:
            String typeName = getASTNodeName();
            if (((ICompilationUnit) parent).getType(typeName).exists()) {
                return new JavaModelStatus(
                    IJavaModelStatusConstants.NAME_COLLISION,
                    Messages.bind(Messages.status_nameCollision, typeName));
            }
            break;
        case IJavaElement.TYPE:
            typeName = getASTNodeName();
            if (((IType) parent).getType(typeName).exists()) {
                return new JavaModelStatus(
                    IJavaModelStatusConstants.NAME_COLLISION,
                    Messages.bind(Messages.status_nameCollision, typeName));
            }
            break;
        // Note: creating local/anonymous type is not supported
    }
    return JavaModelStatus.VERIFIED_OK;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:CreateElementInCUOperation.java   
/**
 * Possible failures: <ul>
 *  <li>NO_ELEMENTS_TO_PROCESS - the compilation unit supplied to the operation is
 *      <code>null</code>.
 *  <li>INVALID_NAME - no name, a name was null or not a valid
 *      import declaration name.
 *  <li>INVALID_SIBLING - the sibling provided for positioning is not valid.
 * </ul>
 * @see IJavaModelStatus
 * @see org.eclipse.jdt.core.JavaConventions
 */
public IJavaModelStatus verify() {
    if (getParentElement() == null) {
        return new JavaModelStatus(IJavaModelStatusConstants.NO_ELEMENTS_TO_PROCESS);
    }
    if (this.anchorElement != null) {
        IJavaElement domPresentParent = this.anchorElement.getParent();
        if (domPresentParent.getElementType() == IJavaElement.IMPORT_CONTAINER) {
            domPresentParent = domPresentParent.getParent();
        }
        if (!domPresentParent.equals(getParentElement())) {
            return new JavaModelStatus(IJavaModelStatusConstants.INVALID_SIBLING, this.anchorElement);
        }
    }
    return JavaModelStatus.VERIFIED_OK;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ClasspathEntry.java   
/**
 * Returns a Java model status describing the problem related to this classpath entry if any,
 * a status object with code <code>IStatus.OK</code> if the entry is fine (that is, if the
 * given classpath entry denotes a valid element to be referenced onto a classpath).
 *
 * @param project the given java project
 * @param entry the given classpath entry
 * @param checkSourceAttachment a flag to determine if source attachment should be checked
 * @param referredByContainer flag indicating whether the given entry is referred by a classpath container
 * @return a java model status describing the problem related to this classpath entry if any, a status object with code <code>IStatus.OK</code> if the entry is fine
 */
public static IJavaModelStatus validateClasspathEntry(IJavaProject project, IClasspathEntry entry, boolean checkSourceAttachment, boolean referredByContainer){
    if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
        JavaModelManager.getJavaModelManager().removeFromInvalidArchiveCache(entry.getPath());
    }
    IJavaModelStatus status = validateClasspathEntry(project, entry, null, checkSourceAttachment, referredByContainer);
    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=171136 and https://bugs.eclipse.org/bugs/show_bug.cgi?id=300136
    // Ignore class path errors from optional entries.
    int statusCode = status.getCode();
    if ( (statusCode == IJavaModelStatusConstants.INVALID_CLASSPATH || 
            statusCode == IJavaModelStatusConstants.CP_CONTAINER_PATH_UNBOUND ||
            statusCode == IJavaModelStatusConstants.CP_VARIABLE_PATH_UNBOUND ||
            statusCode == IJavaModelStatusConstants.INVALID_PATH) &&
            ((ClasspathEntry) entry).isOptional())
        return JavaModelStatus.VERIFIED_OK;
    return status;
}
项目:che    文件:ReconcileWorkingCopyOperation.java   
protected IJavaModelStatus verify() {
  IJavaModelStatus status = super.verify();
  if (!status.isOK()) {
    return status;
  }
  CompilationUnit workingCopy = getWorkingCopy();
  if (!workingCopy.isWorkingCopy()) {
    return new JavaModelStatus(
        IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, workingCopy); // was destroyed
  }
  return status;
}
项目:che    文件:JavaModelOperation.java   
/**
 * Common code used to verify the elements this operation is processing.
 *
 * @see org.eclipse.jdt.internal.core.JavaModelOperation#verify()
 */
protected IJavaModelStatus commonVerify() {
  if (this.elementsToProcess == null || this.elementsToProcess.length == 0) {
    return new JavaModelStatus(IJavaModelStatusConstants.NO_ELEMENTS_TO_PROCESS);
  }
  for (int i = 0; i < this.elementsToProcess.length; i++) {
    if (this.elementsToProcess[i] == null) {
      return new JavaModelStatus(IJavaModelStatusConstants.NO_ELEMENTS_TO_PROCESS);
    }
  }
  return org.eclipse.jdt.internal.core.JavaModelStatus.VERIFIED_OK;
}
项目:che    文件:JavaModelOperation.java   
/** Convenience method to run an operation within this operation */
public void executeNestedOperation(JavaModelOperation operation, int subWorkAmount)
    throws JavaModelException {
  IJavaModelStatus status = operation.verify();
  if (!status.isOK()) {
    throw new JavaModelException(status);
  }
  IProgressMonitor subProgressMonitor = getSubProgressMonitor(subWorkAmount);
  // fix for 1FW7IKC, part (1)
  try {
    operation.setNested(true);
    operation.run(subProgressMonitor);
  } catch (CoreException ce) {
    if (ce instanceof JavaModelException) {
      throw (JavaModelException) ce;
    } else {
      // translate the core exception to a java model exception
      if (ce.getStatus().getCode() == IResourceStatus.OPERATION_FAILED) {
        Throwable e = ce.getStatus().getException();
        if (e instanceof JavaModelException) {
          throw (JavaModelException) e;
        }
      }
      throw new JavaModelException(ce);
    }
  }
}
项目:che    文件:JavaModelOperation.java   
/**
 * Main entry point for Java Model operations. Runs a Java Model Operation as an
 * IWorkspaceRunnable if not read-only.
 */
public void runOperation(IProgressMonitor monitor) throws JavaModelException {
  IJavaModelStatus status = verify();
  if (!status.isOK()) {
    throw new JavaModelException(status);
  }
  try {
    if (isReadOnly()) {
      run(monitor);
    } else {
      // Use IWorkspace.run(...) to ensure that resource changes are batched
      // Note that if the tree is locked, this will throw a CoreException, but this is ok
      // as this operation is modifying the tree (not read-only) and a CoreException will be
      // thrown anyway.
      //                ResourcesPlugin.getWorkspace().run(this, getSchedulingRule(), IWorkspace.AVOID_UPDATE,
      // monitor);
      // todo use ResourcesPlugin.getWorkspace().run
      run(monitor);
    }
  } catch (CoreException ce) {
    if (ce instanceof JavaModelException) {
      throw (JavaModelException) ce;
    } else {
      if (ce.getStatus().getCode() == IResourceStatus.OPERATION_FAILED) {
        Throwable e = ce.getStatus().getException();
        if (e instanceof JavaModelException) {
          throw (JavaModelException) e;
        }
      }
      throw new JavaModelException(ce);
    }
  }
}
项目:Eclipse-Postfix-Code-Completion    文件:CreateCompilationUnitOperation.java   
/**
 * Possible failures: <ul>
 *  <li>NO_ELEMENTS_TO_PROCESS - the package fragment supplied to the operation is
 *      <code>null</code>.
 *  <li>INVALID_NAME - the compilation unit name provided to the operation
 *      is <code>null</code> or has an invalid syntax
 *  <li>INVALID_CONTENTS - the source specified for the compiliation unit is null
 * </ul>
 */
public IJavaModelStatus verify() {
    if (getParentElement() == null) {
        return new JavaModelStatus(IJavaModelStatusConstants.NO_ELEMENTS_TO_PROCESS);
    }
    IJavaProject project = getParentElement().getJavaProject();
    if (JavaConventions.validateCompilationUnitName(this.name, project.getOption(JavaCore.COMPILER_SOURCE, true), project.getOption(JavaCore.COMPILER_COMPLIANCE, true)).getSeverity() == IStatus.ERROR) {
        return new JavaModelStatus(IJavaModelStatusConstants.INVALID_NAME, this.name);
    }
    if (this.source == null) {
        return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CONTENTS);
    }
    return JavaModelStatus.VERIFIED_OK;
}
项目:Eclipse-Postfix-Code-Completion    文件:CreatePackageDeclarationOperation.java   
/**
 * Possible failures: <ul>
 *  <li>NO_ELEMENTS_TO_PROCESS - no compilation unit was supplied to the operation
 *  <li>INVALID_NAME - a name supplied to the operation was not a valid
 *      package declaration name.
 * </ul>
 * @see IJavaModelStatus
 * @see JavaConventions
 */
public IJavaModelStatus verify() {
    IJavaModelStatus status = super.verify();
    if (!status.isOK()) {
        return status;
    }
    IJavaProject project = getParentElement().getJavaProject();
    if (JavaConventions.validatePackageName(this.name, project.getOption(JavaCore.COMPILER_SOURCE, true), project.getOption(JavaCore.COMPILER_COMPLIANCE, true)).getSeverity() == IStatus.ERROR) {
        return new JavaModelStatus(IJavaModelStatusConstants.INVALID_NAME, this.name);
    }
    return JavaModelStatus.VERIFIED_OK;
}
项目:Eclipse-Postfix-Code-Completion    文件:CopyElementsOperation.java   
/**
 * Possible failures:
 * <ul>
 *  <li>NO_ELEMENTS_TO_PROCESS - no elements supplied to the operation
 *  <li>INDEX_OUT_OF_BOUNDS - the number of renamings supplied to the operation
 *      does not match the number of elements that were supplied.
 * </ul>
 */
protected IJavaModelStatus verify() {
    IJavaModelStatus status = super.verify();
    if (!status.isOK()) {
        return status;
    }
    if (this.renamingsList != null && this.renamingsList.length != this.elementsToProcess.length) {
        return new JavaModelStatus(IJavaModelStatusConstants.INDEX_OUT_OF_BOUNDS);
    }
    return JavaModelStatus.VERIFIED_OK;
}
项目:Eclipse-Postfix-Code-Completion    文件:SetClasspathOperation.java   
public IJavaModelStatus verify() {
    IJavaModelStatus status = super.verify();
    if (!status.isOK())
        return status;
    this.project.flushClasspathProblemMarkers(false, false, true);
    return ClasspathEntry.validateClasspath(this.project, this.newRawClasspath, this.newOutputLocation);
}
项目:Eclipse-Postfix-Code-Completion    文件:CreateTypeHierarchyOperation.java   
/**
 * Possible failures: <ul>
 *  <li>NO_ELEMENTS_TO_PROCESS - at least one of a type or region must
 *          be provided to generate a type hierarchy.
 *  <li>ELEMENT_NOT_PRESENT - the provided type or type's project does not exist
 * </ul>
 */
public IJavaModelStatus verify() {
    IJavaElement elementToProcess= getElementToProcess();
    if (elementToProcess == null && !(this.typeHierarchy instanceof RegionBasedTypeHierarchy)) {
        return new JavaModelStatus(IJavaModelStatusConstants.NO_ELEMENTS_TO_PROCESS);
    }
    if (elementToProcess != null && !elementToProcess.exists()) {
        return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, elementToProcess);
    }
    IJavaProject project = this.typeHierarchy.javaProject();
    if (project != null && !project.exists()) {
        return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, project);
    }
    return JavaModelStatus.VERIFIED_OK;
}
项目:Eclipse-Postfix-Code-Completion    文件:CommitWorkingCopyOperation.java   
/**
 * Possible failures: <ul>
 *  <li>INVALID_ELEMENT_TYPES - the compilation unit supplied to this
 *      operation is not a working copy
 *  <li>ELEMENT_NOT_PRESENT - the compilation unit the working copy is
 *      based on no longer exists.
 *  <li>UPDATE_CONFLICT - the original compilation unit has changed since
 *      the working copy was created and the operation specifies no force
 *  <li>READ_ONLY - the original compilation unit is in read-only mode
 *  </ul>
 */
public IJavaModelStatus verify() {
    CompilationUnit cu = getCompilationUnit();
    if (!cu.isWorkingCopy()) {
        return new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, cu);
    }
    if (cu.hasResourceChanged() && !this.force) {
        return new JavaModelStatus(IJavaModelStatusConstants.UPDATE_CONFLICT);
    }
    // no read-only check, since some repository adapters can change the flag on save
    // operation.
    return JavaModelStatus.VERIFIED_OK;
}
项目:Eclipse-Postfix-Code-Completion    文件:CreateFieldOperation.java   
/**
 * @see CreateTypeMemberOperation#verifyNameCollision
 */
protected IJavaModelStatus verifyNameCollision() {
    if (this.createdNode != null) {
        IType type= getType();
        String fieldName = getASTNodeName();
        if (type.getField(fieldName).exists()) {
            return new JavaModelStatus(
                IJavaModelStatusConstants.NAME_COLLISION,
                Messages.bind(Messages.status_nameCollision, fieldName));
        }
    }
    return JavaModelStatus.VERIFIED_OK;
}
项目:Eclipse-Postfix-Code-Completion    文件:CreatePackageFragmentOperation.java   
/**
 * Possible failures: <ul>
 *  <li>NO_ELEMENTS_TO_PROCESS - the root supplied to the operation is
 *      <code>null</code>.
 *  <li>INVALID_NAME - the name provided to the operation
 *      is <code>null</code> or is not a valid package fragment name.
 *  <li>READ_ONLY - the root provided to this operation is read only.
 *  <li>NAME_COLLISION - there is a pre-existing resource (file)
 *      with the same name as a folder in the package fragment's hierarchy.
 *  <li>ELEMENT_NOT_PRESENT - the underlying resource for the root is missing
 * </ul>
 * @see IJavaModelStatus
 * @see JavaConventions
 */
public IJavaModelStatus verify() {
    IJavaElement parentElement = getParentElement();
    if (parentElement == null) {
        return new JavaModelStatus(IJavaModelStatusConstants.NO_ELEMENTS_TO_PROCESS);
    }

    String packageName = this.pkgName == null ? null : Util.concatWith(this.pkgName, '.');
    IJavaProject project = parentElement.getJavaProject();
    if (this.pkgName == null || (this.pkgName.length > 0 && JavaConventions.validatePackageName(packageName, project.getOption(JavaCore.COMPILER_SOURCE, true), project.getOption(JavaCore.COMPILER_COMPLIANCE, true)).getSeverity() == IStatus.ERROR)) {
        return new JavaModelStatus(IJavaModelStatusConstants.INVALID_NAME, packageName);
    }
    IJavaElement root = getParentElement();
    if (root.isReadOnly()) {
        return new JavaModelStatus(IJavaModelStatusConstants.READ_ONLY, root);
    }
    IContainer parentFolder = (IContainer) ((JavaElement) root).resource();
    int i;
    for (i = 0; i < this.pkgName.length; i++) {
        IResource subFolder = parentFolder.findMember(this.pkgName[i]);
        if (subFolder != null) {
            if (subFolder.getType() != IResource.FOLDER) {
                return new JavaModelStatus(
                    IJavaModelStatusConstants.NAME_COLLISION,
                    Messages.bind(Messages.status_nameCollision, subFolder.getFullPath().toString()));
            }
            parentFolder = (IContainer) subFolder;
        }
    }
    return JavaModelStatus.VERIFIED_OK;
}
项目:Eclipse-Postfix-Code-Completion    文件:CreateImportOperation.java   
/**
 * Possible failures: <ul>
 *  <li>NO_ELEMENTS_TO_PROCESS - the compilation unit supplied to the operation is
 *      <code>null</code>.
 *  <li>INVALID_NAME - not a valid import declaration name.
 * </ul>
 * @see IJavaModelStatus
 * @see JavaConventions
 */
public IJavaModelStatus verify() {
    IJavaModelStatus status = super.verify();
    if (!status.isOK()) {
        return status;
    }
    IJavaProject project = getParentElement().getJavaProject();
    if (JavaConventions.validateImportDeclaration(this.importName, project.getOption(JavaCore.COMPILER_SOURCE, true), project.getOption(JavaCore.COMPILER_COMPLIANCE, true)).getSeverity() == IStatus.ERROR) {
        return new JavaModelStatus(IJavaModelStatusConstants.INVALID_NAME, this.importName);
    }
    return JavaModelStatus.VERIFIED_OK;
}
项目:Eclipse-Postfix-Code-Completion    文件:SortElementsOperation.java   
/**
 * Possible failures:
 * <ul>
 *  <li>NO_ELEMENTS_TO_PROCESS - the compilation unit supplied to the operation is <code>null</code></li>.
 *  <li>INVALID_ELEMENT_TYPES - the supplied elements are not an instance of IWorkingCopy</li>.
 * </ul>
 * @return IJavaModelStatus
 */
public IJavaModelStatus verify() {
    if (this.elementsToProcess.length != 1) {
        return new JavaModelStatus(IJavaModelStatusConstants.NO_ELEMENTS_TO_PROCESS);
    }
    if (this.elementsToProcess[0] == null) {
        return new JavaModelStatus(IJavaModelStatusConstants.NO_ELEMENTS_TO_PROCESS);
    }
    if (!(this.elementsToProcess[0] instanceof ICompilationUnit) || !((ICompilationUnit) this.elementsToProcess[0]).isWorkingCopy()) {
        return new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, this.elementsToProcess[0]);
    }
    return JavaModelStatus.VERIFIED_OK;
}
项目:Eclipse-Postfix-Code-Completion    文件:CreateTypeOperation.java   
public IJavaModelStatus verify() {
    IJavaModelStatus status = super.verify();
    if (!status.isOK())
        return status;
    try {
        IJavaElement parent = getParentElement();
        if (this.anchorElement != null && this.anchorElement.getElementType() == IJavaElement.FIELD
                && parent.getElementType() == IJavaElement.TYPE && ((IType)parent).isEnum())
            return new JavaModelStatus(IJavaModelStatusConstants.INVALID_SIBLING, this.anchorElement);
    } catch (JavaModelException e) {
        return e.getJavaModelStatus();
    }
    return JavaModelStatus.VERIFIED_OK;
}
项目:Eclipse-Postfix-Code-Completion    文件:ClasspathEntry.java   
private static IJavaModelStatus validateLibraryContents(IPath path, IJavaProject project, String entryPathMsg) {
    JavaModelManager manager = JavaModelManager.getJavaModelManager();
    try {
        manager.verifyArchiveContent(path);
    } catch (CoreException e) {
        if (e.getStatus().getMessage() == Messages.status_IOException) {
            return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(
                    Messages.classpath_archiveReadError,
                    new String[] {entryPathMsg, project.getElementName()}));
        }
    }
    return JavaModelStatus.VERIFIED_OK;
}
项目:Eclipse-Postfix-Code-Completion    文件:JavaProject.java   
/**
 * @see IJavaProject
 */
public IClasspathEntry[] getResolvedClasspath(boolean ignoreUnresolvedEntry) throws JavaModelException {
    if  (JavaModelManager.getJavaModelManager().isClasspathBeingResolved(this)) {
        if (JavaModelManager.CP_RESOLVE_VERBOSE_ADVANCED)
            verbose_reentering_classpath_resolution();
        return RESOLUTION_IN_PROGRESS;
    }
    PerProjectInfo perProjectInfo = getPerProjectInfo();

    // use synchronized block to ensure consistency
    IClasspathEntry[] resolvedClasspath;
    IJavaModelStatus unresolvedEntryStatus;
    synchronized (perProjectInfo) {
        resolvedClasspath = perProjectInfo.getResolvedClasspath();
        unresolvedEntryStatus = perProjectInfo.unresolvedEntryStatus;
    }

    if (resolvedClasspath == null
            || (unresolvedEntryStatus != null && !unresolvedEntryStatus.isOK())) { // force resolution to ensure initializers are run again
        resolveClasspath(perProjectInfo, false/*don't use previous session values*/, true/*add classpath change*/);
        synchronized (perProjectInfo) {
            resolvedClasspath = perProjectInfo.getResolvedClasspath();
            unresolvedEntryStatus = perProjectInfo.unresolvedEntryStatus;
        }
        if (resolvedClasspath == null) {
            // another thread reset the resolved classpath, use a temporary PerProjectInfo
            PerProjectInfo temporaryInfo = newTemporaryInfo();
            resolveClasspath(temporaryInfo, false/*don't use previous session values*/, true/*add classpath change*/);
            resolvedClasspath = temporaryInfo.getResolvedClasspath();
            unresolvedEntryStatus = temporaryInfo.unresolvedEntryStatus;
        }
    }
    if (!ignoreUnresolvedEntry && unresolvedEntryStatus != null && !unresolvedEntryStatus.isOK())
        throw new JavaModelException(unresolvedEntryStatus);
    return resolvedClasspath;
}
项目:Eclipse-Postfix-Code-Completion    文件:RenameElementsOperation.java   
/**
 * @see MultiOperation
 */
protected IJavaModelStatus verify() {
    IJavaModelStatus status = super.verify();
    if (! status.isOK())
        return status;
    if (this.renamingsList == null || this.renamingsList.length == 0)
        return new JavaModelStatus(IJavaModelStatusConstants.NULL_NAME);
    return JavaModelStatus.VERIFIED_OK;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:CreateCompilationUnitOperation.java   
/**
 * Possible failures: <ul>
 *  <li>NO_ELEMENTS_TO_PROCESS - the package fragment supplied to the operation is
 *      <code>null</code>.
 *  <li>INVALID_NAME - the compilation unit name provided to the operation
 *      is <code>null</code> or has an invalid syntax
 *  <li>INVALID_CONTENTS - the source specified for the compiliation unit is null
 * </ul>
 */
public IJavaModelStatus verify() {
    if (getParentElement() == null) {
        return new JavaModelStatus(IJavaModelStatusConstants.NO_ELEMENTS_TO_PROCESS);
    }
    IJavaProject project = getParentElement().getJavaProject();
    if (JavaConventions.validateCompilationUnitName(this.name, project.getOption(JavaCore.COMPILER_SOURCE, true), project.getOption(JavaCore.COMPILER_COMPLIANCE, true)).getSeverity() == IStatus.ERROR) {
        return new JavaModelStatus(IJavaModelStatusConstants.INVALID_NAME, this.name);
    }
    if (this.source == null) {
        return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CONTENTS);
    }
    return JavaModelStatus.VERIFIED_OK;
}