-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from Saberos/master
- Loading branch information
Showing
5 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.nixos.idea.lang; | ||
|
||
import com.intellij.codeInsight.generation.actions.CommentByBlockCommentAction; | ||
import com.intellij.codeInsight.generation.actions.CommentByLineCommentAction; | ||
import com.intellij.testFramework.fixtures.BasePlatformTestCase; | ||
import org.nixos.idea.file.NixFileType; | ||
|
||
public class NixCommenterTest extends BasePlatformTestCase { | ||
|
||
public void testLineComment() { | ||
myFixture.configureByText(NixFileType.INSTANCE, "<caret>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, "<selection><caret>services.nginx.enable = true;</selection>\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"); | ||
} | ||
} |