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 209448
Collapse All | Expand All

(-)a/spi.editor.hints/apichanges.xml (+15 lines)
Lines 108-113 Link Here
108
108
109
    <changes>
109
    <changes>
110
110
111
        <change id="id-and-details">
112
             <api name="EditorHintsSPI"/>
113
             <summary>Added id and details to ErrorDescriptionFactory.createErrorDescription</summary>
114
             <version major="1" minor="22"/>
115
             <date day="19" month="3" year="2012"/>
116
             <author login="jlahoda"/>
117
             <compatibility addition="yes" binary="compatible" deletion="no" deprecation="no" modification="no" semantic="compatible" source="compatible"/>
118
             <description>
119
                 Added several new variants of ErrorDescriptionFactory.createErrorDescription.
120
                 These new variants allow to specify an optional error/warning id and
121
                 more details.
122
             </description>
123
             <class name="ErrorDescriptionFactory" package="org.netbeans.spi.editor.hints"/>
124
             <issue number="209448"/>
125
        </change>
111
        <change id="attachSubfixes">
126
        <change id="attachSubfixes">
112
             <api name="EditorHintsSPI"/>
127
             <api name="EditorHintsSPI"/>
113
             <summary>Added ErrorDescriptionFactory.attachSubfixes</summary>
128
             <summary>Added ErrorDescriptionFactory.attachSubfixes</summary>
(-)a/spi.editor.hints/nbproject/project.properties (-1 / +1 lines)
Lines 43-48 Link Here
43
javac.source=1.6
43
javac.source=1.6
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.21.0
46
spec.version.base=1.22.0
47
47
48
test.config.stableBTD.includes=**/*Test.class
48
test.config.stableBTD.includes=**/*Test.class
(-)a/spi.editor.hints/src/org/netbeans/spi/editor/hints/ErrorDescription.java (-1 / +24 lines)
Lines 44-49 Link Here
44
package org.netbeans.spi.editor.hints;
44
package org.netbeans.spi.editor.hints;
45
45
46
import java.io.IOException;
46
import java.io.IOException;
47
import org.netbeans.api.annotations.common.CheckForNull;
47
import org.openide.filesystems.FileObject;
48
import org.openide.filesystems.FileObject;
48
import org.openide.text.PositionBounds;
49
import org.openide.text.PositionBounds;
49
50
Lines 56-62 Link Here
56
 */
57
 */
57
public final class ErrorDescription {
58
public final class ErrorDescription {
58
59
60
    private final String id;
59
    private final String description;
61
    private final String description;
62
    private final CharSequence details;
60
    private final Severity severity;
63
    private final Severity severity;
61
    private final LazyFixList fixes;
64
    private final LazyFixList fixes;
62
    private final PositionBounds span;
65
    private final PositionBounds span;
Lines 66-73 Link Here
66
     * The constructor is intentionally not public. Use 
69
     * The constructor is intentionally not public. Use 
67
     * {@link ErrorDescriptionFactory} when you need an instance of this class.
70
     * {@link ErrorDescriptionFactory} when you need an instance of this class.
68
     */
71
     */
69
    ErrorDescription(FileObject file, String description, Severity severity, LazyFixList fixes, PositionBounds span) {
72
    ErrorDescription(FileObject file, String id, String description, CharSequence details, Severity severity, LazyFixList fixes, PositionBounds span) {
73
        this.id = id;
70
        this.description = description;
74
        this.description = description;
75
        this.details = details;
71
        this.severity    = severity;
76
        this.severity    = severity;
72
        this.fixes       = fixes;
77
        this.fixes       = fixes;
73
        this.span        = span;
78
        this.span        = span;
Lines 75-80 Link Here
75
    }
80
    }
76
81
77
    /**
82
    /**
83
     * @return the id specified when constructing this {@link ErrorDescription},
84
     *         or null if none was specified
85
     * @since 1.22
86
     */
87
    public @CheckForNull String getId() {
88
        return id;
89
    }
90
91
    /**
78
     * @return description of the error that is displayed to the user.
92
     * @return description of the error that is displayed to the user.
79
     */
93
     */
80
    public String getDescription() {
94
    public String getDescription() {
Lines 82-87 Link Here
82
    }
96
    }
83
97
84
    /**
98
    /**
99
     * @return the details specified when constructing this {@link ErrorDescription},
100
     *         or null if none was specified
101
     * @since 1.22
102
     */
103
    public @CheckForNull CharSequence getDetails() {
104
        return details;
105
    }
106
107
    /**
85
     * The severity determines how the hint will be rendered.
108
     * The severity determines how the hint will be rendered.
86
     * @return {@link Severity} of the error
109
     * @return {@link Severity} of the error
87
     */
110
     */
(-)a/spi.editor.hints/src/org/netbeans/spi/editor/hints/ErrorDescriptionFactory.java (-3 / +63 lines)
Lines 47-52 Link Here
47
import javax.swing.text.Document;
47
import javax.swing.text.Document;
48
import javax.swing.text.Position;
48
import javax.swing.text.Position;
49
import org.netbeans.api.annotations.common.NonNull;
49
import org.netbeans.api.annotations.common.NonNull;
50
import org.netbeans.api.annotations.common.NullAllowed;
50
import org.netbeans.modules.editor.hints.HintsControllerImpl;
51
import org.netbeans.modules.editor.hints.HintsControllerImpl;
51
import org.netbeans.modules.editor.hints.StaticFixList;
52
import org.netbeans.modules.editor.hints.StaticFixList;
52
import org.openide.filesystems.FileObject;
53
import org.openide.filesystems.FileObject;
Lines 88-93 Link Here
88
     * Should be called inside document read lock to assure consistency
89
     * Should be called inside document read lock to assure consistency
89
     */
90
     */
90
    public static @NonNull ErrorDescription createErrorDescription(@NonNull Severity severity, @NonNull String description, @NonNull LazyFixList fixes, @NonNull Document doc, int lineNumber) {
91
    public static @NonNull ErrorDescription createErrorDescription(@NonNull Severity severity, @NonNull String description, @NonNull LazyFixList fixes, @NonNull Document doc, int lineNumber) {
92
        return createErrorDescription(null, severity, description, null, fixes, doc, lineNumber);
93
    }
94
95
    /**Create a new {@link ErrorDescription} with the given parameters.
96
     *
97
     * Should be called inside document read lock to assure consistency
98
     *
99
     * @param id an optional ID of the {@link ErrorDescription}. Should represent a "type" of an error/warning.
100
     *           It is recommended that providers prefix the ID with their unique prefix.
101
     * @param severity the desired {@link Severity}
102
     * @param description the text of the error/warning
103
     * @param details optional "more details" describing the error/warning
104
     * @param fixes a collection of {@link Fix}es that should be shown for the error/warning
105
     * @param doc document for which the {@link ErrorDescription} should be created
106
     * @param lineNumber line on which the error/warning should be shown
107
     * @return a newly created {@link ErrorDescription} based on the given parameters
108
     * @since 1.22
109
     */
110
    public static @NonNull ErrorDescription createErrorDescription(@NullAllowed String id, @NonNull Severity severity, @NonNull String description, @NullAllowed CharSequence details, @NonNull LazyFixList fixes, @NonNull Document doc, int lineNumber) {
91
        Parameters.notNull("severity", severity);
111
        Parameters.notNull("severity", severity);
92
        Parameters.notNull("description", description);
112
        Parameters.notNull("description", description);
93
        Parameters.notNull("fixes", fixes);
113
        Parameters.notNull("fixes", fixes);
Lines 96-102 Link Here
96
        DataObject od = (DataObject) doc.getProperty(Document.StreamDescriptionProperty);
116
        DataObject od = (DataObject) doc.getProperty(Document.StreamDescriptionProperty);
97
        FileObject file = od != null ? od.getPrimaryFile() : null;
117
        FileObject file = od != null ? od.getPrimaryFile() : null;
98
        
118
        
99
        return new ErrorDescription(file, description, severity, fixes, HintsControllerImpl.fullLine(doc, lineNumber));
119
        return new ErrorDescription(file, id, description, details, severity, fixes, HintsControllerImpl.fullLine(doc, lineNumber));
100
    }
120
    }
101
    
121
    
102
    /**
122
    /**
Lines 130-135 Link Here
130
     * Acquires read lock on the provided document to assure consistency
150
     * Acquires read lock on the provided document to assure consistency
131
     */
151
     */
132
    public static @NonNull ErrorDescription createErrorDescription(@NonNull Severity severity, @NonNull String description, @NonNull LazyFixList fixes, @NonNull Document doc, @NonNull Position start, @NonNull Position end) {
152
    public static @NonNull ErrorDescription createErrorDescription(@NonNull Severity severity, @NonNull String description, @NonNull LazyFixList fixes, @NonNull Document doc, @NonNull Position start, @NonNull Position end) {
153
        return createErrorDescription(null, severity, description, null, fixes, doc, start, end);
154
    }
155
156
    /**Create a new {@link ErrorDescription} with the given parameters.
157
     *
158
     * Acquires read lock on the provided document to assure consistency
159
     *
160
     * @param id an optional ID of the {@link ErrorDescription}. Should represent a "type" of an error/warning.
161
     *           It is recommended that providers prefix the ID with their unique prefix.
162
     * @param severity the desired {@link Severity}
163
     * @param description the text of the error/warning
164
     * @param details optional "more details" describing the error/warning
165
     * @param fixes a collection of {@link Fix}es that should be shown for the error/warning
166
     * @param doc document for which the {@link ErrorDescription} should be created
167
     * @param start starting offset of the error/warning
168
     * @param end ending offset of the error/warning
169
     * @return a newly created {@link ErrorDescription} based on the given parameters
170
     * @since 1.22
171
     */
172
    public static @NonNull ErrorDescription createErrorDescription(@NullAllowed String id, @NonNull Severity severity, @NonNull String description, @NullAllowed CharSequence details, @NonNull LazyFixList fixes, @NonNull Document doc, @NonNull Position start, @NonNull Position end) {
133
        Parameters.notNull("severity", severity);
173
        Parameters.notNull("severity", severity);
134
        Parameters.notNull("description", description);
174
        Parameters.notNull("description", description);
135
        Parameters.notNull("fixes", fixes);
175
        Parameters.notNull("fixes", fixes);
Lines 140-146 Link Here
140
        DataObject od = (DataObject) doc.getProperty(Document.StreamDescriptionProperty);
180
        DataObject od = (DataObject) doc.getProperty(Document.StreamDescriptionProperty);
141
        FileObject file = od != null ? od.getPrimaryFile() : null;
181
        FileObject file = od != null ? od.getPrimaryFile() : null;
142
        
182
        
143
        return new ErrorDescription(file, description, severity, fixes, HintsControllerImpl.linePart(doc, start, end));
183
        return new ErrorDescription(file, id, description, details, severity, fixes, HintsControllerImpl.linePart(doc, start, end));
144
    }
184
    }
145
185
146
    /**
186
    /**
Lines 174-179 Link Here
174
     * Should be called inside document read lock to assure consistency
214
     * Should be called inside document read lock to assure consistency
175
     */
215
     */
176
    public static @NonNull ErrorDescription createErrorDescription(@NonNull Severity severity, @NonNull String description, @NonNull LazyFixList fixes, @NonNull FileObject file, int start, int end) {
216
    public static @NonNull ErrorDescription createErrorDescription(@NonNull Severity severity, @NonNull String description, @NonNull LazyFixList fixes, @NonNull FileObject file, int start, int end) {
217
        return createErrorDescription(null, severity, description, null, fixes, file, start, end);
218
    }
219
220
    /**Create a new {@link ErrorDescription} with the given parameters.
221
     *
222
     * Should be called inside document read lock to assure consistency
223
     *
224
     * @param id an optional ID of the {@link ErrorDescription}. Should represent a "type" of an error/warning.
225
     *           It is recommended that providers prefix the ID with their unique prefix.
226
     * @param severity the desired {@link Severity}
227
     * @param description the text of the error/warning
228
     * @param details optional "more details" describing the error/warning
229
     * @param fixes a collection of {@link Fix}es that should be shown for the error/warning
230
     * @param file for which the {@link ErrorDescription} should be created
231
     * @param start starting offset of the error/warning
232
     * @param end ending offset of the error/warning
233
     * @return a newly created {@link ErrorDescription} based on the given parameters
234
     * @since 1.22
235
     */
236
    public static @NonNull ErrorDescription createErrorDescription(@NullAllowed String id, @NonNull Severity severity, @NonNull String description, @NullAllowed CharSequence details, @NonNull LazyFixList fixes, @NonNull FileObject file, int start, int end) {
177
        Parameters.notNull("severity", severity);
237
        Parameters.notNull("severity", severity);
178
        Parameters.notNull("description", description);
238
        Parameters.notNull("description", description);
179
        Parameters.notNull("fixes", fixes);
239
        Parameters.notNull("fixes", fixes);
Lines 181-187 Link Here
181
        if (start < 0) throw new IndexOutOfBoundsException("start < 0 (" + start + " < 0)");
241
        if (start < 0) throw new IndexOutOfBoundsException("start < 0 (" + start + " < 0)");
182
        if (end < start) throw new IndexOutOfBoundsException("end < start (" + end + " < " + start + ")");
242
        if (end < start) throw new IndexOutOfBoundsException("end < start (" + end + " < " + start + ")");
183
        
243
        
184
        return new ErrorDescription(file, description, severity, fixes, HintsControllerImpl.linePart(file, start, end));
244
        return new ErrorDescription(file, id, description, details, severity, fixes, HintsControllerImpl.linePart(file, start, end));
185
    }
245
    }
186
246
187
    /**
247
    /**
(-)a/spi.editor.hints/test/unit/src/org/netbeans/spi/editor/hints/ErrorDescriptionTestSupport.java (-1 / +1 lines)
Lines 53-59 Link Here
53
public final class ErrorDescriptionTestSupport {
53
public final class ErrorDescriptionTestSupport {
54
    
54
    
55
    public static ErrorDescription createErrorDescription(FileObject file, String description, Severity severity, LazyFixList fixes, PositionBounds span) {
55
    public static ErrorDescription createErrorDescription(FileObject file, String description, Severity severity, LazyFixList fixes, PositionBounds span) {
56
        return new ErrorDescription(file, description, severity, fixes, span);
56
        return new ErrorDescription(file, null, description, null, severity, fixes, span);
57
    }
57
    }
58
58
59
}
59
}

Return to bug 209448