From 6fcf5fbf6824397bc17d61585659e438a8af884e Mon Sep 17 00:00:00 2001 From: Peter Vanusanik Date: Sun, 15 Jan 2023 09:40:11 +0100 Subject: [PATCH 1/8] fixed #13 --- .../en_circle/slt/plugin/lisp/LispParser.java | 42 ++++++++++++------- .../lisp/impl/LispCompoundSymbolImpl.java | 34 +++++++++++++++ .../slt/plugin/lisp/impl/LispDatumImpl.java | 12 +++--- .../plugin/lisp/psi/LispCompoundSymbol.java | 12 ++++++ .../slt/plugin/lisp/psi/LispDatum.java | 6 +-- .../slt/plugin/lisp/psi/LispTypes.java | 4 ++ .../slt/plugin/lisp/psi/LispVisitor.java | 4 ++ .../com/en_circle/slt/plugin/lisp/Lisp.bnf | 6 ++- .../slt/plugin/lisp/LispParserUtil.java | 9 ++-- 9 files changed, 99 insertions(+), 30 deletions(-) create mode 100644 src/main/gen/com/en_circle/slt/plugin/lisp/impl/LispCompoundSymbolImpl.java create mode 100644 src/main/gen/com/en_circle/slt/plugin/lisp/psi/LispCompoundSymbol.java diff --git a/src/main/gen/com/en_circle/slt/plugin/lisp/LispParser.java b/src/main/gen/com/en_circle/slt/plugin/lisp/LispParser.java index 44d2cf1..ce9c7c1 100644 --- a/src/main/gen/com/en_circle/slt/plugin/lisp/LispParser.java +++ b/src/main/gen/com/en_circle/slt/plugin/lisp/LispParser.java @@ -73,10 +73,30 @@ public static boolean comment(PsiBuilder b, int l) { return r; } + /* ********************************************************** */ + // UNINTERN? symbol + public static boolean compound_symbol(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "compound_symbol")) return false; + if (!nextTokenIs(b, "", SYMBOL_TOKEN, UNINTERN)) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, COMPOUND_SYMBOL, ""); + r = compound_symbol_0(b, l + 1); + r = r && symbol(b, l + 1); + exit_section_(b, l, m, r, false, null); + return r; + } + + // UNINTERN? + private static boolean compound_symbol_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "compound_symbol_0")) return false; + consumeToken(b, UNINTERN); + return true; + } + /* ********************************************************** */ // tested | evaled | pathname | UNDEFINED_SEQUENCE | BIT_ARRAY | CHARACTER // | number | real_pair - // | symbol + // | compound_symbol // | string | vector | array | structure | list | pair public static boolean datum(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "datum")) return false; @@ -90,7 +110,7 @@ public static boolean datum(PsiBuilder b, int l) { if (!r) r = consumeToken(b, CHARACTER); if (!r) r = number(b, l + 1); if (!r) r = real_pair(b, l + 1); - if (!r) r = symbol(b, l + 1); + if (!r) r = compound_symbol(b, l + 1); if (!r) r = string(b, l + 1); if (!r) r = vector(b, l + 1); if (!r) r = array(b, l + 1); @@ -376,25 +396,17 @@ public static boolean structure(PsiBuilder b, int l) { } /* ********************************************************** */ - // UNINTERN? SYMBOL_TOKEN + // SYMBOL_TOKEN public static boolean symbol(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "symbol")) return false; - if (!nextTokenIs(b, "", SYMBOL_TOKEN, UNINTERN)) return false; + if (!nextTokenIs(b, SYMBOL_TOKEN)) return false; boolean r; - Marker m = enter_section_(b, l, _NONE_, SYMBOL, ""); - r = symbol_0(b, l + 1); - r = r && consumeToken(b, SYMBOL_TOKEN); - exit_section_(b, l, m, r, false, null); + Marker m = enter_section_(b); + r = consumeToken(b, SYMBOL_TOKEN); + exit_section_(b, m, SYMBOL, r); return r; } - // UNINTERN? - private static boolean symbol_0(PsiBuilder b, int l) { - if (!recursion_guard_(b, l, "symbol_0")) return false; - consumeToken(b, UNINTERN); - return true; - } - /* ********************************************************** */ // (TEST_SUCCESS | TEST_FALURE) sexpr public static boolean tested(PsiBuilder b, int l) { diff --git a/src/main/gen/com/en_circle/slt/plugin/lisp/impl/LispCompoundSymbolImpl.java b/src/main/gen/com/en_circle/slt/plugin/lisp/impl/LispCompoundSymbolImpl.java new file mode 100644 index 0000000..88e1996 --- /dev/null +++ b/src/main/gen/com/en_circle/slt/plugin/lisp/impl/LispCompoundSymbolImpl.java @@ -0,0 +1,34 @@ +// This is a generated file. Not intended for manual editing. +package com.en_circle.slt.plugin.lisp.impl; + +import com.en_circle.slt.plugin.lisp.psi.LispCompoundSymbol; +import com.en_circle.slt.plugin.lisp.psi.LispSymbol; +import com.en_circle.slt.plugin.lisp.psi.LispVisitor; +import com.intellij.extapi.psi.ASTWrapperPsiElement; +import com.intellij.lang.ASTNode; +import com.intellij.psi.PsiElementVisitor; +import org.jetbrains.annotations.NotNull; + +public class LispCompoundSymbolImpl extends ASTWrapperPsiElement implements LispCompoundSymbol { + + public LispCompoundSymbolImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull LispVisitor visitor) { + visitor.visitCompoundSymbol(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof LispVisitor) accept((LispVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public LispSymbol getSymbol() { + return findNotNullChildByClass(LispSymbol.class); + } + +} diff --git a/src/main/gen/com/en_circle/slt/plugin/lisp/impl/LispDatumImpl.java b/src/main/gen/com/en_circle/slt/plugin/lisp/impl/LispDatumImpl.java index b5ee4a9..c773511 100644 --- a/src/main/gen/com/en_circle/slt/plugin/lisp/impl/LispDatumImpl.java +++ b/src/main/gen/com/en_circle/slt/plugin/lisp/impl/LispDatumImpl.java @@ -30,6 +30,12 @@ public LispArray getArray() { return findChildByClass(LispArray.class); } + @Override + @Nullable + public LispCompoundSymbol getCompoundSymbol() { + return findChildByClass(LispCompoundSymbol.class); + } + @Override @Nullable public LispEvaled getEvaled() { @@ -78,12 +84,6 @@ public LispStructure getStructure() { return findChildByClass(LispStructure.class); } - @Override - @Nullable - public LispSymbol getSymbol() { - return findChildByClass(LispSymbol.class); - } - @Override @Nullable public LispTested getTested() { diff --git a/src/main/gen/com/en_circle/slt/plugin/lisp/psi/LispCompoundSymbol.java b/src/main/gen/com/en_circle/slt/plugin/lisp/psi/LispCompoundSymbol.java new file mode 100644 index 0000000..ce5f81b --- /dev/null +++ b/src/main/gen/com/en_circle/slt/plugin/lisp/psi/LispCompoundSymbol.java @@ -0,0 +1,12 @@ +// This is a generated file. Not intended for manual editing. +package com.en_circle.slt.plugin.lisp.psi; + +import com.intellij.psi.PsiElement; +import org.jetbrains.annotations.NotNull; + +public interface LispCompoundSymbol extends PsiElement { + + @NotNull + LispSymbol getSymbol(); + +} diff --git a/src/main/gen/com/en_circle/slt/plugin/lisp/psi/LispDatum.java b/src/main/gen/com/en_circle/slt/plugin/lisp/psi/LispDatum.java index 3647c7c..3f4b610 100644 --- a/src/main/gen/com/en_circle/slt/plugin/lisp/psi/LispDatum.java +++ b/src/main/gen/com/en_circle/slt/plugin/lisp/psi/LispDatum.java @@ -9,6 +9,9 @@ public interface LispDatum extends PsiElement { @Nullable LispArray getArray(); + @Nullable + LispCompoundSymbol getCompoundSymbol(); + @Nullable LispEvaled getEvaled(); @@ -33,9 +36,6 @@ public interface LispDatum extends PsiElement { @Nullable LispStructure getStructure(); - @Nullable - LispSymbol getSymbol(); - @Nullable LispTested getTested(); diff --git a/src/main/gen/com/en_circle/slt/plugin/lisp/psi/LispTypes.java b/src/main/gen/com/en_circle/slt/plugin/lisp/psi/LispTypes.java index c4118ec..4565471 100644 --- a/src/main/gen/com/en_circle/slt/plugin/lisp/psi/LispTypes.java +++ b/src/main/gen/com/en_circle/slt/plugin/lisp/psi/LispTypes.java @@ -11,6 +11,7 @@ public interface LispTypes { IElementType ARRAY = new LispElementType("ARRAY"); IElementType BINARY_NUMBER = new LispElementType("BINARY_NUMBER"); IElementType COMMENT = new LispElementType("COMMENT"); + IElementType COMPOUND_SYMBOL = new LispElementType("COMPOUND_SYMBOL"); IElementType DATUM = new LispElementType("DATUM"); IElementType ENHANCEMENT = new LispElementType("ENHANCEMENT"); IElementType EVALED = new LispElementType("EVALED"); @@ -78,6 +79,9 @@ else if (type == BINARY_NUMBER) { else if (type == COMMENT) { return new LispCommentImpl(node); } + else if (type == COMPOUND_SYMBOL) { + return new LispCompoundSymbolImpl(node); + } else if (type == DATUM) { return new LispDatumImpl(node); } diff --git a/src/main/gen/com/en_circle/slt/plugin/lisp/psi/LispVisitor.java b/src/main/gen/com/en_circle/slt/plugin/lisp/psi/LispVisitor.java index bf26cc5..6b9dd62 100644 --- a/src/main/gen/com/en_circle/slt/plugin/lisp/psi/LispVisitor.java +++ b/src/main/gen/com/en_circle/slt/plugin/lisp/psi/LispVisitor.java @@ -19,6 +19,10 @@ public void visitComment(@NotNull LispComment o) { visitPsiElement(o); } + public void visitCompoundSymbol(@NotNull LispCompoundSymbol o) { + visitPsiElement(o); + } + public void visitDatum(@NotNull LispDatum o) { visitPsiElement(o); } diff --git a/src/main/java/com/en_circle/slt/plugin/lisp/Lisp.bnf b/src/main/java/com/en_circle/slt/plugin/lisp/Lisp.bnf index a7cec01..6a5f6f1 100644 --- a/src/main/java/com/en_circle/slt/plugin/lisp/Lisp.bnf +++ b/src/main/java/com/en_circle/slt/plugin/lisp/Lisp.bnf @@ -28,7 +28,7 @@ enhancement ::= REFERENCE_SET | REFERENCE_LABEL | TEST_SUCCESS | COMMA | BACKQUO datum ::= tested | evaled | pathname | UNDEFINED_SEQUENCE | BIT_ARRAY | CHARACTER | number | real_pair - | symbol + | compound_symbol | string | vector | array | structure | list | pair tested ::= (TEST_SUCCESS | TEST_FALURE) sexpr @@ -67,7 +67,9 @@ integer ::= INTEGER_NUMBER ratio ::= RATIO_NUMBER -symbol ::= UNINTERN? SYMBOL_TOKEN { +compound_symbol ::= UNINTERN? symbol + +symbol ::= SYMBOL_TOKEN { mixin="com.en_circle.slt.plugin.lisp.psi.impl.LispNamedElementImpl" implements="com.en_circle.slt.plugin.lisp.psi.LispNamedElement" methods=[getName setName getNameIdentifier] diff --git a/src/main/java/com/en_circle/slt/plugin/lisp/LispParserUtil.java b/src/main/java/com/en_circle/slt/plugin/lisp/LispParserUtil.java index 3d698dc..8046686 100644 --- a/src/main/java/com/en_circle/slt/plugin/lisp/LispParserUtil.java +++ b/src/main/java/com/en_circle/slt/plugin/lisp/LispParserUtil.java @@ -65,8 +65,9 @@ private static String getPackageName(LispList form) { LispSexpr packageName = sexpressions.get(1); if (packageName.getDatum() != null) { LispDatum datum = packageName.getDatum(); - if (datum.getSymbol() != null) { - String text = datum.getSymbol().getText(); + if (datum.getCompoundSymbol() != null) { + LispCompoundSymbol symbolElement = datum.getCompoundSymbol(); + String text = symbolElement.getSymbol().getText(); if (text.startsWith(":")) { return text.substring(1); } else if (!text.contains(":")) { @@ -86,9 +87,9 @@ private static String getPackageName(LispList form) { private static String getAsSymbol(LispSexpr seSymbol) { LispDatum datum = seSymbol.getDatum(); if (datum != null) { - LispSymbol symbol = datum.getSymbol(); + LispCompoundSymbol symbol = datum.getCompoundSymbol(); if (symbol != null) { - return symbol.getName(); + return symbol.getSymbol().getName(); } } return null; From b196f03ea721b981b0119c8637e91409959bc882 Mon Sep 17 00:00:00 2001 From: Peter Vanusanik Date: Sun, 15 Jan 2023 10:35:31 +0100 Subject: [PATCH 2/8] fixed coc --- CodeOfConduct.md => CODE_OF_CONDUCT | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename CodeOfConduct.md => CODE_OF_CONDUCT (100%) diff --git a/CodeOfConduct.md b/CODE_OF_CONDUCT similarity index 100% rename from CodeOfConduct.md rename to CODE_OF_CONDUCT From fc435eae7205df40cf9d0aff0cd0da9c8797795d Mon Sep 17 00:00:00 2001 From: Peter Vanusanik Date: Sun, 15 Jan 2023 11:19:47 +0100 Subject: [PATCH 3/8] cleanup of readmies --- README.md | 7 +++++++ contributing.md | 3 +++ 2 files changed, 10 insertions(+) create mode 100644 contributing.md diff --git a/README.md b/README.md index 2ccc965..1b2e743 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,13 @@ You can also open this as a project in Intellij Idea. * [ ] List of quicklisp installed packages / ASDF packages * [ ] List of modified top level forms that are yet to be evaluated +### Far futures / possible goals + +* [ ] Virtual Environment à la pycharm so you can specify which interpret instance you want +* [ ] Automatic download of lisp interpret and quicklisp +* [ ] Different lisp interpreter support +* [ ] Remote connections to interpreters + ## License This project is licensed under [Apache License v2](LICENSE.txt). \ No newline at end of file diff --git a/contributing.md b/contributing.md new file mode 100644 index 0000000..f1a8a40 --- /dev/null +++ b/contributing.md @@ -0,0 +1,3 @@ +Report any bugs please! + +I will think of what to write here at later date when it's bit bigger project. \ No newline at end of file From e2081357215155acd20dc28c78e87cd6b5c5081a Mon Sep 17 00:00:00 2001 From: Peter Vanusanik Date: Sun, 15 Jan 2023 13:14:06 +0100 Subject: [PATCH 4/8] version change for 0.1.1 --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index bd2d304..a483b86 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,7 +4,7 @@ plugins { } group = "com.en_circle.slt" -version = "0.1.0" +version = "0.1.1" repositories { mavenCentral() From ac468928687d0a65d1c8f29d195af5fa4b146b47 Mon Sep 17 00:00:00 2001 From: Peter Vanusanik Date: Sun, 15 Jan 2023 19:04:57 +0100 Subject: [PATCH 5/8] instructions --- README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/README.md b/README.md index 1b2e743..524ee45 100644 --- a/README.md +++ b/README.md @@ -15,12 +15,16 @@ IDE capabilities for Common Lisp. ## Requirements 1) Intellij based IDE - tested on `Intellij Idea Community/Ultimate` but should workd on all major IDEs + 1) Versions supported are from 2022.2 and upwards 2) [Steel Bank Common Lisp](https://www.sbcl.org/) installed 3) [Quicklisp](https://www.quicklisp.org/beta/) ## Getting started Download plugin for your IDE from releases and install it via file. + +_ie_ File->Settings->Plugin, click on gear icon and then 'Install plugin from disk' + To find out which release applies to you check this table: | Jetbrains IDE Variant | Plugin name pattern | @@ -36,6 +40,29 @@ To find out which release applies to you check this table: PhpStorm is coming when I read how to build it correctly since just swapping the type does not work. +For the first time use, I recommend installing swank and eclector dependencies manually +from sbcl because there is 10 seconds timeout to see if swank has initialized,and it might +terminate before quicklisp has initialized. + +Start sbcl and run this script: + +On linux and default quicklisp path: + +```common lisp +(load "~/quicklisp/setup.lisp") +(ql:quickload :swank) +(ql:quickload :eclector) +``` + +## Plugin options + +Plugin has 2 options right now. +These are accessible in Settings>SLT Configuration + +- SBCL executable: Full path to sbcl or if sbcl is in path just `sbcl` is fine. + - on windows, you might need .exe or even full path to .exe +- Quicklisp path: path to the `setup.lisp` file of quicklisp. Defaults to `~/quicklisp/setup.lisp` + ## Compiling source Clone the repository and change gradle.properties for your IDE. From 24836aff69a1b1a35fdf7a01f21ac767cf2d8bc1 Mon Sep 17 00:00:00 2001 From: Peter Vanusanik Date: Sun, 15 Jan 2023 19:09:49 +0100 Subject: [PATCH 6/8] fixed #18 --- src/main/java/com/en_circle/slt/plugin/SltSBCL.java | 3 ++- .../en_circle/slt/plugin/settings/SltSettingsConfigurable.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/en_circle/slt/plugin/SltSBCL.java b/src/main/java/com/en_circle/slt/plugin/SltSBCL.java index 7bcb19f..51cb74e 100644 --- a/src/main/java/com/en_circle/slt/plugin/SltSBCL.java +++ b/src/main/java/com/en_circle/slt/plugin/SltSBCL.java @@ -85,7 +85,8 @@ public void stop() throws Exception { listener.onPreStop(); } try { - client.close(); + if (client != null) + client.close(); } finally { SltSBCLSymbolCache.INSTANCE.clear(); SwankServer.stop(); diff --git a/src/main/java/com/en_circle/slt/plugin/settings/SltSettingsConfigurable.java b/src/main/java/com/en_circle/slt/plugin/settings/SltSettingsConfigurable.java index 8aaa2b0..fe0cd6a 100644 --- a/src/main/java/com/en_circle/slt/plugin/settings/SltSettingsConfigurable.java +++ b/src/main/java/com/en_circle/slt/plugin/settings/SltSettingsConfigurable.java @@ -3,6 +3,7 @@ import com.en_circle.slt.plugin.SltBundle; import com.en_circle.slt.plugin.SltSBCL; import com.en_circle.slt.plugin.SltState; +import com.en_circle.slt.plugin.swank.SwankServer; import com.intellij.openapi.options.Configurable; import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.project.ProjectManager; @@ -59,7 +60,7 @@ public void apply() throws ConfigurationException { } settings.sbclExecutable = component.getSbclExecutable(); - if (restartServer) { + if (restartServer && SwankServer.INSTANCE.isActive()) { if (Messages.YES == Messages.showYesNoDialog( SltBundle.message("slt.ui.settings.restart.prompt"), SltBundle.message("slt.ui.settings.restart.title"), From aacc82a41d274828ba06182ee0f07f70efbcdbb6 Mon Sep 17 00:00:00 2001 From: Peter Vanusanik Date: Sun, 15 Jan 2023 19:16:09 +0100 Subject: [PATCH 7/8] fixed #16 --- build.gradle.kts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index a483b86..dc3ddb0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -51,9 +51,13 @@ tasks { } signPlugin { - certificateChain.set(File("./signcerts/chain.crt").readText(Charsets.UTF_8)) - privateKey.set(File("./signcerts/private.pem").readText(Charsets.UTF_8)) - password.set(System.getenv("PRIVATE_KEY_PASSWORD")) + try { + certificateChain.set(File("./signcerts/chain.crt").readText(Charsets.UTF_8)) + privateKey.set(File("./signcerts/private.pem").readText(Charsets.UTF_8)) + password.set(System.getenv("PRIVATE_KEY_PASSWORD")) + } catch (_: Exception) { + + } } publishPlugin { From af61748a08e524e2fe6514941fc56c551b1c657d Mon Sep 17 00:00:00 2001 From: Peter Vanusanik Date: Sun, 15 Jan 2023 19:21:31 +0100 Subject: [PATCH 8/8] more fixes for #16 --- .../en_circle/slt/plugin/settings/SltSettingsComponent.java | 2 ++ .../slt/plugin/settings/SltSettingsConfigurable.java | 5 ++++- src/main/resources/messages/SltBundle.properties | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/en_circle/slt/plugin/settings/SltSettingsComponent.java b/src/main/java/com/en_circle/slt/plugin/settings/SltSettingsComponent.java index 1a1ab5a..6843b39 100644 --- a/src/main/java/com/en_circle/slt/plugin/settings/SltSettingsComponent.java +++ b/src/main/java/com/en_circle/slt/plugin/settings/SltSettingsComponent.java @@ -19,6 +19,8 @@ public SltSettingsComponent() { root = FormBuilder.createFormBuilder() .addLabeledComponent(new JBLabel(SltBundle.message("slt.ui.settings.executable")), sbclExecutable, 1, false) + .addLabeledComponent(new JBLabel(SltBundle.message("slt.ui.settings.port")), + port, 1, false) .addLabeledComponent(new JBLabel(SltBundle.message("slt.ui.settings.qlpath")), quicklispStartScript, 1, false) .addComponentFillVertically(new JPanel(), 0) diff --git a/src/main/java/com/en_circle/slt/plugin/settings/SltSettingsConfigurable.java b/src/main/java/com/en_circle/slt/plugin/settings/SltSettingsConfigurable.java index fe0cd6a..ea48dfd 100644 --- a/src/main/java/com/en_circle/slt/plugin/settings/SltSettingsConfigurable.java +++ b/src/main/java/com/en_circle/slt/plugin/settings/SltSettingsConfigurable.java @@ -49,7 +49,7 @@ public boolean isModified() { public void apply() throws ConfigurationException { SltState settings = SltState.getInstance(); boolean restartServer = false; - if (!settings.sbclExecutable.equals(component.getSbclExecutable())) { + if (!component.getSbclExecutable().equals(settings.sbclExecutable)) { restartServer = true; } if (component.getPort() != settings.port) { @@ -60,6 +60,9 @@ public void apply() throws ConfigurationException { } settings.sbclExecutable = component.getSbclExecutable(); + settings.port = component.getPort(); + settings.quicklispStartScript = component.getQuicklispStartScript(); + if (restartServer && SwankServer.INSTANCE.isActive()) { if (Messages.YES == Messages.showYesNoDialog( SltBundle.message("slt.ui.settings.restart.prompt"), diff --git a/src/main/resources/messages/SltBundle.properties b/src/main/resources/messages/SltBundle.properties index 06f7f03..71a2ff5 100644 --- a/src/main/resources/messages/SltBundle.properties +++ b/src/main/resources/messages/SltBundle.properties @@ -73,6 +73,7 @@ slt.ui.debugger.frame.value=Value slt.ui.settings.title=SLT Configuration slt.ui.settings.executable=SBCL executable: slt.ui.settings.qlpath=Quicklisp path: +slt.ui.settings.port=Swank port: slt.ui.settings.restart.prompt=Settings changed, restart server? slt.ui.settings.restart.title=Settings Changed slt.ui.settings.restart.yes=Yes