Skip to content

Commit 0b4ca34

Browse files
committed
Code cleanup for csl.editor.semantic package
1 parent d244350 commit 0b4ca34

File tree

11 files changed

+196
-705
lines changed

11 files changed

+196
-705
lines changed

ide/csl.api/nbproject/project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
spec.version.base=2.85.0
1919
is.autoload=true
20-
javac.source=1.8
20+
javac.release=17
2121

2222
javadoc.overview=${basedir}/doc/overview.html
2323
javadoc.arch=${basedir}/arch.xml

ide/csl.api/src/org/netbeans/modules/csl/editor/semantic/ColoringManager.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import javax.swing.text.AttributeSet;
3737
import javax.swing.text.Document;
3838
import javax.swing.text.JTextComponent;
39+
import org.netbeans.api.annotations.common.NonNull;
3940
import org.netbeans.api.editor.mimelookup.MimeLookup;
4041
import org.netbeans.api.editor.mimelookup.MimePath;
4142
import org.netbeans.api.editor.settings.AttributesUtilities;
@@ -61,7 +62,7 @@
6162
* @author Jan Lahoda
6263
*/
6364
public 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

Comments
 (0)