Skip to content

Commit

Permalink
try add debugger
Browse files Browse the repository at this point in the history
  • Loading branch information
CppCXY committed Aug 9, 2024
1 parent 586aa75 commit 17f125a
Show file tree
Hide file tree
Showing 32 changed files with 2,597 additions and 1 deletion.
64 changes: 63 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ val buildDataList = listOf(

group = "com.cppcxy"
val emmyluaAnalyzerVersion = "0.6.3"
val emmyDebuggerVersion = "1.8.2"

val emmyluaAnalyzerProjectUrl = "https://github.com/CppCXY/EmmyLuaAnalyzer"

Expand All @@ -44,6 +45,7 @@ val runnerNumber = System.getenv("RUNNER_NUMBER") ?: "Dev"

version = "${emmyluaAnalyzerVersion}.${runnerNumber}-IDEA${buildVersion}"


task("download", type = Download::class) {
src(
arrayOf(
Expand Down Expand Up @@ -83,6 +85,62 @@ task("install", type = Copy::class) {
destinationDir = file("src/main/resources")
}

task("downloadEmmyDebugger", type = Download::class) {
src(arrayOf(
"https://github.com/EmmyLua/EmmyLuaDebugger/releases/download/${emmyDebuggerVersion}/darwin-arm64.zip",
"https://github.com/EmmyLua/EmmyLuaDebugger/releases/download/${emmyDebuggerVersion}/darwin-x64.zip",
"https://github.com/EmmyLua/EmmyLuaDebugger/releases/download/${emmyDebuggerVersion}/linux-x64.zip",
"https://github.com/EmmyLua/EmmyLuaDebugger/releases/download/${emmyDebuggerVersion}/win32-x64.zip",
"https://github.com/EmmyLua/EmmyLuaDebugger/releases/download/${emmyDebuggerVersion}/win32-x86.zip"
))

dest("temp")
}

task("unzipEmmyDebugger", type = Copy::class) {
dependsOn("downloadEmmyDebugger")
from(zipTree("temp/win32-x86.zip")) {
into("windows/x86")
}
from(zipTree("temp/win32-x64.zip")) {
into("windows/x64")
}
from(zipTree("temp/darwin-x64.zip")) {
into("mac/x64")
}
from(zipTree("temp/darwin-arm64.zip")) {
into("mac/arm64")
}
from(zipTree("temp/linux-x64.zip")) {
into("linux")
}
destinationDir = file("temp")
}

task("installEmmyDebugger", type = Copy::class) {
dependsOn("unzipEmmyDebugger")
from("temp/windows/x64/") {
include("emmy_core.dll")
into("debugger/emmy/windows/x64")
}
from("temp/windows/x86/") {
include("emmy_core.dll")
into("debugger/emmy/windows/x86")
}
from("temp/linux/") {
include("emmy_core.so")
into("debugger/emmy/linux")
}
from("temp/mac/x64") {
include("emmy_core.dylib")
into("debugger/emmy/mac/x64")
}
from("temp/mac/arm64") {
include("emmy_core.dylib")
into("debugger/emmy/mac/arm64")
}
destinationDir = file("src/main/resources")
}

// Configure Gradle IntelliJ Plugin
// Read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
Expand Down Expand Up @@ -131,7 +189,7 @@ tasks {
}

buildPlugin {
dependsOn("install")
dependsOn("install", "installEmmyDebugger")
}
// fix by https://youtrack.jetbrains.com/issue/IDEA-325747/IDE-always-actively-disables-LSP-plugins-if-I-ask-the-plugin-to-return-localized-diagnostic-messages.
runIde {
Expand All @@ -144,6 +202,10 @@ tasks {
from("${project.projectDir}/src/main/resources/server")
into("${destinationDir.path}/${pluginName.get()}/server")
}
copy {
from("${project.projectDir}/src/main/resources/debugger")
into("${destinationDir.path}/${pluginName.get()}/debugger")
}
}
}
}
35 changes: 35 additions & 0 deletions src/main/java/com/tang/intellij/lua/debugger/DebugLogger.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright (c) 2017. tangzx([email protected])
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.tang.intellij.lua.debugger

import com.intellij.execution.ui.ConsoleViewContentType
import com.intellij.openapi.project.Project

/**
* console logger
* Created by tangzx on 2017/5/1.
*/
interface DebugLogger {
fun print(text: String, consoleType: LogConsoleType, contentType: ConsoleViewContentType)
fun println(text: String, consoleType: LogConsoleType, contentType: ConsoleViewContentType)
fun printHyperlink(text: String, consoleType: LogConsoleType, handler: (project: Project) -> Unit)
fun error(text: String, consoleType: LogConsoleType = LogConsoleType.EMMY)
}

enum class LogConsoleType {
EMMY, NORMAL
}
40 changes: 40 additions & 0 deletions src/main/java/com/tang/intellij/lua/debugger/DebuggerType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2017. tangzx([email protected])
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.tang.intellij.lua.debugger;

/**
*
* Created by tangzx on 2017/5/7.
*/
public enum DebuggerType {
Attach(1, "Attach Debugger(Not available)"), Mob(2, "Remote Debugger(Mobdebug)");
private int v;
private String desc;
DebuggerType(int v, String desc) {
this.v = v;
this.desc = desc;
}
public static DebuggerType valueOf(int v) {
switch (v) {
case 1: return Attach;
case 2: return Mob;
default: return null;
}
}
public int value() { return v; }
public String toString() { return desc; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright (c) 2017. tangzx([email protected])
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.tang.intellij.lua.debugger

/**
*
* Created by tangzx on 2017/5/7.
*/
interface IRemoteConfiguration {
val port: Int
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright (c) 2017. tangzx([email protected])
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.tang.intellij.lua.debugger

import com.intellij.execution.ExecutionException
import com.intellij.execution.Executor
import com.intellij.execution.configurations.CommandLineState
import com.intellij.execution.process.ColoredProcessHandler
import com.intellij.execution.process.ProcessHandler
import com.intellij.execution.runners.ExecutionEnvironment
import com.intellij.execution.ui.ConsoleView

/**
*
* Created by TangZX on 2016/12/30.
*/
class LuaCommandLineState(environment: ExecutionEnvironment) : CommandLineState(environment) {

@Throws(ExecutionException::class)
override fun startProcess(): ProcessHandler {
val runProfile = environment.runProfile as LuaRunConfiguration
return ColoredProcessHandler(runProfile.createCommandLine()!!)
}

@Throws(ExecutionException::class)
override fun createConsole(executor: Executor): ConsoleView? {
val consoleView = super.createConsole(executor)
consoleView?.addMessageFilter(LuaTracebackFilter(environment.project))
return consoleView
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2017. tangzx([email protected])
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.tang.intellij.lua.debugger

import com.intellij.execution.BeforeRunTask
import com.intellij.execution.configurations.ConfigurationFactory
import com.intellij.execution.configurations.ConfigurationType
import com.intellij.openapi.util.Key

/**
* base configuration factory
* disable `Make` task
*/
abstract class LuaConfigurationFactory(type: ConfigurationType) : ConfigurationFactory(type) {
override fun configureBeforeRunTaskDefaults(providerID: Key<out BeforeRunTask<*>>?, task: BeforeRunTask<*>?) {
if ("Make" == providerID?.toString())
task?.isEnabled = false
}

override fun getId(): String {
return name
}
}
Loading

0 comments on commit 17f125a

Please sign in to comment.