This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 254375
Collapse All | Expand All

(-)a/spi.editor.hints/nbproject/project.properties (-1 / +1 lines)
Lines 43-48 Link Here
43
javac.source=1.7
43
javac.source=1.7
44
javadoc.arch=${basedir}/arch.xml
44
javadoc.arch=${basedir}/arch.xml
45
javadoc.apichanges=${basedir}/apichanges.xml
45
javadoc.apichanges=${basedir}/apichanges.xml
46
spec.version.base=1.38.0
46
spec.version.base=1.39.0
47
47
48
test.config.stableBTD.includes=**/*Test.class
48
test.config.stableBTD.includes=**/*Test.class
(-)a/spi.editor.hints/src/org/netbeans/modules/editor/hints/AnnotationHolder.java (-7 / +20 lines)
Lines 766-772 Link Here
766
        else errorDescriptions = new ArrayList<>(errorDescriptions);
766
        else errorDescriptions = new ArrayList<>(errorDescriptions);
767
767
768
        Severity mostImportantSeverity = Severity.HINT;
768
        Severity mostImportantSeverity = Severity.HINT;
769
769
        String customType = null;
770
        
770
        for (Iterator<ErrorDescription> it = errorDescriptions.iterator(); it.hasNext();) {
771
        for (Iterator<ErrorDescription> it = errorDescriptions.iterator(); it.hasNext();) {
771
            ErrorDescription ed = it.next();
772
            ErrorDescription ed = it.next();
772
            List<Position> positions = errors2Lines.get(ed);
773
            List<Position> positions = errors2Lines.get(ed);
Lines 777-782 Link Here
777
                if (mostImportantSeverity.compareTo(ed.getSeverity()) > 0) {
778
                if (mostImportantSeverity.compareTo(ed.getSeverity()) > 0) {
778
                    mostImportantSeverity = ed.getSeverity();
779
                    mostImportantSeverity = ed.getSeverity();
779
                }
780
                }
781
                customType = ed.getCustomType();
780
            }
782
            }
781
        }
783
        }
782
784
Lines 791-802 Link Here
791
793
792
        Pair<FixData, String> fixData = buildUpFixDataForLine(line);
794
        Pair<FixData, String> fixData = buildUpFixDataForLine(line);
793
795
794
        ParseErrorAnnotation pea = new ParseErrorAnnotation(
796
        ParseErrorAnnotation pea;
795
                mostImportantSeverity,
797
        if (customType == null) {
796
                fixData.first(),
798
            pea = new ParseErrorAnnotation(
797
                fixData.second(),
799
                    mostImportantSeverity,
798
                line,
800
                    fixData.first(),
799
                this);
801
                    fixData.second(),
802
                    line,
803
                    this);
804
        } else {
805
            pea = new ParseErrorAnnotation(
806
                    mostImportantSeverity,
807
                    customType,
808
                    fixData.first(),
809
                    fixData.second(),
810
                    line,
811
                    this);
812
        }
800
        ParseErrorAnnotation previous = line2Annotations.put(line, pea);
813
        ParseErrorAnnotation previous = line2Annotations.put(line, pea);
801
814
802
        if (previous != null) {
815
        if (previous != null) {
(-)a/spi.editor.hints/src/org/netbeans/modules/editor/hints/ParseErrorAnnotation.java (-24 / +48 lines)
Lines 62-67 Link Here
62
public class ParseErrorAnnotation extends Annotation implements PropertyChangeListener {
62
public class ParseErrorAnnotation extends Annotation implements PropertyChangeListener {
63
63
64
    private final Severity severity;
64
    private final Severity severity;
65
    private final String customType;
65
    private final FixData fixes;
66
    private final FixData fixes;
66
    private final String description;
67
    private final String description;
67
    private final String shortDescription;
68
    private final String shortDescription;
Lines 71-76 Link Here
71
    /** Creates a new instance of ParseErrorAnnotation */
72
    /** Creates a new instance of ParseErrorAnnotation */
72
    public ParseErrorAnnotation(Severity severity, FixData fixes, String description, Position lineStart, AnnotationHolder holder) {
73
    public ParseErrorAnnotation(Severity severity, FixData fixes, String description, Position lineStart, AnnotationHolder holder) {
73
        this.severity = severity;
74
        this.severity = severity;
75
        this.customType = null;
76
        this.fixes = fixes;
77
        this.description = description;
78
        this.shortDescription = description + NbBundle.getMessage(ParseErrorAnnotation.class, "LBL_shortcut_promotion"); //NOI18N
79
        this.lineStart = lineStart;
80
        this.holder = holder;
81
        
82
        if (!fixes.isComputed()) {
83
            fixes.addPropertyChangeListener(WeakListeners.propertyChange(this, fixes));
84
        }
85
    }
86
    
87
    public ParseErrorAnnotation(Severity severity, String customType, FixData fixes, String description, Position lineStart, AnnotationHolder holder) {
88
        this.severity = severity;
89
        this.customType = customType;
74
        this.fixes = fixes;
90
        this.fixes = fixes;
75
        this.description = description;
91
        this.description = description;
76
        this.shortDescription = description + NbBundle.getMessage(ParseErrorAnnotation.class, "LBL_shortcut_promotion"); //NOI18N
92
        this.shortDescription = description + NbBundle.getMessage(ParseErrorAnnotation.class, "LBL_shortcut_promotion"); //NOI18N
Lines 85-114 Link Here
85
    public String getAnnotationType() {
101
    public String getAnnotationType() {
86
        boolean hasFixes = fixes.isComputed() && !fixes.getFixes().isEmpty();
102
        boolean hasFixes = fixes.isComputed() && !fixes.getFixes().isEmpty();
87
        
103
        
88
        switch (severity) {
104
        if (customType == null) {
89
            case ERROR:
105
            switch (severity) {
90
                if (hasFixes)
106
                case ERROR:
91
                    return "org-netbeans-spi-editor-hints-parser_annotation_err_fixable";
107
                    if (hasFixes)
92
                else
108
                        return "org-netbeans-spi-editor-hints-parser_annotation_err_fixable";
93
                    return "org-netbeans-spi-editor-hints-parser_annotation_err";
109
                    else
94
                
110
                        return "org-netbeans-spi-editor-hints-parser_annotation_err";
95
            case WARNING:
111
96
                if (hasFixes)
112
                case WARNING:
97
                    return "org-netbeans-spi-editor-hints-parser_annotation_warn_fixable";
113
                    if (hasFixes)
98
                else
114
                        return "org-netbeans-spi-editor-hints-parser_annotation_warn_fixable";
99
                    return "org-netbeans-spi-editor-hints-parser_annotation_warn";
115
                    else
100
            case VERIFIER:
116
                        return "org-netbeans-spi-editor-hints-parser_annotation_warn";
101
                if (hasFixes)
117
                case VERIFIER:
102
                    return "org-netbeans-spi-editor-hints-parser_annotation_verifier_fixable";
118
                    if (hasFixes)
103
                else
119
                        return "org-netbeans-spi-editor-hints-parser_annotation_verifier_fixable";
104
                    return "org-netbeans-spi-editor-hints-parser_annotation_verifier";
120
                    else
105
            case HINT:
121
                        return "org-netbeans-spi-editor-hints-parser_annotation_verifier";
106
                if (hasFixes)
122
                case HINT:
107
                    return "org-netbeans-spi-editor-hints-parser_annotation_hint_fixable";
123
                    if (hasFixes)
108
                else
124
                        return "org-netbeans-spi-editor-hints-parser_annotation_hint_fixable";
109
                    return "org-netbeans-spi-editor-hints-parser_annotation_hint";
125
                    else
110
            default:
126
                        return "org-netbeans-spi-editor-hints-parser_annotation_hint";
111
                throw new IllegalArgumentException(String.valueOf(severity));
127
                default:
128
                    throw new IllegalArgumentException(String.valueOf(severity));
129
            }
130
        } else {
131
            return customType;
112
        }
132
        }
113
    }
133
    }
114
134
Lines 141-146 Link Here
141
    Severity getSeverity() {
161
    Severity getSeverity() {
142
        return severity;
162
        return severity;
143
    }
163
    }
164
    
165
    String getCustomType() {
166
        return customType;
167
    }
144
168
145
    private StyledDocument attachedTo;
169
    private StyledDocument attachedTo;
146
170
(-)a/spi.editor.hints/src/org/netbeans/spi/editor/hints/ErrorDescription.java (+17 lines)
Lines 61-66 Link Here
61
    private final String description;
61
    private final String description;
62
    private final CharSequence details;
62
    private final CharSequence details;
63
    private final Severity severity;
63
    private final Severity severity;
64
    private final String customType;
64
    private final LazyFixList fixes;
65
    private final LazyFixList fixes;
65
    private final PositionBounds span;
66
    private final PositionBounds span;
66
    private final FileObject file;
67
    private final FileObject file;
Lines 74-79 Link Here
74
        this.description = description;
75
        this.description = description;
75
        this.details = details;
76
        this.details = details;
76
        this.severity    = severity;
77
        this.severity    = severity;
78
        this.customType = null;
79
        this.fixes       = fixes;
80
        this.span        = span;
81
        this.file        = file;
82
    }
83
    
84
    ErrorDescription(FileObject file, String id, String description, CharSequence details, Severity severity, String customType, LazyFixList fixes, PositionBounds span) {
85
        this.id = id;
86
        this.description = description;
87
        this.details = details;
88
        this.severity    = severity;
89
        this.customType = customType;
77
        this.fixes       = fixes;
90
        this.fixes       = fixes;
78
        this.span        = span;
91
        this.span        = span;
79
        this.file        = file;
92
        this.file        = file;
Lines 111-116 Link Here
111
    public Severity getSeverity() {
124
    public Severity getSeverity() {
112
        return severity;
125
        return severity;
113
    }
126
    }
127
    
128
    public String getCustomType() {
129
        return customType;
130
    }
114
131
115
    /**
132
    /**
116
     * The list of fixes that will be associated with the error.
133
     * The list of fixes that will be associated with the error.
(-)a/spi.editor.hints/src/org/netbeans/spi/editor/hints/ErrorDescriptionFactory.java (+28 lines)
Lines 288-293 Link Here
288
        
288
        
289
        return new ErrorDescription(file, id, description, details, severity, fixes, errorBounds);
289
        return new ErrorDescription(file, id, description, details, severity, fixes, errorBounds);
290
    }
290
    }
291
    
292
    /**Create a new {@link ErrorDescription} with the given parameters.
293
     *
294
     * @param id an optional ID of the {@link ErrorDescription}. Should represent a "type" of an error/warning.
295
     *           It is recommended that providers prefix the ID with their unique prefix.
296
     * @param severity the desired {@link Severity}
297
     * @param customType custom {@link Severity}
298
     * @param description the text of the error/warning
299
     * @param details optional "more details" describing the error/warning
300
     * @param fixes a collection of {@link Fix}es that should be shown for the error/warning
301
     * @param file for which the {@link ErrorDescription} should be created
302
     * @param errorBounds start and end position of the error/warning
303
     * @return a newly created {@link ErrorDescription} based on the given parameters
304
     * @since 1.39
305
     */
306
    public static @NonNull ErrorDescription createErrorDescription(@NullAllowed String id, @NonNull Severity severity, @NullAllowed String customType, @NonNull String description, @NullAllowed CharSequence details,  @NonNull List<Fix> fixes, @NonNull Document doc, @NonNull Position start, @NonNull Position end) {
307
        Parameters.notNull("severity", severity);
308
        Parameters.notNull("description", description);
309
        Parameters.notNull("fixes", fixes);
310
        Parameters.notNull("doc", doc);
311
        Parameters.notNull("start", start);
312
        Parameters.notNull("end", end);
313
        
314
        DataObject od = (DataObject) doc.getProperty(Document.StreamDescriptionProperty);
315
        FileObject file = od != null ? od.getPrimaryFile() : null;
316
        
317
        return new ErrorDescription(file, id, description, details, severity, customType, new StaticFixList(fixes), HintsControllerImpl.linePart(doc, start, end));
318
    }
291
319
292
    /**
320
    /**
293
     * Converts "normal" list of {@link Fix}es into {@link LazyFixList}
321
     * Converts "normal" list of {@link Fix}es into {@link LazyFixList}

Return to bug 254375