Example usage for org.eclipse.jdt.core.compiler CategorizedProblem CAT_BUILDPATH

List of usage examples for org.eclipse.jdt.core.compiler CategorizedProblem CAT_BUILDPATH

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.compiler CategorizedProblem CAT_BUILDPATH.

Prototype

int CAT_BUILDPATH

To view the source code for org.eclipse.jdt.core.compiler CategorizedProblem CAT_BUILDPATH.

Click Source Link

Document

Category for problems related to buildpath

Usage

From source file:astview.ProblemNode.java

License:Open Source License

private String getCategoryCode() {
    CategorizedProblem categorized = (CategorizedProblem) fProblem;
    int categoryID = categorized.getCategoryID();
    StringBuffer buf = new StringBuffer();

    switch (categoryID) {
    case CategorizedProblem.CAT_UNSPECIFIED:
        buf.append("Unspecified");
        break;/*  ww  w . jav a  2 s .c  om*/

    case CategorizedProblem.CAT_BUILDPATH:
        buf.append("Buildpath");
        break;
    case CategorizedProblem.CAT_SYNTAX:
        buf.append("Syntax");
        break;
    case CategorizedProblem.CAT_IMPORT:
        buf.append("Import");
        break;
    case CategorizedProblem.CAT_TYPE:
        buf.append("Type");
        break;
    case CategorizedProblem.CAT_MEMBER:
        buf.append("Member");
        break;
    case CategorizedProblem.CAT_INTERNAL:
        buf.append("Internal");
        break;
    case CategorizedProblem.CAT_JAVADOC:
        buf.append("Javadoc");
        break;
    case CategorizedProblem.CAT_CODE_STYLE:
        buf.append("Code Style");
        break;
    case CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM:
        buf.append("Potential Programming Problem");
        break;
    case CategorizedProblem.CAT_NAME_SHADOWING_CONFLICT:
        buf.append("Name Shadowing Conflict");
        break;
    case CategorizedProblem.CAT_DEPRECATION:
        buf.append("Deprecation");
        break;
    case CategorizedProblem.CAT_UNNECESSARY_CODE:
        buf.append("Unnecessary Code");
        break;
    case CategorizedProblem.CAT_UNCHECKED_RAW:
        buf.append("Unchecked Raw");
        break;
    case CategorizedProblem.CAT_NLS:
        buf.append("NLS");
        break;
    case CategorizedProblem.CAT_RESTRICTION:
        buf.append("Restriction");
        break;
    default:
        buf.append("<UNKNOWN CATEGORY>");
        break;
    }

    buf.append(" = ").append(categoryID);

    return buf.toString();
}

From source file:fromastview.ProblemNode.java

License:Open Source License

private String getCategoryCode() {
    CategorizedProblem categorized = (CategorizedProblem) fProblem;
    int categoryID = categorized.getCategoryID();
    StringBuffer buf = new StringBuffer();

    switch (categoryID) {
    case CategorizedProblem.CAT_UNSPECIFIED:
        buf.append("Unspecified");
        break;//from  w w w. j a v a 2s  .co  m
    case CategorizedProblem.CAT_BUILDPATH:
        buf.append("Buildpath");
        break;
    case CategorizedProblem.CAT_SYNTAX:
        buf.append("Syntax");
        break;
    case CategorizedProblem.CAT_IMPORT:
        buf.append("Import");
        break;
    case CategorizedProblem.CAT_TYPE:
        buf.append("Type");
        break;
    case CategorizedProblem.CAT_MEMBER:
        buf.append("Member");
        break;
    case CategorizedProblem.CAT_INTERNAL:
        buf.append("Internal");
        break;
    case CategorizedProblem.CAT_JAVADOC:
        buf.append("Javadoc");
        break;
    case CategorizedProblem.CAT_CODE_STYLE:
        buf.append("Code Style");
        break;
    case CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM:
        buf.append("Potential Programming Problem");
        break;
    case CategorizedProblem.CAT_NAME_SHADOWING_CONFLICT:
        buf.append("Name Shadowing Conflict");
        break;
    case CategorizedProblem.CAT_DEPRECATION:
        buf.append("Deprecation");
        break;
    case CategorizedProblem.CAT_UNNECESSARY_CODE:
        buf.append("Unnecessary Code");
        break;
    case CategorizedProblem.CAT_UNCHECKED_RAW:
        buf.append("Unchecked Raw");
        break;
    case CategorizedProblem.CAT_NLS:
        buf.append("NLS");
        break;
    case CategorizedProblem.CAT_RESTRICTION:
        buf.append("Restriction");
        break;
    default:
        buf.append("<UNKNOWN CATEGORY>");
        break;
    }

    buf.append(" = ").append(categoryID);

    return buf.toString();
}

From source file:net.sf.j2s.core.builder.AbstractImageBuilder.java

License:Open Source License

/**
 * Creates a marker from each problem and adds it to the resource.
 * The marker is as follows:/*ww  w . j a  va2s . c o  m*/
 *   - its type is T_PROBLEM
 *   - its plugin ID is the JavaBuilder's plugin ID
 *    - its message is the problem's message
 *    - its priority reflects the severity of the problem
 *    - its range is the problem's range
 *    - it has an extra attribute "ID" which holds the problem's id
 *   - it's {@link IMarker#SOURCE_ID} attribute is positioned to {@link JavaBuilder#SOURCE_ID} if
 *     the problem was generated by JDT; else the {@link IMarker#SOURCE_ID} attribute is
 *     carried from the problem to the marker in extra attributes, if present.
 */
protected void storeProblemsFor(SourceFile sourceFile, CategorizedProblem[] problems) throws CoreException {
    if (sourceFile == null || problems == null || problems.length == 0)
        return;
    // once a classpath error is found, ignore all other problems for this project so the user can see the main error
    // but still try to compile as many source files as possible to help the case when the base libraries are in source
    if (!this.keepStoringProblemMarkers)
        return; // only want the one error recorded on this source file

    HashSet managedMarkerTypes = JavaModelManager.getJavaModelManager().compilationParticipants
            .managedMarkerTypes();
    problems: for (int i = 0, l = problems.length; i < l; i++) {
        CategorizedProblem problem = problems[i];
        int id = problem.getID();
        // we may use a different resource for certain problems such as IProblem.MissingNonNullByDefaultAnnotationOnPackage
        // but at the start of the next problem we should reset it to the source file's resource
        IResource resource = sourceFile.resource;

        // handle missing classfile situation
        if (id == IProblem.IsClassPathCorrect) {
            String missingClassfileName = problem.getArguments()[0];
            if (JavaBuilder.DEBUG)
                System.out.println(Messages.bind(Messages.build_incompleteClassPath, missingClassfileName));
            boolean isInvalidClasspathError = JavaCore.ERROR
                    .equals(this.javaBuilder.javaProject.getOption(JavaCore.CORE_INCOMPLETE_CLASSPATH, true));
            // insert extra classpath problem, and make it the only problem for this project (optional)
            if (isInvalidClasspathError && JavaCore.ABORT.equals(
                    this.javaBuilder.javaProject.getOption(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, true))) {
                JavaBuilder.removeProblemsAndTasksFor(this.javaBuilder.currentProject); // make this the only problem for this project
                this.keepStoringProblemMarkers = false;
            }
            IMarker marker = this.javaBuilder.currentProject
                    .createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
            marker.setAttributes(
                    new String[] { IMarker.MESSAGE, IMarker.SEVERITY, IJavaModelMarker.CATEGORY_ID,
                            IMarker.SOURCE_ID },
                    new Object[] { Messages.bind(Messages.build_incompleteClassPath, missingClassfileName),
                            new Integer(isInvalidClasspathError ? IMarker.SEVERITY_ERROR
                                    : IMarker.SEVERITY_WARNING),
                            new Integer(CategorizedProblem.CAT_BUILDPATH), JavaBuilder.SOURCE_ID });
            // even if we're not keeping more markers, still fall through rest of the problem reporting, so that offending
            // IsClassPathCorrect problem gets recorded since it may help locate the offending reference
        }

        String markerType = problem.getMarkerType();
        boolean managedProblem = false;
        if (IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER.equals(markerType)
                || (managedProblem = managedMarkerTypes.contains(markerType))) {
            if (id == IProblem.MissingNonNullByDefaultAnnotationOnPackage
                    && !(CharOperation.equals(sourceFile.getMainTypeName(), TypeConstants.PACKAGE_INFO_NAME))) {
                // for this kind of problem, marker needs to be created on the package instead of on the source file
                // see bug 372012
                char[] fileName = sourceFile.getFileName();
                int pkgEnd = CharOperation.lastIndexOf('/', fileName);
                if (pkgEnd == -1)
                    pkgEnd = CharOperation.lastIndexOf(File.separatorChar, fileName);
                PackageFragment pkg = null;
                if (pkgEnd != -1)
                    pkg = (PackageFragment) Util.getPackageFragment(sourceFile.getFileName(), pkgEnd,
                            -1 /*no jar separator for java files*/);

                if (pkg != null) {
                    try {
                        IMarker[] existingMarkers = pkg.resource().findMarkers(
                                IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_ZERO);
                        int len = existingMarkers.length;
                        for (int j = 0; j < len; j++) {
                            if (((Integer) existingMarkers[j].getAttribute(IJavaModelMarker.ID))
                                    .intValue() == IProblem.MissingNonNullByDefaultAnnotationOnPackage) {
                                continue problems; // marker already present
                            }
                        }
                    } catch (CoreException e) {
                        // marker retrieval failed, cannot do much
                        if (JavaModelManager.VERBOSE) {
                            e.printStackTrace();
                        }
                    }
                    IResource tempRes = pkg.resource();
                    if (tempRes != null) {
                        resource = tempRes;
                    }
                }
            }
            IMarker marker = resource.createMarker(markerType);

            String[] attributeNames = JAVA_PROBLEM_MARKER_ATTRIBUTE_NAMES;
            int standardLength = attributeNames.length;
            String[] allNames = attributeNames;
            int managedLength = managedProblem ? 0 : 1;
            String[] extraAttributeNames = problem.getExtraMarkerAttributeNames();
            int extraLength = extraAttributeNames == null ? 0 : extraAttributeNames.length;
            if (managedLength > 0 || extraLength > 0) {
                allNames = new String[standardLength + managedLength + extraLength];
                System.arraycopy(attributeNames, 0, allNames, 0, standardLength);
                if (managedLength > 0)
                    allNames[standardLength] = IMarker.SOURCE_ID;
                System.arraycopy(extraAttributeNames, 0, allNames, standardLength + managedLength, extraLength);
            }

            Object[] allValues = new Object[allNames.length];
            // standard attributes
            int index = 0;
            allValues[index++] = problem.getMessage(); // message
            allValues[index++] = problem.isError() ? S_ERROR : S_WARNING; // severity
            allValues[index++] = new Integer(id); // ID
            allValues[index++] = new Integer(problem.getSourceStart()); // start
            allValues[index++] = new Integer(problem.getSourceEnd() + 1); // end
            allValues[index++] = new Integer(problem.getSourceLineNumber()); // line
            allValues[index++] = Util.getProblemArgumentsForMarker(problem.getArguments()); // arguments
            allValues[index++] = new Integer(problem.getCategoryID()); // category ID
            // SOURCE_ID attribute for JDT problems
            if (managedLength > 0)
                allValues[index++] = JavaBuilder.SOURCE_ID;
            // optional extra attributes
            if (extraLength > 0)
                System.arraycopy(problem.getExtraMarkerAttributeValues(), 0, allValues, index, extraLength);

            marker.setAttributes(allNames, allValues);

            if (!this.keepStoringProblemMarkers)
                return; // only want the one error recorded on this source file
        }
    }
}

From source file:net.sf.j2s.core.builder.JavaBuilder.java

License:Open Source License

private void createInconsistentBuildMarker(CoreException coreException) throws CoreException {
    String message = null;// ww w . j  a v a 2  s  .  c o  m
    IStatus status = coreException.getStatus();
    if (status.isMultiStatus()) {
        IStatus[] children = status.getChildren();
        if (children != null && children.length > 0)
            message = children[0].getMessage();
    }
    if (message == null)
        message = coreException.getMessage();

    IMarker marker = this.currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
    marker.setAttributes(
            new String[] { IMarker.MESSAGE, IMarker.SEVERITY, IJavaModelMarker.CATEGORY_ID, IMarker.SOURCE_ID },
            new Object[] { Messages.bind(Messages.build_inconsistentProject, message),
                    new Integer(IMarker.SEVERITY_ERROR), new Integer(CategorizedProblem.CAT_BUILDPATH),
                    JavaBuilder.SOURCE_ID });
}

From source file:net.sf.j2s.core.builder.JavaBuilder.java

License:Open Source License

boolean hasBuildpathErrors() throws CoreException {
    IMarker[] markers = this.currentProject.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, false,
            IResource.DEPTH_ZERO);/*from   w  ww . j a  va 2  s .c  o  m*/
    for (int i = 0, l = markers.length; i < l; i++)
        if (markers[i].getAttribute(IJavaModelMarker.CATEGORY_ID, -1) == CategorizedProblem.CAT_BUILDPATH)
            return true;
    return false;
}

From source file:net.sf.j2s.core.builder.JavaBuilder.java

License:Open Source License

private boolean isWorthBuilding() throws CoreException {
    boolean abortBuilds = JavaCore.ABORT
            .equals(this.javaProject.getOption(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, true));
    if (!abortBuilds)
        return true;

    // Abort build only if there are classpath errors
    if (isClasspathBroken(this.javaProject.getRawClasspath(), this.currentProject)) {
        if (DEBUG)
            System.out.println(// w  ww . j av a  2 s. co  m
                    "JavaBuilder: Aborted build because project has classpath errors (incomplete or involved in cycle)"); //$NON-NLS-1$

        removeProblemsAndTasksFor(this.currentProject); // remove all compilation problems

        IMarker marker = this.currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
        marker.setAttributes(
                new String[] { IMarker.MESSAGE, IMarker.SEVERITY, IJavaModelMarker.CATEGORY_ID,
                        IMarker.SOURCE_ID },
                new Object[] { Messages.build_abortDueToClasspathProblems, new Integer(IMarker.SEVERITY_ERROR),
                        new Integer(CategorizedProblem.CAT_BUILDPATH), JavaBuilder.SOURCE_ID });
        return false;
    }

    if (JavaCore.WARNING.equals(this.javaProject.getOption(JavaCore.CORE_INCOMPLETE_CLASSPATH, true)))
        return true;

    // make sure all prereq projects have valid build states... only when aborting builds since projects in cycles do not have build states
    // except for projects involved in a 'warning' cycle (see below)
    IProject[] requiredProjects = getRequiredProjects(false);
    for (int i = 0, l = requiredProjects.length; i < l; i++) {
        IProject p = requiredProjects[i];
        if (getLastState(p) == null) {
            // The prereq project has no build state: if this prereq project has a 'warning' cycle marker then allow build (see bug id 23357)
            JavaProject prereq = (JavaProject) JavaCore.create(p);
            if (prereq.hasCycleMarker() && JavaCore.WARNING
                    .equals(this.javaProject.getOption(JavaCore.CORE_CIRCULAR_CLASSPATH, true))) {
                if (DEBUG)
                    System.out
                            .println("JavaBuilder: Continued to build even though prereq project " + p.getName() //$NON-NLS-1$
                                    + " was not built since its part of a cycle"); //$NON-NLS-1$
                continue;
            }
            if (!hasJavaBuilder(p)) {
                if (DEBUG)
                    System.out
                            .println("JavaBuilder: Continued to build even though prereq project " + p.getName() //$NON-NLS-1$
                                    + " is not built by JavaBuilder"); //$NON-NLS-1$
                continue;
            }
            if (DEBUG)
                System.out.println("JavaBuilder: Aborted build because prereq project " + p.getName() //$NON-NLS-1$
                        + " was not built"); //$NON-NLS-1$

            removeProblemsAndTasksFor(this.currentProject); // make this the only problem for this project
            IMarker marker = this.currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
            marker.setAttributes(
                    new String[] { IMarker.MESSAGE, IMarker.SEVERITY, IJavaModelMarker.CATEGORY_ID,
                            IMarker.SOURCE_ID },
                    new Object[] {
                            isClasspathBroken(prereq.getRawClasspath(), p)
                                    ? Messages.bind(Messages.build_prereqProjectHasClasspathProblems,
                                            p.getName())
                                    : Messages.bind(Messages.build_prereqProjectMustBeRebuilt, p.getName()),
                            new Integer(IMarker.SEVERITY_ERROR), new Integer(CategorizedProblem.CAT_BUILDPATH),
                            JavaBuilder.SOURCE_ID });
            return false;
        }
    }
    return true;
}

From source file:org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.java

License:Open Source License

/**
 * Creates a marker from each problem and adds it to the resource.
 * The marker is as follows:/*from  ww w.  ja  va  2 s.  com*/
 *   - its type is T_PROBLEM
 *   - its plugin ID is the JavaBuilder's plugin ID
 *    - its message is the problem's message
 *    - its priority reflects the severity of the problem
 *    - its range is the problem's range
 *    - it has an extra attribute "ID" which holds the problem's id
 *   - it's {@link IMarker#SOURCE_ID} attribute is positioned to {@link JavaBuilder#SOURCE_ID} if
 *     the problem was generated by JDT; else the {@link IMarker#SOURCE_ID} attribute is
 *     carried from the problem to the marker in extra attributes, if present.
 */
protected void storeProblemsFor(SourceFile sourceFile, CategorizedProblem[] problems) throws CoreException {
    if (sourceFile == null || problems == null || problems.length == 0)
        return;
    // once a classpath error is found, ignore all other problems for this project so the user can see the main error
    // but still try to compile as many source files as possible to help the case when the base libraries are in source
    if (!this.keepStoringProblemMarkers)
        return; // only want the one error recorded on this source file

    IResource resource = sourceFile.resource;
    HashSet managedMarkerTypes = JavaModelManager.getJavaModelManager().compilationParticipants
            .managedMarkerTypes();
    for (int i = 0, l = problems.length; i < l; i++) {
        CategorizedProblem problem = problems[i];
        int id = problem.getID();

        // handle missing classfile situation
        if (id == IProblem.IsClassPathCorrect) {
            String missingClassfileName = problem.getArguments()[0];
            if (JavaBuilder.DEBUG)
                System.out.println(Messages.bind(Messages.build_incompleteClassPath, missingClassfileName));
            boolean isInvalidClasspathError = JavaCore.ERROR
                    .equals(this.javaBuilder.javaProject.getOption(JavaCore.CORE_INCOMPLETE_CLASSPATH, true));
            // insert extra classpath problem, and make it the only problem for this project (optional)
            if (isInvalidClasspathError && JavaCore.ABORT.equals(
                    this.javaBuilder.javaProject.getOption(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, true))) {
                JavaBuilder.removeProblemsAndTasksFor(this.javaBuilder.currentProject); // make this the only problem for this project
                this.keepStoringProblemMarkers = false;
            }
            IMarker marker = this.javaBuilder.currentProject
                    .createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
            marker.setAttributes(
                    new String[] { IMarker.MESSAGE, IMarker.SEVERITY, IJavaModelMarker.CATEGORY_ID,
                            IMarker.SOURCE_ID },
                    new Object[] { Messages.bind(Messages.build_incompleteClassPath, missingClassfileName),
                            new Integer(isInvalidClasspathError ? IMarker.SEVERITY_ERROR
                                    : IMarker.SEVERITY_WARNING),
                            new Integer(CategorizedProblem.CAT_BUILDPATH), JavaBuilder.SOURCE_ID });
            // even if we're not keeping more markers, still fall through rest of the problem reporting, so that offending
            // IsClassPathCorrect problem gets recorded since it may help locate the offending reference
        }

        String markerType = problem.getMarkerType();
        boolean managedProblem = false;
        if (IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER.equals(markerType)
                || (managedProblem = managedMarkerTypes.contains(markerType))) {
            IMarker marker = resource.createMarker(markerType);

            String[] attributeNames = JAVA_PROBLEM_MARKER_ATTRIBUTE_NAMES;
            int standardLength = attributeNames.length;
            String[] allNames = attributeNames;
            int managedLength = managedProblem ? 0 : 1;
            String[] extraAttributeNames = problem.getExtraMarkerAttributeNames();
            int extraLength = extraAttributeNames == null ? 0 : extraAttributeNames.length;
            if (managedLength > 0 || extraLength > 0) {
                allNames = new String[standardLength + managedLength + extraLength];
                System.arraycopy(attributeNames, 0, allNames, 0, standardLength);
                if (managedLength > 0)
                    allNames[standardLength] = IMarker.SOURCE_ID;
                System.arraycopy(extraAttributeNames, 0, allNames, standardLength + managedLength, extraLength);
            }

            Object[] allValues = new Object[allNames.length];
            // standard attributes
            int index = 0;
            allValues[index++] = problem.getMessage(); // message
            allValues[index++] = problem.isError() ? S_ERROR : S_WARNING; // severity
            allValues[index++] = new Integer(id); // ID
            allValues[index++] = new Integer(problem.getSourceStart()); // start
            int end = problem.getSourceEnd();
            allValues[index++] = new Integer(end > 0 ? end + 1 : end); // end
            allValues[index++] = new Integer(problem.getSourceLineNumber()); // line
            allValues[index++] = Util.getProblemArgumentsForMarker(problem.getArguments()); // arguments
            allValues[index++] = new Integer(problem.getCategoryID()); // category ID
            // SOURCE_ID attribute for JDT problems
            if (managedLength > 0)
                allValues[index++] = JavaBuilder.SOURCE_ID;
            // optional extra attributes
            if (extraLength > 0)
                System.arraycopy(problem.getExtraMarkerAttributeValues(), 0, allValues, index, extraLength);

            marker.setAttributes(allNames, allValues);

            if (!this.keepStoringProblemMarkers)
                return; // only want the one error recorded on this source file
        }
    }
}

From source file:org.eclipse.jdt.internal.core.JavaProject.java

License:Open Source License

/**
 * Record a new marker denoting a classpath problem
 *//*from w ww . j ava2  s.  com*/
public void createClasspathProblemMarker(IJavaModelStatus status) {

    IMarker marker = null;
    int severity;
    String[] arguments = CharOperation.NO_STRINGS;
    boolean isCycleProblem = false, isClasspathFileFormatProblem = false, isOutputOverlapping = false;
    switch (status.getCode()) {

    case IJavaModelStatusConstants.CLASSPATH_CYCLE:
        isCycleProblem = true;
        if (JavaCore.ERROR.equals(getOption(JavaCore.CORE_CIRCULAR_CLASSPATH, true))) {
            severity = IMarker.SEVERITY_ERROR;
        } else {
            severity = IMarker.SEVERITY_WARNING;
        }
        break;

    case IJavaModelStatusConstants.INVALID_CLASSPATH_FILE_FORMAT:
        isClasspathFileFormatProblem = true;
        severity = IMarker.SEVERITY_ERROR;
        break;

    case IJavaModelStatusConstants.INCOMPATIBLE_JDK_LEVEL:
        String setting = getOption(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL, true);
        if (JavaCore.ERROR.equals(setting)) {
            severity = IMarker.SEVERITY_ERROR;
        } else if (JavaCore.WARNING.equals(setting)) {
            severity = IMarker.SEVERITY_WARNING;
        } else {
            return; // setting == IGNORE
        }
        break;
    case IJavaModelStatusConstants.OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE:
        isOutputOverlapping = true;
        setting = getOption(JavaCore.CORE_OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE, true);
        if (JavaCore.ERROR.equals(setting)) {
            severity = IMarker.SEVERITY_ERROR;
        } else if (JavaCore.WARNING.equals(setting)) {
            severity = IMarker.SEVERITY_WARNING;
        } else {
            return; // setting == IGNORE
        }
        break;
    default:
        IPath path = status.getPath();
        if (path != null)
            arguments = new String[] { path.toString() };
        if (JavaCore.ERROR.equals(getOption(JavaCore.CORE_INCOMPLETE_CLASSPATH, true))
                && status.getSeverity() != IStatus.WARNING) {
            severity = IMarker.SEVERITY_ERROR;
        } else {
            severity = IMarker.SEVERITY_WARNING;
        }
        break;
    }

    try {
        marker = this.project.createMarker(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER);
        marker.setAttributes(
                new String[] { IMarker.MESSAGE, IMarker.SEVERITY, IMarker.LOCATION,
                        IJavaModelMarker.CYCLE_DETECTED, IJavaModelMarker.CLASSPATH_FILE_FORMAT,
                        IJavaModelMarker.OUTPUT_OVERLAPPING_SOURCE, IJavaModelMarker.ID,
                        IJavaModelMarker.ARGUMENTS, IJavaModelMarker.CATEGORY_ID, IMarker.SOURCE_ID, },
                new Object[] { status.getMessage(), new Integer(severity), Messages.classpath_buildPath,
                        isCycleProblem ? "true" : "false", //$NON-NLS-1$ //$NON-NLS-2$
                        isClasspathFileFormatProblem ? "true" : "false", //$NON-NLS-1$ //$NON-NLS-2$
                        isOutputOverlapping ? "true" : "false", //$NON-NLS-1$ //$NON-NLS-2$
                        new Integer(status.getCode()), Util.getProblemArgumentsForMarker(arguments),
                        new Integer(CategorizedProblem.CAT_BUILDPATH), JavaBuilder.SOURCE_ID, });
    } catch (CoreException e) {
        // could not create marker: cannot do much
        if (JavaModelManager.VERBOSE) {
            e.printStackTrace();
        }
    }
}

From source file:org.eclipse.objectteams.otdt.internal.migration.MigrationMarkers.java

License:Open Source License

/** 
 * Add a marker./*from   w  ww .  j a  v a  2s .  c o  m*/
 * @param    the resource to which the marker should be added
 * @param   the marker message
 * @param    problemID one of {@link #PROBLEM_ID_BUILDER}, {@link #PROBLEM_ID_NATURE}, 
 *          {@link #PROBLEM_ID_OTEQUINOX_BUNDLE} or  {@link #PROBLEM_ID_EXTENSIONPOINT}. 
 * @param   lineNo line number within the resource where the error occurred
 */
public static void addProblemMarker(IResource resource, String message, int problemID, int lineNo) {
    try {
        IMarker marker = resource.createMarker(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER);
        marker.setAttributes(
                new String[] { IMarker.MESSAGE, IMarker.SEVERITY, IJavaModelMarker.CATEGORY_ID,
                        MigrationMarkers.PROBLEM_ID, IMarker.SOURCE_ID },
                new Object[] { message, new Integer(IMarker.SEVERITY_ERROR),
                        new Integer(CategorizedProblem.CAT_BUILDPATH), new Integer(problemID),
                        MigrationMarkers.SOURCE_ID_OTDT });
        if (lineNo > -1)
            marker.setAttribute(IMarker.LINE_NUMBER, new Integer(lineNo));
    } catch (CoreException ce) {
        OTPDEUIPlugin.getDefault().getLog()
                .log(new Status(IStatus.ERROR, OTPDEUIPlugin.PLUGIN_ID, "Error setting problem marker", ce)); //$NON-NLS-1$
    }
}

From source file:org.eclipse.objectteams.otdt.internal.migration.MigrationMarkers.java

License:Open Source License

/**
 * Remove all migration markers specified by the arguments:
 * @param resource only markers of this resource
 * @param handledIDs only markers with a {@link #PROBLEM_ID} from this set 
 *//*  w w  w. j a  v a2  s. com*/
public static void removeMarkers(IResource resource, int[] handledIDs) {
    try {
        for (IMarker existingMarker : resource.findMarkers(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER, false,
                IResource.DEPTH_ZERO)) {
            if (existingMarker.getAttribute(IJavaModelMarker.CATEGORY_ID, 0) == CategorizedProblem.CAT_BUILDPATH
                    && MigrationMarkers.SOURCE_ID_OTDT.equals(existingMarker.getAttribute(IMarker.SOURCE_ID))) {
                int id = existingMarker.getAttribute(PROBLEM_ID, 0);
                for (int handledID : handledIDs)
                    if (handledID == id) {
                        existingMarker.delete();
                        break;
                    }
            }
        }
    } catch (CoreException ce) {
        OTPDEUIPlugin.getDefault().getLog()
                .log(new Status(IStatus.ERROR, OTPDEUIPlugin.PLUGIN_ID, "Error deleting problem markers", ce)); //$NON-NLS-1$
    }
}