diff --git a/spi.editor.hints/src/org/netbeans/modules/editor/hints/FixAction.java b/spi.editor.hints/src/org/netbeans/modules/editor/hints/FixAction.java --- a/spi.editor.hints/src/org/netbeans/modules/editor/hints/FixAction.java +++ b/spi.editor.hints/src/org/netbeans/modules/editor/hints/FixAction.java @@ -44,6 +44,9 @@ package org.netbeans.modules.editor.hints; import java.awt.event.ActionEvent; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; import javax.swing.AbstractAction; import javax.swing.Action; import javax.swing.text.JTextComponent; @@ -59,16 +62,34 @@ */ public class FixAction extends AbstractAction { + private static final Set fixableAnnotations = new HashSet<>(); + static { + fixableAnnotations.add("org-netbeans-spi-editor-hints-parser_annotation_err_fixable"); // NOI18N + fixableAnnotations.add("org-netbeans-spi-editor-hints-parser_annotation_hint_fixable"); // NOI18N + fixableAnnotations.add("org-netbeans-spi-editor-hints-parser_annotation_verifier_fixable"); // NOI18N + fixableAnnotations.add("org-netbeans-spi-editor-hints-parser_annotation_warn_fixable"); // NOI18N + } + public FixAction() { putValue(NAME, NbBundle.getMessage(FixAction.class, "NM_FixAction")); - putValue("supported-annotation-types", new String[] { - "org-netbeans-spi-editor-hints-parser_annotation_err_fixable", - "org-netbeans-spi-editor-hints-parser_annotation_warn_fixable", - "org-netbeans-spi-editor-hints-parser_annotation_verifier_fixable", - "org-netbeans-spi-editor-hints-parser_annotation_hint_fixable" - }); } - + + /*package*/ static void addFixableAnnotationType(String fixableAnnotation) { + fixableAnnotations.add(fixableAnnotation); + } + + /*package*/ static Set getFixableAnnotationTypes() { + return Collections.unmodifiableSet(fixableAnnotations); + } + + @Override + public Object getValue(String key) { + if ("supported-annotation-types".equals(key)) {//NOI18N + return fixableAnnotations.toArray(new String[0]); + } + return super.getValue(key); //To change body of generated methods, choose Tools | Templates. + } + public void actionPerformed(ActionEvent e) { if (!HintsUI.getDefault().invokeDefaultAction(true)) { Object source = e.getSource(); diff --git a/spi.editor.hints/src/org/netbeans/modules/editor/hints/HintsUI.java b/spi.editor.hints/src/org/netbeans/modules/editor/hints/HintsUI.java --- a/spi.editor.hints/src/org/netbeans/modules/editor/hints/HintsUI.java +++ b/spi.editor.hints/src/org/netbeans/modules/editor/hints/HintsUI.java @@ -51,7 +51,6 @@ import java.awt.Container; import java.awt.Cursor; import java.awt.Dimension; -import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import java.awt.HeadlessException; @@ -73,11 +72,9 @@ import java.lang.ref.WeakReference; import java.util.Arrays; import java.util.Collection; -import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; import java.util.logging.Level; import java.util.logging.LogRecord; @@ -155,20 +152,11 @@ //-J-Dorg.netbeans.modules.editor.hints.HintsUI.always.show.error=true private static final boolean ALWAYS_SHOW_ERROR_MESSAGE = Boolean.getBoolean(HintsUI.class.getName() + ".always.show.error"); private static HintsUI INSTANCE; - private static final Set fixableAnnotations; private static final String POPUP_NAME = "hintsPopup"; // NOI18N private static final String SUB_POPUP_NAME = "subHintsPopup"; // NOI18N private static final int POPUP_VERTICAL_OFFSET = 5; private static final RequestProcessor WORKER = new RequestProcessor(HintsUI.class.getName(), 1, false, false); - static { - fixableAnnotations = new HashSet(3); - - fixableAnnotations.add("org-netbeans-spi-editor-hints-parser_annotation_err_fixable"); // NOI18N - fixableAnnotations.add("org-netbeans-spi-editor-hints-parser_annotation_hint_fixable"); // NOI18N - fixableAnnotations.add("org-netbeans-spi-editor-hints-parser_annotation_verifier_fixable"); // NOI18N - fixableAnnotations.add("org-netbeans-spi-editor-hints-parser_annotation_warn_fixable"); // NOI18N - } public static synchronized HintsUI getDefault() { if (INSTANCE == null) @@ -681,7 +669,7 @@ return false; } String type = activeAnnotation.getAnnotationType(); - if (!fixableAnnotations.contains(type) && onlyActive) { + if (!FixAction.getFixableAnnotationTypes().contains(type) && onlyActive) { return false; } if (onlyActive) { diff --git a/spi.editor.hints/src/org/netbeans/modules/editor/hints/ParseErrorAnnotation.java b/spi.editor.hints/src/org/netbeans/modules/editor/hints/ParseErrorAnnotation.java --- a/spi.editor.hints/src/org/netbeans/modules/editor/hints/ParseErrorAnnotation.java +++ b/spi.editor.hints/src/org/netbeans/modules/editor/hints/ParseErrorAnnotation.java @@ -128,6 +128,10 @@ throw new IllegalArgumentException(String.valueOf(severity)); } } else { + if (hasFixes) { + //dynamicly change the regiister of fixable annotations Fix action (click on the icon) will work for. + FixAction.addFixableAnnotationType(customType); + } return customType; } }