Java Code Examples for org.netbeans.spi.editor.hints.ErrorDescription#getSeverity()

The following examples show how to use org.netbeans.spi.editor.hints.ErrorDescription#getSeverity() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnnotationHolder.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static List<ErrorDescription> filter(List<ErrorDescription> errors, boolean onlyErrors) {
    List<ErrorDescription> result = new ArrayList<ErrorDescription>();

    for (ErrorDescription e : errors) {
        if (e.getSeverity() == Severity.ERROR) {
            if (onlyErrors)
                result.add(e);
        } else {
            if (!onlyErrors)
                result.add(e);
        }
    }

    return result;
}
 
Example 2
Source File: AnnotationHolder.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public synchronized boolean hasErrors() {
    for (ErrorDescription e : errors2Lines.keySet()) {
        if (e.getSeverity() == Severity.ERROR)
            return true;
    }

    return false;
}
 
Example 3
Source File: NextErrorAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private String buildText(List<ErrorDescription> errors) {
    List<ErrorDescription> trueErrors = new LinkedList<ErrorDescription>();
    List<ErrorDescription> others = new LinkedList<ErrorDescription>();

    for (ErrorDescription ed : errors) {
        if (ed == null) {
            continue;
        }

        if (ed.getSeverity() == Severity.ERROR) {
            trueErrors.add(ed);
        } else {
            others.add(ed);
        }
    }

    //build up the description of the annotation:
    StringBuffer description = new StringBuffer();

    concatDescription(trueErrors, description);

    if (!trueErrors.isEmpty() && !others.isEmpty()) {
        description.append(" ");
    }

    concatDescription(others, description);

    return description.toString().replace('\n', ' ');
}
 
Example 4
Source File: AnnotationHolder.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void updateAnnotationOnLine(Position line, boolean synchronous) throws BadLocationException {
    List<ErrorDescription> errorDescriptions = getErrorsForLine(line, false);

    if (errorDescriptions == null) errorDescriptions = Collections.emptyList();
    else errorDescriptions = new ArrayList<>(errorDescriptions);

    Severity mostImportantSeverity = Severity.HINT;
    String customType = null;
    
    for (Iterator<ErrorDescription> it = errorDescriptions.iterator(); it.hasNext();) {
        ErrorDescription ed = it.next();
        List<Position> positions = errors2Lines.get(ed);

        if (positions == null || positions.isEmpty() || positions.get(0) != line) {
            it.remove();
        } else {
            if (mostImportantSeverity.compareTo(ed.getSeverity()) > 0) {
                mostImportantSeverity = ed.getSeverity();
            }
            customType = ed.getCustomType();
        }
    }

    if (errorDescriptions.isEmpty()) {
        //nothing to do, remove old:
        ParseErrorAnnotation ann = line2Annotations.remove(line);
        if (ann != null) {
            detachAnnotation(ann, synchronous);
        }
        return;
    }

    Pair<FixData, String> fixData = buildUpFixDataForLine(line);

    ParseErrorAnnotation pea;
    if (customType == null) {
        pea = new ParseErrorAnnotation(
                mostImportantSeverity,
                fixData.first(),
                fixData.second(),
                line,
                this);
    } else {
        pea = new ParseErrorAnnotation(
                mostImportantSeverity,
                customType,
                fixData.first(),
                fixData.second(),
                line,
                this);
    }
    ParseErrorAnnotation previous = line2Annotations.put(line, pea);

    if (previous != null) {
        detachAnnotation(previous, synchronous);
    }

    attachAnnotation(line, pea, synchronous);   
}