3636import javax .swing .text .AttributeSet ;
3737import javax .swing .text .Document ;
3838import javax .swing .text .JTextComponent ;
39+ import org .netbeans .api .annotations .common .NonNull ;
3940import org .netbeans .api .editor .mimelookup .MimeLookup ;
4041import org .netbeans .api .editor .mimelookup .MimePath ;
4142import org .netbeans .api .editor .settings .AttributesUtilities ;
6162 * @author Jan Lahoda
6263 */
6364public final class ColoringManager {
64- private String mimeType ;
65+ private final String mimeType ;
6566 private final Map <Set <ColoringAttributes >, String > type2Coloring ;
6667
6768 //private static final Font ITALIC = SettingsDefaults.defaultFont.deriveFont(Font.ITALIC);
@@ -71,7 +72,7 @@ public final class ColoringManager {
7172 public ColoringManager (String mimeType ) {
7273 this .mimeType = mimeType ;
7374
74- type2Coloring = new LinkedHashMap <Set < ColoringAttributes >, String >();
75+ type2Coloring = new LinkedHashMap <>();
7576
7677 put ("mark-occurrences" , MARK_OCCURRENCES );
7778 put ("mod-abstract" , ABSTRACT );
@@ -123,7 +124,7 @@ private void put(String coloring, ColoringAttributes... attributes) {
123124 type2Coloring .put (attribs , coloring );
124125 }
125126
126- Map <Set <ColoringAttributes >,Coloring > COLORING_MAP = new IdentityHashMap <Set < ColoringAttributes >, Coloring >();
127+ final Map <Set <ColoringAttributes >,Coloring > COLORING_MAP = new IdentityHashMap <>();
127128
128129 public Coloring getColoring (Set <ColoringAttributes > attrs ) {
129130 Coloring c = COLORING_MAP .get (attrs );
@@ -139,7 +140,8 @@ public Coloring getColoring(Set<ColoringAttributes> attrs) {
139140
140141 return c ;
141142 }
142-
143+
144+ @ NonNull
143145 public AttributeSet getColoringImpl (Coloring colorings ) {
144146 FontColorSettings fcs = MimeLookup .getLookup (MimePath .get (mimeType )).lookup (FontColorSettings .class );
145147
@@ -150,7 +152,7 @@ public AttributeSet getColoringImpl(Coloring colorings) {
150152
151153 assert fcs != null ;
152154
153- List <AttributeSet > attribs = new LinkedList <AttributeSet >();
155+ List <AttributeSet > attribs = new LinkedList <>();
154156
155157 EnumSet <ColoringAttributes > es = EnumSet .noneOf (ColoringAttributes .class );
156158
@@ -184,13 +186,11 @@ public AttributeSet getColoringImpl(Coloring colorings) {
184186
185187 Collections .reverse (attribs );
186188
187- AttributeSet result = AttributesUtilities .createComposite (attribs .toArray (new AttributeSet [0 ]));
188-
189- return result ;
189+ return AttributesUtilities .createComposite (attribs .toArray (AttributeSet []::new ));
190190 }
191191
192192 private static AttributeSet adjustAttributes (AttributeSet as ) {
193- Collection <Object > attrs = new LinkedList <Object >();
193+ Collection <Object > attrs = new LinkedList <>();
194194
195195 for (Enumeration <?> e = as .getAttributeNames (); e .hasMoreElements (); ) {
196196 Object key = e .nextElement ();
@@ -205,8 +205,9 @@ private static AttributeSet adjustAttributes(AttributeSet as) {
205205 return AttributesUtilities .createImmutable (attrs .toArray ());
206206 }
207207
208- final class UnusedTooltipResolver implements HighlightAttributeValue <String > {
208+ private final class UnusedTooltipResolver implements HighlightAttributeValue <String > {
209209
210+ @ Override
210211 public String getValue (JTextComponent component , Document document , Object attributeKey , int startOffset , final int endOffset ) {
211212 return NbBundle .getMessage (ColoringManager .class , "LBL_UNUSED" );
212213 }
0 commit comments