Skip to content

Commit

Permalink
Code cleanup for csl.editor.semantic package
Browse files Browse the repository at this point in the history
  • Loading branch information
lkishalmi committed Dec 11, 2024
1 parent d244350 commit 0b4ca34
Show file tree
Hide file tree
Showing 11 changed files with 196 additions and 705 deletions.
2 changes: 1 addition & 1 deletion ide/csl.api/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

spec.version.base=2.85.0
is.autoload=true
javac.source=1.8
javac.release=17

javadoc.overview=${basedir}/doc/overview.html
javadoc.arch=${basedir}/arch.xml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import javax.swing.text.AttributeSet;
import javax.swing.text.Document;
import javax.swing.text.JTextComponent;
import org.netbeans.api.annotations.common.NonNull;
import org.netbeans.api.editor.mimelookup.MimeLookup;
import org.netbeans.api.editor.mimelookup.MimePath;
import org.netbeans.api.editor.settings.AttributesUtilities;
Expand All @@ -61,7 +62,7 @@
* @author Jan Lahoda
*/
public final class ColoringManager {
private String mimeType;
private final String mimeType;
private final Map<Set<ColoringAttributes>, String> type2Coloring;

//private static final Font ITALIC = SettingsDefaults.defaultFont.deriveFont(Font.ITALIC);
Expand All @@ -71,7 +72,7 @@ public final class ColoringManager {
public ColoringManager(String mimeType) {
this.mimeType = mimeType;

type2Coloring = new LinkedHashMap<Set<ColoringAttributes>, String>();
type2Coloring = new LinkedHashMap<>();

put("mark-occurrences", MARK_OCCURRENCES);
put("mod-abstract", ABSTRACT);
Expand Down Expand Up @@ -123,7 +124,7 @@ private void put(String coloring, ColoringAttributes... attributes) {
type2Coloring.put(attribs, coloring);
}

Map<Set<ColoringAttributes>,Coloring> COLORING_MAP = new IdentityHashMap<Set<ColoringAttributes>, Coloring>();
final Map<Set<ColoringAttributes>,Coloring> COLORING_MAP = new IdentityHashMap<>();

public Coloring getColoring(Set<ColoringAttributes> attrs) {
Coloring c = COLORING_MAP.get(attrs);
Expand All @@ -139,7 +140,8 @@ public Coloring getColoring(Set<ColoringAttributes> attrs) {

return c;
}


@NonNull
public AttributeSet getColoringImpl(Coloring colorings) {
FontColorSettings fcs = MimeLookup.getLookup(MimePath.get(mimeType)).lookup(FontColorSettings.class);

Expand All @@ -150,7 +152,7 @@ public AttributeSet getColoringImpl(Coloring colorings) {

assert fcs != null;

List<AttributeSet> attribs = new LinkedList<AttributeSet>();
List<AttributeSet> attribs = new LinkedList<>();

EnumSet<ColoringAttributes> es = EnumSet.noneOf(ColoringAttributes.class);

Expand Down Expand Up @@ -184,13 +186,11 @@ public AttributeSet getColoringImpl(Coloring colorings) {

Collections.reverse(attribs);

AttributeSet result = AttributesUtilities.createComposite(attribs.toArray(new AttributeSet[0]));

return result;
return AttributesUtilities.createComposite(attribs.toArray(AttributeSet[]::new));
}

private static AttributeSet adjustAttributes(AttributeSet as) {
Collection<Object> attrs = new LinkedList<Object>();
Collection<Object> attrs = new LinkedList<>();

for (Enumeration<?> e = as.getAttributeNames(); e.hasMoreElements(); ) {
Object key = e.nextElement();
Expand All @@ -205,8 +205,9 @@ private static AttributeSet adjustAttributes(AttributeSet as) {
return AttributesUtilities.createImmutable(attrs.toArray());
}

final class UnusedTooltipResolver implements HighlightAttributeValue<String> {
private final class UnusedTooltipResolver implements HighlightAttributeValue<String> {

@Override
public String getValue(JTextComponent component, Document document, Object attributeKey, int startOffset, final int endOffset) {
return NbBundle.getMessage(ColoringManager.class, "LBL_UNUSED");
}
Expand Down
Loading

0 comments on commit 0b4ca34

Please sign in to comment.