Example usage for org.eclipse.jdt.core.compiler IProblem Internal

List of usage examples for org.eclipse.jdt.core.compiler IProblem Internal

Introduction

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

Prototype

int Internal

To view the source code for org.eclipse.jdt.core.compiler IProblem Internal.

Click Source Link

Usage

From source file:astview.ProblemNode.java

License:Open Source License

private String getErrorLabel() {
    int id = fProblem.getID();
    StringBuffer buf = new StringBuffer();

    if ((id & IProblem.TypeRelated) != 0) {
        buf.append("TypeRelated + "); //$NON-NLS-1$
    }//from   ww  w  .  j av a2 s .  com
    if ((id & IProblem.FieldRelated) != 0) {
        buf.append("FieldRelated + "); //$NON-NLS-1$
    }
    if ((id & IProblem.ConstructorRelated) != 0) {
        buf.append("ConstructorRelated + "); //$NON-NLS-1$
    }
    if ((id & IProblem.MethodRelated) != 0) {
        buf.append("MethodRelated + "); //$NON-NLS-1$
    }
    if ((id & IProblem.ImportRelated) != 0) {
        buf.append("ImportRelated + "); //$NON-NLS-1$
    }
    if ((id & IProblem.Internal) != 0) {
        buf.append("Internal + "); //$NON-NLS-1$
    }
    if ((id & IProblem.Syntax) != 0) {
        buf.append("Syntax + "); //$NON-NLS-1$
    }
    if ((id & IProblem.Javadoc) != 0) {
        buf.append("Javadoc + "); //$NON-NLS-1$
    }
    buf.append(id & IProblem.IgnoreCategoriesMask);

    buf.append(" = 0x").append(Integer.toHexString(id)).append(" = ").append(id);

    return buf.toString();
}

From source file:fromastview.ProblemNode.java

License:Open Source License

private String getErrorLabel() {
    int id = fProblem.getID();
    StringBuffer buf = new StringBuffer();

    if ((id & IProblem.TypeRelated) != 0) {
        buf.append("TypeRelated + ");
    }/*w ww  .j  a v  a2 s .c o m*/
    if ((id & IProblem.FieldRelated) != 0) {
        buf.append("FieldRelated + ");
    }
    if ((id & IProblem.ConstructorRelated) != 0) {
        buf.append("ConstructorRelated + ");
    }
    if ((id & IProblem.MethodRelated) != 0) {
        buf.append("MethodRelated + ");
    }
    if ((id & IProblem.ImportRelated) != 0) {
        buf.append("ImportRelated + ");
    }
    if ((id & IProblem.Internal) != 0) {
        buf.append("Internal + ");
    }
    if ((id & IProblem.Syntax) != 0) {
        buf.append("Syntax + ");
    }
    if ((id & IProblem.Javadoc) != 0) {
        buf.append("Javadoc + ");
    }
    buf.append(id & IProblem.IgnoreCategoriesMask);

    buf.append(" = 0x").append(Integer.toHexString(id)).append(" = ").append(id);

    return buf.toString();
}

From source file:org.eclipse.jst.jsp.core.internal.validation.JSPJavaValidator.java

License:Open Source License

/**
 * Creates an IMessage from asn IProblem
 * // ww  w . ja  v a  2s  . co  m
 * @param problem
 * @param f
 * @param translation
 * @param structuredDoc
 * @return message representation of the problem, or null if it could not
 *         create one
 */
private IMessage createMessageFromProblem(IProblem problem, IFile f, IJSPTranslation translation,
        IStructuredDocument structuredDoc) {
    int sev = -1;
    int sourceStart = -1;
    int sourceEnd = -1;

    if (problem instanceof IJSPProblem) {
        sourceStart = problem.getSourceStart();
        sourceEnd = problem.getSourceEnd();
        switch (((IJSPProblem) problem).getEID()) {
        case IJSPProblem.TEIClassNotFound:
            sev = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_TRANSLATION_TEI_CLASS_NOT_FOUND);
            break;
        case IJSPProblem.TEIValidationMessage:
            sev = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_TRANSLATION_TEI_VALIDATION_MESSAGE);
            break;
        case IJSPProblem.TEIClassNotInstantiated:
            sev = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_TRANSLATION_TEI_CLASS_NOT_INSTANTIATED);
            break;
        case IJSPProblem.TEIClassMisc:
            sev = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_TRANSLATION_TEI_CLASS_RUNTIME_EXCEPTION);
            break;
        case IJSPProblem.TagClassNotFound:
            sev = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_TRANSLATION_TAG_HANDLER_CLASS_NOT_FOUND);
            break;
        case IJSPProblem.UseBeanInvalidID:
            sev = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_TRANSLATION_USEBEAN_INVALID_ID);
            break;
        case IJSPProblem.UseBeanMissingTypeInfo:
            sev = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_TRANSLATION_USBEAN_MISSING_TYPE_INFO);
            break;
        case IJSPProblem.UseBeanAmbiguousType:
            sev = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_TRANSLATION_USEBEAN_AMBIGUOUS_TYPE_INFO);
            break;
        default:
            sev = problem.isError() ? IMessage.HIGH_SEVERITY
                    : (problem.isWarning() ? IMessage.NORMAL_SEVERITY : ValidationMessage.IGNORE);

        }
    } else {
        sourceStart = translation.getJspOffset(problem.getSourceStart());
        sourceEnd = translation.getJspOffset(problem.getSourceEnd());
        switch (problem.getID()) {
        case IProblem.LocalVariableIsNeverUsed: {
            sev = getSourceSeverity(JSPCorePreferenceNames.VALIDATION_JAVA_LOCAL_VARIABLE_NEVER_USED,
                    sourceStart, sourceEnd);
        }
            break;
        case IProblem.NullLocalVariableReference: {
            sev = getSourceSeverity(JSPCorePreferenceNames.VALIDATION_JAVA_NULL_LOCAL_VARIABLE_REFERENCE,
                    sourceStart, sourceEnd);
        }
            break;
        case IProblem.ArgumentIsNeverUsed: {
            sev = getSourceSeverity(JSPCorePreferenceNames.VALIDATION_JAVA_ARGUMENT_IS_NEVER_USED, sourceStart,
                    sourceEnd);
        }
            break;
        case IProblem.PotentialNullLocalVariableReference: {
            sev = getSourceSeverity(
                    JSPCorePreferenceNames.VALIDATION_JAVA_POTENTIAL_NULL_LOCAL_VARIABLE_REFERENCE, sourceStart,
                    sourceEnd);
        }
            break;
        case IProblem.UnusedImport: {
            sev = getSourceSeverity(JSPCorePreferenceNames.VALIDATION_JAVA_UNUSED_IMPORT, sourceStart,
                    sourceEnd);
        }
            break;
        case IProblem.UnusedPrivateField:
        case IProblem.MissingSerialVersion: {
            // JSP files don't get serialized...right?
            sev = ValidationMessage.IGNORE;
        }
            break;

        default: {
            if (problem.isError()) {
                sev = IMessage.HIGH_SEVERITY;
            } else if (problem.isWarning()) {
                sev = IMessage.NORMAL_SEVERITY;
            } else {
                sev = IMessage.LOW_SEVERITY;
            }
        }
            if (sev == ValidationMessage.IGNORE) {
                return null;
            }

            /* problems without JSP positions are in generated code */
            if (sourceStart == -1) {
                int problemID = problem.getID();
                /*
                 * Quoting IProblem doc: "When a problem is tagged as
                 * Internal, it means that no change other than a
                 * local source code change can fix the corresponding
                 * problem." Assuming that our generated code is
                 * correct, that should reduce the reported problems
                 * to those the user can correct.
                 */
                if (((problemID & IProblem.Internal) != 0) && ((problemID & IProblem.Syntax) != 0)
                        && translation instanceof JSPTranslation) {
                    // Attach to the last code scripting section
                    JSPTranslation jspTranslation = ((JSPTranslation) translation);
                    Position[] jspPositions = (Position[]) jspTranslation.getJsp2JavaMap().keySet()
                            .toArray(new Position[jspTranslation.getJsp2JavaMap().size()]);
                    for (int i = 0; i < jspPositions.length; i++) {
                        sourceStart = Math.max(sourceStart, jspPositions[i].getOffset());
                    }
                    IMessage m = new LocalizedMessage(sev, problem.getMessage(), f);
                    m.setOffset(sourceStart);
                    m.setLength(1);
                    return m;
                } else {
                    return null;
                }
            }
        }
    }
    if (sev == ValidationMessage.IGNORE) {
        return null;
    }

    final boolean isIndirect = translation.isIndirect(problem.getSourceStart());
    if (isIndirect && !FragmentValidationTools.shouldValidateFragment(f)) {
        return null;
    }

    // line number for marker starts @ 1
    // line number from document starts @ 0
    int lineNo = structuredDoc.getLineOfOffset(sourceStart) + 1;

    IMessage m = new LocalizedMessage(sev, problem.getMessage(), f);

    m.setLineNo(lineNo);
    m.setOffset(sourceStart);
    m.setLength((sourceEnd >= sourceStart) ? (sourceEnd - sourceStart + 1) : 0);

    // need additional adjustment for problems from
    // indirect (included) files
    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=119633
    if (isIndirect) {
        adjustIndirectPosition(m, translation);
    }

    return m;
}