### Complete API Test Example Source: https://plugins.jetbrains.com/docs/intellij/integration-tests-api.html This is a comprehensive example demonstrating how to set up a test context, install a plugin, run the IDE with a driver, and interact with plugin services and utilities. ```kotlin import org.junit.jupiter.api.Test import org.junit.jupiter.api.Assertions import java.io.File internal class ApiTest { @Test fun testStubs() { Starter.newContext( "testExample", TestCase( IdeProductProvider.IC, GitHubProject.fromGithub( branchName = "master", repoRelativeUrl = "JetBrains/ij-perf-report-aggregator" ) ) .withVersion("2024.3") ) .apply { val pathToPlugin = System.getProperty("path.to.build.plugin") PluginConfigurator(this).installPluginFromFolder(File(pathToPlugin)) }.runIdeWithDriver().useDriverAndCloseIde { val storage = utility().getPluginStorage() val key = storage.getKey() val attributes = storage.getAttributes() Assertions.assertEquals("static method", key) Assertions.assertEquals(listOf("static1", "static2"), attributes) val answer = service().getAnswer() Assertions.assertEquals(42, answer) waitForProjectOpen() val project = singleProject() val strings = service(project).getStrings() Assertions.assertArrayEquals(arrayOf("foo", "bar"), strings) } } } ``` -------------------------------- ### Complete Integration Test Example Source: https://plugins.jetbrains.com/docs/intellij/integration-tests-intro.html A comprehensive integration test setup that includes downloading a project, installing a plugin, running the IDE, and monitoring for exceptions. This serves as a foundation for more complex tests. ```kotlin class PluginTest { init { di = DI { extend(di) bindSingleton(overrides = true) { object : CIServer by NoCIServer { override fun reportTestFailure( testName: String, message: String, details: String, linkToLogs: String? ) { fail { "$testName fails: $message. \n$details" } } } } } } @Test fun simpleTest() { val result = Starter.newContext( "testExample", TestCase( IdeProductProvider.IC, GitHubProject.fromGithub( branchName = "master", repoRelativeUrl = "JetBrains/ij-perf-report-aggregator" ) ).withVersion("2024.2") ).apply { val pathToPlugin = System.getProperty("path.to.build.plugin") PluginConfigurator(this).installPluginFromFolder(File(pathToPlugin)) }.runIdeWithDriver().useDriverAndCloseIde { waitForIndicators(5.minutes) } } } ``` -------------------------------- ### Minimal LSP Plugin Setup Source: https://plugins.jetbrains.com/docs/intellij/language-server-protocol.html Implement LspServerSupportProvider to register and start an LSP server for specific file types. This involves defining how to check file support and create the server's command line. ```kotlin import com.intellij.platform.lsp.api.LspServerSupportProvider import com.intellij.platform.lsp.api.ProjectWideLspServerDescriptor internal class FooLspServerSupportProvider : LspServerSupportProvider { override fun fileOpened(project: Project, file: VirtualFile, serverStarter: LspServerStarter) { if (file.extension == "foo") { serverStarter.ensureServerStarted(FooLspServerDescriptor(project)) } } } private class FooLspServerDescriptor(project: Project) : ProjectWideLspServerDescriptor(project, "Foo") { override fun isSupportedFile(file: VirtualFile) = file.extension == "foo" override fun createCommandLine() = GeneralCommandLine("foo", "--stdio") } ``` -------------------------------- ### Create a Simple Integration Test Source: https://plugins.jetbrains.com/docs/intellij/integration-tests-intro.html Write a basic integration test that starts the IDE with the plugin installed, waits for background processes, and then shuts down. The plugin path is specified via the 'path.to.build.plugin' system property. ```kotlin import com.intellij.ide.starter.ide.IdeProductProvider import com.intellij.ide.starter.models.TestCase import com.intellij.ide.starter.plugins.PluginConfigurator import com.intellij.ide.starter.project.NoProject import com.intellij.ide.starter.runner.Starter class PluginTest { @Test fun simpleTestWithoutProject() { Starter.newContext( testName = "testExample", TestCase(IdeProductProvider.IC, projectInfo = NoProject) .withVersion("2024.3"), ).apply { val pathToPlugin = System.getProperty("path.to.build.plugin") PluginConfigurator(this).installPluginFromDir(Path.of(pathToPlugin)) }.runIdeWithDriver().useDriverAndCloseIde { } } } ``` -------------------------------- ### Get Project-Level Service Example Source: https://plugins.jetbrains.com/docs/intellij/integration-tests-api.html Demonstrates how to obtain a project-level service instance using the `service()` extension method, requiring a `Project` stub obtained via `singleProject()`. ```kotlin service().getOpenProjects().singleOrNull() ``` -------------------------------- ### Full Integration Test Example with GitHub Project Source: https://plugins.jetbrains.com/docs/intellij/integration-tests-intro.html A complete integration test demonstrating context creation, plugin installation, IDE startup with a GitHub project, and waiting for IDE indicators. This test verifies that the plugin does not interfere with IDE startup. ```kotlin @Test fun simpleTest() { Starter.newContext( "testExample", TestCase( IdeProductProvider.IC, GitHubProject.fromGithub( branchName = "master", repoRelativeUrl = "JetBrains/ij-perf-report-aggregator" ) ).withVersion("2024.2") ).apply { val pathToPlugin = System.getProperty("path.to.build.plugin") PluginConfigurator(this).installPluginFromFolder(File(pathToPlugin)) }.runIdeWithDriver().useDriverAndCloseIde { waitForIndicators(5.minutes) } } ``` -------------------------------- ### Bottom-Up PSI Navigation Example Source: https://plugins.jetbrains.com/docs/intellij/navigating-psi.html Demonstrates a common bottom-up navigation pattern starting from a PSI file and offset. It finds the element at the offset, then its containing method, and finally its containing class. ```java PsiFile psiFile = anActionEvent.getData(CommonDataKeys.PSI_FILE); PsiElement element = psiFile.findElementAt(offset); PsiMethod containingMethod = PsiTreeUtil.getParentOfType(element, PsiMethod.class); PsiClass containingClass = containingMethod.getContainingClass(); ``` -------------------------------- ### Example Postfix Template Key Placeholder Source: https://plugins.jetbrains.com/docs/intellij/postfix-templates.html This example shows how the '$key' placeholder is used in template files to represent the actual template key, which is then displayed in the preview UI. ```java cart.getProducts()$key ``` ```java cart.getProducts().var ``` -------------------------------- ### Example Test File Content Source: https://plugins.jetbrains.com/docs/intellij/lexer-and-parser-definition.html This is an example content for a `.simple` file used for testing the lexer and parser. It includes comments, properties, and values with spaces or special characters. ```properties # You are reading the ".properties" entry. ! The exclamation mark can also mark text as comments. website = https://en.wikipedia.org/ language = English # The backslash below tells the application to continue reading # the value onto the next line. message = Welcome to \ Wikipedia! # Add spaces to the key key\ with\ spaces = This is the value that could be looked up with the key "key with spaces". # Unicode tab : \u0009 ``` -------------------------------- ### Setup Maven Central and Default IntelliJ Repositories Source: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-repositories-extension.html Configure Maven Central alongside the default IntelliJ Platform repositories. This setup is suitable for most plugin development scenarios. ```kotlin repositories { mavenCentral() intellijPlatform { defaultRepositories() } } ``` ```groovy repositories { mavenCentral() intellijPlatform { defaultRepositories() } } ``` -------------------------------- ### Install Plugin from Folder Source: https://plugins.jetbrains.com/docs/intellij/integration-tests-intro.html Installs a plugin into the IDE context from a local folder path. The path is typically defined via a system property in the Gradle configuration. ```kotlin .apply { val pathToPlugin = System.getProperty("path.to.build.plugin") PluginConfigurator(this).installPluginFromFolder(File(pathToPlugin)) } ``` -------------------------------- ### Registering Services in plugin.xml Source: https://plugins.jetbrains.com/docs/intellij/plugin-services.html Example of registering application-level and project-level services in the plugin.xml descriptor file. ```xml ``` -------------------------------- ### Action Implementation Example Source: https://plugins.jetbrains.com/docs/intellij/action-system.html Illustrates a basic action implementation by extending `AnAction`. This example shows how to override `actionPerformed` to define the action's behavior when triggered. ```java import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import org.jetbrains.annotations.NotNull; public class SimpleAction extends AnAction { @Override public void actionPerformed(@NotNull AnActionEvent e) { // TODO: implement action logic } } ``` -------------------------------- ### Gradle Build Script Setup for IntelliJ IDEA Plugin Source: https://plugins.jetbrains.com/docs/intellij/idea.html Minimum setup for a build.gradle.kts file to define dependencies for an IntelliJ IDEA plugin project. Ensure you replace '' with the desired IDE version. ```gradle repositories { mavenCentral() intellijPlatform { defaultRepositories() } } dependencies { intellijPlatform { intellijIdea("") } } ``` -------------------------------- ### Stub Indexer Implementation Example Source: https://plugins.jetbrains.com/docs/intellij/stub-indexes.html Shows a basic implementation of a stub indexer for a custom language element, like a method. This is a conceptual example. ```java public class JavaMethodStubElementType extends StubElementType { // ... constructor and other methods @Override public void indexStub(@NotNull MethodStub stub, @NotNull IndexSink sink) { sink.occurrence(JavaStubIndexKeys.METHOD_BY_NAME, stub.getName()); } } ``` -------------------------------- ### Example: SafeDeleteProcessorDelegate implementation for Properties language Source: https://plugins.jetbrains.com/docs/intellij/safe-delete-refactoring.html An example of implementing `SafeDeleteProcessorDelegate` to customize Safe Delete behavior for elements in the Properties language. ```java public class PropertiesSafeDeleteProcessor implements SafeDeleteProcessorDelegate { @Override public boolean canDeleteElement(@NotNull PsiElement element) { // Custom logic to determine if the element can be deleted safely return element instanceof Property; } // Other methods of SafeDeleteProcessorDelegate... } ``` -------------------------------- ### Plugin XML for Custom Settings (Example 2) Source: https://plugins.jetbrains.com/docs/intellij/rider.html This example demonstrates a plugin.xml where the backend plugin ID is derived from both the vendor name and the plugin ID due to the absence of a dot in the plugin ID. ```xml Enterprise Jean-Luc Picard ``` -------------------------------- ### Row Layout Examples Source: https://plugins.jetbrains.com/docs/intellij/kotlin-ui-dsl-version-2.html Demonstrates default row layout and how to explicitly set the layout to INDEPENDENT. ```kotlin row("Label:") { textField() } row("Long label:") { textField() } ``` ```kotlin row("Long label:") { textField() }.layout(RowLayout.INDEPENDENT) ``` -------------------------------- ### Example Quick-Fix Wording Source: https://plugins.jetbrains.com/docs/intellij/inspections.html Demonstrates the wording for a quick-fix, using single quotes for referenced code. ```text Replace with 'new-method()' ``` -------------------------------- ### Get PSI Tree for a Specific Language Source: https://plugins.jetbrains.com/docs/intellij/file-view-providers.html Obtain the PSI tree for a particular language from a FileViewProvider. For example, to get the XML PSI tree, use `fileViewProvider.getPsi(XMLLanguage.INSTANCE)`. ```java fileViewProvider.getPsi(language) ``` -------------------------------- ### Example Postfix Template Description Files Source: https://plugins.jetbrains.com/docs/intellij/postfix-templates.html These files demonstrate how to describe a postfix template's behavior before and after expansion, using '' to mark important code parts and caret positions. ```java cart.getProducts().var ``` ```java List products = cart.getProducts(); ``` -------------------------------- ### Implement RunConfiguration Source: https://plugins.jetbrains.com/docs/intellij/run-configurations-tutorial.html Represents a custom run configuration. It extends `RunConfigurationBase` and defines how to get options, configure the editor, and start the execution process. ```java public class DemoRunConfiguration extends RunConfigurationBase { protected DemoRunConfiguration(Project project, ConfigurationFactory factory, String name) { super(project, factory, name); } @NotNull @Override protected DemoRunConfigurationOptions getOptions() { return (DemoRunConfigurationOptions) super.getOptions(); } public String getScriptName() { return getOptions().getScriptName(); } public void setScriptName(String scriptName) { getOptions().setScriptName(scriptName); } @NotNull @Override public SettingsEditor getConfigurationEditor() { return new DemoSettingsEditor(); } @Nullable @Override public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment environment) { return new CommandLineState(environment) { @NotNull @Override protected ProcessHandler startProcess() throws ExecutionException { GeneralCommandLine commandLine = new GeneralCommandLine(getOptions().getScriptName()); OSProcessHandler processHandler = ProcessHandlerFactory.getInstance() .createColoredProcessHandler(commandLine); ProcessTerminatedListener.attach(processHandler); return processHandler; } }; } } ``` -------------------------------- ### Structure View Factory for Properties Language Source: https://plugins.jetbrains.com/docs/intellij/structure-view.html Example of implementing `PsiStructureViewFactory` for the Properties language plugin. This serves as a starting point for customizing the structure view. ```java public class PropertiesStructureViewFactory implements PsiStructureViewFactory { @Override public StructureViewBuilder getStructureViewBuilder(final PsiElement seo) { return new TreeBasedStructureViewBuilder() { @Override public StructureViewModel createStructureViewModel(@Nullable Editor editor) { return new PropertiesStructureViewModel(editor, seo); } @Override public boolean enterInTestConstructor(final PsiElement elementForFocus) { return false; } }; } } ``` -------------------------------- ### Setup Releases and Marketplace Repositories Source: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin.html Configures Maven Central, releases, and marketplace repositories. Use this to build against a release version of the IntelliJ Platform and depend on plugins from the JetBrains Marketplace. ```kotlin repositories { mavenCentral() intellijPlatform { releases() marketplace() } } ``` ```groovy repositories { mavenCentral() intellijPlatform { releases() marketplace() } } ``` -------------------------------- ### Enable Split Mode in Gradle Source: https://plugins.jetbrains.com/docs/intellij/configuring-split-mode.html Enable split mode and set the plugin installation target in the `intellijPlatform` extension. This starts separate frontend and backend processes for local development. ```gradle intellijPlatform { splitMode = true pluginInstallationTarget = SplitModeAware.PluginInstallationTarget.BOTH } ``` -------------------------------- ### Setup Custom SDK Paths and Save Source: https://plugins.jetbrains.com/docs/intellij/sdk.html Implement setupSdkPaths to configure SDK paths and save changes using modificator.commitChanges(). This is crucial for making custom SDK settings persistent. ```java @Override public boolean setupSdkPaths(@NotNull Sdk sdk, @NotNull SdkModel sdkModel) { SdkModificator modificator = sdk.getSdkModificator(); modificator.setVersionString(getVersionString(sdk)); modificator.commitChanges(); // save return true; } ``` -------------------------------- ### Setting Up Plugin Dependencies Source: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin.html Specify dependencies on plugins, distinguishing between bundled and marketplace plugins. Ensure `defaultRepositories()` is configured. ```kotlin repositories { intellijPlatform { defaultRepositories() } } dependencies { intellijPlatform { intellijIdea("2026.1.2") bundledPlugin("com.intellij.java") plugin("org.intellij.scala", "2024.1.4") } } ``` ```groovy repositories { intellijPlatform { defaultRepositories() } } dependencies { intellijPlatform { intellijIdea '2026.1.2' bundledPlugin 'com.intellij.java' plugin 'org.intellij.scala', '2024.1.4' } } ``` -------------------------------- ### Setup Project Structure with Module Creation Source: https://plugins.jetbrains.com/docs/intellij/legacy-project-wizard.html Implement `setupProjectStructure` to create a module if no other modules exist in the project. This method is called during project import to define the project's structure. ```java @Override public void setupProjectStructure( @NotNull Collection roots, @NotNull ProjectDescriptor projectDescriptor, @NotNull ProjectFromSourcesBuilder builder) { List modules = projectDescriptor.getModules(); if (modules.isEmpty()) { modules = new ArrayList<>(); for (DetectedProjectRoot root : roots) { modules.add(new ModuleDescriptor(root.getDirectory(), MyModuleType.getInstance(), ContainerUtil.emptyList())); } projectDescriptor.setModules(modules); } } ``` -------------------------------- ### PsiReference.handleElementRename() Example Source: https://plugins.jetbrains.com/docs/intellij/rename-refactoring.html Example of calling `PsiReference.handleElementRename()` for references to a renamed element. ```java reference.handleElementRename(newName); ``` -------------------------------- ### Example Inspection Description - Quick Fix Source: https://plugins.jetbrains.com/docs/intellij/inspections.html An example of an inspection description that includes a quick-fix. ```text Reports usages of the 'java.util.Date' class. Use 'java.time.Instant' instead. ``` -------------------------------- ### PropertyRenameHandler Example Source: https://plugins.jetbrains.com/docs/intellij/rename-refactoring.html Example of implementing `PropertyRenameHandler` to customize the UI and workflow for renaming Groovy properties. ```java public class PropertyRenameHandler implements RenameHandler { ... } ``` -------------------------------- ### Sample plugin.xml with Required and Optional Dependencies Source: https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html This example shows a plugin.xml file declaring a required dependency on the Java plugin and an optional dependency on the Kotlin plugin, along with extension definitions. ```xml ... com.intellij.java org.jetbrains.kotlin ``` -------------------------------- ### YAMLAnchorRenameInputValidator Example Source: https://plugins.jetbrains.com/docs/intellij/rename-refactoring.html Example of `YAMLAnchorRenameInputValidator` for validating YAML language anchor names during rename operations. ```java public class YAMLAnchorRenameInputValidator extends RenameInputValidator { ... } ``` -------------------------------- ### Implement DocumentationTargetProvider for Offset Documentation Source: https://plugins.jetbrains.com/docs/intellij/documentation.html Implement this extension point to build documentation for a specific offset within a PsiFile. Register it as 'com.intellij.platform.backend.documentation.targetProvider'. ```java com.intellij.platform.backend.documentation.targetProvider ``` -------------------------------- ### setName() Implementation Example Source: https://plugins.jetbrains.com/docs/intellij/rename-refactoring.html Example of implementing the `setName()` method for a Properties language plugin during rename refactoring. ```java psiElement.setName(newName); ``` -------------------------------- ### Example Inspection Description - Specific Problems Source: https://plugins.jetbrains.com/docs/intellij/inspections.html An example of an inspection description that is specific about the code problems it detects. ```text Reports if a method is annotated with '@Deprecated' but not documented with Javadoc. ``` -------------------------------- ### Example Inspection Name Source: https://plugins.jetbrains.com/docs/intellij/inspections.html An example of a concise and descriptive inspection name that reflects the code problem it detects. ```text Do not use 'check' or 'inspection' in names ``` -------------------------------- ### Project-Level Light Service (Java) Source: https://plugins.jetbrains.com/docs/intellij/plugin-services.html Example of a project-level light service implementation in Java. It demonstrates constructor injection of the Project and requires the class to be final. ```java @Service(Service.Level.PROJECT) public final class MyProjectService { private final Project myProject; MyProjectService(Project project) { myProject = project; } public void doSomething(String param) { String projectName = myProject.getName(); // ... } } ``` -------------------------------- ### Get Package Name of Java Class Source: https://plugins.jetbrains.com/docs/intellij/psi-cookbook.html Use PsiUtil.getPackageName() to get the package name for a Java class. ```java PsiUtil.getPackageName() ``` -------------------------------- ### RenamePsiElementProcessor Example Source: https://plugins.jetbrains.com/docs/intellij/rename-refactoring.html Example of `RenamePsiElementProcessor` for renaming properties in the Properties plugin language, allowing for extended renaming logic. ```java public class PropertiesRenamePsiElementProcessor extends RenamePsiElementProcessor { ... } ``` -------------------------------- ### Application-Level Light Service (Kotlin) Source: https://plugins.jetbrains.com/docs/intellij/plugin-services.html Example of an application-level light service implementation in Kotlin. Ensure the class is final. ```kotlin @Service class MyAppService { fun doSomething(param: String) { // ... } } ``` -------------------------------- ### Example IDE Component Attributes Source: https://plugins.jetbrains.com/docs/intellij/integration-tests-ui.html An example of the HTML attributes representing an IDE component, as seen when inspecting the UI structure through a browser. ```html
``` -------------------------------- ### Project-Level Light Service (Kotlin) Source: https://plugins.jetbrains.com/docs/intellij/plugin-services.html Example of a project-level light service implementation in Kotlin. It demonstrates constructor injection of the Project and requires the class to be final. ```kotlin @Service(Service.Level.PROJECT) class MyProjectService(private val project: Project) { fun doSomething(param: String) { val projectName = project.name // ... } } ``` -------------------------------- ### Example JBR Archive Naming Convention Source: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-jetbrains-runtime.html Illustrates the naming convention for JetBrains Runtime archives, showing how to parse prefix, JDK, OS, architecture, and build numbers. ```text jbr_[prefix]-[jdk]-[os]-[arch]-b[build].tar.gz e.g.: jbr_jcef-21.0.3-osx-aarch64-b446.1.tar.gz ``` -------------------------------- ### Stub Element Type Registration Example Source: https://plugins.jetbrains.com/docs/intellij/stub-indexes.html Illustrates how to register stub element types for a language. This is a conceptual example based on common patterns. ```java public interface JavaStubElementTypes { IStubElementType FIELD = new JavaFieldStubElementType(); IStubElementType METHOD = new JavaMethodStubElementType(); // ... other stub element types } ``` -------------------------------- ### Stub File Element Type Example Source: https://plugins.jetbrains.com/docs/intellij/stub-indexes.html Demonstrates extending IStubFileElementType to define a custom file element type for stub support. This is a conceptual example. ```java public class MyLanguageFileElementType extends IStubFileElementType { public static final External લાઇसेन्स.Key EXTERNAL_ID = new External લાઇसेन्स.Key<>("my.language.stub.file"); public MyLanguageFileElementType() { super(MyLanguage.INSTANCE); } @Override public External લાઇसेन्स.Key getExternalId() { return EXTERNAL_ID; } } ``` -------------------------------- ### Application-Level Light Service (Java) Source: https://plugins.jetbrains.com/docs/intellij/plugin-services.html Example of an application-level light service implementation in Java. Ensure the class is final. ```java @Service public final class MyAppService { public void doSomething(String param) { // ... } } ``` -------------------------------- ### CLion Plugin Gradle Setup Source: https://plugins.jetbrains.com/docs/intellij/clion.html Defines the necessary repositories and dependencies for a CLion plugin project using the IntelliJ Platform Gradle Plugin. ```gradle repositories { mavenCentral() intellijPlatform { defaultRepositories() } } dependencies { intellijPlatform { clion("") bundledPlugin("com.intellij.clion") } } ``` -------------------------------- ### GroovyTokenSets Example Source: https://plugins.jetbrains.com/docs/intellij/implementing-lexer.html This example shows how to define a TokenSet for grouping related token types, specifically for keywords in a Groovy language plugin. This promotes reusability. ```java package org.jetbrains.plugins.groovy.lang.parser; import com.intellij.psi.tree.TokenSet; import static org.jetbrains.plugins.groovy.GroovyBundle.message; import static org.jetbrains.plugins.groovy.GroovyElementTypes.*; public interface GroovyTokenSets { TokenSet COMMENT_SET = TokenSet.create(GROOVY_DOC_COMMENT, LINE_COMMENT, BLOCK_COMMENT); TokenSet KEYWORD_SET = TokenSet.create(ABSTRACT, AS, ASSERT, BOOLEAN, BREAK, CASE, CATCH, CLASS, CONTINUE, DEF, DEFAULT, DELETE, DO, DOUBLE, ELSE, ENUM, EXTENDS, FINAL, FINALLY, FLOAT, FOR, GOTO, IF, IMPLEMENTS, IMPORT, INSTANCEOF, INT, INTERFACE, LONG, NATIVE, NEW, PACKAGE, PRIVATE, PROTECTED, PUBLIC, RETURN, SHORT, STATIC, SUPER, SWITCH, SYNCHRONIZED, THIS, THROW, THROWS, TRANSIENT, TRY, VOID, VOLATILE, WHILE); TokenSet LITERAL_SET = TokenSet.create(STRING_LITERAL, GSTRING_LITERAL, CHARACTER_LITERAL, INTEGER_LITERAL, DECIMAL_FLOATING_POINT_LITERAL, BOOLEAN_LITERAL, NULL_LITERAL); TokenSet OPERATOR_SET = TokenSet.create(PLUS, MINUS, MULTIPLY, DIVIDE, MODULO, ASSIGN, EQUAL, NOT_EQUAL, GREATER_THAN, LESS_THAN, GREATER_EQUAL, LESS_EQUAL, AND, OR, NOT, XOR, BINARY_AND, BINARY_OR, BINARY_NOT, SHIFT_LEFT, SHIFT_RIGHT, UNSIGNED_SHIFT_RIGHT, PLUS_ASSIGN, MINUS_ASSIGN, MULTIPLY_ASSIGN, DIVIDE_ASSIGN, MODULO_ASSIGN, AND_ASSIGN, OR_ASSIGN, XOR_ASSIGN, SHIFT_LEFT_ASSIGN, SHIFT_RIGHT_ASSIGN, UNSIGNED_SHIFT_RIGHT_ASSIGN, ELVIS_OPERATOR, SPREAD_OPERATOR, SPREAD_MAP_OPERATOR, RANGE_INC, RANGE_EXC, INSTANCEOF, AS); TokenSet BRACKET_SET = TokenSet.create(LPARENTHS, RPARENTHS, LBRACKET, RBRACKET, LBRACE, RBRACE); TokenSet DOT_SET = TokenSet.create(DOT, SAFE_DOT); } ``` -------------------------------- ### Embeddable Install Plugin Button Source: https://plugins.jetbrains.com/docs/intellij/marketing.html Provides a button to allow users to install your plugin directly from your website into their IDE. Requires the user to have an IDE open. ```html ``` -------------------------------- ### Implement PsiDocumentationTargetProvider for PSI Element Documentation Source: https://plugins.jetbrains.com/docs/intellij/documentation.html Implement this extension point to build documentation for PSI elements. Register it as 'com.intellij.platform.backend.documentation.psiTargetProvider'. ```java com.intellij.platform.backend.documentation.psiTargetProvider ``` -------------------------------- ### Example: delete() implementation for Property in Properties language Source: https://plugins.jetbrains.com/docs/intellij/safe-delete-refactoring.html A concrete example of implementing the `delete()` method for a `Property` PSI element within a Properties language plugin. ```java public class Property extends PsiElementBase { // ... @Override public void delete() throws IncorrectOperationException { ASTNode node = getNode(); if (node != null) { node.getTreeParent().removeChild(node); } } // ... } ``` -------------------------------- ### Apply File Bundling to All PrepareSandboxTasks (Kotlin) Source: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-recipes.html Apply file bundling configuration to all `PrepareSandboxTask` instances using `withType`. This ensures consistent file inclusion across all sandbox preparations. ```kotlin tasks { withType { from(...) { into(...) } } } ``` -------------------------------- ### Apply File Bundling to All PrepareSandboxTasks (Groovy) Source: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-recipes.html Apply file bundling configuration to all `PrepareSandboxTask` instances using `withType` in Groovy. This ensures consistent file inclusion across all sandbox preparations. ```groovy tasks { withType(PrepareSandboxTask) { from(...) into(...) } } ``` -------------------------------- ### Get Logger Instance in Kotlin Source: https://plugins.jetbrains.com/docs/intellij/ide-infrastructure.html This Kotlin snippet shows how to get a dedicated logger instance for your class. It utilizes the logger extension function for concise instantiation. ```Kotlin import com.intellij.openapi.diagnostic.logger private val LOG = logger() class MyClass { fun someMethod() { LOG.info("someMethod() was called") } } ``` -------------------------------- ### Basic GotItTooltip with Header (Java) Source: https://plugins.jetbrains.com/docs/intellij/got-it-tooltip.html Instantiate a GotItTooltip with essential parameters and add a header to provide context. This is useful for highlighting new or changed features. ```java new GotItTooltip(TOOLTIP_ID, GET_IT_TEXT, parentDisposable) .withHeader("The reader mode is on"); ``` -------------------------------- ### Initialize GotItTooltip (Java) Source: https://plugins.jetbrains.com/docs/intellij/got-it-tooltip.html Basic initialization of GotItTooltip in Java. Use this for showing tooltips tied to specific UI elements. ```java new GotItTooltip(TOOLTIP_ID, GOT_IT_TEXT, parentDisposable) .show(gutterComponent, GotItTooltip.TOP_MIDDLE); ``` -------------------------------- ### Basic GotItTooltip with Header Source: https://plugins.jetbrains.com/docs/intellij/got-it-tooltip.html Instantiate a GotItTooltip with essential parameters and add a header to provide context. This is useful for highlighting new or changed features. ```kotlin GotItTooltip(TOOLTIP_ID, GET_IT_TEXT, parentDisposable) .withHeader("The reader mode is on") ```