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,8 +1,9 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 154 140">
<g fill="#F7A41D">
<g fill="#F7A41D">
<g>
<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"
shape-rendering="crispEdges"/>
<polygon points="31,95 12,117 4,106"/>
</g>
<g>
@ -14,8 +15,9 @@
</g>
<g>
<polygon points="141,22 140,40 122,45"/>
<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="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="125,95 130,110 106,117"/>
</g>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 831 B

After

Width:  |  Height:  |  Size: 1 KiB

View file

@ -21,23 +21,23 @@
<stop
offset=".09"
stop-color="#fc801d"
id="stop196" />
id="stop196"/>
<stop
offset=".23"
stop-color="#b07f61"
id="stop198" />
id="stop198"/>
<stop
offset=".41"
stop-color="#577db3"
id="stop200" />
id="stop200"/>
<stop
offset=".53"
stop-color="#1e7ce6"
id="stop202" />
id="stop202"/>
<stop
offset=".59"
stop-color="#087cfa"
id="stop204" />
id="stop204"/>
</linearGradient>
<linearGradient
id="c"
@ -49,35 +49,35 @@
<stop
offset="0"
stop-color="#fe2857"
id="stop228" />
id="stop228"/>
<stop
offset=".08"
stop-color="#fe295f"
id="stop230" />
id="stop230"/>
<stop
offset=".21"
stop-color="#ff2d76"
id="stop232" />
id="stop232"/>
<stop
offset=".3"
stop-color="#ff318c"
id="stop234" />
id="stop234"/>
<stop
offset=".38"
stop-color="#ea3896"
id="stop236" />
id="stop236"/>
<stop
offset=".55"
stop-color="#b248ae"
id="stop238" />
id="stop238"/>
<stop
offset=".79"
stop-color="#5a63d6"
id="stop240" />
id="stop240"/>
<stop
offset="1"
stop-color="#087cfa"
id="stop242" />
id="stop242"/>
</linearGradient>
</defs>
<sodipodi:namedview
@ -98,7 +98,7 @@
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="g30" />
inkscape:current-layer="g30"/>
<g
fill="#F7A41D"
id="g30">
@ -108,18 +108,18 @@
<polygon
points="46,22 28,44 19,30"
id="polygon2"
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" />
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="28,44 22,44 22,95 31,95 20,100 12,117 0,117 0,22 46,22 33,33 "
shape-rendering="crispEdges"
id="polygon4"
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"
inkscape:transform-center-x="-7.3684862"
inkscape:transform-center-y="8.702662" />
inkscape:transform-center-y="8.702662"/>
<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" />
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"
@ -127,25 +127,25 @@
<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" />
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" />
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" />
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" />
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" />
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"
@ -153,16 +153,16 @@
<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" />
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" />
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" />
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>

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(() -> {
ApplicationManager.getApplication().runWriteAction(() -> {
markup.removeAllHighlighters();
for (var range: highlightRanges) {
markup.addRangeHighlighter(range.color(), range.start(), range.end(), HighlighterLayer.SYNTAX, HighlighterTargetArea.EXACT_RANGE);
for (var range : highlightRanges) {
markup.addRangeHighlighter(range.color(), range.start(), range.end(), HighlighterLayer.SYNTAX,
HighlighterTargetArea.EXACT_RANGE);
}
});
});

View file

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

View file

@ -30,8 +30,8 @@ import java.util.Map;
public class ZigColorSettingsPage implements ColorSettingsPage {
private static final AttributesDescriptor[] DESCRIPTORS = new AttributesDescriptor[]{
new AttributesDescriptor("Type", ZigAttributes.Type.KEY),
private static final AttributesDescriptor[] DESCRIPTORS =
new AttributesDescriptor[]{new AttributesDescriptor("Type", ZigAttributes.Type.KEY),
new AttributesDescriptor("Parameter", ZigAttributes.Parameter.KEY),
new AttributesDescriptor("Variable", ZigAttributes.Variable.KEY),
new AttributesDescriptor("Enum member", ZigAttributes.EnumMember.KEY),
@ -45,8 +45,7 @@ public class ZigColorSettingsPage implements ColorSettingsPage {
new AttributesDescriptor("Number", ZigAttributes.Number.KEY),
new AttributesDescriptor("Operator", ZigAttributes.Operator.KEY),
new AttributesDescriptor("Builtin", ZigAttributes.Builtin.KEY),
new AttributesDescriptor("Label", ZigAttributes.Label.KEY),
};
new AttributesDescriptor("Label", ZigAttributes.Label.KEY),};
@Nullable
@Override

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -28,8 +28,10 @@ import javax.swing.JPanel;
public class AppSettingsComponent {
private final JPanel myMainPanel;
private final TextFieldWithBrowseButton zlsPathText = new TextFieldWithBrowseButton();
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()
.addLabeledComponent(new JBLabel("ZLS path: "), zlsPathText, 1, false)
.addComponentFillVertically(new JPanel(), 0)

View file

@ -26,10 +26,8 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@Service(Service.Level.PROJECT)
@State(
name = "com.falsepattern.zigbrains.settings.AppSettingsState",
storages = @Storage("ZigBrainsSettings.xml")
)
@State(name = "com.falsepattern.zigbrains.settings.AppSettingsState",
storages = @Storage("ZigBrainsSettings.xml"))
public final class AppSettingsState implements PersistentStateComponent<AppSettingsState> {
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));
}
}
public static List<SemaRange> decodePayload(Editor editor, SemanticTokensLegend legend, List<Integer> responseData) {
var result = new ArrayList<SemaRange>();
var application = ApplicationManager.getApplication();
@ -55,7 +56,8 @@ public class TokenDecoder {
for (int i = 0; i < dataSize - 5; i += 5) {
var token = Token.from(prevToken, responseData, i);
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;
Set<String> modifierSet = null;
if (token.modifiers() != 0) {

View file

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