From 92f56c098358ea71ef78f48afd590142d95558a5 Mon Sep 17 00:00:00 2001 From: Saberos Date: Mon, 18 Jan 2021 19:44:58 +0100 Subject: [PATCH 1/2] Add commenter --- .../org/nixos/idea/lang/NixCommenter.java | 31 +++++++++++++++++++ src/main/resources/META-INF/plugin.xml | 4 +++ .../org/nixos/idea/lang/NixCommenterTest.java | 29 +++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 src/main/java/org/nixos/idea/lang/NixCommenter.java create mode 100644 src/test/java/org/nixos/idea/lang/NixCommenterTest.java diff --git a/src/main/java/org/nixos/idea/lang/NixCommenter.java b/src/main/java/org/nixos/idea/lang/NixCommenter.java new file mode 100644 index 00000000..e70ca73c --- /dev/null +++ b/src/main/java/org/nixos/idea/lang/NixCommenter.java @@ -0,0 +1,31 @@ +package org.nixos.idea.lang; + +import com.intellij.lang.Commenter; +import org.jetbrains.annotations.Nullable; + +public class NixCommenter implements Commenter { + @Override + public @Nullable String getLineCommentPrefix() { + return "#"; + } + + @Override + public @Nullable String getBlockCommentPrefix() { + return "/*"; + } + + @Override + public @Nullable String getBlockCommentSuffix() { + return "*/"; + } + + @Override + public @Nullable String getCommentedBlockCommentPrefix() { + return null; + } + + @Override + public @Nullable String getCommentedBlockCommentSuffix() { + return null; + } +} diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 26075515..8199fe55 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -27,6 +27,10 @@ language="Nix" implementationClass="org.nixos.idea.lang.NixBraceMatcher" /> + + services.nginx.enable = true;"); + + CommentByLineCommentAction commentAction = new CommentByLineCommentAction(); + commentAction.actionPerformedImpl(getProject(), myFixture.getEditor()); + myFixture.checkResult("#services.nginx.enable = true;"); + commentAction.actionPerformedImpl(getProject(), myFixture.getEditor()); + myFixture.checkResult("services.nginx.enable = true;"); + } + + public void testBlockComment() { + myFixture.configureByText(NixFileType.INSTANCE, "services.nginx.enable = true;\n"); + + CommentByBlockCommentAction commentAction = new CommentByBlockCommentAction(); + commentAction.actionPerformedImpl(getProject(), myFixture.getEditor()); + myFixture.checkResult("/*services.nginx.enable = true;*/\n"); + commentAction.actionPerformedImpl(getProject(), myFixture.getEditor()); + myFixture.checkResult("services.nginx.enable = true;\n"); + } +} \ No newline at end of file From f8c88b65a5d21e6024c1018cecad6911cb12cddf Mon Sep 17 00:00:00 2001 From: Saberos Date: Wed, 20 Jan 2021 19:43:34 +0100 Subject: [PATCH 2/2] Bump version and update changelog --- CHANGELOG.md | 3 +++ gradle.properties | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c07bc6fb..a7ef7265 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## [Unreleased] ### Added +- Support line comment and block comment IDEA actions +## [0.3.0.4] +### Added - Support for IDEA 2020.3 ### Removed - Support for IDEA 2019.3 diff --git a/gradle.properties b/gradle.properties index 058eb66b..dd787fa0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ pluginGroup = org.nixos.idea pluginName = NixIDEA -pluginVersion = 0.3.0.4 +pluginVersion = 0.3.0.5 pluginSinceBuild = 201 pluginUntilBuild = 203.* # Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl