This page is part of multi-step Custom Language Support Tutorial. All previous steps must be executed in sequence for the code to work.
A commenter enables the user to comment-out a line of code at the cursor or selected code automatically. The Commenter
defines support for and actions.
The SimpleCommenter
for Simple Language defines the line comment prefix as #
.
final class SimpleCommenter implements Commenter { @Override public String getLineCommentPrefix() { return "#"; } @Override public String getBlockCommentPrefix() { return ""; } @Nullable @Override public String getBlockCommentSuffix() { return null; } @Nullable @Override public String getCommentedBlockCommentPrefix() { return null; } @Nullable @Override public String getCommentedBlockCommentSuffix() { return null; } }
The SimpleCommenter
implementation is registered in the plugin configuration file using the com.intellij.lang.commenter
extension point.
<extensions defaultExtensionNs="com.intellij"> <lang.commenter language="Simple" implementationClass="org.intellij.sdk.language.SimpleCommenter"/> </extensions>
Run the ProjectRun the plugin by using the Gradle runIde
task.
Open the example Simple Language properties file in the IDE Development Instance. Place the cursor at the website
line. Select . The line is converted to a comment. Select again, and the comment is converted back to active code.
19 March 2025
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4