diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index a27f848..c09c03c 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -9,7 +9,7 @@ Development The plugin is built using Gradle and uses [gradle-intellij-plugin][gradle-intellij-plugin] to integrate with IntelliJ Platform. -First, make sure gradle is using java 17, and not any other version. +First, make sure gradle is using java 21, and not any other version like [this](https://stackoverflow.com/questions/67079327/how-can-i-fix-unsupported-class-file-major-version-60-in-intellij-idea) ### Directly from IntelliJ You can run and debug DockDockBuild directly from the IntelliJ. @@ -56,3 +56,4 @@ The plugin is written in [Kotlin](http://kotlinlang.org/). [Grammar-Kit]:https://github.com/jetbrains/grammar-kit [Grammar-Kit plugin]:https://plugins.jetbrains.com/plugin/6606-grammar-kit +[gradle-intellij-plugin]:https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin.html diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4fb02df..6fa0276 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,10 +12,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v2 with: - java-version: '17' + java-version: '21' distribution: 'adopt' - name: Validate Gradle wrapper uses: gradle/wrapper-validation-action@v1.0.4 diff --git a/.gitignore b/.gitignore index 8111b89..b452539 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,6 @@ .idea/ build/ out/ +.intellijPlatform/ .DS_Store diff --git a/CHANGELOG.md b/CHANGELOG.md index f52687b..b503b6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,17 @@ # DockDockBuild Changelog +## [2.3.0] +### Changed +- Update Java to v21 +- Update Gradle to v8.10 +- Update IntelliJ Gradle plugin to 2.X +- More dependencies upgrade + +### Added +- Support for IntelliJ 2024.2 + + ## [2.2.1] ### Fixed - getId() Intellij warning diff --git a/build.gradle.kts b/build.gradle.kts index 3b866bd..6deb46e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,109 +1,148 @@ +import org.jetbrains.changelog.Changelog import org.jetbrains.changelog.markdownToHTML -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile - -fun properties(key: String) = project.findProperty(key).toString() +import org.jetbrains.intellij.platform.gradle.TestFrameworkType plugins { - // Java support - id("java") - // Kotlin support - id("org.jetbrains.kotlin.jvm") version "1.9.0" - // Gradle IntelliJ Plugin - id("org.jetbrains.intellij") version "1.10.1" - // Gradle Changelog Plugin - id("org.jetbrains.changelog") version "1.3.1" - // Gradle Qodana Plugin - id("org.jetbrains.qodana") version "0.1.13" - // Jacoco - id("jacoco") + id("java") // Java support + alias(libs.plugins.kotlin) // Kotlin support + alias(libs.plugins.intelliJPlatform) // IntelliJ Platform Gradle Plugin + alias(libs.plugins.changelog) // Gradle Changelog Plugin + alias(libs.plugins.qodana) // Gradle Qodana Plugin + alias(libs.plugins.kover) // Gradle Kover Plugin // ktlint linter - read more: https://github.com/JLLeitschuh/ktlint-gradle - id("org.jlleitschuh.gradle.ktlint") version "10.2.1" + id("org.jlleitschuh.gradle.ktlint") version "12.1.1" + id("jacoco") } -group = properties("pluginGroup") -version = properties("pluginVersion") +group = providers.gradleProperty("pluginGroup").get() +version = providers.gradleProperty("pluginVersion").get() + +// Set the JVM language level used to build the project. +kotlin { + jvmToolchain(21) +} // Configure project's dependencies repositories { mavenCentral() + + // IntelliJ Platform Gradle Plugin Repositories Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-repositories-extension.html + intellijPlatform { + defaultRepositories() + } } -// Configure Gradle IntelliJ Plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin -intellij { - pluginName.set(properties("pluginName")) - version.set(properties("platformVersion")) - type.set(properties("platformType")) +// Dependencies are managed with Gradle version catalog - read more: https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog +dependencies { - // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file. - plugins.set(properties("platformPlugins").split(',').map(String::trim).filter(String::isNotEmpty)) -} + // IntelliJ Platform Gradle Plugin Dependencies Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html + intellijPlatform { + create(providers.gradleProperty("platformType"), providers.gradleProperty("platformVersion")) -// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin -changelog { - version.set(properties("pluginVersion")) - groups.set(emptyList()) -} + // Plugin Dependencies. Uses `platformBundledPlugins` property from the gradle.properties file for bundled IntelliJ Platform plugins. + bundledPlugins(providers.gradleProperty("platformBundledPlugins").map { it.split(',') }) -// Configure Gradle Qodana Plugin - read more: https://github.com/JetBrains/gradle-qodana-plugin -qodana { - cachePath.set(projectDir.resolve(".qodana").canonicalPath) - reportPath.set(projectDir.resolve("build/reports/inspections").canonicalPath) - saveReport.set(true) - showReport.set(System.getenv("QODANA_SHOW_REPORT")?.toBoolean() ?: false) -} + // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file for plugin from JetBrains Marketplace. + plugins(providers.gradleProperty("platformPlugins").map { it.split(',') }) -tasks.named("processResources") { - duplicatesStrategy = DuplicatesStrategy.INCLUDE -} + instrumentationTools() + pluginVerifier() + zipSigner() + testFramework(TestFrameworkType.Platform) + } -dependencies { implementation("com.fasterxml.jackson.core:jackson-core:2.13.3") implementation("com.fasterxml.jackson.core:jackson-databind:2.13.3") testImplementation("org.hamcrest:hamcrest-all:1.3") + testImplementation(libs.junit) + testImplementation("org.opentest4j:opentest4j:1.2.0") } -tasks { - // Set the JVM compatibility versions - properties("javaVersion").let { - withType { - sourceCompatibility = it - targetCompatibility = it - } - withType { - kotlinOptions.jvmTarget = it - } - } - - wrapper { - gradleVersion = properties("gradleVersion") - } - - patchPluginXml { - version.set(properties("pluginVersion")) - sinceBuild.set(properties("pluginSinceBuild")) - untilBuild.set(properties("pluginUntilBuild")) +// Configure IntelliJ Platform Gradle Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html +intellijPlatform { + pluginConfiguration { + version = providers.gradleProperty("pluginVersion") // Extract the section from README.md and provide for the plugin's manifest - pluginDescription.set( - projectDir.resolve("README.md").readText().lines().run { + description = + providers.fileContents(layout.projectDirectory.file("README.md")).asText.map { val start = "" val end = "" - if (!containsAll(listOf(start, end))) { - throw GradleException("Plugin description section not found in README.md:\n$start ... $end") + with(it.lines()) { + if (!containsAll(listOf(start, end))) { + throw GradleException("Plugin description section not found in README.md:\n$start ... $end") + } + subList(indexOf(start) + 1, indexOf(end)).joinToString("\n").let(::markdownToHTML) } - subList(indexOf(start) + 1, indexOf(end)) - }.joinToString("\n").run { markdownToHTML(this) } - ) + } + val changelog = project.changelog // local variable for configuration cache compatibility // Get the latest available change notes from the changelog file - changeNotes.set( - provider { - changelog.run { - getOrNull(properties("pluginVersion")) ?: getLatest() - }.toHTML() + changeNotes = + providers.gradleProperty("pluginVersion").map { pluginVersion -> + with(changelog) { + renderItem( + (getOrNull(pluginVersion) ?: getUnreleased()) + .withHeader(false) + .withEmptySections(false), + Changelog.OutputType.HTML, + ) + } + } + + ideaVersion { + sinceBuild = providers.gradleProperty("pluginSinceBuild") +// untilBuild = providers.gradleProperty("pluginUntilBuild") + } + } + +// signing { +// certificateChain = providers.environmentVariable("CERTIFICATE_CHAIN") +// privateKey = providers.environmentVariable("PRIVATE_KEY") +// password = providers.environmentVariable("PRIVATE_KEY_PASSWORD") +// } +// +// publishing { +// token = providers.environmentVariable("PUBLISH_TOKEN") +// // The pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3 +// // Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more: +// // https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel +// channels = providers.gradleProperty("pluginVersion").map { listOf(it.substringAfter('-', "").substringBefore('.').ifEmpty { "default" }) } +// } + + pluginVerification { + ides { + recommended() + } + } +} + +// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin +changelog { + groups.empty() + repositoryUrl = providers.gradleProperty("pluginRepositoryUrl") +} + +// Configure Gradle Kover Plugin - read more: https://github.com/Kotlin/kotlinx-kover#configuration +kover { + reports { + total { + xml { + onCheck = true } - ) + } + } +} + +tasks.named("processResources") { + duplicatesStrategy = DuplicatesStrategy.INCLUDE +} + +tasks { + + wrapper { + gradleVersion = providers.gradleProperty("gradleVersion").get() } kotlin { @@ -121,7 +160,7 @@ tasks { } } - jar { + composedJar { duplicatesStrategy = DuplicatesStrategy.INCLUDE // Run ktlint before creating the JAR @@ -140,51 +179,6 @@ tasks { }) } - buildScan { - termsOfServiceUrl = "https://gradle.com/terms-of-service" - termsOfServiceAgree = "yes" - -// publishAlways() - - fun execCommandWithOutput(input: String): String { - return try { - val parts = input.split("\\s".toRegex()) - val proc = ProcessBuilder(*parts.toTypedArray()) - .directory(rootDir) - .redirectOutput(ProcessBuilder.Redirect.PIPE) - .redirectError(ProcessBuilder.Redirect.PIPE) - .start() - proc.waitFor(20, TimeUnit.SECONDS) - proc.inputStream.bufferedReader().readText() - } catch (e: java.io.IOException) { - "" - } - } - - // Fastest way to safely check Git https://gist.github.com/sindresorhus/3898739 - value("Git Branch", execCommandWithOutput("git symbolic-ref --short HEAD")) - value("Git Commit", execCommandWithOutput("git rev-parse --verify HEAD")) - - val gitStatus = execCommandWithOutput("git status --porcelain") - if (gitStatus.isNotEmpty()) { - value("Git Local Changes", gitStatus) - tag("dirty") - } - - if (!System.getenv("CI").isNullOrEmpty()) { - tag("CI") - } - } - - // Configure UI tests plugin - // Read more: https://github.com/JetBrains/intellij-ui-test-robot - runIdeForUiTests { - systemProperty("robot-server.port", "8082") - systemProperty("ide.mac.message.dialogs.as.sheets", "false") - systemProperty("jb.privacy.policy.text", "") - systemProperty("jb.consents.confirmation.enabled", "false") - } - test { finalizedBy(jacocoTestReport) // report is always generated after tests run } @@ -192,18 +186,29 @@ tasks { dependsOn(test) // tests are required to run before generating the report } - signPlugin { - certificateChain.set(System.getenv("CERTIFICATE_CHAIN")) - privateKey.set(System.getenv("PRIVATE_KEY")) - password.set(System.getenv("PRIVATE_KEY_PASSWORD")) + publishPlugin { + dependsOn(patchChangelog) } +} - publishPlugin { - dependsOn("patchChangelog") - token.set(System.getenv("PUBLISH_TOKEN")) - // pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3 - // Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more: - // https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel - channels.set(listOf(properties("pluginVersion").split('-').getOrElse(1) { "default" }.split('.').first())) +intellijPlatformTesting { + runIde { + register("runIdeForUiTests") { + task { + jvmArgumentProviders += + CommandLineArgumentProvider { + listOf( + "-Drobot-server.port=8082", + "-Dide.mac.message.dialogs.as.sheets=false", + "-Djb.privacy.policy.text=", + "-Djb.consents.confirmation.enabled=false", + ) + } + } + + plugins { + robotServerPlugin() + } + } } } diff --git a/docker/Dockerfile b/docker/Dockerfile index 602cbb7..97a342b 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM openjdk:17-jdk +FROM openjdk:21-jdk # install general tools RUN apt-get update && apt-get install --yes --no-install-recommends && apt-get install -y wget && apt-get install -y vim && \ @@ -6,7 +6,7 @@ RUN apt-get update && apt-get install --yes --no-install-recommends && apt-get i # install gradle ENV GRADLE_HOME /opt/gradle -ENV GRADLE_VERSION 7.5 +ENV GRADLE_VERSION 8.10 ARG GRADLE_DOWNLOAD_SHA256=cb87f222c5585bd46838ad4db78463a5c5f3d336e5e2b98dc7c0c586527351c2 RUN set -o errexit -o nounset && \ echo "Downloading Gradle" && \ diff --git a/gradle.properties b/gradle.properties index cce1399..3e6f171 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,26 +4,28 @@ pluginGroup = com.intuit.dockdockbuild pluginName = DockDockBuild # SemVer format -> https://semver.org -pluginVersion = 2.2.5 +pluginVersion = 2.3.0 # See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html # for insight into build numbers and IntelliJ Platform versions. -pluginSinceBuild = 241 -pluginUntilBuild = 241.* +pluginSinceBuild = 242 +#pluginUntilBuild = 241.* # IntelliJ Platform Properties -> https://github.com/JetBrains/gradle-intellij-plugin#intellij-platform-properties platformType = IC -platformVersion = 2024.1 +platformVersion = 2024.2 # Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html -# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22 +# Example: platformPlugins = com.jetbrains.php:203.4449.22, org.intellij.scala:2023.3.27@EAP platformPlugins = +# Example: platformBundledPlugins = com.intellij.java +platformBundledPlugins = com.intellij.java -# Java language level used to compile sources and to generate the files for - Java 17 is required since 2022.2 -javaVersion = 17 +# Java language level used to compile sources and to generate the files for - Java 21 is required since 2024.2 +javaVersion = 21 # Gradle Releases -> https://github.com/gradle/gradle/releases -gradleVersion = 7.5 +gradleVersion = 8.10 # Opt-out flag for bundling Kotlin standard library. # See https://plugins.jetbrains.com/docs/intellij/kotlin.html#kotlin-standard-library for details. diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..4c2f43f --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,20 @@ +[versions] +# libraries +junit = "4.13.2" + +# plugins +changelog = "2.2.1" +intelliJPlatform = "2.1.0" +kotlin = "1.9.25" +kover = "0.8.3" +qodana = "2024.2.3" + +[libraries] +junit = { group = "junit", name = "junit", version.ref = "junit" } + +[plugins] +changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" } +intelliJPlatform = { id = "org.jetbrains.intellij.platform", version.ref = "intelliJPlatform" } +kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } +kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" } +qodana = { id = "org.jetbrains.qodana", version.ref = "qodana" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8049c68..e1adfb4 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/images/VirtualBox/create_shared_folder1.JPG b/images/VirtualBox/create_shared_folder1.JPG deleted file mode 100644 index 7173234..0000000 Binary files a/images/VirtualBox/create_shared_folder1.JPG and /dev/null differ diff --git a/images/VirtualBox/create_shared_folder2.JPG b/images/VirtualBox/create_shared_folder2.JPG deleted file mode 100644 index 93a15ad..0000000 Binary files a/images/VirtualBox/create_shared_folder2.JPG and /dev/null differ diff --git a/images/VirtualBox/shared fodlers screen.JPG b/images/VirtualBox/shared fodlers screen.JPG deleted file mode 100644 index 6a175fb..0000000 Binary files a/images/VirtualBox/shared fodlers screen.JPG and /dev/null differ diff --git a/images/gradle_version.png b/images/gradle_version.png new file mode 100644 index 0000000..329f71e Binary files /dev/null and b/images/gradle_version.png differ diff --git a/src/main/java/com/intuit/ddb/CmdProcessBuilder.java b/src/main/java/com/intuit/ddb/CmdProcessBuilder.java index e693594..acdfb8e 100644 --- a/src/main/java/com/intuit/ddb/CmdProcessBuilder.java +++ b/src/main/java/com/intuit/ddb/CmdProcessBuilder.java @@ -49,7 +49,7 @@ public static void main(String[] args) throws IOException, InterruptedException */ Parameters p = Parameters.readParams(args[0]); - // if using an image, the tag will be the the tag given in dockerImgUrl, else (for build) use default + // if using an image, the tag will be the tag given in dockerImgUrl, else (for build) use default String imageTag = p.isImage == Boolean.TRUE ? p.dockerImgUrl : DEFAULT_TAG; String codeVol = p.codePath + ":" + CODE_PATH_DOCKER; String mavenVol = p.m2Path + ":" + M2_PATH_DOCKER; diff --git a/src/main/kotlin/com/intuit/ddb/DockDockBuild.kt b/src/main/kotlin/com/intuit/ddb/DockDockBuild.kt index eb0ac24..209205b 100644 --- a/src/main/kotlin/com/intuit/ddb/DockDockBuild.kt +++ b/src/main/kotlin/com/intuit/ddb/DockDockBuild.kt @@ -12,7 +12,6 @@ fun getDefaultCodePath(project: Project): String { } fun getDefaultDockerPath(): String { - when { SystemUtils.IS_OS_WINDOWS -> return "docker" SystemUtils.IS_OS_MAC || SystemUtils.IS_OS_UNIX -> return "/usr/local/bin/docker" @@ -34,7 +33,10 @@ fun getMakefileFilename(makefileFilename: String): String { } // get relative path for makefile to cd into in the Docker container -fun getMakefileDir(project: Project, makefileFilename: String): String { +fun getMakefileDir( + project: Project, + makefileFilename: String, +): String { val pathAbsolute = Paths.get(makefileFilename) val pathBase = Paths.get(getBasePath(project)) val pathRelative = pathBase.relativize(pathAbsolute) @@ -52,7 +54,10 @@ fun getDefaultDockerfileDir(makefileFilePath: String): String { } // get Docker container set_env.sh path -fun getSetEnvRelPath(project: Project, path: String): String { +fun getSetEnvRelPath( + project: Project, + path: String, +): String { val pathAbsolute = Paths.get(path) val pathBase = Paths.get(getBasePath(project)) diff --git a/src/main/kotlin/com/intuit/ddb/DockDockBuildConfigurable.kt b/src/main/kotlin/com/intuit/ddb/DockDockBuildConfigurable.kt index 473438c..cdfb75d 100644 --- a/src/main/kotlin/com/intuit/ddb/DockDockBuildConfigurable.kt +++ b/src/main/kotlin/com/intuit/ddb/DockDockBuildConfigurable.kt @@ -13,7 +13,6 @@ import javax.swing.JTextField // Docker Make project config class DockDockBuildConfigurable(project: Project) : Configurable { - private val settings = project.getService(DockDockBuildProjectSettings::class.java) private val dockerPathField = TextFieldWithBrowseButton() private val codePathField = TextFieldWithBrowseButton() @@ -25,16 +24,22 @@ class DockDockBuildConfigurable(project: Project) : Configurable { settings.settings.codePath = settings.settings.codePath.ifEmpty { getDefaultCodePath(project) } dockerPathField.addBrowseFolderListener( - PLUGIN_NAME, "Path to Docker executable", project, - FileChooserDescriptor(true, false, false, false, false, false) + PLUGIN_NAME, + "Path to Docker executable", + project, + FileChooserDescriptor(true, false, false, false, false, false), ) codePathField.addBrowseFolderListener( - PLUGIN_NAME, "Path to code root", project, - FileChooserDescriptor(false, true, false, false, false, false) + PLUGIN_NAME, + "Path to code root", + project, + FileChooserDescriptor(false, true, false, false, false, false), ) mavenCachePathField.addBrowseFolderListener( - PLUGIN_NAME, "Path to Maven cache", project, - FileChooserDescriptor(false, true, false, false, false, false) + PLUGIN_NAME, + "Path to Maven cache", + project, + FileChooserDescriptor(false, true, false, false, false, false), ) } diff --git a/src/main/kotlin/com/intuit/ddb/DockDockBuildRunTargetAction.kt b/src/main/kotlin/com/intuit/ddb/DockDockBuildRunTargetAction.kt index 394940f..4ef4225 100644 --- a/src/main/kotlin/com/intuit/ddb/DockDockBuildRunTargetAction.kt +++ b/src/main/kotlin/com/intuit/ddb/DockDockBuildRunTargetAction.kt @@ -16,11 +16,10 @@ import name.kropp.intellij.makefile.psi.MakefileTarget // This class creates the context and runs the plugin when an event was received class DockDockBuildRunTargetAction(private val target: MakefileTarget) : AnAction( PLUGIN_NAME + " ${target.name}", - PLUGIN_NAME + " ${target.name}", MakefileTargetIcon + PLUGIN_NAME + " ${target.name}", + MakefileTargetIcon, ) { - override fun actionPerformed(event: AnActionEvent) { - val dataContext = SimpleDataContext.getSimpleContext(Location.DATA_KEY, PsiLocation(target), event.dataContext) val context = ConfigurationContext.getFromContext(dataContext, event.place) diff --git a/src/main/kotlin/com/intuit/ddb/DockerfileFileChooserDescriptor.kt b/src/main/kotlin/com/intuit/ddb/DockerfileFileChooserDescriptor.kt index dd03276..48ecdcd 100644 --- a/src/main/kotlin/com/intuit/ddb/DockerfileFileChooserDescriptor.kt +++ b/src/main/kotlin/com/intuit/ddb/DockerfileFileChooserDescriptor.kt @@ -5,14 +5,21 @@ import com.intellij.openapi.fileChooser.FileElement import com.intellij.openapi.vfs.VirtualFile class DockerfileFileChooserDescriptor : FileChooserDescriptor( - true, false, - false, false, false, false + true, + false, + false, + false, + false, + false, ) { init { title = "Dockerfile" } - override fun isFileVisible(file: VirtualFile, showHiddenFiles: Boolean) = when { + override fun isFileVisible( + file: VirtualFile, + showHiddenFiles: Boolean, + ) = when { !showHiddenFiles && FileElement.isFileHidden(file) -> false file.isDirectory -> true else -> file.name.endsWith("") && file.name == "Dockerfile" diff --git a/src/main/kotlin/com/intuit/ddb/conf/DockDockBuildRunConfiguration.kt b/src/main/kotlin/com/intuit/ddb/conf/DockDockBuildRunConfiguration.kt index c889af5..3b4d16e 100644 --- a/src/main/kotlin/com/intuit/ddb/conf/DockDockBuildRunConfiguration.kt +++ b/src/main/kotlin/com/intuit/ddb/conf/DockDockBuildRunConfiguration.kt @@ -1,16 +1,18 @@ +@file:Suppress("ktlint:standard:no-wildcard-imports") + package com.intuit.ddb.conf import com.fasterxml.jackson.databind.ObjectMapper import com.intellij.execution.Executor import com.intellij.execution.configuration.EnvironmentVariablesData -import com.intellij.execution.configurations.* // ktlint-disable no-wildcard-imports +import com.intellij.execution.configurations.* import com.intellij.execution.process.ColoredProcessHandler import com.intellij.execution.process.ProcessHandler import com.intellij.execution.process.ProcessTerminatedListener import com.intellij.execution.runners.ExecutionEnvironment import com.intellij.openapi.project.Project import com.intellij.util.lang.UrlClassLoader -import com.intuit.ddb.* // ktlint-disable no-wildcard-imports +import com.intuit.ddb.* import org.jdom.Element import java.io.File import java.net.URLDecoder @@ -18,7 +20,6 @@ import java.net.URLDecoder // This class handles the *run* configurations of the plugin open class DockDockBuildRunConfiguration(project: Project, factoryDocker: DockDockBuildRunConfigurationFactory, name: String) : LocatableConfigurationBase(project, factoryDocker, name) { - var makefileFilePath = "" var dockerfileDir = "" var dockerImageUrl = "" @@ -77,8 +78,10 @@ open class DockDockBuildRunConfiguration(project: Project, factoryDocker: DockDo } } - override fun getState(executor: Executor, executionEnvironment: ExecutionEnvironment): RunProfileState? { - + override fun getState( + executor: Executor, + executionEnvironment: ExecutionEnvironment, + ): RunProfileState? { handleParams() val decodedCP = getClassPath() @@ -86,20 +89,23 @@ open class DockDockBuildRunConfiguration(project: Project, factoryDocker: DockDo return object : CommandLineState(executionEnvironment) { override fun startProcess(): ProcessHandler { - // java -cp com.intuit.ddb.CmdProcessBuilder val params = ParametersList() params.addAll("-cp", decodedCP, PROCESS_TO_RUN, getParamsFile(project)) - val cmd = GeneralCommandLine() - .withExePath("java") - .withWorkDirectory(userDir) - .withEnvironment(environmentVariables.envs) - .withParentEnvironmentType( - if (environmentVariables.isPassParentEnvs) GeneralCommandLine.ParentEnvironmentType.CONSOLE - else GeneralCommandLine.ParentEnvironmentType.NONE - ) - .withParameters(params.list) + val cmd = + GeneralCommandLine() + .withExePath("java") + .withWorkDirectory(userDir) + .withEnvironment(environmentVariables.envs) + .withParentEnvironmentType( + if (environmentVariables.isPassParentEnvs) { + GeneralCommandLine.ParentEnvironmentType.CONSOLE + } else { + GeneralCommandLine.ParentEnvironmentType.NONE + }, + ) + .withParameters(params.list) val processHandler = ColoredProcessHandler(cmd) ProcessTerminatedListener.attach(processHandler) @@ -110,16 +116,19 @@ open class DockDockBuildRunConfiguration(project: Project, factoryDocker: DockDo } private fun handleParams() { - // Plugin (project) configuration - val dockerPath = project.getService(DockDockBuildProjectSettings::class.java) - .settings.dockerPath - val codePath = project.getService(DockDockBuildProjectSettings::class.java) - .settings.codePath - val m2Path = project.getService(DockDockBuildProjectSettings::class.java) - .settings.mavenCachePath - val advancedDockerSettings = project.getService(DockDockBuildProjectSettings::class.java) - .settings.advancedDockerSettings + val dockerPath = + project.getService(DockDockBuildProjectSettings::class.java) + .settings.dockerPath + val codePath = + project.getService(DockDockBuildProjectSettings::class.java) + .settings.codePath + val m2Path = + project.getService(DockDockBuildProjectSettings::class.java) + .settings.mavenCachePath + val advancedDockerSettings = + project.getService(DockDockBuildProjectSettings::class.java) + .settings.advancedDockerSettings // Runtime configurations // on host @@ -131,10 +140,11 @@ open class DockDockBuildRunConfiguration(project: Project, factoryDocker: DockDo // create Parameters obj and write to file to be used in CmdProcessBuilder val objectMapper = ObjectMapper() - val cmdParams = Parameters( - dockerPath, dockerfileDir, dockerImageUrl, isDockerImage.toBoolean(), - makefilePath, makefileFileName, target, codePath, m2Path, envScriptPath, advancedDockerSettings - ) + val cmdParams = + Parameters( + dockerPath, dockerfileDir, dockerImageUrl, isDockerImage.toBoolean(), + makefilePath, makefileFileName, target, codePath, m2Path, envScriptPath, advancedDockerSettings, + ) objectMapper.writeValue(File(getParamsFile(project)), cmdParams) } diff --git a/src/main/kotlin/com/intuit/ddb/conf/DockDockBuildRunConfigurationEditor.kt b/src/main/kotlin/com/intuit/ddb/conf/DockDockBuildRunConfigurationEditor.kt index 08ffa3e..118d0d7 100644 --- a/src/main/kotlin/com/intuit/ddb/conf/DockDockBuildRunConfigurationEditor.kt +++ b/src/main/kotlin/com/intuit/ddb/conf/DockDockBuildRunConfigurationEditor.kt @@ -1,3 +1,5 @@ +@file:Suppress("ktlint:standard:no-wildcard-imports") + package com.intuit.ddb.conf import com.intellij.execution.configuration.EnvironmentVariablesComponent @@ -17,12 +19,11 @@ import name.kropp.intellij.makefile.MakefileFileChooserDescriptor import name.kropp.intellij.makefile.MakefileTargetIcon import name.kropp.intellij.makefile.findTargets import java.awt.GridLayout -import javax.swing.* // ktlint-disable no-wildcard-imports +import javax.swing.* import javax.swing.event.DocumentEvent // This class builds the run conf UI class DockDockBuildRunConfigurationEditor(private val project: Project) : SettingsEditor() { - // create UI elements // Docker file\ image buttons private val dockerFilenameField = TextFieldWithBrowseButton() @@ -34,13 +35,18 @@ class DockDockBuildRunConfigurationEditor(private val project: Project) : Settin private val makeFilenameField = TextFieldWithBrowseButton() - private val targetCompletionProvider = TextFieldWithAutoCompletion.StringsCompletionProvider( - emptyList(), MakefileTargetIcon - ) - private val targetField = TextFieldWithAutoCompletion( - project, targetCompletionProvider, - true, "" - ) + private val targetCompletionProvider = + TextFieldWithAutoCompletion.StringsCompletionProvider( + emptyList(), + MakefileTargetIcon, + ) + private val targetField = + TextFieldWithAutoCompletion( + project, + targetCompletionProvider, + true, + "", + ) private val envScriptPathField = TextFieldWithBrowseButton() private val argumentsField = ExpandableTextField() @@ -66,14 +72,18 @@ class DockDockBuildRunConfigurationEditor(private val project: Project) : Settin init { dockerFilenameField.addBrowseFolderListener( - "Dockerfile", "Dockerfile path", project, - DockerfileFileChooserDescriptor() + "Dockerfile", + "Dockerfile path", + project, + DockerfileFileChooserDescriptor(), + ) + dockerFilenameField.textField.document.addDocumentListener( + object : DocumentAdapter() { + override fun textChanged(event: DocumentEvent) { + updateTargetCompletion(dockerFilenameField.text) + } + }, ) - dockerFilenameField.textField.document.addDocumentListener(object : DocumentAdapter() { - override fun textChanged(event: DocumentEvent) { - updateTargetCompletion(dockerFilenameField.text) - } - }) isDockerfileBox.addActionListener { dockerFilenameField.isEnabled = true @@ -88,24 +98,32 @@ class DockDockBuildRunConfigurationEditor(private val project: Project) : Settin } makeFilenameField.addBrowseFolderListener( - "Makefile", "Makefile path", project, - MakefileFileChooserDescriptor() + "Makefile", + "Makefile path", + project, + MakefileFileChooserDescriptor(), + ) + makeFilenameField.textField.document.addDocumentListener( + object : DocumentAdapter() { + override fun textChanged(event: DocumentEvent) { + updateTargetCompletion(makeFilenameField.text) + } + }, ) - makeFilenameField.textField.document.addDocumentListener(object : DocumentAdapter() { - override fun textChanged(event: DocumentEvent) { - updateTargetCompletion(makeFilenameField.text) - } - }) envScriptPathField.addBrowseFolderListener( - "Environment Script", "Environment script path", - project, FileChooserDescriptorFactory.createSingleFileDescriptor("sh") + "Environment Script", + "Environment script path", + project, + FileChooserDescriptorFactory.createSingleFileDescriptor("sh"), + ) + envScriptPathField.textField.document.addDocumentListener( + object : DocumentAdapter() { + override fun textChanged(event: DocumentEvent) { + updateTargetCompletion(envScriptPathField.text) + } + }, ) - envScriptPathField.textField.document.addDocumentListener(object : DocumentAdapter() { - override fun textChanged(event: DocumentEvent) { - updateTargetCompletion(envScriptPathField.text) - } - }) } fun updateTargetCompletion(filename: String) { @@ -154,7 +172,6 @@ class DockDockBuildRunConfigurationEditor(private val project: Project) : Settin } private fun dockerPanel(): JPanel { - // put radio buttons in the same group isImageGroup.add(isDockerImageBox) isImageGroup.add(isDockerfileBox) @@ -173,10 +190,11 @@ class DockDockBuildRunConfigurationEditor(private val project: Project) : Settin // Add a titled border to the button panel radioPanel.border = BorderFactory.createEmptyBorder() - radioPanel.border = BorderFactory.createTitledBorder( - radioPanel.border, - "Select Docker file or image to run" - ) + radioPanel.border = + BorderFactory.createTitledBorder( + radioPanel.border, + "Select Docker file or image to run", + ) return radioPanel } diff --git a/src/main/kotlin/com/intuit/ddb/conf/DockDockBuildRunConfigurationFactory.kt b/src/main/kotlin/com/intuit/ddb/conf/DockDockBuildRunConfigurationFactory.kt index 221fddc..e20ccc2 100644 --- a/src/main/kotlin/com/intuit/ddb/conf/DockDockBuildRunConfigurationFactory.kt +++ b/src/main/kotlin/com/intuit/ddb/conf/DockDockBuildRunConfigurationFactory.kt @@ -7,10 +7,12 @@ import com.intuit.ddb.PLUGIN_NAME class DockDockBuildRunConfigurationFactory(runConfigurationType: DockDockBuildRunConfigurationType) : ConfigurationFactory(runConfigurationType) { - - override fun createTemplateConfiguration(project: Project) = DockDockBuildRunConfiguration( - project, this, PLUGIN_NAME - ) + override fun createTemplateConfiguration(project: Project) = + DockDockBuildRunConfiguration( + project, + this, + PLUGIN_NAME, + ) override fun getSingletonPolicy() = RunConfigurationSingletonPolicy.SINGLE_INSTANCE_ONLY diff --git a/src/main/kotlin/com/intuit/ddb/conf/DockDockBuildRunConfigurationProducer.kt b/src/main/kotlin/com/intuit/ddb/conf/DockDockBuildRunConfigurationProducer.kt index d396816..2dd589a 100644 --- a/src/main/kotlin/com/intuit/ddb/conf/DockDockBuildRunConfigurationProducer.kt +++ b/src/main/kotlin/com/intuit/ddb/conf/DockDockBuildRunConfigurationProducer.kt @@ -11,7 +11,6 @@ import name.kropp.intellij.makefile.psi.MakefileTarget import java.io.File class DockDockBuildRunConfigurationProducer : LazyRunConfigurationProducer() { - override fun getConfigurationFactory(): ConfigurationFactory { return DockDockBuildRunConfigurationFactory(DockDockBuildRunConfigurationType) } @@ -20,9 +19,8 @@ class DockDockBuildRunConfigurationProducer : LazyRunConfigurationProducer + sourceElement: Ref, ): Boolean { - if (context.psiLocation?.containingFile !is MakefileFile) { return false } @@ -42,9 +40,8 @@ class DockDockBuildRunConfigurationProducer : LazyRunConfigurationProducer { val file = psiFile as MakefileFile val rule = MakefileElementFactory.createRule(project, prerequisite.text) diff --git a/src/main/kotlin/name/kropp/intellij/makefile/MakefileAnnotator.kt b/src/main/kotlin/name/kropp/intellij/makefile/MakefileAnnotator.kt index f107ab0..38e37c1 100644 --- a/src/main/kotlin/name/kropp/intellij/makefile/MakefileAnnotator.kt +++ b/src/main/kotlin/name/kropp/intellij/makefile/MakefileAnnotator.kt @@ -1,3 +1,5 @@ +@file:Suppress("ktlint:standard:no-wildcard-imports") + package name.kropp.intellij.makefile import com.intellij.codeInspection.ProblemHighlightType @@ -8,12 +10,15 @@ import com.intellij.openapi.util.TextRange import com.intellij.psi.PsiElement import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReference import com.intellij.psi.tree.TokenSet -import name.kropp.intellij.makefile.psi.* // ktlint-disable no-wildcard-imports +import name.kropp.intellij.makefile.psi.* class MakefileAnnotator : Annotator { private val lineTokenSet = TokenSet.create(MakefileTypes.LINE) - override fun annotate(element: PsiElement, holder: AnnotationHolder) { + override fun annotate( + element: PsiElement, + holder: AnnotationHolder, + ) { if (element is MakefileRule && element.isUnused()) { holder.newAnnotation(HighlightSeverity.INFORMATION, "Redundant rule").range(element) .highlightType(ProblemHighlightType.LIKE_UNUSED_SYMBOL) diff --git a/src/main/kotlin/name/kropp/intellij/makefile/MakefileChooseByNameContributor.kt b/src/main/kotlin/name/kropp/intellij/makefile/MakefileChooseByNameContributor.kt index 41f56f4..e29dcd7 100644 --- a/src/main/kotlin/name/kropp/intellij/makefile/MakefileChooseByNameContributor.kt +++ b/src/main/kotlin/name/kropp/intellij/makefile/MakefileChooseByNameContributor.kt @@ -4,6 +4,17 @@ import com.intellij.navigation.ChooseByNameContributor import com.intellij.openapi.project.Project class MakefileChooseByNameContributor : ChooseByNameContributor { - override fun getItemsByName(name: String, pattern: String, project: Project, includeNonProjectItems: Boolean) = findTargets(project, name).filterNot { it.isSpecialTarget }.toTypedArray() - override fun getNames(project: Project, includeNonProjectItems: Boolean) = findAllTargets(project).filterNot(String::isNullOrEmpty).toTypedArray() + override fun getItemsByName( + name: String, + pattern: String, + project: Project, + includeNonProjectItems: Boolean, + ) = findTargets(project, name).filterNot { it.isSpecialTarget }.toTypedArray() + + override fun getNames( + project: Project, + includeNonProjectItems: Boolean, + ) = findAllTargets( + project, + ).filterNot(String::isNullOrEmpty).toTypedArray() } diff --git a/src/main/kotlin/name/kropp/intellij/makefile/MakefileCodeStyleSettingsProvider.kt b/src/main/kotlin/name/kropp/intellij/makefile/MakefileCodeStyleSettingsProvider.kt index f7d3daf..89abde5 100644 --- a/src/main/kotlin/name/kropp/intellij/makefile/MakefileCodeStyleSettingsProvider.kt +++ b/src/main/kotlin/name/kropp/intellij/makefile/MakefileCodeStyleSettingsProvider.kt @@ -6,14 +6,14 @@ import com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider class MakefileCodeStyleSettingsProvider : LanguageCodeStyleSettingsProvider() { override fun customizeDefaults( commonSettings: CommonCodeStyleSettings, - indentOptions: CommonCodeStyleSettings.IndentOptions + indentOptions: CommonCodeStyleSettings.IndentOptions, ) { super.customizeDefaults( commonSettings, indentOptions.apply { INDENT_SIZE = 4 USE_TAB_CHARACTER = true - } + }, ) } diff --git a/src/main/kotlin/name/kropp/intellij/makefile/MakefileColorSettingsPage.kt b/src/main/kotlin/name/kropp/intellij/makefile/MakefileColorSettingsPage.kt index 6c6381a..7f6e203 100644 --- a/src/main/kotlin/name/kropp/intellij/makefile/MakefileColorSettingsPage.kt +++ b/src/main/kotlin/name/kropp/intellij/makefile/MakefileColorSettingsPage.kt @@ -6,39 +6,45 @@ import com.intellij.openapi.options.colors.ColorSettingsPage class MakefileColorSettingsPage : ColorSettingsPage { override fun getDisplayName() = "Makefile" + override fun getIcon() = MakefileIcon - private val tags = mapOf( - "target" to MakefileSyntaxHighlighter.TARGET, - "specialTarget" to MakefileSyntaxHighlighter.SPECIAL_TARGET, - "variableName" to MakefileSyntaxHighlighter.VARIABLE, - "prerequisite" to MakefileSyntaxHighlighter.PREREQUISITE, - "function" to MakefileSyntaxHighlighter.FUNCTION, - "functionParam" to MakefileSyntaxHighlighter.FUNCTION_PARAM, - "variableUsage" to MakefileSyntaxHighlighter.VARIABLE_USAGE - ) - - private val DESCRIPTORS = arrayOf( - AttributesDescriptor("Comment", MakefileSyntaxHighlighter.COMMENT), - AttributesDescriptor("Documentation Comment", MakefileSyntaxHighlighter.DOCCOMMENT), - AttributesDescriptor("Keyword", MakefileSyntaxHighlighter.KEYWORD), - AttributesDescriptor("Target", MakefileSyntaxHighlighter.TARGET), - AttributesDescriptor("Special Target", MakefileSyntaxHighlighter.SPECIAL_TARGET), - AttributesDescriptor("Separator", MakefileSyntaxHighlighter.SEPARATOR), - AttributesDescriptor("Prerequisite", MakefileSyntaxHighlighter.PREREQUISITE), - AttributesDescriptor("Variable Name", MakefileSyntaxHighlighter.VARIABLE), - AttributesDescriptor("Variable Value", MakefileSyntaxHighlighter.VARIABLE_VALUE), - AttributesDescriptor("Variable Usage", MakefileSyntaxHighlighter.VARIABLE_USAGE), - AttributesDescriptor("Line Split", MakefileSyntaxHighlighter.LINE_SPLIT), - AttributesDescriptor("Tab", MakefileSyntaxHighlighter.TAB), - AttributesDescriptor("Function", MakefileSyntaxHighlighter.FUNCTION), - AttributesDescriptor("Function Param", MakefileSyntaxHighlighter.FUNCTION_PARAM) - ) + private val tags = + mapOf( + "target" to MakefileSyntaxHighlighter.TARGET, + "specialTarget" to MakefileSyntaxHighlighter.SPECIAL_TARGET, + "variableName" to MakefileSyntaxHighlighter.VARIABLE, + "prerequisite" to MakefileSyntaxHighlighter.PREREQUISITE, + "function" to MakefileSyntaxHighlighter.FUNCTION, + "functionParam" to MakefileSyntaxHighlighter.FUNCTION_PARAM, + "variableUsage" to MakefileSyntaxHighlighter.VARIABLE_USAGE, + ) + + @Suppress("ktlint") + private val DESCRIPTORS = + arrayOf( + AttributesDescriptor("Comment", MakefileSyntaxHighlighter.COMMENT), + AttributesDescriptor("Documentation Comment", MakefileSyntaxHighlighter.DOCCOMMENT), + AttributesDescriptor("Keyword", MakefileSyntaxHighlighter.KEYWORD), + AttributesDescriptor("Target", MakefileSyntaxHighlighter.TARGET), + AttributesDescriptor("Special Target", MakefileSyntaxHighlighter.SPECIAL_TARGET), + AttributesDescriptor("Separator", MakefileSyntaxHighlighter.SEPARATOR), + AttributesDescriptor("Prerequisite", MakefileSyntaxHighlighter.PREREQUISITE), + AttributesDescriptor("Variable Name", MakefileSyntaxHighlighter.VARIABLE), + AttributesDescriptor("Variable Value", MakefileSyntaxHighlighter.VARIABLE_VALUE), + AttributesDescriptor("Variable Usage", MakefileSyntaxHighlighter.VARIABLE_USAGE), + AttributesDescriptor("Line Split", MakefileSyntaxHighlighter.LINE_SPLIT), + AttributesDescriptor("Tab", MakefileSyntaxHighlighter.TAB), + AttributesDescriptor("Function", MakefileSyntaxHighlighter.FUNCTION), + AttributesDescriptor("Function Param", MakefileSyntaxHighlighter.FUNCTION_PARAM), + ) override fun getAttributeDescriptors() = DESCRIPTORS + override fun getHighlighter() = MakefileSyntaxHighlighter() - override fun getDemoText() = """# Simple Makefile + override fun getDemoText() = + """# Simple Makefile include make.mk all: hello ## Doc comment @@ -59,5 +65,6 @@ ${'\t'}$(error Architecture $(ARCH)() { - override fun addCompletions(parameters: CompletionParameters, context: ProcessingContext, resultSet: CompletionResultSet) { + override fun addCompletions( + parameters: CompletionParameters, + context: ProcessingContext, + resultSet: CompletionResultSet, + ) { resultSet.addAllElements(keywords.map { LookupElementBuilder.create(it) }) } - } + }, ) } } diff --git a/src/main/kotlin/name/kropp/intellij/makefile/MakefileDocumentationProvider.kt b/src/main/kotlin/name/kropp/intellij/makefile/MakefileDocumentationProvider.kt index 754cd5e..0aaf04e 100644 --- a/src/main/kotlin/name/kropp/intellij/makefile/MakefileDocumentationProvider.kt +++ b/src/main/kotlin/name/kropp/intellij/makefile/MakefileDocumentationProvider.kt @@ -5,6 +5,13 @@ import com.intellij.psi.PsiElement import name.kropp.intellij.makefile.psi.MakefileTarget class MakefileDocumentationProvider : AbstractDocumentationProvider() { - override fun getQuickNavigateInfo(element: PsiElement, originalElement: PsiElement?) = (element as? MakefileTarget)?.docComment - override fun generateDoc(element: PsiElement?, originalElement: PsiElement?) = (element as? MakefileTarget)?.docComment + override fun getQuickNavigateInfo( + element: PsiElement, + originalElement: PsiElement?, + ) = (element as? MakefileTarget)?.docComment + + override fun generateDoc( + element: PsiElement?, + originalElement: PsiElement?, + ) = (element as? MakefileTarget)?.docComment } diff --git a/src/main/kotlin/name/kropp/intellij/makefile/MakefileFileChooserDescriptor.kt b/src/main/kotlin/name/kropp/intellij/makefile/MakefileFileChooserDescriptor.kt index 6f33ae5..11d116c 100644 --- a/src/main/kotlin/name/kropp/intellij/makefile/MakefileFileChooserDescriptor.kt +++ b/src/main/kotlin/name/kropp/intellij/makefile/MakefileFileChooserDescriptor.kt @@ -9,7 +9,10 @@ class MakefileFileChooserDescriptor : FileChooserDescriptor(true, false, false, title = "Makefile" } - override fun isFileVisible(file: VirtualFile, showHiddenFiles: Boolean) = when { + override fun isFileVisible( + file: VirtualFile, + showHiddenFiles: Boolean, + ) = when { !showHiddenFiles && FileElement.isFileHidden(file) -> false file.isDirectory -> true else -> file.name.endsWith(".mk") || file.name == "Makefile" diff --git a/src/main/kotlin/name/kropp/intellij/makefile/MakefileFileType.kt b/src/main/kotlin/name/kropp/intellij/makefile/MakefileFileType.kt index 1667c81..d7d79c3 100644 --- a/src/main/kotlin/name/kropp/intellij/makefile/MakefileFileType.kt +++ b/src/main/kotlin/name/kropp/intellij/makefile/MakefileFileType.kt @@ -1,7 +1,9 @@ +@file:Suppress("ktlint:standard:no-wildcard-imports") + package name.kropp.intellij.makefile import com.intellij.icons.AllIcons -import com.intellij.openapi.fileTypes.* // ktlint-disable no-wildcard-imports +import com.intellij.openapi.fileTypes.* import com.intellij.openapi.util.IconLoader import javax.swing.Icon @@ -9,7 +11,6 @@ val MakefileIcon = IconLoader.getIcon("/ddb/icon/DockDockBuild15pxl.png", Makefi val MakefileTargetIcon = AllIcons.RunConfigurations.TestState.Run class MakefileFileType : LanguageFileType(MakefileLanguage) { - override fun getName(): String { return "Makefile" } diff --git a/src/main/kotlin/name/kropp/intellij/makefile/MakefileFindUsagesProvider.kt b/src/main/kotlin/name/kropp/intellij/makefile/MakefileFindUsagesProvider.kt index 4b9234a..453ff10 100644 --- a/src/main/kotlin/name/kropp/intellij/makefile/MakefileFindUsagesProvider.kt +++ b/src/main/kotlin/name/kropp/intellij/makefile/MakefileFindUsagesProvider.kt @@ -8,12 +8,38 @@ import name.kropp.intellij.makefile.psi.MakefileTarget import name.kropp.intellij.makefile.psi.MakefileTypes class MakefileFindUsagesProvider : FindUsagesProvider { - override fun getWordsScanner() = DefaultWordsScanner(MakefileLexerAdapter(), TokenSet.create(MakefileTypes.IDENTIFIER), TokenSet.create(MakefileTypes.COMMENT), TokenSet.EMPTY) + override fun getWordsScanner() = + DefaultWordsScanner( + MakefileLexerAdapter(), + TokenSet.create(MakefileTypes.IDENTIFIER), + TokenSet.create(MakefileTypes.COMMENT), + TokenSet.EMPTY, + ) override fun canFindUsagesFor(element: PsiElement) = element is MakefileTarget && !element.isSpecialTarget - override fun getType(element: PsiElement) = if (canFindUsagesFor(element)) { "Makefile target" } else "" - override fun getDescriptiveName(element: PsiElement) = if (canFindUsagesFor(element)) { element.text } else "" - override fun getNodeText(element: PsiElement, useFullName: Boolean) = if (canFindUsagesFor(element)) { element.text } else "" + + override fun getType(element: PsiElement) = + if (canFindUsagesFor(element)) { + "Makefile target" + } else { + "" + } + + override fun getDescriptiveName(element: PsiElement) = + if (canFindUsagesFor(element)) { + element.text + } else { + "" + } + + override fun getNodeText( + element: PsiElement, + useFullName: Boolean, + ) = if (canFindUsagesFor(element)) { + element.text + } else { + "" + } override fun getHelpId(element: PsiElement) = null } diff --git a/src/main/kotlin/name/kropp/intellij/makefile/MakefileFoldingBuilder.kt b/src/main/kotlin/name/kropp/intellij/makefile/MakefileFoldingBuilder.kt index 05f0bb5..c11a212 100644 --- a/src/main/kotlin/name/kropp/intellij/makefile/MakefileFoldingBuilder.kt +++ b/src/main/kotlin/name/kropp/intellij/makefile/MakefileFoldingBuilder.kt @@ -13,18 +13,27 @@ import name.kropp.intellij.makefile.psi.MakefileRule import name.kropp.intellij.makefile.psi.MakefileVariableAssignment class MakefileFoldingBuilder : FoldingBuilderEx(), DumbAware { - override fun buildFoldRegions(root: PsiElement, document: Document, quick: Boolean) = - PsiTreeUtil.findChildrenOfAnyType(root, MakefileRule::class.java, MakefileVariableAssignment::class.java, MakefileDefine::class.java) - .mapNotNull { - when (it) { - is MakefileRule -> MakefileRuleFoldingDescriptor(it) - is MakefileVariableAssignment -> MakefileVariableFoldingDescriptor(it) - is MakefileDefine -> MakefileDefineFoldingDescriptor(it) - else -> null - } - }.toTypedArray() + override fun buildFoldRegions( + root: PsiElement, + document: Document, + quick: Boolean, + ) = PsiTreeUtil.findChildrenOfAnyType( + root, + MakefileRule::class.java, + MakefileVariableAssignment::class.java, + MakefileDefine::class.java, + ) + .mapNotNull { + when (it) { + is MakefileRule -> MakefileRuleFoldingDescriptor(it) + is MakefileVariableAssignment -> MakefileVariableFoldingDescriptor(it) + is MakefileDefine -> MakefileDefineFoldingDescriptor(it) + else -> null + } + }.toTypedArray() override fun getPlaceholderText(node: ASTNode) = "..." + override fun isCollapsedByDefault(node: ASTNode) = node.psi is MakefileDefine companion object { @@ -38,15 +47,27 @@ class MakefileFoldingBuilder : FoldingBuilderEx(), DumbAware { }?.trim() ?: "" } - fun PsiElement.trimmedTextRange() = TextRange.create(textRange.startOffset, textRange.startOffset + text.indexOfLast { !it.isWhitespace() } + 1) + fun PsiElement.trimmedTextRange() = + TextRange.create( + textRange.startOffset, + textRange.startOffset + + text.indexOfLast { + !it.isWhitespace() + } + 1, + ) } class MakefileRuleFoldingDescriptor(private val rule: MakefileRule) : FoldingDescriptor(rule, rule.trimmedTextRange()) { override fun getPlaceholderText() = rule.targetLine.targets.text + ":" } - class MakefileVariableFoldingDescriptor(private val variable: MakefileVariableAssignment) : FoldingDescriptor(variable, variable.trimmedTextRange()) { + + class MakefileVariableFoldingDescriptor(private val variable: MakefileVariableAssignment) : FoldingDescriptor( + variable, + variable.trimmedTextRange(), + ) { override fun getPlaceholderText() = "${variable.variable.text}${variable.assignment?.text ?: "="}${cutValue(variable.value)}" } + class MakefileDefineFoldingDescriptor(private val define: MakefileDefine) : FoldingDescriptor(define, define.trimmedTextRange()) { override fun getPlaceholderText() = "${define.variable?.text}${define.assignment?.text ?: "="}${cutValue(define.value)}" } diff --git a/src/main/kotlin/name/kropp/intellij/makefile/MakefileParserDefinition.kt b/src/main/kotlin/name/kropp/intellij/makefile/MakefileParserDefinition.kt index f0aff43..fc155b5 100644 --- a/src/main/kotlin/name/kropp/intellij/makefile/MakefileParserDefinition.kt +++ b/src/main/kotlin/name/kropp/intellij/makefile/MakefileParserDefinition.kt @@ -17,15 +17,22 @@ class MakefileParserDefinition : ParserDefinition { } override fun getFileNodeType() = FILE + override fun getWhitespaceTokens() = WHITE_SPACES + override fun getCommentTokens() = COMMENTS + override fun getStringLiteralElements() = TokenSet.EMPTY - override fun spaceExistenceTypeBetweenTokens(left: ASTNode?, right: ASTNode?) = ParserDefinition.SpaceRequirements.MAY + override fun spaceExistenceTypeBetweenTokens( + left: ASTNode?, + right: ASTNode?, + ) = ParserDefinition.SpaceRequirements.MAY override fun createFile(viewProvider: FileViewProvider) = MakefileFile(viewProvider) override fun createParser(project: Project?) = MakefileParser() + override fun createLexer(project: Project?) = MakefileLexerAdapter() override fun createElement(node: ASTNode?) = MakefileTypes.Factory.createElement(node) diff --git a/src/main/kotlin/name/kropp/intellij/makefile/MakefileStructureViewElement.kt b/src/main/kotlin/name/kropp/intellij/makefile/MakefileStructureViewElement.kt index 64db555..79f92df 100644 --- a/src/main/kotlin/name/kropp/intellij/makefile/MakefileStructureViewElement.kt +++ b/src/main/kotlin/name/kropp/intellij/makefile/MakefileStructureViewElement.kt @@ -22,6 +22,7 @@ class MakefileStructureViewElement(private val element: PsiElement) : StructureV } override fun canNavigate() = (element as? NavigationItem)?.canNavigate() ?: false + override fun canNavigateToSource() = (element as? NavigationItem)?.canNavigateToSource() ?: false override fun navigate(requestFocus: Boolean) { diff --git a/src/main/kotlin/name/kropp/intellij/makefile/MakefileStructureViewFactory.kt b/src/main/kotlin/name/kropp/intellij/makefile/MakefileStructureViewFactory.kt index fed7b07..164185c 100644 --- a/src/main/kotlin/name/kropp/intellij/makefile/MakefileStructureViewFactory.kt +++ b/src/main/kotlin/name/kropp/intellij/makefile/MakefileStructureViewFactory.kt @@ -6,7 +6,8 @@ import com.intellij.openapi.editor.Editor import com.intellij.psi.PsiFile class MakefileStructureViewFactory : PsiStructureViewFactory { - override fun getStructureViewBuilder(psiFile: PsiFile) = object : TreeBasedStructureViewBuilder() { - override fun createStructureViewModel(editor: Editor?) = MakefileStructureViewModel(psiFile) - } + override fun getStructureViewBuilder(psiFile: PsiFile) = + object : TreeBasedStructureViewBuilder() { + override fun createStructureViewModel(editor: Editor?) = MakefileStructureViewModel(psiFile) + } } diff --git a/src/main/kotlin/name/kropp/intellij/makefile/MakefileSyntaxHighlighter.kt b/src/main/kotlin/name/kropp/intellij/makefile/MakefileSyntaxHighlighter.kt index cb5d070..c7e2a5e 100644 --- a/src/main/kotlin/name/kropp/intellij/makefile/MakefileSyntaxHighlighter.kt +++ b/src/main/kotlin/name/kropp/intellij/makefile/MakefileSyntaxHighlighter.kt @@ -44,22 +44,24 @@ class MakefileSyntaxHighlighter : SyntaxHighlighterBase() { private val EMPTY_KEYS = emptyArray() } - override fun getTokenHighlights(tokenType: IElementType) = when (tokenType) { - MakefileTypes.DOC_COMMENT -> DOCCOMMENT_KEYS - MakefileTypes.COMMENT -> COMMENT_KEYS - MakefileTypes.TARGET -> TARGET_KEYS - MakefileTypes.COLON, MakefileTypes.DOUBLECOLON, MakefileTypes.ASSIGN, MakefileTypes.SEMICOLON, MakefileTypes.PIPE -> SEPARATOR_KEYS - MakefileTypes.KEYWORD_INCLUDE, MakefileTypes.KEYWORD_IFEQ, MakefileTypes.KEYWORD_IFNEQ, MakefileTypes.KEYWORD_IFDEF, MakefileTypes.KEYWORD_IFNDEF, MakefileTypes.KEYWORD_ELSE, MakefileTypes.KEYWORD_ENDIF, MakefileTypes.KEYWORD_DEFINE, MakefileTypes.KEYWORD_ENDEF, MakefileTypes.KEYWORD_UNDEFINE, MakefileTypes.KEYWORD_OVERRIDE, MakefileTypes.KEYWORD_EXPORT, MakefileTypes.KEYWORD_PRIVATE, MakefileTypes.KEYWORD_VPATH -> KEYWORD_KEYS - MakefileTypes.PREREQUISITE -> PREREQUISITE_KEYS - MakefileTypes.VARIABLE -> VARIABLE_KEYS - MakefileTypes.VARIABLE_VALUE -> VARIABLE_VALUE_KEYS - MakefileTypes.SPLIT -> LINE_SPLIT_KEYS - MakefileTypes.TAB -> TAB_KEYS - MakefileTypes.FUNCTION_PARAM_TEXT -> FUNCTION_PARAM_KEYS - MakefileTypes.VARIABLE_USAGE -> VARIABLE_USAGE_KEYS - TokenType.BAD_CHARACTER -> BAD_CHAR_KEYS - else -> EMPTY_KEYS - } + @Suppress("ktlint:standard:max-line-length") + override fun getTokenHighlights(tokenType: IElementType) = + when (tokenType) { + MakefileTypes.DOC_COMMENT -> DOCCOMMENT_KEYS + MakefileTypes.COMMENT -> COMMENT_KEYS + MakefileTypes.TARGET -> TARGET_KEYS + MakefileTypes.COLON, MakefileTypes.DOUBLECOLON, MakefileTypes.ASSIGN, MakefileTypes.SEMICOLON, MakefileTypes.PIPE -> SEPARATOR_KEYS + MakefileTypes.KEYWORD_INCLUDE, MakefileTypes.KEYWORD_IFEQ, MakefileTypes.KEYWORD_IFNEQ, MakefileTypes.KEYWORD_IFDEF, MakefileTypes.KEYWORD_IFNDEF, MakefileTypes.KEYWORD_ELSE, MakefileTypes.KEYWORD_ENDIF, MakefileTypes.KEYWORD_DEFINE, MakefileTypes.KEYWORD_ENDEF, MakefileTypes.KEYWORD_UNDEFINE, MakefileTypes.KEYWORD_OVERRIDE, MakefileTypes.KEYWORD_EXPORT, MakefileTypes.KEYWORD_PRIVATE, MakefileTypes.KEYWORD_VPATH -> KEYWORD_KEYS + MakefileTypes.PREREQUISITE -> PREREQUISITE_KEYS + MakefileTypes.VARIABLE -> VARIABLE_KEYS + MakefileTypes.VARIABLE_VALUE -> VARIABLE_VALUE_KEYS + MakefileTypes.SPLIT -> LINE_SPLIT_KEYS + MakefileTypes.TAB -> TAB_KEYS + MakefileTypes.FUNCTION_PARAM_TEXT -> FUNCTION_PARAM_KEYS + MakefileTypes.VARIABLE_USAGE -> VARIABLE_USAGE_KEYS + TokenType.BAD_CHARACTER -> BAD_CHAR_KEYS + else -> EMPTY_KEYS + } override fun getHighlightingLexer() = MakefileLexerAdapter() } diff --git a/src/main/kotlin/name/kropp/intellij/makefile/MakefileSyntaxHighlighterFactory.kt b/src/main/kotlin/name/kropp/intellij/makefile/MakefileSyntaxHighlighterFactory.kt index 28b23f1..50c5fa0 100644 --- a/src/main/kotlin/name/kropp/intellij/makefile/MakefileSyntaxHighlighterFactory.kt +++ b/src/main/kotlin/name/kropp/intellij/makefile/MakefileSyntaxHighlighterFactory.kt @@ -5,5 +5,8 @@ import com.intellij.openapi.project.Project import com.intellij.openapi.vfs.VirtualFile class MakefileSyntaxHighlighterFactory : SyntaxHighlighterFactory() { - override fun getSyntaxHighlighter(project: Project?, virtualFile: VirtualFile?) = MakefileSyntaxHighlighter() + override fun getSyntaxHighlighter( + project: Project?, + virtualFile: VirtualFile?, + ) = MakefileSyntaxHighlighter() } diff --git a/src/main/kotlin/name/kropp/intellij/makefile/MakefileTargetKeyIndex.kt b/src/main/kotlin/name/kropp/intellij/makefile/MakefileTargetKeyIndex.kt index aab3e2c..831f3b8 100644 --- a/src/main/kotlin/name/kropp/intellij/makefile/MakefileTargetKeyIndex.kt +++ b/src/main/kotlin/name/kropp/intellij/makefile/MakefileTargetKeyIndex.kt @@ -1,3 +1,5 @@ +@file:Suppress("ktlint:standard:no-wildcard-imports") + package name.kropp.intellij.makefile import com.intellij.openapi.project.Project @@ -5,7 +7,7 @@ import com.intellij.psi.search.GlobalSearchScope import com.intellij.psi.stubs.StringStubIndexExtension import com.intellij.psi.stubs.StubIndex import com.intellij.psi.stubs.StubIndexKey -import com.intellij.util.* // ktlint-disable no-wildcard-imports +import com.intellij.util.* import name.kropp.intellij.makefile.psi.MakefileTarget val TARGET_INDEX_KEY = StubIndexKey.createIndexKey("makefile.target.index") @@ -19,6 +21,9 @@ object MakefileTargetIndex : StringStubIndexExtension() { override fun getKey(): StubIndexKey = TARGET_INDEX_KEY - override fun get(key: String, project: Project, scope: GlobalSearchScope): Collection = - StubIndex.getElements(TARGET_INDEX_KEY, key, project, scope, MakefileTarget::class.java) + override fun get( + key: String, + project: Project, + scope: GlobalSearchScope, + ): Collection = StubIndex.getElements(TARGET_INDEX_KEY, key, project, scope, MakefileTarget::class.java) } diff --git a/src/main/kotlin/name/kropp/intellij/makefile/MakefileTargetReference.kt b/src/main/kotlin/name/kropp/intellij/makefile/MakefileTargetReference.kt index 3d89329..7f760d8 100644 --- a/src/main/kotlin/name/kropp/intellij/makefile/MakefileTargetReference.kt +++ b/src/main/kotlin/name/kropp/intellij/makefile/MakefileTargetReference.kt @@ -1,3 +1,5 @@ +@file:Suppress("ktlint:standard:no-wildcard-imports") + package name.kropp.intellij.makefile import com.intellij.codeInsight.lookup.LookupElementBuilder @@ -5,16 +7,16 @@ import com.intellij.openapi.util.TextRange import com.intellij.psi.PsiElement import com.intellij.psi.PsiElementResolveResult import com.intellij.psi.PsiReference -import name.kropp.intellij.makefile.psi.* // ktlint-disable no-wildcard-imports +import name.kropp.intellij.makefile.psi.* class MakefileTargetReference(private val prerequisite: MakefilePrerequisite) : PsiReference { override fun getElement() = prerequisite + override fun getRangeInElement() = TextRange.create(0, element.textLength) + override fun bindToElement(element: PsiElement): PsiElement? = null - override fun isReferenceTo( - element: PsiElement - ): Boolean { + override fun isReferenceTo(element: PsiElement): Boolean { if (element is MakefileTarget) { return element.matches(prerequisite.text) } @@ -45,7 +47,12 @@ class MakefileTargetReference(private val prerequisite: MakefilePrerequisite) : get() = prerequisite.parent.parent.parent.parent as? MakefileRule override fun getVariants() = - (prerequisite.containingFile as MakefileFile).targets.filterNot { it.isPatternTarget || rule?.targets?.any { t -> t.name == it.name } == true }.distinctBy { it.name }.map { + (prerequisite.containingFile as MakefileFile).targets.filterNot { + it.isPatternTarget || rule?.targets?.any { + t -> + t.name == it.name + } == true + }.distinctBy { it.name }.map { LookupElementBuilder.create(it).withIcon(MakefileTargetIcon) }.toTypedArray() diff --git a/src/main/kotlin/name/kropp/intellij/makefile/MakefileTargetStructureViewPresentation.kt b/src/main/kotlin/name/kropp/intellij/makefile/MakefileTargetStructureViewPresentation.kt index b9ba066..466cb1c 100644 --- a/src/main/kotlin/name/kropp/intellij/makefile/MakefileTargetStructureViewPresentation.kt +++ b/src/main/kotlin/name/kropp/intellij/makefile/MakefileTargetStructureViewPresentation.kt @@ -5,6 +5,8 @@ import name.kropp.intellij.makefile.psi.MakefileTarget class MakefileTargetStructureViewPresentation(private val target: MakefileTarget) : ItemPresentation { override fun getIcon(b: Boolean) = MakefileTargetIcon + override fun getPresentableText() = target.text + override fun getLocationString() = "" } diff --git a/src/main/kotlin/name/kropp/intellij/makefile/RemoveRuleFix.kt b/src/main/kotlin/name/kropp/intellij/makefile/RemoveRuleFix.kt index 75d1012..d4f3b3f 100644 --- a/src/main/kotlin/name/kropp/intellij/makefile/RemoveRuleFix.kt +++ b/src/main/kotlin/name/kropp/intellij/makefile/RemoveRuleFix.kt @@ -9,11 +9,20 @@ import name.kropp.intellij.makefile.psi.MakefileRule class RemoveRuleFix(private val rule: MakefileRule) : BaseIntentionAction() { override fun getText() = "Remove Empty Rule" + override fun getFamilyName() = "Remove Empty Rule" - override fun isAvailable(project: Project, editor: Editor?, psiFile: PsiFile?) = true + override fun isAvailable( + project: Project, + editor: Editor?, + psiFile: PsiFile?, + ) = true - override fun invoke(project: Project, editor: Editor?, psiFile: PsiFile?) { + override fun invoke( + project: Project, + editor: Editor?, + psiFile: PsiFile?, + ) { WriteCommandAction.writeCommandAction(project, psiFile).run { rule.delete() } diff --git a/src/main/kotlin/name/kropp/intellij/makefile/psi/MakefileElementFactory.kt b/src/main/kotlin/name/kropp/intellij/makefile/psi/MakefileElementFactory.kt index ea7714c..ae0523a 100644 --- a/src/main/kotlin/name/kropp/intellij/makefile/psi/MakefileElementFactory.kt +++ b/src/main/kotlin/name/kropp/intellij/makefile/psi/MakefileElementFactory.kt @@ -7,18 +7,33 @@ import name.kropp.intellij.makefile.MakefileFile import name.kropp.intellij.makefile.MakefileFileType object MakefileElementFactory { - fun createFile(project: Project, text: String) = - PsiFileFactory.getInstance(project).createFileFromText("Makefile", MakefileFileType.INSTANCE, text) as MakefileFile + fun createFile( + project: Project, + text: String, + ) = PsiFileFactory.getInstance(project).createFileFromText("Makefile", MakefileFileType.INSTANCE, text) as MakefileFile - fun createRule(project: Project, target: String) = - createFile(project, "$target:\n").firstChild as MakefileRule + fun createRule( + project: Project, + target: String, + ) = createFile(project, "$target:\n").firstChild as MakefileRule - fun createTarget(project: Project, name: String) = - createRule(project, name).firstChild.firstChild.firstChild as MakefileTarget + fun createTarget( + project: Project, + name: String, + ) = createRule(project, name).firstChild.firstChild.firstChild as MakefileTarget - fun createPrerequisite(project: Project, name: String) = - (createFile(project, "a: $name").firstChild as MakefileRule).targetLine.prerequisites!!.normalPrerequisites.firstChild as MakefilePrerequisite + fun createPrerequisite( + project: Project, + name: String, + ) = ( + createFile( + project, + "a: $name", + ).firstChild as MakefileRule + ).targetLine.prerequisites!!.normalPrerequisites.firstChild as MakefilePrerequisite - fun createWhiteSpace(project: Project, whitespace: String) = - createFile(project, whitespace).firstChild as PsiWhiteSpace + fun createWhiteSpace( + project: Project, + whitespace: String, + ) = createFile(project, whitespace).firstChild as PsiWhiteSpace } diff --git a/src/main/kotlin/name/kropp/intellij/makefile/psi/MakefilePrerequisiteManipulator.kt b/src/main/kotlin/name/kropp/intellij/makefile/psi/MakefilePrerequisiteManipulator.kt index f2fa2a6..6af17bf 100644 --- a/src/main/kotlin/name/kropp/intellij/makefile/psi/MakefilePrerequisiteManipulator.kt +++ b/src/main/kotlin/name/kropp/intellij/makefile/psi/MakefilePrerequisiteManipulator.kt @@ -5,5 +5,9 @@ import com.intellij.psi.AbstractElementManipulator import name.kropp.intellij.makefile.psi.impl.MakefilePrerequisiteImpl class MakefilePrerequisiteManipulator : AbstractElementManipulator() { - override fun handleContentChange(element: MakefilePrerequisiteImpl, textRange: TextRange, newContent: String?) = element.updateText(newContent) + override fun handleContentChange( + element: MakefilePrerequisiteImpl, + textRange: TextRange, + newContent: String?, + ) = element.updateText(newContent) } diff --git a/src/main/kotlin/name/kropp/intellij/makefile/psi/MakefileTargetPresentation.kt b/src/main/kotlin/name/kropp/intellij/makefile/psi/MakefileTargetPresentation.kt index 0ffcb71..32077ab 100644 --- a/src/main/kotlin/name/kropp/intellij/makefile/psi/MakefileTargetPresentation.kt +++ b/src/main/kotlin/name/kropp/intellij/makefile/psi/MakefileTargetPresentation.kt @@ -5,6 +5,8 @@ import name.kropp.intellij.makefile.MakefileTargetIcon class MakefileTargetPresentation(private val target: MakefileTarget) : ItemPresentation { override fun getIcon(b: Boolean) = MakefileTargetIcon + override fun getPresentableText() = target.text + override fun getLocationString() = "in " + target.containingFile?.virtualFile?.presentableName } diff --git a/src/main/kotlin/name/kropp/intellij/makefile/stub/MakefileTargetStubElementImpl.kt b/src/main/kotlin/name/kropp/intellij/makefile/stub/MakefileTargetStubElementImpl.kt index 4ce07e3..64b5d39 100644 --- a/src/main/kotlin/name/kropp/intellij/makefile/stub/MakefileTargetStubElementImpl.kt +++ b/src/main/kotlin/name/kropp/intellij/makefile/stub/MakefileTargetStubElementImpl.kt @@ -4,4 +4,10 @@ import com.intellij.psi.stubs.NamedStubBase import com.intellij.psi.stubs.StubElement import name.kropp.intellij.makefile.psi.MakefileTarget -class MakefileTargetStubElementImpl(parent: StubElement<*>?, name: String?) : NamedStubBase(parent, MakefileTargetStubElementType, name), MakefileTargetStubElement +class MakefileTargetStubElementImpl(parent: StubElement<*>?, name: String?) : + NamedStubBase( + parent, + MakefileTargetStubElementType, + name, + ), + MakefileTargetStubElement diff --git a/src/main/kotlin/name/kropp/intellij/makefile/stub/MakefileTargetStubElementType.kt b/src/main/kotlin/name/kropp/intellij/makefile/stub/MakefileTargetStubElementType.kt index 71bd2d7..15810b4 100644 --- a/src/main/kotlin/name/kropp/intellij/makefile/stub/MakefileTargetStubElementType.kt +++ b/src/main/kotlin/name/kropp/intellij/makefile/stub/MakefileTargetStubElementType.kt @@ -12,20 +12,34 @@ import name.kropp.intellij.makefile.psi.impl.MakefileTargetImpl object MakefileTargetStubElementType : IStubElementType("TARGET", MakefileLanguage) { @JvmStatic + @Suppress("UNUSED_PARAMETER") fun getInstance(debugName: String) = MakefileTargetStubElementType override fun getExternalId() = "Makefile" - override fun createStub(psi: MakefileTarget, parent: StubElement<*>?) = MakefileTargetStubElementImpl(parent, psi.name) + override fun createStub( + psi: MakefileTarget, + parent: StubElement<*>?, + ) = MakefileTargetStubElementImpl(parent, psi.name) + override fun createPsi(stub: MakefileTargetStubElement) = MakefileTargetImpl(stub, stub.stubType) - override fun indexStub(stub: MakefileTargetStubElement, sink: IndexSink) { + override fun indexStub( + stub: MakefileTargetStubElement, + sink: IndexSink, + ) { sink.occurrence(TARGET_INDEX_KEY, stub.name!!) } - override fun serialize(e: MakefileTargetStubElement, outputStream: StubOutputStream) { + override fun serialize( + e: MakefileTargetStubElement, + outputStream: StubOutputStream, + ) { outputStream.writeName(e.name) } - override fun deserialize(inputStream: StubInputStream, parent: StubElement<*>?) = - MakefileTargetStubElementImpl(parent, inputStream.readName()?.string) + + override fun deserialize( + inputStream: StubInputStream, + parent: StubElement<*>?, + ) = MakefileTargetStubElementImpl(parent, inputStream.readName()?.string) } diff --git a/src/main/kotlin/name/kropp/intellij/makefile/utils.kt b/src/main/kotlin/name/kropp/intellij/makefile/utils.kt index fabbee4..ad32dfd 100644 --- a/src/main/kotlin/name/kropp/intellij/makefile/utils.kt +++ b/src/main/kotlin/name/kropp/intellij/makefile/utils.kt @@ -1,3 +1,5 @@ +@file:Suppress("ktlint:standard:package-name", "ktlint:standard:filename") + package name.kropp.intellij.makefile import com.intellij.openapi.project.Project @@ -8,7 +10,9 @@ import name.kropp.intellij.makefile.psi.MakefileTarget fun findAllTargets(project: Project) = MakefileTargetIndex.getAllKeys(project) -fun findTargets(project: Project, name: String): Collection = - MakefileTargetIndex.get(name, project, GlobalSearchScope.allScope(project)) +fun findTargets( + project: Project, + name: String, +): Collection = MakefileTargetIndex.get(name, project, GlobalSearchScope.allScope(project)) fun findTargets(psiFile: PsiFile) = PsiTreeUtil.findChildrenOfType(psiFile, MakefileTarget::class.java).asIterable() diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index cd12321..4e1ceee 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -8,14 +8,15 @@ -
  • Support for IntelliJ 2023.2
  • +
  • Support for IntelliJ 2024.2
  • ]]>
    - + com.intellij.modules.lang com.intellij.modules.platform + com.intellij.java