Package org.eclipse.jdt.core

Examples of org.eclipse.jdt.core.IJavaModelStatus


          rs.perform(parent, window);
          adapter.setLastName(name);
          return true;
        }
      } catch (JavaModelException jme){
        IJavaModelStatus status=jme.getJavaModelStatus();
        if(!status.isDoesNotExist()){
          ParserPlugin.getLogger().error(jme);
        }else{
          return true;
        }
      } catch (Exception e) {
View Full Code Here


          rs.perform(parent, window);
          adaptable.setLastName(name);
          return true;
        }
      } catch (JavaModelException jme) {
        IJavaModelStatus status = jme.getJavaModelStatus();
        if (!status.isDoesNotExist()) {
          ParserPlugin.getLogger().error(jme);
        } else {
          return true;
        }
      } catch (Exception e) {
View Full Code Here

    buffer.append(this.newOutputLocation.toString());
    return buffer.toString();
  }

  public IJavaModelStatus verify() {
    IJavaModelStatus status = super.verify();
    if (!status.isOK())
      return status;
    return ClasspathEntry.validateClasspaththis.project, this.newRawClasspath, this.newOutputLocation);
  }
View Full Code Here

    }

    // use synchronized block to ensure consistency
    IClasspathEntry[] rawClasspath;
    IPath outputLocation;
    IJavaModelStatus status;
    synchronized (perProjectInfo) {
      rawClasspath = perProjectInfo.rawClasspath;
      outputLocation = perProjectInfo.outputLocation;
      status = perProjectInfo.rawClasspathStatus; // status has been set during POST_CHANGE
    }

    // update classpath format problems
    this.project.flushClasspathProblemMarkers(false/*cycle*/, true/*format*/);
    if (!status.isOK())
      this.project.createClasspathProblemMarker(status);

    // update resolved classpath problems
    this.project.flushClasspathProblemMarkers(false/*cycle*/, false/*format*/);

    if (rawClasspath != JavaProject.INVALID_CLASSPATH && outputLocation != null) {
       for (int i = 0; i < rawClasspath.length; i++) {
        status = ClasspathEntry.validateClasspathEntry(this.project, rawClasspath[i], false/*src attach*/, false /*not referred by a container*/);
        if (!status.isOK()) {
          this.project.createClasspathProblemMarker(status);
        }
       }
      status = ClasspathEntry.validateClasspath(this.project, rawClasspath, outputLocation);
      if (!status.isOK())
        this.project.createClasspathProblemMarker(status);
     }
  }
View Full Code Here

   * @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){
    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())
View Full Code Here

      // container entry check
      case IClasspathEntry.CPE_CONTAINER :
        if (path.segmentCount() >= 1){
          try {
            IJavaModelStatus status = null;
            // Validate extra attributes
            IClasspathAttribute[] extraAttributes = entry.getExtraAttributes();
            if (extraAttributes != null) {
              int length = extraAttributes.length;
              HashSet set = new HashSet(length);
              for (int i=0; i<length; i++) {
                String attName = extraAttributes[i].getName();
                if (!set.add(attName)) {
                  status = new JavaModelStatus(IJavaModelStatusConstants.NAME_COLLISION, Messages.bind(Messages.classpath_duplicateEntryExtraAttribute, new String[] {attName, entryPathMsg, projectName}));
                  break;
                }
              }
            }
            IClasspathContainer container = JavaModelManager.getJavaModelManager().getClasspathContainer(path, project);
            // container retrieval is performing validation check on container entry kinds.
            if (container == null) {
              if (status != null)
                return status;
              return new JavaModelStatus(IJavaModelStatusConstants.CP_CONTAINER_PATH_UNBOUND, project, path);
            } else if (container == JavaModelManager.CONTAINER_INITIALIZATION_IN_PROGRESS) {
              // don't create a marker if initialization is in progress (case of cp initialization batching)
              return JavaModelStatus.VERIFIED_OK;
            }
            IClasspathEntry[] containerEntries = container.getClasspathEntries();
            if (containerEntries != null){
              for (int i = 0, length = containerEntries.length; i < length; i++){
                IClasspathEntry containerEntry = containerEntries[i];
                int kind = containerEntry == null ? 0 : containerEntry.getEntryKind();
                if (containerEntry == null
                  || kind == IClasspathEntry.CPE_SOURCE
                  || kind == IClasspathEntry.CPE_VARIABLE
                  || kind == IClasspathEntry.CPE_CONTAINER){
                    return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CP_CONTAINER_ENTRY, project, path);
                }
                IJavaModelStatus containerEntryStatus = validateClasspathEntry(project, containerEntry, container, checkSourceAttachment, true/*referred by container*/);
                if (!containerEntryStatus.isOK()){
                  return containerEntryStatus;
                }
              }
            }
          } catch(JavaModelException e){
            return new JavaModelStatus(e);
          }
        } else {
          return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_illegalContainerPath, new String[] {entryPathMsg, projectName}));
        }
        break;

      // variable entry check
      case IClasspathEntry.CPE_VARIABLE :
        if (path.segmentCount() >= 1){
          try {
            entry = JavaCore.getResolvedClasspathEntry(entry);
          } catch (AssertionFailedException e) {
            // Catch the assertion failure and throw java model exception instead
            // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=55992
            return new JavaModelStatus(IJavaModelStatusConstants.INVALID_PATH, e.getMessage());
          }
          if (entry == null){
            return new JavaModelStatus(IJavaModelStatusConstants.CP_VARIABLE_PATH_UNBOUND, project, path);
          }

          // get validation status
          IJavaModelStatus status = validateClasspathEntry(project, entry, null, checkSourceAttachment, false/*not referred by container*/);
          if (!status.isOK()) return status;

          // return deprecation status if any
          String variableName = path.segment(0);
          String deprecatedMessage = JavaCore.getClasspathVariableDeprecationMessage(variableName);
          if (deprecatedMessage != null) {
            return new JavaModelStatus(IStatus.WARNING, IJavaModelStatusConstants.DEPRECATED_VARIABLE, project, path, deprecatedMessage);
          }
          return status;
        } else {
          return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_illegalVariablePath, new String[] {entryPathMsg, projectName}));
        }

      // library entry check
      case IClasspathEntry.CPE_LIBRARY :
        path = ClasspathEntry.resolveDotDot(project.getProject().getLocation(), path);
       
        // do not validate entries from Class-Path: in manifest
        // (these entries are considered optional since the user cannot act on them)
        // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=252392
       
        String containerInfo = null;
        if (entryContainer != null) {
          if (entryContainer instanceof UserLibraryClasspathContainer) {
            containerInfo = Messages.bind(Messages.classpath_userLibraryInfo, new String[] {entryContainer.getDescription()});
          } else {
            containerInfo = Messages.bind(Messages.classpath_containerInfo, new String[] {entryContainer.getDescription()});
          }
        }
        IJavaModelStatus status = validateLibraryEntry(path, project, containerInfo, checkSourceAttachment ? entry.getSourceAttachmentPath() : null, entryPathMsg);
        // https://bugs.eclipse.org/bugs/show_bug.cgi?id=171136, ignore class path errors from optional entries
        if (status.getCode() == IJavaModelStatusConstants.INVALID_CLASSPATH && ((ClasspathEntry) entry).isOptional())
          status = JavaModelStatus.VERIFIED_OK;
        if (!status.isOK())
          return status;
        break;

      // project entry check
      case IClasspathEntry.CPE_PROJECT :
View Full Code Here

                return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundSourceAttachment, new String [] {sourceAttachment.toString(), path.toString(), project.getElementName()}));
              }
            }
            // https://bugs.eclipse.org/bugs/show_bug.cgi?id=229042
            // Validate the contents of the archive
            IJavaModelStatus status = validateLibraryContents(path, project, entryPathMsg);
            if (status != JavaModelStatus.VERIFIED_OK)
              return status;
            break;
          case IResource.FOLDER :  // internal binary folder
            if (sourceAttachment != null
              && !sourceAttachment.isEmpty()
              && JavaModel.getTarget(sourceAttachment, true) == null){
              if (container != null) {
                return  new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundSourceAttachmentInContainedLibrary, new String [] {sourceAttachment.toString(), path.toString(), container}));
              } else {
                return  new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundSourceAttachment, new String [] {sourceAttachment.toString(), path.toString(), project.getElementName()}));
              }
            }
        }
      } else if (target instanceof File){
        File file = JavaModel.getFile(target);
        if (file == null) {
          if (container != null) {
            return  new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_illegalExternalFolderInContainer, new String[] {path.toOSString(), container}));
          } else {
            return  new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_illegalExternalFolder, new String[] {path.toOSString(), project.getElementName()}));
          }
        } else {
          if (sourceAttachment != null
              && !sourceAttachment.isEmpty()
              && JavaModel.getTarget(sourceAttachment, true) == null){
            if (container != null) {
              return  new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundSourceAttachmentInContainedLibrary, new String [] {sourceAttachment.toString(), path.toOSString(), container}));
            } else {
              return  new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundSourceAttachment, new String [] {sourceAttachment.toString(), path.toOSString(), project.getElementName()}));
            }
          }
          // https://bugs.eclipse.org/bugs/show_bug.cgi?id=229042
          // Validate the contents of the archive
          if(file.isFile()) {
            IJavaModelStatus status = validateLibraryContents(path, project, entryPathMsg);
            if (status != JavaModelStatus.VERIFIED_OK)
              return status;
          }
        }
      } else {
View Full Code Here

    }
    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;
  }
View Full Code Here

    }
    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;
  }
View Full Code Here

}
/**
* @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;
}
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.IJavaModelStatus

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.