code cleanup

This commit is contained in:
FalsePattern 2023-07-29 12:25:36 +02:00
parent 365bcbbd93
commit 623dc2aca7
Signed by: falsepattern
GPG key ID: FDF7126A9E124447
14 changed files with 245 additions and 266 deletions

View file

@ -1,21 +1,23 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 154 140"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 154 140">
<g fill="#F7A41D"> <g fill="#F7A41D">
<g> <g>
<polygon points="46,22 28,44 19,30"/> <polygon points="46,22 28,44 19,30"/>
<polygon points="46,22 33,33 28,44 22,44 22,95 31,95 20,100 12,117 0,117 0,22" shape-rendering="crispEdges"/> <polygon points="46,22 33,33 28,44 22,44 22,95 31,95 20,100 12,117 0,117 0,22"
<polygon points="31,95 12,117 4,106"/> shape-rendering="crispEdges"/>
</g> <polygon points="31,95 12,117 4,106"/>
<g> </g>
<polygon points="56,22 62,36 37,44"/> <g>
<polygon points="56,22 111,22 111,44 37,44 56,32" shape-rendering="crispEdges"/> <polygon points="56,22 62,36 37,44"/>
<polygon points="116,95 97,117 90,104"/> <polygon points="56,22 111,22 111,44 37,44 56,32" shape-rendering="crispEdges"/>
<polygon points="116,95 100,104 97,117 42,117 42,95" shape-rendering="crispEdges"/> <polygon points="116,95 97,117 90,104"/>
<polygon points="150,0 52,117 3,140 101,22"/> <polygon points="116,95 100,104 97,117 42,117 42,95" shape-rendering="crispEdges"/>
</g> <polygon points="150,0 52,117 3,140 101,22"/>
<g> </g>
<polygon points="141,22 140,40 122,45"/> <g>
<polygon points="153,22 153,117 106,117 120,105 125,95 131,95 131,45 122,45 132,36 141,22" shape-rendering="crispEdges"/> <polygon points="141,22 140,40 122,45"/>
<polygon points="125,95 130,110 106,117"/> <polygon points="153,22 153,117 106,117 120,105 125,95 131,95 131,45 122,45 132,36 141,22"
</g> shape-rendering="crispEdges"/>
</g> <polygon points="125,95 130,110 106,117"/>
</g>
</g>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 831 B

After

Width:  |  Height:  |  Size: 1 KiB

View file

@ -1,168 +1,168 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg <svg
viewBox="0 0 154 140" viewBox="0 0 154 140"
version="1.1" version="1.1"
id="svg32" id="svg32"
sodipodi:docname="pluginIcon.svg" sodipodi:docname="pluginIcon.svg"
inkscape:version="1.2.2 (b0a8486541, 2022-12-01)" inkscape:version="1.2.2 (b0a8486541, 2022-12-01)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"> xmlns:svg="http://www.w3.org/2000/svg">
<defs <defs
id="defs36"> id="defs36">
<linearGradient <linearGradient
id="a" id="a"
gradientUnits="userSpaceOnUse" gradientUnits="userSpaceOnUse"
x1="-19.526318" x1="-19.526318"
x2="131.8147" x2="131.8147"
y1="46.48267" y1="46.48267"
y2="1.6522136"> y2="1.6522136">
<stop <stop
offset=".09" offset=".09"
stop-color="#fc801d" stop-color="#fc801d"
id="stop196" /> id="stop196"/>
<stop <stop
offset=".23" offset=".23"
stop-color="#b07f61" stop-color="#b07f61"
id="stop198" /> id="stop198"/>
<stop <stop
offset=".41" offset=".41"
stop-color="#577db3" stop-color="#577db3"
id="stop200" /> id="stop200"/>
<stop <stop
offset=".53" offset=".53"
stop-color="#1e7ce6" stop-color="#1e7ce6"
id="stop202" /> id="stop202"/>
<stop <stop
offset=".59" offset=".59"
stop-color="#087cfa" stop-color="#087cfa"
id="stop204" /> id="stop204"/>
</linearGradient> </linearGradient>
<linearGradient <linearGradient
id="c" id="c"
gradientUnits="userSpaceOnUse" gradientUnits="userSpaceOnUse"
x1="43.479305" x1="43.479305"
x2="97.645195" x2="97.645195"
y1="20.836823" y1="20.836823"
y2="116.85369"> y2="116.85369">
<stop <stop
offset="0" offset="0"
stop-color="#fe2857" stop-color="#fe2857"
id="stop228" /> id="stop228"/>
<stop <stop
offset=".08" offset=".08"
stop-color="#fe295f" stop-color="#fe295f"
id="stop230" /> id="stop230"/>
<stop <stop
offset=".21" offset=".21"
stop-color="#ff2d76" stop-color="#ff2d76"
id="stop232" /> id="stop232"/>
<stop <stop
offset=".3" offset=".3"
stop-color="#ff318c" stop-color="#ff318c"
id="stop234" /> id="stop234"/>
<stop <stop
offset=".38" offset=".38"
stop-color="#ea3896" stop-color="#ea3896"
id="stop236" /> id="stop236"/>
<stop <stop
offset=".55" offset=".55"
stop-color="#b248ae" stop-color="#b248ae"
id="stop238" /> id="stop238"/>
<stop <stop
offset=".79" offset=".79"
stop-color="#5a63d6" stop-color="#5a63d6"
id="stop240" /> id="stop240"/>
<stop <stop
offset="1" offset="1"
stop-color="#087cfa" stop-color="#087cfa"
id="stop242" /> id="stop242"/>
</linearGradient> </linearGradient>
</defs> </defs>
<sodipodi:namedview <sodipodi:namedview
id="namedview34" id="namedview34"
pagecolor="#ffffff" pagecolor="#ffffff"
bordercolor="#000000" bordercolor="#000000"
borderopacity="0.25" borderopacity="0.25"
inkscape:showpageshadow="2" inkscape:showpageshadow="2"
inkscape:pageopacity="0.0" inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0" inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1" inkscape:deskcolor="#d1d1d1"
showgrid="false" showgrid="false"
inkscape:zoom="2.2172848" inkscape:zoom="2.2172848"
inkscape:cx="76.219347" inkscape:cx="76.219347"
inkscape:cy="71.709327" inkscape:cy="71.709327"
inkscape:window-width="1918" inkscape:window-width="1918"
inkscape:window-height="1034" inkscape:window-height="1034"
inkscape:window-x="0" inkscape:window-x="0"
inkscape:window-y="0" inkscape:window-y="0"
inkscape:window-maximized="1" inkscape:window-maximized="1"
inkscape:current-layer="g30" /> inkscape:current-layer="g30"/>
<g
fill="#F7A41D"
id="g30">
<g <g
id="g8" fill="#F7A41D"
style="font-variation-settings:normal;opacity:1;vector-effect:none;fill:url(#a);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000;stop-opacity:1;fill-rule:nonzero"> id="g30">
<polygon <g
points="46,22 28,44 19,30" id="g8"
id="polygon2" style="font-variation-settings:normal;opacity:1;vector-effect:none;fill:url(#a);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000;stop-opacity:1;fill-rule:nonzero">
style="font-variation-settings:normal;vector-effect:none;fill:url(#a);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000;stop-opacity:1;fill-rule:nonzero" /> <polygon
<polygon points="46,22 28,44 19,30"
points="28,44 22,44 22,95 31,95 20,100 12,117 0,117 0,22 46,22 33,33 " id="polygon2"
shape-rendering="crispEdges" style="font-variation-settings:normal;vector-effect:none;fill:url(#a);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000;stop-opacity:1;fill-rule:nonzero"/>
id="polygon4" <polygon
style="font-variation-settings:normal;vector-effect:none;fill:url(#a);fill-opacity:1;fill-rule:nonzero;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000;stop-opacity:1" points="28,44 22,44 22,95 31,95 20,100 12,117 0,117 0,22 46,22 33,33 "
inkscape:transform-center-x="-7.3684862" shape-rendering="crispEdges"
inkscape:transform-center-y="8.702662" /> id="polygon4"
<polygon style="font-variation-settings:normal;vector-effect:none;fill:url(#a);fill-opacity:1;fill-rule:nonzero;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000;stop-opacity:1"
points="31,95 12,117 4,106" inkscape:transform-center-x="-7.3684862"
id="polygon6" inkscape:transform-center-y="8.702662"/>
style="font-variation-settings:normal;vector-effect:none;fill:url(#a);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000;stop-opacity:1;fill-rule:nonzero" /> <polygon
points="31,95 12,117 4,106"
id="polygon6"
style="font-variation-settings:normal;vector-effect:none;fill:url(#a);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000;stop-opacity:1;fill-rule:nonzero"/>
</g>
<g
id="g20"
style="font-variation-settings:normal;opacity:1;vector-effect:none;fill:url(#c);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000;stop-opacity:1">
<polygon
points="56,22 62,36 37,44"
id="polygon10"
style="font-variation-settings:normal;vector-effect:none;fill:url(#c);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000;stop-opacity:1"/>
<polygon
points="56,22 111,22 111,44 37,44 56,32"
shape-rendering="crispEdges"
id="polygon12"
style="font-variation-settings:normal;vector-effect:none;fill:url(#c);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000;stop-opacity:1"/>
<polygon
points="116,95 97,117 90,104"
id="polygon14"
style="font-variation-settings:normal;vector-effect:none;fill:url(#c);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000;stop-opacity:1"/>
<polygon
points="116,95 100,104 97,117 42,117 42,95"
shape-rendering="crispEdges"
id="polygon16"
style="font-variation-settings:normal;vector-effect:none;fill:url(#c);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000;stop-opacity:1"/>
<polygon
points="150,0 52,117 3,140 101,22"
id="polygon18"
style="font-variation-settings:normal;vector-effect:none;fill:url(#c);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000;stop-opacity:1"/>
</g>
<g
id="g28"
style="font-variation-settings:normal;opacity:1;vector-effect:none;fill:#087cfa;fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000;stop-opacity:1">
<polygon
points="141,22 140,40 122,45"
id="polygon22"
style="font-variation-settings:normal;vector-effect:none;fill:#087cfa;fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000;stop-opacity:1"/>
<polygon
points="153,22 153,117 106,117 120,105 125,95 131,95 131,45 122,45 132,36 141,22"
shape-rendering="crispEdges"
id="polygon24"
style="font-variation-settings:normal;vector-effect:none;fill:#087cfa;fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000;stop-opacity:1"/>
<polygon
points="125,95 130,110 106,117"
id="polygon26"
style="font-variation-settings:normal;vector-effect:none;fill:#087cfa;fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000;stop-opacity:1"/>
</g>
</g> </g>
<g
id="g20"
style="font-variation-settings:normal;opacity:1;vector-effect:none;fill:url(#c);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000;stop-opacity:1">
<polygon
points="56,22 62,36 37,44"
id="polygon10"
style="font-variation-settings:normal;vector-effect:none;fill:url(#c);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000;stop-opacity:1" />
<polygon
points="56,22 111,22 111,44 37,44 56,32"
shape-rendering="crispEdges"
id="polygon12"
style="font-variation-settings:normal;vector-effect:none;fill:url(#c);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000;stop-opacity:1" />
<polygon
points="116,95 97,117 90,104"
id="polygon14"
style="font-variation-settings:normal;vector-effect:none;fill:url(#c);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000;stop-opacity:1" />
<polygon
points="116,95 100,104 97,117 42,117 42,95"
shape-rendering="crispEdges"
id="polygon16"
style="font-variation-settings:normal;vector-effect:none;fill:url(#c);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000;stop-opacity:1" />
<polygon
points="150,0 52,117 3,140 101,22"
id="polygon18"
style="font-variation-settings:normal;vector-effect:none;fill:url(#c);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000;stop-opacity:1" />
</g>
<g
id="g28"
style="font-variation-settings:normal;opacity:1;vector-effect:none;fill:#087cfa;fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000;stop-opacity:1">
<polygon
points="141,22 140,40 122,45"
id="polygon22"
style="font-variation-settings:normal;vector-effect:none;fill:#087cfa;fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000;stop-opacity:1" />
<polygon
points="153,22 153,117 106,117 120,105 125,95 131,95 131,45 122,45 132,36 141,22"
shape-rendering="crispEdges"
id="polygon24"
style="font-variation-settings:normal;vector-effect:none;fill:#087cfa;fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000;stop-opacity:1" />
<polygon
points="125,95 130,110 106,117"
id="polygon26"
style="font-variation-settings:normal;vector-effect:none;fill:#087cfa;fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000;stop-opacity:1" />
</g>
</g>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

View file

@ -40,8 +40,9 @@ public class HighlightingUtil {
SwingUtilities.invokeLater(() -> { SwingUtilities.invokeLater(() -> {
ApplicationManager.getApplication().runWriteAction(() -> { ApplicationManager.getApplication().runWriteAction(() -> {
markup.removeAllHighlighters(); markup.removeAllHighlighters();
for (var range: highlightRanges) { for (var range : highlightRanges) {
markup.addRangeHighlighter(range.color(), range.start(), range.end(), HighlighterLayer.SYNTAX, HighlighterTargetArea.EXACT_RANGE); markup.addRangeHighlighter(range.color(), range.start(), range.end(), HighlighterLayer.SYNTAX,
HighlighterTargetArea.EXACT_RANGE);
} }
}); });
}); });

View file

@ -46,8 +46,7 @@ public enum ZigAttributes {
Label(LABEL), Label(LABEL),
KeywordLiteral(KEYWORD), KeywordLiteral(KEYWORD),
Namespace(CLASS_NAME), Namespace(CLASS_NAME),
Struct(CLASS_NAME) Struct(CLASS_NAME);
;
public final TextAttributesKey KEY; public final TextAttributesKey KEY;
public final String type; public final String type;
public final @Unmodifiable Set<String> modifiers; public final @Unmodifiable Set<String> modifiers;
@ -64,8 +63,9 @@ public enum ZigAttributes {
if (type == null) { if (type == null) {
return Optional.empty(); return Optional.empty();
} }
for (var known: values()) { for (var known : values()) {
if (known.type.equals(type) && ((modifiers != null && modifiers.containsAll(known.modifiers)) || (modifiers == null && known.modifiers.size() == 0))) { if (known.type.equals(type) && ((modifiers != null && modifiers.containsAll(known.modifiers)) ||
(modifiers == null && known.modifiers.size() == 0))) {
return Optional.of(known.KEY); return Optional.of(known.KEY);
} }
} }

View file

@ -30,23 +30,22 @@ import java.util.Map;
public class ZigColorSettingsPage implements ColorSettingsPage { public class ZigColorSettingsPage implements ColorSettingsPage {
private static final AttributesDescriptor[] DESCRIPTORS = new AttributesDescriptor[]{ private static final AttributesDescriptor[] DESCRIPTORS =
new AttributesDescriptor("Type", ZigAttributes.Type.KEY), new AttributesDescriptor[]{new AttributesDescriptor("Type", ZigAttributes.Type.KEY),
new AttributesDescriptor("Parameter", ZigAttributes.Parameter.KEY), new AttributesDescriptor("Parameter", ZigAttributes.Parameter.KEY),
new AttributesDescriptor("Variable", ZigAttributes.Variable.KEY), new AttributesDescriptor("Variable", ZigAttributes.Variable.KEY),
new AttributesDescriptor("Enum member", ZigAttributes.EnumMember.KEY), new AttributesDescriptor("Enum member", ZigAttributes.EnumMember.KEY),
new AttributesDescriptor("Field", ZigAttributes.Field.KEY), new AttributesDescriptor("Field", ZigAttributes.Field.KEY),
new AttributesDescriptor("Error tag", ZigAttributes.ErrorTag.KEY), new AttributesDescriptor("Error tag", ZigAttributes.ErrorTag.KEY),
new AttributesDescriptor("Function", ZigAttributes.Function.KEY), new AttributesDescriptor("Function", ZigAttributes.Function.KEY),
new AttributesDescriptor("Keyword//Regular", ZigAttributes.Keyword.KEY), new AttributesDescriptor("Keyword//Regular", ZigAttributes.Keyword.KEY),
new AttributesDescriptor("Keyword//Literal", ZigAttributes.KeywordLiteral.KEY), new AttributesDescriptor("Keyword//Literal", ZigAttributes.KeywordLiteral.KEY),
new AttributesDescriptor("Comment", ZigAttributes.Comment.KEY), new AttributesDescriptor("Comment", ZigAttributes.Comment.KEY),
new AttributesDescriptor("String", ZigAttributes.String.KEY), new AttributesDescriptor("String", ZigAttributes.String.KEY),
new AttributesDescriptor("Number", ZigAttributes.Number.KEY), new AttributesDescriptor("Number", ZigAttributes.Number.KEY),
new AttributesDescriptor("Operator", ZigAttributes.Operator.KEY), new AttributesDescriptor("Operator", ZigAttributes.Operator.KEY),
new AttributesDescriptor("Builtin", ZigAttributes.Builtin.KEY), new AttributesDescriptor("Builtin", ZigAttributes.Builtin.KEY),
new AttributesDescriptor("Label", ZigAttributes.Label.KEY), new AttributesDescriptor("Label", ZigAttributes.Label.KEY),};
};
@Nullable @Nullable
@Override @Override

View file

@ -26,6 +26,7 @@ import javax.swing.Icon;
public class ZigFileType extends LanguageFileType { public class ZigFileType extends LanguageFileType {
public static final ZigFileType INSTANCE = new ZigFileType(); public static final ZigFileType INSTANCE = new ZigFileType();
private ZigFileType() { private ZigFileType() {
super(ZigLanguage.INSTANCE); super(ZigLanguage.INSTANCE);
} }

View file

@ -41,22 +41,9 @@ import java.util.concurrent.TimeoutException;
import static org.wso2.lsp4intellij.requests.Timeout.getTimeout; import static org.wso2.lsp4intellij.requests.Timeout.getTimeout;
public class ZLSEditorEventManager extends EditorEventManager { public class ZLSEditorEventManager extends EditorEventManager {
public ZLSEditorEventManager(Editor editor, public ZLSEditorEventManager(Editor editor, DocumentListener documentListener, EditorMouseListener mouseListener, EditorMouseMotionListener mouseMotionListener, LSPCaretListenerImpl caretListener, RequestManager requestmanager, ServerOptions serverOptions, LanguageServerWrapper wrapper) {
DocumentListener documentListener, super(editor, documentListener, mouseListener, mouseMotionListener, caretListener, requestmanager,
EditorMouseListener mouseListener, serverOptions, wrapper);
EditorMouseMotionListener mouseMotionListener,
LSPCaretListenerImpl caretListener,
RequestManager requestmanager,
ServerOptions serverOptions,
LanguageServerWrapper wrapper) {
super(editor,
documentListener,
mouseListener,
mouseMotionListener,
caretListener,
requestmanager,
serverOptions,
wrapper);
} }
@Override @Override

View file

@ -34,23 +34,14 @@ import org.wso2.lsp4intellij.listeners.LSPCaretListenerImpl;
public class ZLSExtensionManager implements LSPExtensionManager { public class ZLSExtensionManager implements LSPExtensionManager {
@Override @Override
public <T extends DefaultRequestManager> T getExtendedRequestManagerFor(LanguageServerWrapper wrapper, public <T extends DefaultRequestManager> T getExtendedRequestManagerFor(LanguageServerWrapper wrapper, LanguageServer server, LanguageClient client, ServerCapabilities serverCapabilities) {
LanguageServer server,
LanguageClient client,
ServerCapabilities serverCapabilities) {
return (T) new ZLSRequestManager(wrapper, server, client, serverCapabilities); return (T) new ZLSRequestManager(wrapper, server, client, serverCapabilities);
} }
@Override @Override
public <T extends EditorEventManager> T getExtendedEditorEventManagerFor(Editor editor, public <T extends EditorEventManager> T getExtendedEditorEventManagerFor(Editor editor, DocumentListener documentListener, EditorMouseListenerImpl mouseListener, EditorMouseMotionListenerImpl mouseMotionListener, LSPCaretListenerImpl caretListener, RequestManager requestManager, ServerOptions serverOptions, LanguageServerWrapper wrapper) {
DocumentListener documentListener, return (T) new ZLSEditorEventManager(editor, documentListener, mouseListener, mouseMotionListener,
EditorMouseListenerImpl mouseListener, caretListener, requestManager, serverOptions, wrapper);
EditorMouseMotionListenerImpl mouseMotionListener,
LSPCaretListenerImpl caretListener,
RequestManager requestManager,
ServerOptions serverOptions,
LanguageServerWrapper wrapper) {
return (T) new ZLSEditorEventManager(editor, documentListener, mouseListener, mouseMotionListener, caretListener, requestManager, serverOptions, wrapper);
} }
@Override @Override

View file

@ -36,17 +36,15 @@ import java.util.concurrent.CompletableFuture;
public class ZLSRequestManager extends DefaultRequestManager { public class ZLSRequestManager extends DefaultRequestManager {
private static final Logger LOG = Logger.getInstance(ZLSRequestManager.class); private static final Logger LOG = Logger.getInstance(ZLSRequestManager.class);
public ZLSRequestManager(LanguageServerWrapper wrapper, public ZLSRequestManager(LanguageServerWrapper wrapper, LanguageServer server, LanguageClient client, ServerCapabilities serverCapabilities) {
LanguageServer server,
LanguageClient client,
ServerCapabilities serverCapabilities) {
super(wrapper, server, client, serverCapabilities); super(wrapper, server, client, serverCapabilities);
} }
public CompletableFuture<SemanticTokens> semanticTokens(SemanticTokensParams params) { public CompletableFuture<SemanticTokens> semanticTokens(SemanticTokensParams params) {
if (checkStatus()) { if (checkStatus()) {
try { try {
return (getServerCapabilities().getSemanticTokensProvider() != null) ? getTextDocumentService().semanticTokensFull(params) : null; return (getServerCapabilities().getSemanticTokensProvider() != null)
? getTextDocumentService().semanticTokensFull(params) : null;
} catch (Exception e) { } catch (Exception e) {
crashed(e); crashed(e);
return null; return null;

View file

@ -37,17 +37,15 @@ public class ZLSStartupActivity implements StartupActivity {
try { try {
path = Path.of(pathTxt); path = Path.of(pathTxt);
} catch (InvalidPathException e) { } catch (InvalidPathException e) {
Notifications.Bus.notify(new Notification("ZigBrains.Nag", Notifications.Bus.notify(
"No ZLS binary", new Notification("ZigBrains.Nag", "No ZLS binary", "Invalid ZLS binary path \"" + pathTxt + "\"",
"Invalid ZLS binary path \"" + pathTxt + "\"", NotificationType.ERROR));
NotificationType.ERROR));
return; return;
} }
if (!Files.exists(path) || Files.isDirectory(path)) { if (!Files.exists(path) || Files.isDirectory(path)) {
Notifications.Bus.notify(new Notification("ZigBrains.Nag", Notifications.Bus.notify(new Notification("ZigBrains.Nag", "No ZLS binary",
"No ZLS binary", "The ZLS binary at \"" + pathTxt +
"The ZLS binary at \"" + pathTxt + "\" doesn't exist or is a directory!", "\" doesn't exist or is a directory!", NotificationType.ERROR));
NotificationType.ERROR));
} }
if (IntellijLanguageClient.getExtensionManagerFor("zig") == null) { if (IntellijLanguageClient.getExtensionManagerFor("zig") == null) {
IntellijLanguageClient.addExtensionManager("zig", new ZLSExtensionManager()); IntellijLanguageClient.addExtensionManager("zig", new ZLSExtensionManager());
@ -61,8 +59,7 @@ public class ZLSStartupActivity implements StartupActivity {
public void runActivity(@NotNull Project project) { public void runActivity(@NotNull Project project) {
var path = AppSettingsState.getInstance().zlsPath; var path = AppSettingsState.getInstance().zlsPath;
if ("".equals(path)) { if ("".equals(path)) {
Notifications.Bus.notify(new Notification("ZigBrains.Nag", Notifications.Bus.notify(new Notification("ZigBrains.Nag", "No ZLS binary",
"No ZLS binary",
"Please configure the path to the zls executable in the Zig language configuration menu!", "Please configure the path to the zls executable in the Zig language configuration menu!",
NotificationType.INFORMATION)); NotificationType.INFORMATION));
return; return;

View file

@ -28,12 +28,14 @@ import javax.swing.JPanel;
public class AppSettingsComponent { public class AppSettingsComponent {
private final JPanel myMainPanel; private final JPanel myMainPanel;
private final TextFieldWithBrowseButton zlsPathText = new TextFieldWithBrowseButton(); private final TextFieldWithBrowseButton zlsPathText = new TextFieldWithBrowseButton();
public AppSettingsComponent() { public AppSettingsComponent() {
zlsPathText.addBrowseFolderListener(new TextBrowseFolderListener(new FileChooserDescriptor(true, false, false, false, false, false))); zlsPathText.addBrowseFolderListener(
new TextBrowseFolderListener(new FileChooserDescriptor(true, false, false, false, false, false)));
myMainPanel = FormBuilder.createFormBuilder() myMainPanel = FormBuilder.createFormBuilder()
.addLabeledComponent(new JBLabel("ZLS path: "), zlsPathText, 1, false) .addLabeledComponent(new JBLabel("ZLS path: "), zlsPathText, 1, false)
.addComponentFillVertically(new JPanel(), 0) .addComponentFillVertically(new JPanel(), 0)
.getPanel(); .getPanel();
} }
public JPanel getPanel() { public JPanel getPanel() {

View file

@ -26,10 +26,8 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@Service(Service.Level.PROJECT) @Service(Service.Level.PROJECT)
@State( @State(name = "com.falsepattern.zigbrains.settings.AppSettingsState",
name = "com.falsepattern.zigbrains.settings.AppSettingsState", storages = @Storage("ZigBrainsSettings.xml"))
storages = @Storage("ZigBrainsSettings.xml")
)
public final class AppSettingsState implements PersistentStateComponent<AppSettingsState> { public final class AppSettingsState implements PersistentStateComponent<AppSettingsState> {
public String zlsPath = ""; public String zlsPath = "";

View file

@ -43,6 +43,7 @@ public class TokenDecoder {
return new Token(line, start, data.get(index + 2), data.get(index + 3), data.get(index + 4)); return new Token(line, start, data.get(index + 2), data.get(index + 3), data.get(index + 4));
} }
} }
public static List<SemaRange> decodePayload(Editor editor, SemanticTokensLegend legend, List<Integer> responseData) { public static List<SemaRange> decodePayload(Editor editor, SemanticTokensLegend legend, List<Integer> responseData) {
var result = new ArrayList<SemaRange>(); var result = new ArrayList<SemaRange>();
var application = ApplicationManager.getApplication(); var application = ApplicationManager.getApplication();
@ -55,7 +56,8 @@ public class TokenDecoder {
for (int i = 0; i < dataSize - 5; i += 5) { for (int i = 0; i < dataSize - 5; i += 5) {
var token = Token.from(prevToken, responseData, i); var token = Token.from(prevToken, responseData, i);
var logiPosStart = new LogicalPosition(token.line(), token.start()); var logiPosStart = new LogicalPosition(token.line(), token.start());
int tokenStartOffset = application.runReadAction((Computable<Integer>) () -> editor.logicalPositionToOffset(logiPosStart)); int tokenStartOffset =
application.runReadAction((Computable<Integer>) () -> editor.logicalPositionToOffset(logiPosStart));
var type = types.size() > token.type() ? types.get(token.type()) : null; var type = types.size() > token.type() ? types.get(token.type()) : null;
Set<String> modifierSet = null; Set<String> modifierSet = null;
if (token.modifiers() != 0) { if (token.modifiers() != 0) {

View file

@ -22,7 +22,7 @@
<!-- for displaying the statusbar icon --> <!-- for displaying the statusbar icon -->
<statusBarWidgetFactory implementation="org.wso2.lsp4intellij.statusbar.LSPServerStatusWidgetFactory" <statusBarWidgetFactory implementation="org.wso2.lsp4intellij.statusbar.LSPServerStatusWidgetFactory"
id="org.wso2.lsp4intellij.statusbar.LSPServerStatusWidgetFactory" id="org.wso2.lsp4intellij.statusbar.LSPServerStatusWidgetFactory"
order="first" /> order="first"/>
<!-- needed for completion --> <!-- needed for completion -->
<completion.contributor implementationClass="org.wso2.lsp4intellij.contributors.LSPCompletionContributor" <completion.contributor implementationClass="org.wso2.lsp4intellij.contributors.LSPCompletionContributor"
@ -40,8 +40,10 @@
id="LSPSymbolContributor"/> id="LSPSymbolContributor"/>
<!-- needed for renaming --> <!-- needed for renaming -->
<renameHandler implementation="org.wso2.lsp4intellij.contributors.rename.LSPRenameHandler" id="LSPRenameHandler" order="first"/> <renameHandler implementation="org.wso2.lsp4intellij.contributors.rename.LSPRenameHandler" id="LSPRenameHandler"
<renamePsiElementProcessor implementation="org.wso2.lsp4intellij.contributors.rename.LSPRenameProcessor" id="LSPRenameProcessor" order="first"/> order="first"/>
<renamePsiElementProcessor implementation="org.wso2.lsp4intellij.contributors.rename.LSPRenameProcessor"
id="LSPRenameProcessor" order="first"/>
<!-- endregion LSP4IntelliJ --> <!-- endregion LSP4IntelliJ -->
@ -53,11 +55,10 @@
<colorSettingsPage implementation="com.falsepattern.zigbrains.ide.ZigColorSettingsPage"/> <colorSettingsPage implementation="com.falsepattern.zigbrains.ide.ZigColorSettingsPage"/>
<projectConfigurable <projectConfigurable parentId="language"
parentId="language" instance="com.falsepattern.zigbrains.settings.AppSettingsConfigurable"
instance="com.falsepattern.zigbrains.settings.AppSettingsConfigurable" id="com.falsepattern.zigbrains.settings.AppSettingsConfigurable"
id="com.falsepattern.zigbrains.settings.AppSettingsConfigurable" displayName="Zig"/>
displayName="Zig"/>
<postStartupActivity implementation="com.falsepattern.zigbrains.lsp.ZLSStartupActivity"/> <postStartupActivity implementation="com.falsepattern.zigbrains.lsp.ZLSStartupActivity"/>
<notificationGroup displayType="BALLOON" id="ZigBrains.Nag"/> <notificationGroup displayType="BALLOON" id="ZigBrains.Nag"/>