Examples of IJavaModelStatus


Examples of org.eclipse.jdt.core.IJavaModelStatus

    }

    // 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*/, false/*overlapping*/);
    if (!status.isOK())
      this.project.createClasspathProblemMarker(status);

    // update overlapping output problem markers
    this.project.flushClasspathProblemMarkers(false/*cycle*/, false/*format*/, true/*overlapping*/);
   
    // update resolved classpath problems
    this.project.flushClasspathProblemMarkers(false/*cycle*/, false/*format*/, false/*overlapping*/);

    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.getCode() != IStatus.OK)
        this.project.createClasspathProblemMarker(status);
     }
  }
View Full Code Here

Examples of org.eclipse.jdt.core.IJavaModelStatus

    // ensure that no specific output is coincidating with another source folder (only allowed if matching current source folder)
    // 36465 - for 2.0 backward compatibility, only check specific output locations (the default can still coincidate)
    // perform one separate iteration so as to not take precedence over previously checked scenarii (in particular should
    // diagnose nesting source folder issue before this one, for example, [src]"Project/", [src]"Project/source/" and output="Project/" should
    // first complain about missing exclusion pattern
    IJavaModelStatus cachedStatus = null;
    for (int i = 0 ; i < length; i++) {
      IClasspathEntry entry = classpath[i];
      if (entry == null) continue;
      IPath entryPath = entry.getPath();
      int kind = entry.getEntryKind();
View Full Code Here

Examples of org.eclipse.jdt.core.IJavaModelStatus

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

Examples of org.eclipse.jdt.core.IJavaModelStatus

      // 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, ((ClasspathEntry) entry).isOptional());
        if (!status.isOK())
          return status;
        break;

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

Examples of org.eclipse.jdt.core.IJavaModelStatus

                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

Examples of org.eclipse.jdt.core.IJavaModelStatus

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

Examples of org.eclipse.jdt.core.IJavaModelStatus

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

Examples of org.eclipse.jdt.core.IJavaModelStatus

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

Examples of org.eclipse.jdt.core.IJavaModelStatus

  {
    FileOffsets offsets = FileOffsets.compile(classpath);
    String classpathValue = IOUtils.toString(new FileInputStream(classpath));
    ArrayList<Error> errors = new ArrayList<Error>();
    for(IClasspathEntry entry : entries){
      IJavaModelStatus status = JavaConventions
        .validateClasspathEntry(javaProject, entry, true);
      if(!status.isOK()){
        errors.add(createErrorForEntry(
              javaProject, entry, status, offsets, classpath, classpathValue));
      }
    }

    IJavaModelStatus status = JavaConventions.validateClasspath(
        javaProject, entries, javaProject.getOutputLocation());

    // always set the classpathValue anyways, so that the user can correct the
    // file.
    //if(status.isOK() && errors.isEmpty()){
      javaProject.setRawClasspath(entries, null);
      javaProject.makeConsistent(null);
    //}

    if(!status.isOK()){
      errors.add(new Error(status.getMessage(), classpath, 1, 1, false));
    }
    return errors;
  }
View Full Code Here

Examples of org.eclipse.jdt.core.IJavaModelStatus

    }
    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
TOP
Copyright © 2018 www.massapi.com. 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.