diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 50ae1f8..0d48e56 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,7 +5,7 @@ name: Release on: release: - types: [ prereleased, released ] + types: [prereleased, released] jobs: diff --git a/.gitignore b/.gitignore index b63da45..e2e5d94 100644 --- a/.gitignore +++ b/.gitignore @@ -1,42 +1,4 @@ .gradle -build/ -!gradle/wrapper/gradle-wrapper.jar -!**/src/main/**/build/ -!**/src/test/**/build/ - -### IntelliJ IDEA ### -.idea/modules.xml -.idea/jarRepositories.xml -.idea/compiler.xml -.idea/libraries/ -*.iws -*.iml -*.ipr -out/ -!**/src/main/**/out/ -!**/src/test/**/out/ - -### Eclipse ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache -bin/ -!**/src/main/**/bin/ -!**/src/test/**/bin/ - -### NetBeans ### -/nbproject/private/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ - -### VS Code ### -.vscode/ - -### Mac OS ### -.DS_Store \ No newline at end of file +.idea +.qodana +build diff --git a/.run/Run IDE for UI Tests.run.xml b/.run/Run IDE for UI Tests.run.xml index 474c6fd..ee99b7e 100644 --- a/.run/Run IDE for UI Tests.run.xml +++ b/.run/Run IDE for UI Tests.run.xml @@ -1,25 +1,25 @@ - - - - - - - true - true - false - false - - + + + + + + + true + true + false + false + + \ No newline at end of file diff --git a/.run/Run Plugin.run.xml b/.run/Run Plugin.run.xml index 7747a29..d15ff68 100644 --- a/.run/Run Plugin.run.xml +++ b/.run/Run Plugin.run.xml @@ -1,24 +1,24 @@ - - - - - - - true - true - false - - + + + + + + + true + true + false + + \ No newline at end of file diff --git a/.run/Run Qodana.run.xml b/.run/Run Qodana.run.xml index 0834c88..c92f33c 100644 --- a/.run/Run Qodana.run.xml +++ b/.run/Run Qodana.run.xml @@ -1,30 +1,30 @@ - - - - - - - true - true - false - false - - + + + + + + + true + true + false + false + + \ No newline at end of file diff --git a/.run/Run Tests.run.xml b/.run/Run Tests.run.xml index 298bd6f..132d9ad 100644 --- a/.run/Run Tests.run.xml +++ b/.run/Run Tests.run.xml @@ -1,24 +1,24 @@ - - - - - - - true - true - false - - + + + + + + + true + true + false + + diff --git a/.run/Run Verifications.run.xml b/.run/Run Verifications.run.xml index daf5e0b..3a8d688 100644 --- a/.run/Run Verifications.run.xml +++ b/.run/Run Verifications.run.xml @@ -1,27 +1,26 @@ - - - - - - - true - true - false - - - + + + + + + + true + true + false + + + \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index c68b425..5e402fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,8 +3,5 @@ # dlvx Changelog ## [Unreleased] - ### Added - -- Initial scaffold created - from [IntelliJ Platform Plugin Template](https://github.com/JetBrains/intellij-platform-plugin-template) +- Initial scaffold created from [IntelliJ Platform Plugin Template](https://github.com/JetBrains/intellij-platform-plugin-template) diff --git a/README.md b/README.md index 4f2ac19..1abfae1 100644 --- a/README.md +++ b/README.md @@ -5,48 +5,40 @@ [![Downloads](https://img.shields.io/jetbrains/plugin/d/PLUGIN_ID.svg)](https://plugins.jetbrains.com/plugin/PLUGIN_ID) ## Template ToDo list - - [x] Create a new [IntelliJ Platform Plugin Template][template] project. - [ ] Get familiar with the [template documentation][template]. -- [ ] Adjust the [pluginGroup](./gradle.properties), [plugin ID](./src/main/resources/META-INF/plugin.xml) - and [sources package](./src/main/kotlin). +- [ ] Adjust the [pluginGroup](./gradle.properties), [plugin ID](./src/main/resources/META-INF/plugin.xml) and [sources package](./src/main/kotlin). - [ ] Adjust the plugin description in `README` (see [Tips][docs:plugin-description]) -- [ ] Review - the [Legal Agreements](https://plugins.jetbrains.com/docs/marketplace/legal-agreements.html?from=IJPluginTemplate). -- [ ] [Publish a plugin manually](https://plugins.jetbrains.com/docs/intellij/publishing-plugin.html?from=IJPluginTemplate) - for the first time. +- [ ] Review the [Legal Agreements](https://plugins.jetbrains.com/docs/marketplace/legal-agreements.html?from=IJPluginTemplate). +- [ ] [Publish a plugin manually](https://plugins.jetbrains.com/docs/intellij/publishing-plugin.html?from=IJPluginTemplate) for the first time. - [ ] Set the `PLUGIN_ID` in the above README badges. -- [ ] Set the [Plugin Signing](https://plugins.jetbrains.com/docs/intellij/plugin-signing.html?from=IJPluginTemplate) - related [secrets](https://github.com/JetBrains/intellij-platform-plugin-template#environment-variables). -- [ ] Set - the [Deployment Token](https://plugins.jetbrains.com/docs/marketplace/plugin-upload.html?from=IJPluginTemplate). -- [ ] Click the Watch button on the top of the [IntelliJ Platform Plugin Template][template] to be notified - about releases containing new features and fixes. +- [ ] Set the [Plugin Signing](https://plugins.jetbrains.com/docs/intellij/plugin-signing.html?from=IJPluginTemplate) related [secrets](https://github.com/JetBrains/intellij-platform-plugin-template#environment-variables). +- [ ] Set the [Deployment Token](https://plugins.jetbrains.com/docs/marketplace/plugin-upload.html?from=IJPluginTemplate). +- [ ] Click the Watch button on the top of the [IntelliJ Platform Plugin Template][template] to be notified about releases containing new features and fixes. This Fancy IntelliJ Platform Plugin is going to be your implementation of the brilliant ideas that you have. -This specific section is a source for the [plugin.xml](/src/main/resources/META-INF/plugin.xml) file which will be -extracted by the [Gradle](/build.gradle.kts) during the build process. +This specific section is a source for the [plugin.xml](/src/main/resources/META-INF/plugin.xml) file which will be extracted by the [Gradle](/build.gradle.kts) during the build process. -To keep everything working, do not remove `` sections. +To keep everything working, do not remove `` sections. ## Installation - Using the IDE built-in plugin system: - + Settings/Preferences > Plugins > Marketplace > Search for "dlvx" > Install - + - Manually: Download the [latest release](https://github.com/BOFA1ex/dlvx/releases/latest) and install it manually using Settings/Preferences > Plugins > ⚙️ > Install plugin from disk... + --- Plugin based on the [IntelliJ Platform Plugin Template][template]. [template]: https://github.com/JetBrains/intellij-platform-plugin-template - [docs:plugin-description]: https://plugins.jetbrains.com/docs/intellij/plugin-user-experience.html#plugin-description-and-presentation diff --git a/build.gradle.kts b/build.gradle.kts index 4f487b7..bf0c939 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,60 +1,131 @@ +import org.jetbrains.changelog.Changelog +import org.jetbrains.changelog.markdownToHTML + fun properties(key: String) = providers.gradleProperty(key) fun environment(key: String) = providers.environmentVariable(key) plugins { - id("java") - alias(libs.plugins.kotlin) // Kotlin support - alias(libs.plugins.gradleIntelliJPlugin) // Gradle IntelliJ Plugin + id("java") // Java support + alias(libs.plugins.kotlin) // Kotlin support + alias(libs.plugins.gradleIntelliJPlugin) // Gradle IntelliJ Plugin + alias(libs.plugins.changelog) // Gradle Changelog Plugin + alias(libs.plugins.qodana) // Gradle Qodana Plugin + alias(libs.plugins.kover) // Gradle Kover Plugin } -group = "io.github.bofa1ex" -version = "1.0-SNAPSHOT" +group = properties("pluginGroup").get() +version = properties("pluginVersion").get() +// Configure project's dependencies repositories { - mavenCentral() + mavenCentral() } // Dependencies are managed with Gradle version catalog - read more: https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog dependencies { - implementation(libs.annotations) +// implementation(libs.annotations) +} + +// Set the JVM language level used to build the project. Use Java 11 for 2020.3+, and Java 17 for 2022.2+. +kotlin { + @Suppress("UnstableApiUsage") + jvmToolchain { + languageVersion = JavaLanguageVersion.of(17) + vendor = JvmVendorSpec.JETBRAINS + } } -// Configure Gradle IntelliJ Plugin -// Read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html +// Configure Gradle IntelliJ Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html intellij { - pluginName = properties("pluginName") - version = properties("platformVersion") - type = properties("platformType") - // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file. - plugins = properties("platformPlugins").map { it.split(',').map(String::trim).filter(String::isNotEmpty) } + pluginName = properties("pluginName") + version = properties("platformVersion") + type = properties("platformType") + + // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file. + plugins = properties("platformPlugins").map { it.split(',').map(String::trim).filter(String::isNotEmpty) } +} + +// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin +changelog { + groups.empty() + repositoryUrl = properties("pluginRepositoryUrl") +} + +// Configure Gradle Qodana Plugin - read more: https://github.com/JetBrains/gradle-qodana-plugin +qodana { + cachePath = provider { file(".qodana").canonicalPath } + reportPath = provider { file("build/reports/inspections").canonicalPath } + saveReport = true + showReport = environment("QODANA_SHOW_REPORT").map { it.toBoolean() }.getOrElse(false) +} - updateSinceUntilBuild = false +// Configure Gradle Kover Plugin - read more: https://github.com/Kotlin/kotlinx-kover#configuration +koverReport { + defaults { + xml { + onCheck = true + } + } } tasks { - // Set the JVM compatibility versions - withType { - sourceCompatibility = "17" - targetCompatibility = "17" - } - withType { - kotlinOptions.jvmTarget = "17" - } - - - patchPluginXml { - version = properties("pluginVersion") - sinceBuild = properties("pluginSinceBuild") - untilBuild = properties("pluginUntilBuild") - } - - signPlugin { - certificateChain.set(System.getenv("CERTIFICATE_CHAIN")) - privateKey.set(System.getenv("PRIVATE_KEY")) - password.set(System.getenv("PRIVATE_KEY_PASSWORD")) - } - - publishPlugin { - token.set(System.getenv("PUBLISH_TOKEN")) - } + wrapper { + gradleVersion = properties("gradleVersion").get() + } + + patchPluginXml { + version = properties("pluginVersion") + sinceBuild = properties("pluginSinceBuild") + untilBuild = properties("pluginUntilBuild") + + // Extract the section from README.md and provide for the plugin's manifest + pluginDescription = providers.fileContents(layout.projectDirectory.file("README.md")).asText.map { + val start = "" + val 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) + } + } + + val changelog = project.changelog // local variable for configuration cache compatibility + // Get the latest available change notes from the changelog file + changeNotes = properties("pluginVersion").map { pluginVersion -> + with(changelog) { + renderItem( + (getOrNull(pluginVersion) ?: getUnreleased()) + .withHeader(false) + .withEmptySections(false), + Changelog.OutputType.HTML, + ) + } + } + } + + // 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") + } + + signPlugin { + certificateChain = environment("CERTIFICATE_CHAIN") + privateKey = environment("PRIVATE_KEY") + password = environment("PRIVATE_KEY_PASSWORD") + } + + publishPlugin { + dependsOn("patchChangelog") + token = environment("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 = properties("pluginVersion").map { listOf(it.split('-').getOrElse(1) { "default" }.split('.').first()) } + } } diff --git a/gradle.properties b/gradle.properties index 2668416..28432f4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,19 +1,22 @@ -pluginGroup = io.github.bofa1ex -pluginName = Dlvx +# IntelliJ Platform Artifacts Repositories -> https://plugins.jetbrains.com/docs/intellij/intellij-artifacts.html + +pluginGroup = com.github.bofa1ex.dlvx +pluginName = dlvx +pluginRepositoryUrl = https://github.com/BOFA1ex/dlvx # SemVer format -> https://semver.org -pluginVersion = 0.1.0 +pluginVersion = 0.0.1 # Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html -pluginSinceBuild = 222 +pluginSinceBuild = 223 pluginUntilBuild = 233.* # IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension -platformType = GO -platformVersion = 2023.3.2 +platformType = IC +platformVersion = 2022.3.3 # Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html # Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22 -platformPlugins = org.jetbrains.plugins.go +platformPlugins = # Gradle Releases -> https://github.com/gradle/gradle/releases gradleVersion = 8.5 @@ -29,6 +32,3 @@ org.gradle.caching = true # Enable Gradle Kotlin DSL Lazy Property Assignment -> https://docs.gradle.org/current/userguide/kotlin_dsl.html#kotdsl:assignment systemProp.org.gradle.unsafe.kotlin.assignment = true - -org.gradle.parallel = true -org.gradle.jvmargs = '-Dfile.encoding=UTF-8' \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 249e583..d64cd49 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e411586..1af9e09 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 1b6c787..1aa94a4 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,13 +80,11 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,22 +131,29 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -193,11 +198,15 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ @@ -205,6 +214,12 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/gradlew.bat b/gradlew.bat index 107acd3..93e3f59 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/settings.gradle.kts b/settings.gradle.kts index 8887d63..2699691 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,8 +1,5 @@ -pluginManagement { - repositories { - mavenCentral() - gradlePluginPortal() - } +plugins { + id("org.gradle.toolchains.foojay-resolver-convention") version "0.7.0" } -rootProject.name = "dlvx" \ No newline at end of file +rootProject.name = "dlvx" diff --git a/src/main/java/io/github/bofa1ex/dlvx/DlvMirrorDebugProcess.java b/src/main/java/io/github/bofa1ex/dlvx/DlvMirrorDebugProcess.java deleted file mode 100644 index a028058..0000000 --- a/src/main/java/io/github/bofa1ex/dlvx/DlvMirrorDebugProcess.java +++ /dev/null @@ -1,339 +0,0 @@ -package io.github.bofa1ex.dlvx; - -import com.goide.dlv.DlvCommandProcessor; -import com.goide.dlv.DlvDebugProcess; -import com.goide.dlv.DlvVm; -import com.goide.dlv.breakpoint.DlvBreakpointProperties; -import com.goide.dlv.protocol.DlvApi; -import com.goide.dlv.protocol.DlvRequest; -import com.intellij.execution.ExecutionResult; -import com.intellij.execution.process.ProcessHandler; -import com.intellij.execution.ui.ExecutionConsole; -import com.intellij.ide.plugins.IdeaPluginDescriptor; -import com.intellij.openapi.Disposable; -import com.intellij.openapi.actionSystem.DefaultActionGroup; -import com.intellij.openapi.util.Computable; -import com.intellij.openapi.util.SystemInfo; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.util.io.socketConnection.ConnectionStatus; -import com.intellij.xdebugger.*; -import com.intellij.xdebugger.breakpoints.XBreakpoint; -import com.intellij.xdebugger.breakpoints.XBreakpointHandler; -import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider; -import com.intellij.xdebugger.evaluation.XDebuggerEvaluator; -import com.intellij.xdebugger.frame.XDropFrameHandler; -import com.intellij.xdebugger.frame.XSuspendContext; -import com.intellij.xdebugger.frame.XValueMarkerProvider; -import com.intellij.xdebugger.stepping.XSmartStepIntoHandler; -import com.intellij.xdebugger.ui.XDebugTabLayouter; -import io.github.bofa1ex.dlvx.execution.DlvFunctionBreakpointHandler; -import io.github.bofa1ex.dlvx.execution.DlvMirrorBreakpointHandler; -import org.jetbrains.annotations.Nls; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.concurrency.Promise; -import org.jetbrains.concurrency.Promises; -import org.jetbrains.debugger.ProcessHandlerWrapper; -import org.jetbrains.debugger.connection.VmConnection; -import org.jetbrains.jsonProtocol.Request; - -import javax.swing.event.HyperlinkListener; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.net.InetSocketAddress; -import java.util.Map; -import java.util.function.Function; - -@SuppressWarnings({"UnstableApiUsage", "deprecation"}) -public final class DlvMirrorDebugProcess extends XDebugProcess implements Disposable { - private final DlvDebugProcess debugProcess; - private final XBreakpointHandler[] breakpointHandlers; - private final ExecutionResult executionResult; - private final VmConnection connection; - - public DlvMirrorDebugProcess(XDebugSession session, VmConnection connection, ExecutionResult executionResult, @NotNull InetSocketAddress socketAddress) { - super(session); - this.connection = connection; - this.executionResult = executionResult; - this.breakpointHandlers = new XBreakpointHandler[] {new DlvMirrorBreakpointHandler(this), new DlvFunctionBreakpointHandler(this)}; - this.debugProcess = new DlvDebugProcess(session, connection, executionResult, true); - this.debugProcess.connect(socketAddress); - } - - @Override - public void dispose() { - debugProcess.dispose(); - } - - @Override - public @NotNull XDebuggerEditorsProvider getEditorsProvider() { - return debugProcess.getEditorsProvider(); - } - - @Override - public XBreakpointHandler @NotNull [] getBreakpointHandlers() { - final ConnectionStatus status = connection.getState().getStatus(); - return switch (status) { - case DISCONNECTED, DETACHED, CONNECTION_FAILED -> XBreakpointHandler.EMPTY_ARRAY; - default -> breakpointHandlers; - }; - } - - @Override - public @NotNull ExecutionConsole createConsole() { - return debugProcess.createConsole(); - } - - @Override - public void sessionInitialized() { - debugProcess.sessionInitialized(); - } - - @Override - public void startPausing() { - debugProcess.startPausing(); - } - - @Override - @SuppressWarnings("deprecation") - public void startStepOver() { - debugProcess.startStepOver(); - } - - @Override - public void startStepOver(@Nullable XSuspendContext context) { - debugProcess.startStepOver(context); - } - - @Override - public void startForceStepInto(@Nullable XSuspendContext context) { - debugProcess.startForceStepInto(context); - } - - @SuppressWarnings("deprecation") - @Override - public void startStepInto() { - debugProcess.startStepInto(); - } - - @Override - public void startStepInto(@Nullable XSuspendContext context) { - debugProcess.startStepInto(context); - } - - @SuppressWarnings("deprecation") - @Override - public void startStepOut() { - debugProcess.startStepOut(); - } - - @Override - public void startStepOut(@Nullable XSuspendContext context) { - debugProcess.startStepOut(context); - } - - @Override - public @Nullable XSmartStepIntoHandler getSmartStepIntoHandler() { - return debugProcess.getSmartStepIntoHandler(); - } - - @Override - public @Nullable XDropFrameHandler getDropFrameHandler() { - return debugProcess.getDropFrameHandler(); - } - - @Override - public @Nullable XAlternativeSourceHandler getAlternativeSourceHandler() { - return debugProcess.getAlternativeSourceHandler(); - } - - @Override - public void stop() { - debugProcess.stop(); - } - - @Override - public @NotNull Promise stopAsync() { - return debugProcess.stopAsync(); - } - - @Override - public void resume() { - debugProcess.resume(); - } - - @Override - public void resume(@Nullable XSuspendContext context) { - debugProcess.resume(context); - } - - @Override - public void runToPosition(@NotNull XSourcePosition position) { - debugProcess.runToPosition(position); - } - - @Override - public void runToPosition(@NotNull XSourcePosition position, @Nullable XSuspendContext context) { - debugProcess.runToPosition(position, context); - } - - @Override - public boolean checkCanPerformCommands() { - return debugProcess.checkCanPerformCommands(); - } - - @Override - public boolean checkCanInitBreakpoints() { - return debugProcess.checkCanInitBreakpoints(); - } - - @Override - protected @NotNull ProcessHandler doGetProcessHandler() { - ProcessHandler handler = executionResult != null ? executionResult.getProcessHandler() : null; - return handler == null ? new DefaultDebugProcessHandler() { - public boolean isSilentlyDestroyOnClose() { - return true; - } - } : new ProcessHandlerWrapper(this, handler); - } - - @Override - public @Nullable XValueMarkerProvider createValueMarkerProvider() { - return debugProcess.createValueMarkerProvider(); - } - - @Override - public void registerAdditionalActions(@NotNull DefaultActionGroup leftToolbar, @NotNull DefaultActionGroup topToolbar, @NotNull DefaultActionGroup settings) { - debugProcess.registerAdditionalActions(leftToolbar, topToolbar, settings); - } - - @Override - public @Nls String getCurrentStateMessage() { - return debugProcess.getCurrentStateMessage(); - } - - @Override - public @Nullable HyperlinkListener getCurrentStateHyperlinkListener() { - return debugProcess.getCurrentStateHyperlinkListener(); - } - - @Override - public @NotNull XDebugTabLayouter createTabLayouter() { - return debugProcess.createTabLayouter(); - } - - @Override - public boolean isValuesCustomSorted() { - return debugProcess.isValuesCustomSorted(); - } - - @Override - public @Nullable XDebuggerEvaluator getEvaluator() { - return debugProcess.getEvaluator(); - } - - @Override - public boolean isLibraryFrameFilterSupported() { - return debugProcess.isLibraryFrameFilterSupported(); - } - - @Override - public void logStack(@NotNull XSuspendContext suspendContext, @NotNull XDebugSession session) { - debugProcess.logStack(suspendContext, session); - } - - @Override - public boolean dependsOnPlugin(@NotNull IdeaPluginDescriptor descriptor) { - return debugProcess.dependsOnPlugin(descriptor); - } - - @SuppressWarnings("unchecked") - public Map, Integer> breakpoints() { - try { - final Field field = DlvDebugProcess.class.getDeclaredField("myBreakpoints"); - field.setAccessible(true); - return (Map, Integer>) field.get(debugProcess); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - public @Nullable String getDebuggerPath(@NotNull VirtualFile file) { - try { - final Method method = DlvDebugProcess.class.getDeclaredMethod("getDebuggerPath", VirtualFile.class); - method.setAccessible(true); - return (String) method.invoke(debugProcess, file); - } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { - throw new RuntimeException(e); - } - } - - public void pauseIfNeededAndProcess(@NotNull Computable> computable) { - try { - final Method method = DlvDebugProcess.class.getDeclaredMethod("pauseIfNeededAndProcess", Computable.class); - method.setAccessible(true); - method.invoke(debugProcess, computable); - } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { - throw new RuntimeException(e); - } - } - - public @NotNull Promise send(@NotNull Request request) { - final DlvCommandProcessor processor = getProcessor(); - if (processor == null) { - request.getBuffer().release(); - return Promises.rejectedPromise(); - } - - return processor.send(request).onError((t) -> { - String message = t.getMessage(); - if (isConditionEvaluationFailed(message)) { - consumeStateWithError(message); - } else if (SystemInfo.isMac && "bad access".equals(message)) { - this.consumeStateWithError("bad access: nil dereference"); - } else { - DlvVm.LOG.info(t); - } - }); - } - - private @Nullable DlvCommandProcessor getProcessor() { - try { - final Method method = DlvDebugProcess.class.getDeclaredMethod("getProcessor"); - method.setAccessible(true); - return (DlvCommandProcessor) method.invoke(debugProcess); - } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { - throw new RuntimeException(e); - } - } - - @SuppressWarnings("unchecked") - private @NotNull Function> myStateConsumer() { - try { - final Field field = DlvDebugProcess.class.getDeclaredField("myStateConsumer"); - field.setAccessible(true); - return (Function>) field.get(debugProcess); - } catch (NoSuchFieldException | IllegalAccessException e) { - throw new RuntimeException(e); - } - } - - private static boolean isConditionEvaluationFailed(@NonNls @Nullable String s) { - return s != null && (s.startsWith("error evaluating expression:") || s.startsWith("condition expression unreadable:") || s.startsWith("condition expression not boolean")); - } - - void consumeStateWithError(@NotNull String message) { - this.send(new DlvRequest.State()).thenAsync((s) -> { - s.err = message; - return consumeDebuggerState(s); - }); - } - - @NotNull Promise consumeDebuggerState(@NotNull DlvApi.@NotNull DebuggerState state) { - Promise promise = Promises.resolvedPromise(state); - Function> stateConsumer = myStateConsumer(); - return promise.thenAsync(stateConsumer::apply); - } -} diff --git a/src/main/java/io/github/bofa1ex/dlvx/breakpoint/DlvFunctionBreakPointType.java b/src/main/java/io/github/bofa1ex/dlvx/breakpoint/DlvFunctionBreakPointType.java deleted file mode 100644 index 85ffaf3..0000000 --- a/src/main/java/io/github/bofa1ex/dlvx/breakpoint/DlvFunctionBreakPointType.java +++ /dev/null @@ -1,35 +0,0 @@ -package io.github.bofa1ex.dlvx.breakpoint; - -import com.goide.dlv.breakpoint.DlvBreakpointProperties; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.xdebugger.breakpoints.XLineBreakpoint; -import com.intellij.xdebugger.breakpoints.XLineBreakpointType; -import io.github.bofa1ex.dlvx.utils.DlvxUtils; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public class DlvFunctionBreakPointType extends XLineBreakpointType { - public static final @NonNls String ID = "DlvFunctionBreakpoint"; - - public DlvFunctionBreakPointType() { - super(ID, "GoFunction breakpoint"); - } - - @Override - public boolean canPutAt(@NotNull VirtualFile file, int line, @NotNull Project project) { - if (line < 0) return false; - return DlvxUtils.findFunction(project, file, line) != null; - } - - @Override - public @Nullable DlvFunctionBreakpointProperties createBreakpointProperties(@NotNull VirtualFile virtualFile, int line) { - return new DlvFunctionBreakpointProperties(); - } - - @Override - public String getDisplayText(XLineBreakpoint breakpoint) { - return "Dlvx Function breakpoint"; - } -} diff --git a/src/main/java/io/github/bofa1ex/dlvx/breakpoint/DlvFunctionBreakpointProperties.java b/src/main/java/io/github/bofa1ex/dlvx/breakpoint/DlvFunctionBreakpointProperties.java deleted file mode 100644 index c3367a1..0000000 --- a/src/main/java/io/github/bofa1ex/dlvx/breakpoint/DlvFunctionBreakpointProperties.java +++ /dev/null @@ -1,27 +0,0 @@ -package io.github.bofa1ex.dlvx.breakpoint; - -import com.goide.dlv.breakpoint.DlvBreakpointProperties; -import com.intellij.util.xmlb.annotations.Attribute; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.Objects; - -public class DlvFunctionBreakpointProperties extends DlvBreakpointProperties { - @Attribute("method") - public String functionName; - - @Override - public @Nullable DlvFunctionBreakpointProperties getState() { - return this; - } - - @Override - public void loadState(@NotNull DlvBreakpointProperties state) { - Objects.requireNonNull(state); - if (state instanceof DlvFunctionBreakpointProperties) { - final DlvFunctionBreakpointProperties castedState = (DlvFunctionBreakpointProperties) state; - this.functionName = castedState.functionName; - } - } -} diff --git a/src/main/java/io/github/bofa1ex/dlvx/execution/DlvBreakpointProxyHandler.java b/src/main/java/io/github/bofa1ex/dlvx/execution/DlvBreakpointProxyHandler.java deleted file mode 100644 index 137011c..0000000 --- a/src/main/java/io/github/bofa1ex/dlvx/execution/DlvBreakpointProxyHandler.java +++ /dev/null @@ -1,52 +0,0 @@ -package io.github.bofa1ex.dlvx.execution; - -import com.goide.dlv.protocol.DlvRequest; -import com.goide.i18n.GoBundle; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.xdebugger.XExpression; -import com.intellij.xdebugger.XSourcePosition; -import com.intellij.xdebugger.breakpoints.XBreakpointHandler; -import com.intellij.xdebugger.breakpoints.XBreakpointType; -import com.intellij.xdebugger.breakpoints.XLineBreakpoint; -import io.github.bofa1ex.dlvx.DlvMirrorDebugProcess; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.concurrency.Promise; -import org.jetbrains.concurrency.Promises; - -public abstract class DlvBreakpointProxyHandler> extends XBreakpointHandler { - protected DlvMirrorDebugProcess mirrorDebugProcess; - protected DlvBreakpointProxyHandler(@NotNull Class> breakpointTypeClass, DlvMirrorDebugProcess mirrorDebugProcess) { - super(breakpointTypeClass); - this.mirrorDebugProcess = mirrorDebugProcess; - } - - abstract Promise sendSetBreakpoint(B breakpoint, int line, String condition, String debuggerPath); - - @Override - public void registerBreakpoint(@NotNull B breakpoint) { - final XSourcePosition breakpointPosition = breakpoint.getSourcePosition(); - if (breakpointPosition == null) return; - - final VirtualFile file = breakpointPosition.getFile(); - final XExpression expression = breakpoint.getConditionExpression(); - final String condition = expression != null ? expression.getExpression() : null; - final String debuggerPath = mirrorDebugProcess.getDebuggerPath(file); - - if (debuggerPath == null) { - mirrorDebugProcess.getSession().setBreakpointInvalid(breakpoint, GoBundle.message("go.debugger.cannot.find.debugger.path", file.getPath())); - } else { - mirrorDebugProcess.pauseIfNeededAndProcess(() -> this.sendSetBreakpoint(breakpoint, breakpointPosition.getLine(), condition, debuggerPath)); - } - } - - @Override - public void unregisterBreakpoint(@NotNull B breakpoint, boolean temp) { - XSourcePosition breakpointPosition = breakpoint.getSourcePosition(); - if (breakpointPosition == null) return; - - mirrorDebugProcess.pauseIfNeededAndProcess(() -> { - final Integer id = mirrorDebugProcess.breakpoints().remove(breakpoint); - return id != null ? mirrorDebugProcess.send(new DlvRequest.ClearBreakpoint(id)) : Promises.resolvedPromise(); - }); - } -} diff --git a/src/main/java/io/github/bofa1ex/dlvx/execution/DlvFunctionBreakpointHandler.java b/src/main/java/io/github/bofa1ex/dlvx/execution/DlvFunctionBreakpointHandler.java deleted file mode 100644 index e5fc43a..0000000 --- a/src/main/java/io/github/bofa1ex/dlvx/execution/DlvFunctionBreakpointHandler.java +++ /dev/null @@ -1,80 +0,0 @@ -package io.github.bofa1ex.dlvx.execution; - -import com.esotericsoftware.kryo.kryo5.util.Null; -import com.goide.dlv.protocol.DlvApi; -import com.goide.dlv.protocol.DlvRequest; -import com.goide.i18n.GoBundle; -import com.goide.psi.GoFunctionOrMethodDeclaration; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.openapi.vfs.VirtualFileManager; -import com.intellij.xdebugger.XExpression; -import com.intellij.xdebugger.XSourcePosition; -import com.intellij.xdebugger.breakpoints.XLineBreakpoint; -import io.github.bofa1ex.dlvx.DlvMirrorDebugProcess; -import io.github.bofa1ex.dlvx.breakpoint.DlvFunctionBreakPointType; -import io.github.bofa1ex.dlvx.breakpoint.DlvFunctionBreakpointProperties; -import io.github.bofa1ex.dlvx.protocol.DlvCreateFunctionBreakpoint; -import io.github.bofa1ex.dlvx.utils.DlvxUtils; -import org.apache.commons.lang3.StringUtils; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.concurrency.Promise; -import org.jetbrains.concurrency.Promises; - -import java.util.List; -import java.util.Objects; - -public class DlvFunctionBreakpointHandler extends DlvBreakpointProxyHandler> { - public DlvFunctionBreakpointHandler(DlvMirrorDebugProcess debugProcess) { - super(DlvFunctionBreakPointType.class, debugProcess); - } - - @Override - public void registerBreakpoint(@NotNull XLineBreakpoint breakpoint) { - final XSourcePosition breakpointPosition = breakpoint.getSourcePosition(); - if (breakpointPosition == null) return; - - final GoFunctionOrMethodDeclaration function = DlvxUtils.findFunction( - mirrorDebugProcess.getSession().getProject(), - Objects.requireNonNull(VirtualFileManager.getInstance().findFileByUrl(breakpoint.getFileUrl())), - breakpointPosition.getLine() - ); - - if (function == null) { - mirrorDebugProcess.getSession().setBreakpointInvalid(breakpoint, "go function not found."); - return; - } - - if (StringUtils.isBlank(function.getName())) { - mirrorDebugProcess.getSession().setBreakpointInvalid(breakpoint, "go function name empty."); - return; - } - - breakpoint.getProperties().functionName = function.getQualifiedName(); - final XExpression expression = breakpoint.getConditionExpression(); - final String condition = expression != null ? expression.getExpression() : null; - - mirrorDebugProcess.pauseIfNeededAndProcess(() -> this.sendSetBreakpoint(breakpoint, breakpointPosition.getLine(), condition, null)); - } - - @Override - public Promise sendSetBreakpoint(@NotNull XLineBreakpoint breakpoint, int line, @Nullable String condition, @Nullable String path) { - final Promise> findLocationPromise = mirrorDebugProcess.send(new DlvRequest.FindLocation(breakpoint.getProperties().functionName)); - return findLocationPromise.thenAsync(locations -> { - if (locations.isEmpty()) { - mirrorDebugProcess.getSession().setBreakpointVerified(breakpoint); - return Promises.resolvedPromise(); - } - return mirrorDebugProcess.send(new DlvCreateFunctionBreakpoint(locations.get(0).pc)); - }).onSuccess((b) -> { - mirrorDebugProcess.breakpoints().put(breakpoint, b.id); - mirrorDebugProcess.getSession().setBreakpointVerified(breakpoint); - }).onError((t) -> { - String message = t == null ? null : t.getMessage(); - if (message != null && message.equals("could not find file " + path)) { - message = GoBundle.message("go.debugger.no.debug.information.for.file", path); - } - mirrorDebugProcess.getSession().setBreakpointInvalid(breakpoint, message); - }); - } -} diff --git a/src/main/java/io/github/bofa1ex/dlvx/execution/DlvMirrorBreakpointHandler.java b/src/main/java/io/github/bofa1ex/dlvx/execution/DlvMirrorBreakpointHandler.java deleted file mode 100644 index 67f2ac9..0000000 --- a/src/main/java/io/github/bofa1ex/dlvx/execution/DlvMirrorBreakpointHandler.java +++ /dev/null @@ -1,33 +0,0 @@ -package io.github.bofa1ex.dlvx.execution; - -import com.goide.dlv.breakpoint.DlvBreakpointProperties; -import com.goide.dlv.breakpoint.DlvBreakpointType; -import com.goide.dlv.protocol.DlvApi; -import com.goide.dlv.protocol.DlvRequest; -import com.goide.i18n.GoBundle; -import com.intellij.xdebugger.breakpoints.XLineBreakpoint; -import io.github.bofa1ex.dlvx.DlvMirrorDebugProcess; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.concurrency.Promise; - -public class DlvMirrorBreakpointHandler extends DlvBreakpointProxyHandler> { - public DlvMirrorBreakpointHandler(DlvMirrorDebugProcess debugProcess) { - super(DlvBreakpointType.class, debugProcess); - } - - @Override - public Promise sendSetBreakpoint(@NotNull XLineBreakpoint breakpoint, int line, @Nullable String condition, @NotNull String path) { - return mirrorDebugProcess.send(new DlvRequest.CreateBreakpoint(path, line + 1, condition)) - .onSuccess((b) -> { - mirrorDebugProcess.breakpoints().put(breakpoint, b.id); - mirrorDebugProcess.getSession().setBreakpointVerified(breakpoint); - }).onError((t) -> { - String message = t == null ? null : t.getMessage(); - if (message != null && message.equals("could not find file " + path)) { - message = GoBundle.message("go.debugger.no.debug.information.for.file", path); - } - mirrorDebugProcess.getSession().setBreakpointInvalid(breakpoint, message); - }); - } -} diff --git a/src/main/java/io/github/bofa1ex/dlvx/execution/DlvxRemoteDebugConfiguration.java b/src/main/java/io/github/bofa1ex/dlvx/execution/DlvxRemoteDebugConfiguration.java deleted file mode 100644 index 33da5c0..0000000 --- a/src/main/java/io/github/bofa1ex/dlvx/execution/DlvxRemoteDebugConfiguration.java +++ /dev/null @@ -1,41 +0,0 @@ -package io.github.bofa1ex.dlvx.execution; - -import com.goide.dlv.DlvDebugProcess; -import com.goide.dlv.DlvDisconnectOption; -import com.goide.dlv.DlvRemoteVmConnection; -import com.goide.execution.DlvRemoteDebugDisconnectOption; -import com.goide.execution.GoRemoteDebugConfigurationType; -import com.intellij.execution.ExecutionResult; -import com.intellij.execution.configurations.ConfigurationFactory; -import com.intellij.execution.runners.ExecutionEnvironment; -import com.intellij.openapi.project.Project; -import com.intellij.xdebugger.XDebugProcess; -import com.intellij.xdebugger.XDebugSession; -import io.github.bofa1ex.dlvx.DlvMirrorDebugProcess; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.net.InetSocketAddress; - -public class DlvxRemoteDebugConfiguration extends GoRemoteDebugConfigurationType.DlvRemoteDebugConfiguration { - private final DlvRemoteDebugDisconnectOption myDisconnectOption; - - public DlvxRemoteDebugConfiguration(Project project, @NotNull ConfigurationFactory factory, String name) { - super(project, factory, name); - this.myDisconnectOption = DlvRemoteDebugDisconnectOption.ASK; - } - - @Override - public @NotNull XDebugProcess createDebugProcess(@NotNull InetSocketAddress socketAddress, @NotNull XDebugSession session, @Nullable ExecutionResult executionResult, @NotNull ExecutionEnvironment environment) { - DlvDisconnectOption disconnectOption = DlvDisconnectOption.LEAVE_RUNNING; - if (myDisconnectOption == DlvRemoteDebugDisconnectOption.STOP) { - disconnectOption = DlvDisconnectOption.DETACH; - } - - return new DlvMirrorDebugProcess(session, - new DlvRemoteVmConnection(disconnectOption), - executionResult, - socketAddress - ); - } -} diff --git a/src/main/java/io/github/bofa1ex/dlvx/execution/DlvxRemoteDebugConfigurationType.java b/src/main/java/io/github/bofa1ex/dlvx/execution/DlvxRemoteDebugConfigurationType.java deleted file mode 100644 index f8a323e..0000000 --- a/src/main/java/io/github/bofa1ex/dlvx/execution/DlvxRemoteDebugConfigurationType.java +++ /dev/null @@ -1,39 +0,0 @@ -package io.github.bofa1ex.dlvx.execution; - -import com.goide.GoIcons; -import com.goide.i18n.GoBundle; -import com.intellij.execution.configurations.ConfigurationFactory; -import com.intellij.execution.configurations.ConfigurationTypeBase; -import com.intellij.execution.configurations.RunConfiguration; -import com.intellij.execution.configurations.RunConfigurationSingletonPolicy; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.NotNullLazyValue; -import org.jetbrains.annotations.NotNull; - -public class DlvxRemoteDebugConfigurationType extends ConfigurationTypeBase { - public DlvxRemoteDebugConfigurationType() { - super("GoRemoteDebugConfigurationType", - "Dlvx " + GoBundle.message("go.execution.remote.run.configuration.display.name"), - "Dlvx " + GoBundle.message("go.execution.remote.run.configuration.description"), - NotNullLazyValue.lazy(() -> GoIcons.GO_REMOTE_DEBUG_ICON) - ); - - this.addFactory(new ConfigurationFactory(this) { - public @NotNull String getId() { - return "Dlvx Go Remote"; - } - - public @NotNull RunConfigurationSingletonPolicy getSingletonPolicy() { - return RunConfigurationSingletonPolicy.SINGLE_INSTANCE_ONLY; - } - - public @NotNull RunConfiguration createTemplateConfiguration(@NotNull Project project) { - return new DlvxRemoteDebugConfiguration(project, this, ""); - } - - public boolean isEditableInDumbMode() { - return true; - } - }); - } -} diff --git a/src/main/java/io/github/bofa1ex/dlvx/protocol/DlvCreateFunctionBreakpoint.java b/src/main/java/io/github/bofa1ex/dlvx/protocol/DlvCreateFunctionBreakpoint.java deleted file mode 100644 index c3cedeb..0000000 --- a/src/main/java/io/github/bofa1ex/dlvx/protocol/DlvCreateFunctionBreakpoint.java +++ /dev/null @@ -1,44 +0,0 @@ -package io.github.bofa1ex.dlvx.protocol; - -import com.goide.dlv.protocol.DlvApi; -import com.google.gson.stream.JsonWriter; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.jsonProtocol.OutMessage; -import org.jetbrains.jsonProtocol.Request; - -import java.io.IOException; -import java.math.BigInteger; - -public class DlvCreateFunctionBreakpoint extends OutMessage implements Request { - public DlvCreateFunctionBreakpoint(@NotNull BigInteger addr) { - try { - JsonWriter w = this.getWriter(); - w.name("method").value(this.getMethodName()); - w.name("params").beginArray().beginObject(); - w.name("Breakpoint").beginObject() - .name("addr").value(addr) - .endObject(); - w.endObject().endArray(); - } catch (IOException var3) { - throw new RuntimeException(var3); - } - } - - @NotNull - @Override - public String getMethodName() { - return "RPCServer.CreateBreakpoint"; - } - - @Override - public void finalize(int id) { - try { - this.getWriter().name("id").value(id); - this.getWriter().endObject(); - this.getWriter().close(); - } catch (IOException var3) { - throw new RuntimeException(var3); - } - } -} diff --git a/src/main/java/io/github/bofa1ex/dlvx/run/DlvxGoDebugRunner.java b/src/main/java/io/github/bofa1ex/dlvx/run/DlvxGoDebugRunner.java deleted file mode 100644 index 6c9226c..0000000 --- a/src/main/java/io/github/bofa1ex/dlvx/run/DlvxGoDebugRunner.java +++ /dev/null @@ -1,39 +0,0 @@ -package io.github.bofa1ex.dlvx.run; - -import com.goide.execution.GoBuildingRunner; -import com.goide.execution.GoRunningState; -import com.goide.util.GoHistoryProcessListener; -import com.intellij.execution.ExecutionResult; -import com.intellij.xdebugger.XDebugProcessStarter; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.net.InetSocketAddress; -import java.util.function.Supplier; - -@Deprecated -public class DlvxGoDebugRunner extends GoBuildingRunner { - - @Override - public @NotNull String getRunnerId() { - return "DlvxGoDebugRunner"; - } - - @Override - protected @NotNull GoStarter createStarter(@NotNull GoRunningState state, @NotNull GoHistoryProcessListener historyProcessListener, @NotNull Supplier<@Nullable String> outputFilePath, int compilationExitCode) { - if (state.isDebug()) return new DlvxGoDebugStarter(outputFilePath, historyProcessListener, compilationExitCode); - return new GoStarter(outputFilePath, historyProcessListener, compilationExitCode); - } - - public class DlvxGoDebugStarter extends GoDebugStarter { - public DlvxGoDebugStarter(@NotNull Supplier<@Nullable String> outputFilePath, @NotNull GoHistoryProcessListener historyListener, int compilationExitCode) { - super(outputFilePath, historyListener, compilationExitCode); - } - - @Override - protected @NotNull XDebugProcessStarter createDebugProcessStarter(@Nullable ExecutionResult executionResult, boolean remote, @Nullable InetSocketAddress socket) { - return super.createDebugProcessStarter(executionResult, remote, socket); - } - } -} diff --git a/src/main/java/io/github/bofa1ex/dlvx/utils/DlvxUtils.java b/src/main/java/io/github/bofa1ex/dlvx/utils/DlvxUtils.java deleted file mode 100644 index 3e6fcc2..0000000 --- a/src/main/java/io/github/bofa1ex/dlvx/utils/DlvxUtils.java +++ /dev/null @@ -1,50 +0,0 @@ -package io.github.bofa1ex.dlvx.utils; - -import com.goide.GoLanguage; -import com.goide.psi.GoFunctionOrMethodDeclaration; -import com.intellij.lang.LanguageUtil; -import com.intellij.openapi.editor.Document; -import com.intellij.openapi.fileEditor.FileDocumentManager; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.Ref; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiFile; -import com.intellij.psi.PsiManager; -import com.intellij.util.DocumentUtil; -import com.intellij.xdebugger.XDebuggerUtil; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public class DlvxUtils { - - public static @Nullable GoFunctionOrMethodDeclaration findFunction(@NotNull Project project, @NotNull VirtualFile file, int line) { - if (LanguageUtil.getLanguageForPsi(project, file) != GoLanguage.INSTANCE) return null; - - final PsiFile psiFile = PsiManager.getInstance(project).findFile(file); - if (psiFile == null) return null; - - final Document document = FileDocumentManager.getInstance().getDocument(file); - if (document == null) return null; - - final Ref res = Ref.create(); - XDebuggerUtil.getInstance().iterateLine(project, document, line, psiElement -> { - PsiElement parent = psiElement; - while (psiElement != null) { - final int offset = psiElement.getTextOffset(); - if (!DocumentUtil.isValidOffset(offset, document) || document.getLineNumber(offset) != line) break; - parent = psiElement; - psiElement = psiElement.getParent(); - } - - if (parent instanceof GoFunctionOrMethodDeclaration) { - res.set(((GoFunctionOrMethodDeclaration) parent)); - return false; - } - - return true; - }); - - return res.get(); - } -} diff --git a/src/main/java/io/github/bofa1ex/dlvx/MyBundle.kt b/src/main/kotlin/com/github/bofa1ex/dlvx/MyBundle.kt similarity index 100% rename from src/main/java/io/github/bofa1ex/dlvx/MyBundle.kt rename to src/main/kotlin/com/github/bofa1ex/dlvx/MyBundle.kt diff --git a/src/main/kotlin/com/github/bofa1ex/dlvx/listeners/MyApplicationActivationListener.kt b/src/main/kotlin/com/github/bofa1ex/dlvx/listeners/MyApplicationActivationListener.kt new file mode 100644 index 0000000..90bb271 --- /dev/null +++ b/src/main/kotlin/com/github/bofa1ex/dlvx/listeners/MyApplicationActivationListener.kt @@ -0,0 +1,12 @@ +package com.github.bofa1ex.dlvx.listeners + +import com.intellij.openapi.application.ApplicationActivationListener +import com.intellij.openapi.diagnostic.thisLogger +import com.intellij.openapi.wm.IdeFrame + +internal class MyApplicationActivationListener : ApplicationActivationListener { + + override fun applicationActivated(ideFrame: IdeFrame) { + thisLogger().warn("Don't forget to remove all non-needed sample code files with their corresponding registration entries in `plugin.xml`.") + } +} diff --git a/src/main/kotlin/com/github/bofa1ex/dlvx/services/MyProjectService.kt b/src/main/kotlin/com/github/bofa1ex/dlvx/services/MyProjectService.kt new file mode 100644 index 0000000..2cc7089 --- /dev/null +++ b/src/main/kotlin/com/github/bofa1ex/dlvx/services/MyProjectService.kt @@ -0,0 +1,17 @@ +package com.github.bofa1ex.dlvx.services + +import com.intellij.openapi.components.Service +import com.intellij.openapi.diagnostic.thisLogger +import com.intellij.openapi.project.Project +import com.github.bofa1ex.dlvx.MyBundle + +@Service(Service.Level.PROJECT) +class MyProjectService(project: Project) { + + init { + thisLogger().info(MyBundle.message("projectService", project.name)) + thisLogger().warn("Don't forget to remove all non-needed sample code files with their corresponding registration entries in `plugin.xml`.") + } + + fun getRandomNumber() = (1..100).random() +} diff --git a/src/main/kotlin/com/github/bofa1ex/dlvx/toolWindow/MyToolWindowFactory.kt b/src/main/kotlin/com/github/bofa1ex/dlvx/toolWindow/MyToolWindowFactory.kt new file mode 100644 index 0000000..3afd648 --- /dev/null +++ b/src/main/kotlin/com/github/bofa1ex/dlvx/toolWindow/MyToolWindowFactory.kt @@ -0,0 +1,45 @@ +package com.github.bofa1ex.dlvx.toolWindow + +import com.intellij.openapi.components.service +import com.intellij.openapi.diagnostic.thisLogger +import com.intellij.openapi.project.Project +import com.intellij.openapi.wm.ToolWindow +import com.intellij.openapi.wm.ToolWindowFactory +import com.intellij.ui.components.JBLabel +import com.intellij.ui.components.JBPanel +import com.intellij.ui.content.ContentFactory +import com.github.bofa1ex.dlvx.MyBundle +import com.github.bofa1ex.dlvx.services.MyProjectService +import javax.swing.JButton + + +class MyToolWindowFactory : ToolWindowFactory { + + init { + thisLogger().warn("Don't forget to remove all non-needed sample code files with their corresponding registration entries in `plugin.xml`.") + } + + override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) { + val myToolWindow = MyToolWindow(toolWindow) + val content = ContentFactory.getInstance().createContent(myToolWindow.getContent(), null, false) + toolWindow.contentManager.addContent(content) + } + + override fun shouldBeAvailable(project: Project) = true + + class MyToolWindow(toolWindow: ToolWindow) { + + private val service = toolWindow.project.service() + + fun getContent() = JBPanel>().apply { + val label = JBLabel(MyBundle.message("randomLabel", "?")) + + add(label) + add(JButton(MyBundle.message("shuffle")).apply { + addActionListener { + label.text = MyBundle.message("randomLabel", service.getRandomNumber()) + } + }) + } + } +} diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 90ff46b..2858043 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -1,28 +1,18 @@ - - com.bofa1ex.dlvx + com.github.bofa1ex.dlvx + dlvx Template + bofa1ex - - Dlvx + com.intellij.modules.platform - - icoder + messages.MyBundle - - - com.intellij.modules.platform - org.jetbrains.plugins.go + + + - - - - - - - \ No newline at end of file + + + + diff --git a/src/test/testData/rename/foo.xml b/src/test/testData/rename/foo.xml index 1e4c39f..b21e9f2 100644 --- a/src/test/testData/rename/foo.xml +++ b/src/test/testData/rename/foo.xml @@ -1,4 +1,3 @@ - 1>Foo + 1>Foo