--- a/spi.editor.hints/apichanges.xml Fri Mar 09 18:16:51 2012 -0800 +++ a/spi.editor.hints/apichanges.xml Mon Mar 12 12:18:02 2012 +0100 @@ -108,6 +108,21 @@ + + + Added id and details to ErrorDescriptionFactory.createErrorDescription + + + + + + Added several new variants of ErrorDescriptionFactory.createErrorDescription. + These new variants allow to specify an optional error/warning id and + more details. + + + + Added ErrorDescriptionFactory.attachSubfixes --- a/spi.editor.hints/nbproject/project.properties Fri Mar 09 18:16:51 2012 -0800 +++ a/spi.editor.hints/nbproject/project.properties Mon Mar 12 12:18:02 2012 +0100 @@ -43,6 +43,6 @@ javac.source=1.6 javadoc.arch=${basedir}/arch.xml javadoc.apichanges=${basedir}/apichanges.xml -spec.version.base=1.21.0 +spec.version.base=1.22.0 test.config.stableBTD.includes=**/*Test.class --- a/spi.editor.hints/src/org/netbeans/spi/editor/hints/ErrorDescription.java Fri Mar 09 18:16:51 2012 -0800 +++ a/spi.editor.hints/src/org/netbeans/spi/editor/hints/ErrorDescription.java Mon Mar 12 12:18:02 2012 +0100 @@ -44,6 +44,7 @@ package org.netbeans.spi.editor.hints; import java.io.IOException; +import org.netbeans.api.annotations.common.CheckForNull; import org.openide.filesystems.FileObject; import org.openide.text.PositionBounds; @@ -56,7 +57,9 @@ */ public final class ErrorDescription { + private final String id; private final String description; + private final CharSequence details; private final Severity severity; private final LazyFixList fixes; private final PositionBounds span; @@ -66,8 +69,10 @@ * The constructor is intentionally not public. Use * {@link ErrorDescriptionFactory} when you need an instance of this class. */ - ErrorDescription(FileObject file, String description, Severity severity, LazyFixList fixes, PositionBounds span) { + ErrorDescription(FileObject file, String id, String description, CharSequence details, Severity severity, LazyFixList fixes, PositionBounds span) { + this.id = id; this.description = description; + this.details = details; this.severity = severity; this.fixes = fixes; this.span = span; @@ -75,6 +80,15 @@ } /** + * @return the id specified when constructing this {@link ErrorDescription}, + * or null if none was specified + * @since 1.22 + */ + public @CheckForNull String getId() { + return id; + } + + /** * @return description of the error that is displayed to the user. */ public String getDescription() { @@ -82,6 +96,15 @@ } /** + * @return the details specified when constructing this {@link ErrorDescription}, + * or null if none was specified + * @since 1.22 + */ + public @CheckForNull CharSequence getDetails() { + return details; + } + + /** * The severity determines how the hint will be rendered. * @return {@link Severity} of the error */ --- a/spi.editor.hints/src/org/netbeans/spi/editor/hints/ErrorDescriptionFactory.java Fri Mar 09 18:16:51 2012 -0800 +++ a/spi.editor.hints/src/org/netbeans/spi/editor/hints/ErrorDescriptionFactory.java Mon Mar 12 12:18:02 2012 +0100 @@ -47,6 +47,7 @@ import javax.swing.text.Document; import javax.swing.text.Position; import org.netbeans.api.annotations.common.NonNull; +import org.netbeans.api.annotations.common.NullAllowed; import org.netbeans.modules.editor.hints.HintsControllerImpl; import org.netbeans.modules.editor.hints.StaticFixList; import org.openide.filesystems.FileObject; @@ -88,6 +89,25 @@ * Should be called inside document read lock to assure consistency */ public static @NonNull ErrorDescription createErrorDescription(@NonNull Severity severity, @NonNull String description, @NonNull LazyFixList fixes, @NonNull Document doc, int lineNumber) { + return createErrorDescription(null, severity, description, null, fixes, doc, lineNumber); + } + + /**Create a new {@link ErrorDescription} with the given parameters. + * + * Should be called inside document read lock to assure consistency + * + * @param id an optional ID of the {@link ErrorDescription}. Should represent a "type" of an error/warning. + * It is recommended that providers prefix the ID with their unique prefix. + * @param severity the desired {@link Severity} + * @param description the text of the error/warning + * @param details optional "more details" describing the error/warning + * @param fixes a collection of {@link Fix}es that should be shown for the error/warning + * @param doc document for which the {@link ErrorDescription} should be created + * @param lineNumber line on which the error/warning should be shown + * @return a newly created {@link ErrorDescription} based on the given parameters + * @since 1.22 + */ + 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) { Parameters.notNull("severity", severity); Parameters.notNull("description", description); Parameters.notNull("fixes", fixes); @@ -96,7 +116,7 @@ DataObject od = (DataObject) doc.getProperty(Document.StreamDescriptionProperty); FileObject file = od != null ? od.getPrimaryFile() : null; - return new ErrorDescription(file, description, severity, fixes, HintsControllerImpl.fullLine(doc, lineNumber)); + return new ErrorDescription(file, id, description, details, severity, fixes, HintsControllerImpl.fullLine(doc, lineNumber)); } /** @@ -130,6 +150,26 @@ * Acquires read lock on the provided document to assure consistency */ public static @NonNull ErrorDescription createErrorDescription(@NonNull Severity severity, @NonNull String description, @NonNull LazyFixList fixes, @NonNull Document doc, @NonNull Position start, @NonNull Position end) { + return createErrorDescription(null, severity, description, null, fixes, doc, start, end); + } + + /**Create a new {@link ErrorDescription} with the given parameters. + * + * Acquires read lock on the provided document to assure consistency + * + * @param id an optional ID of the {@link ErrorDescription}. Should represent a "type" of an error/warning. + * It is recommended that providers prefix the ID with their unique prefix. + * @param severity the desired {@link Severity} + * @param description the text of the error/warning + * @param details optional "more details" describing the error/warning + * @param fixes a collection of {@link Fix}es that should be shown for the error/warning + * @param doc document for which the {@link ErrorDescription} should be created + * @param start starting offset of the error/warning + * @param end ending offset of the error/warning + * @return a newly created {@link ErrorDescription} based on the given parameters + * @since 1.22 + */ + 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) { Parameters.notNull("severity", severity); Parameters.notNull("description", description); Parameters.notNull("fixes", fixes); @@ -140,7 +180,7 @@ DataObject od = (DataObject) doc.getProperty(Document.StreamDescriptionProperty); FileObject file = od != null ? od.getPrimaryFile() : null; - return new ErrorDescription(file, description, severity, fixes, HintsControllerImpl.linePart(doc, start, end)); + return new ErrorDescription(file, id, description, details, severity, fixes, HintsControllerImpl.linePart(doc, start, end)); } /** @@ -174,6 +214,26 @@ * Should be called inside document read lock to assure consistency */ public static @NonNull ErrorDescription createErrorDescription(@NonNull Severity severity, @NonNull String description, @NonNull LazyFixList fixes, @NonNull FileObject file, int start, int end) { + return createErrorDescription(null, severity, description, null, fixes, file, start, end); + } + + /**Create a new {@link ErrorDescription} with the given parameters. + * + * Should be called inside document read lock to assure consistency + * + * @param id an optional ID of the {@link ErrorDescription}. Should represent a "type" of an error/warning. + * It is recommended that providers prefix the ID with their unique prefix. + * @param severity the desired {@link Severity} + * @param description the text of the error/warning + * @param details optional "more details" describing the error/warning + * @param fixes a collection of {@link Fix}es that should be shown for the error/warning + * @param file for which the {@link ErrorDescription} should be created + * @param start starting offset of the error/warning + * @param end ending offset of the error/warning + * @return a newly created {@link ErrorDescription} based on the given parameters + * @since 1.22 + */ + 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) { Parameters.notNull("severity", severity); Parameters.notNull("description", description); Parameters.notNull("fixes", fixes); @@ -181,7 +241,7 @@ if (start < 0) throw new IndexOutOfBoundsException("start < 0 (" + start + " < 0)"); if (end < start) throw new IndexOutOfBoundsException("end < start (" + end + " < " + start + ")"); - return new ErrorDescription(file, description, severity, fixes, HintsControllerImpl.linePart(file, start, end)); + return new ErrorDescription(file, id, description, details, severity, fixes, HintsControllerImpl.linePart(file, start, end)); } /** --- a/spi.editor.hints/test/unit/src/org/netbeans/spi/editor/hints/ErrorDescriptionTestSupport.java Fri Mar 09 18:16:51 2012 -0800 +++ a/spi.editor.hints/test/unit/src/org/netbeans/spi/editor/hints/ErrorDescriptionTestSupport.java Mon Mar 12 12:18:02 2012 +0100 @@ -53,7 +53,7 @@ public final class ErrorDescriptionTestSupport { public static ErrorDescription createErrorDescription(FileObject file, String description, Severity severity, LazyFixList fixes, PositionBounds span) { - return new ErrorDescription(file, description, severity, fixes, span); + return new ErrorDescription(file, null, description, null, severity, fixes, span); } }