From 0afb4dfb2d8ecd376fd7cca41c7e089846d59de0 Mon Sep 17 00:00:00 2001
From: ale <345036769@qq.com>
Date: Thu, 8 Jan 2026 17:37:52 +0800
Subject: [PATCH 1/2] build for 152
---
.github/workflows/build.yml | 11 +-
.idea/modules.xml | 8 -
build.gradle.kts | 93 ++---
gradle/wrapper/gradle-wrapper.properties | 2 +-
.../java/com/tang/intellij/lua/LuaBundle.java | 6 -
.../codeInsight/LuaParameterInfoHandler.kt | 37 +-
.../inspection/RemoveUnusedLocal.kt | 39 +-
.../debugger/app/LuaAppSettingsEditor.java | 16 +-
.../formatter/LuaCodeStyleSettingsProvider.kt | 13 +-
.../formatter/LuaFormattingModelBuilder.kt | 74 ++--
.../lua/errorreporting/error-report.kt | 379 +++++++++---------
.../hierarchy/call/LuaCallHierarchyBrowser.kt | 10 +-
.../intellij/lua/lang/LuaFileTypeDetector.kt | 1 -
.../intellij/lua/lang/LuaParserDefinition.kt | 124 +++---
.../intellij/lua/luacheck/LuaCheckActions.kt | 51 ---
.../intellij/lua/luacheck/LuaCheckInvoker.kt | 168 --------
.../intellij/lua/luacheck/LuaCheckNodes.kt | 77 ----
.../intellij/lua/luacheck/LuaCheckPanel.kt | 248 ------------
.../intellij/lua/luacheck/LuaCheckSettings.kt | 49 ---
.../lua/luacheck/LuaCheckSettingsPanel.form | 58 ---
.../lua/luacheck/LuaCheckSettingsPanel.java | 99 -----
.../lua/luacheck/LuaCheckToolWindowFactory.kt | 35 --
.../intellij/lua/luacheck/LuaCheckView.kt | 36 --
.../tang/intellij/lua/project/LuaSdkType.kt | 6 +-
.../lua/project/LuaSettingsPanel.java | 3 +-
.../lua/project/LuaSourceRootManager.kt | 4 +-
.../com/tang/intellij/lua/psi/LuaPsiFile.kt | 4 +-
.../refactoring/move/LuaMoveFileHandler.kt | 2 +-
.../LuaSpellBundledDictionaryProvider.kt | 23 --
.../spellchecker/LuaSpellcheckingStrategy.kt | 57 ---
.../intellij/lua/usages/UsageTypeProvider.kt | 2 +-
src/main/resources/!!DONT_UNZIP_ME!!.txt | 1 -
src/main/resources/META-INF/emmylua-core.xml | 3 -
src/main/resources/META-INF/plugin.xml | 25 +-
34 files changed, 422 insertions(+), 1342 deletions(-)
delete mode 100644 .idea/modules.xml
delete mode 100644 src/main/java/com/tang/intellij/lua/luacheck/LuaCheckActions.kt
delete mode 100644 src/main/java/com/tang/intellij/lua/luacheck/LuaCheckInvoker.kt
delete mode 100644 src/main/java/com/tang/intellij/lua/luacheck/LuaCheckNodes.kt
delete mode 100644 src/main/java/com/tang/intellij/lua/luacheck/LuaCheckPanel.kt
delete mode 100644 src/main/java/com/tang/intellij/lua/luacheck/LuaCheckSettings.kt
delete mode 100644 src/main/java/com/tang/intellij/lua/luacheck/LuaCheckSettingsPanel.form
delete mode 100644 src/main/java/com/tang/intellij/lua/luacheck/LuaCheckSettingsPanel.java
delete mode 100644 src/main/java/com/tang/intellij/lua/luacheck/LuaCheckToolWindowFactory.kt
delete mode 100644 src/main/java/com/tang/intellij/lua/luacheck/LuaCheckView.kt
delete mode 100644 src/main/java/com/tang/intellij/lua/spellchecker/LuaSpellBundledDictionaryProvider.kt
delete mode 100644 src/main/java/com/tang/intellij/lua/spellchecker/LuaSpellcheckingStrategy.kt
delete mode 100644 src/main/resources/!!DONT_UNZIP_ME!!.txt
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 7bc8d560f..bbb72f848 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -2,7 +2,8 @@ name: Build Plugin
on:
push:
- branches: *
+ branches:
+ - '*'
# pull_request:
# branches: [ "master" ]
@@ -16,7 +17,7 @@ jobs:
env:
CI: true
- CI_BUILD_VERSION: 1.3.7.${{ github.run_number }}
+ CI_BUILD_VERSION: 1.4.0.${{ github.run_number }}
steps:
- name: Checkout
@@ -28,13 +29,13 @@ jobs:
java-version: '17'
distribution: 'temurin'
- - name: Build 2023.1-EAP
+ - name: Build 2025.3
env:
- IDEA_VER: 231
+ IDEA_VER: 245
run: ./gradlew buildPlugin
- name: Upload artifact
- uses: actions/upload-artifact@v3.1.0
+ uses: actions/upload-artifact@v4
with:
name: v${{ env.CI_BUILD_VERSION }}
path: build/distributions/*.zip
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index ef5f7d170..000000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/build.gradle.kts b/build.gradle.kts
index 4142dc85e..41c46fba8 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -14,13 +14,17 @@
* limitations under the License.
*/
-import de.undercouch.gradle.tasks.download.*
+import de.undercouch.gradle.tasks.download.Download
import org.apache.tools.ant.taskdefs.condition.Os
+import org.jetbrains.intellij.platform.gradle.tasks.PrepareSandboxTask
+import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import java.io.ByteArrayOutputStream
+import kotlin.text.get
+import kotlin.text.set
plugins {
- id("org.jetbrains.intellij").version("1.10.0")
- id("org.jetbrains.kotlin.jvm").version("1.7.22")
+ id("org.jetbrains.intellij.platform") version "2.7.0"
+ id("org.jetbrains.kotlin.jvm").version("2.1.0")
id("de.undercouch.download").version("5.3.0")
}
@@ -41,38 +45,13 @@ data class BuildData(
val buildDataList = listOf(
BuildData(
- ideaSDKShortVersion = "231",
- // 223.7571.123-EAP-SNAPSHOT
- // LATEST-EAP-SNAPSHOT
- ideaSDKVersion = "LATEST-EAP-SNAPSHOT",
- sinceBuild = "231",
- untilBuild = "231.*",
+ ideaSDKShortVersion = "2025.2",
+ ideaSDKVersion = "252.23892.409",
+ sinceBuild = "252",
+ untilBuild = "252.*",
bunch = "212",
targetCompatibilityLevel = JavaVersion.VERSION_17,
jvmTarget = "17"
- ),
- BuildData(
- ideaSDKShortVersion = "223",
- ideaSDKVersion = "2022.3",
- sinceBuild = "223",
- untilBuild = "223.*",
- bunch = "212",
- targetCompatibilityLevel = JavaVersion.VERSION_17,
- jvmTarget = "17"
- ),
- BuildData(
- ideaSDKShortVersion = "222",
- ideaSDKVersion = "2022.2",
- sinceBuild = "212",
- untilBuild = "222.*",
- bunch = "212"
- ),
- BuildData(
- ideaSDKShortVersion = "211",
- ideaSDKVersion = "2021.1",
- sinceBuild = "211",
- untilBuild = "211.*",
- bunch = "203"
)
)
@@ -115,11 +94,11 @@ fun getRev(): String {
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"
+ "https://github.com/leinlin/EmmyLuaDebugger/releases/download/${emmyDebuggerVersion}/darwin-arm64.zip",
+ "https://github.com/leinlin/EmmyLuaDebugger/releases/download/${emmyDebuggerVersion}/darwin-x64.zip",
+ "https://github.com/leinlin/EmmyLuaDebugger/releases/download/${emmyDebuggerVersion}/linux-x64.zip",
+ "https://github.com/leinlin/EmmyLuaDebugger/releases/download/${emmyDebuggerVersion}/win32-x64.zip",
+ "https://github.com/leinlin/EmmyLuaDebugger/releases/download/${emmyDebuggerVersion}/win32-x86.zip"
))
dest("temp")
@@ -172,8 +151,11 @@ task("installEmmyDebugger", type = Copy::class) {
project(":") {
repositories {
- maven(url = "https://www.jetbrains.com/intellij-repository/releases")
mavenCentral()
+ intellijPlatform {
+ defaultRepositories()
+ marketplace()
+ }
}
dependencies {
@@ -183,6 +165,10 @@ project(":") {
implementation("org.luaj:luaj-jse:3.0.1")
implementation("org.eclipse.mylyn.github:org.eclipse.egit.github.core:2.1.5")
implementation("com.jgoodies:forms:1.2.1")
+ intellijPlatform {
+ intellijIdeaCommunity(buildVersionData.ideaSDKShortVersion)
+ //bundledModule("intellij.spellchecker")
+ }
}
sourceSets {
@@ -193,18 +179,14 @@ project(":") {
}
}
- configure {
+ /*configure {
sourceCompatibility = buildVersionData.targetCompatibilityLevel
targetCompatibility = buildVersionData.targetCompatibilityLevel
- }
+ }*/
- intellij {
- type.set("IC")
- updateSinceUntilBuild.set(false)
- downloadSources.set(!isCI)
- version.set(buildVersionData.ideaSDKVersion)
- //localPath.set(System.getenv("IDEA_HOME_${buildVersionData.ideaSDKShortVersion}"))
- sandboxDir.set("${project.buildDir}/${buildVersionData.ideaSDKShortVersion}/idea-sandbox")
+ intellijPlatform {
+ version = version
+ sandboxContainer.set(layout.buildDirectory.dir("${buildVersionData.ideaSDKShortVersion}/idea-sandbox"))
}
task("bunch") {
@@ -242,26 +224,27 @@ project(":") {
}
}
+ processResources {
+ dependsOn("installEmmyDebugger")
+ }
+
compileKotlin {
- kotlinOptions {
- jvmTarget = buildVersionData.jvmTarget
+ compilerOptions {
+ jvmTarget.set(JvmTarget.fromTarget(buildVersionData.jvmTarget))
}
}
patchPluginXml {
+ dependsOn("installEmmyDebugger")
sinceBuild.set(buildVersionData.sinceBuild)
untilBuild.set(buildVersionData.untilBuild)
}
- instrumentCode {
- compilerVersion.set(buildVersionData.instrumentCodeCompilerVersion)
- }
-
publishPlugin {
token.set(System.getenv("IDEA_PUBLISH_TOKEN"))
}
- withType {
+ withType {
doLast {
copy {
from("src/main/resources/std")
@@ -274,4 +257,4 @@ project(":") {
}
}
}
-}
+}
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 80498c8cf..a16afb865 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -16,6 +16,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.2-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/src/main/java/com/tang/intellij/lua/LuaBundle.java b/src/main/java/com/tang/intellij/lua/LuaBundle.java
index c1653e984..e6a63c2e6 100644
--- a/src/main/java/com/tang/intellij/lua/LuaBundle.java
+++ b/src/main/java/com/tang/intellij/lua/LuaBundle.java
@@ -31,12 +31,6 @@ public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) Stri
return CommonBundle.message(getBundle(), key, params);
}
- @Nullable
- public static String messageOfNull(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key,
- @NotNull Object... params) {
- return CommonBundle.messageOfNull(getBundle(), key, params);
- }
-
private static Reference ourBundle;
@NonNls
private static final String BUNDLE = "LuaBundle";
diff --git a/src/main/java/com/tang/intellij/lua/codeInsight/LuaParameterInfoHandler.kt b/src/main/java/com/tang/intellij/lua/codeInsight/LuaParameterInfoHandler.kt
index 5657b1e45..f7ae9a404 100644
--- a/src/main/java/com/tang/intellij/lua/codeInsight/LuaParameterInfoHandler.kt
+++ b/src/main/java/com/tang/intellij/lua/codeInsight/LuaParameterInfoHandler.kt
@@ -16,7 +16,6 @@
package com.tang.intellij.lua.codeInsight
-import com.intellij.codeInsight.lookup.LookupElement
import com.intellij.lang.parameterInfo.*
import com.intellij.psi.util.PsiTreeUtil
import com.intellij.util.Processor
@@ -34,18 +33,6 @@ data class ParameterInfoType(val sig: IFunSignature, val isColonStyle: Boolean)
* Created by tangzx on 2016/12/25.
*/
class LuaParameterInfoHandler : ParameterInfoHandler {
- override fun couldShowInLookup(): Boolean {
- return false
- }
-
- override fun getParametersForLookup(lookupElement: LookupElement, parameterInfoContext: ParameterInfoContext): Array? {
- return emptyArray()
- }
-
- override fun getParametersForDocumentation(o: ParameterInfoType, parameterInfoContext: ParameterInfoContext): Array? {
- return emptyArray()
- }
-
override fun findElementForParameterInfo(context: CreateParameterInfoContext): LuaArgs? {
val file = context.file
val luaArgs = PsiTreeUtil.findElementOfClassAtOffset(file, context.offset, LuaArgs::class.java, false)
@@ -85,14 +72,6 @@ class LuaParameterInfoHandler : ParameterInfoHandler
}
}
- override fun getParameterCloseChars(): String? {
- return ",()"
- }
-
- override fun tracksParameterIndex(): Boolean {
- return true
- }
-
override fun updateUI(o: ParameterInfoType?, context: ParameterInfoUIContext) {
if (o == null)
return
@@ -113,14 +92,14 @@ class LuaParameterInfoHandler : ParameterInfoHandler
}
if (str.isNotEmpty()) {
context.setupUIComponentPresentation(
- str,
- start,
- end,
- false,
- false,
- false,
- context.defaultParameterColor
+ str,
+ start,
+ end,
+ false,
+ false,
+ false,
+ context.defaultParameterColor
)
}
}
-}
+}
\ No newline at end of file
diff --git a/src/main/java/com/tang/intellij/lua/codeInsight/inspection/RemoveUnusedLocal.kt b/src/main/java/com/tang/intellij/lua/codeInsight/inspection/RemoveUnusedLocal.kt
index 06019d159..9d368db37 100644
--- a/src/main/java/com/tang/intellij/lua/codeInsight/inspection/RemoveUnusedLocal.kt
+++ b/src/main/java/com/tang/intellij/lua/codeInsight/inspection/RemoveUnusedLocal.kt
@@ -23,6 +23,7 @@ import com.intellij.openapi.util.TextRange
import com.intellij.psi.PsiElementVisitor
import com.intellij.psi.search.searches.ReferencesSearch
import com.intellij.refactoring.RefactoringFactory
+import com.intellij.util.Processor
import com.tang.intellij.lua.Constants
import com.tang.intellij.lua.comment.psi.LuaDocPsiElement
import com.tang.intellij.lua.psi.LuaLocalDef
@@ -44,17 +45,17 @@ class RemoveUnusedLocal : LocalInspectionTool() {
return
val search = ReferencesSearch.search(o, o.useScope)
var found = false
- for (reference in search) {
+ search.forEach(Processor { reference ->
if (reference.element !is LuaDocPsiElement) {
found = true
- break
}
- }
+ !found
+ })
if (!found) {
holder.registerProblem(o,
- "Unused parameter : '${o.name}'",
- ProblemHighlightType.LIKE_UNUSED_SYMBOL,
- RenameToUnderlineFix())
+ "Unused parameter : '${o.name}'",
+ ProblemHighlightType.LIKE_UNUSED_SYMBOL,
+ RenameToUnderlineFix())
}
}
@@ -68,16 +69,16 @@ class RemoveUnusedLocal : LocalInspectionTool() {
val offset = name.node.startOffset - o.node.startOffset
val textRange = TextRange(offset, offset + name.textLength)
holder.registerProblem(o,
- "Unused local : '${name.text}'",
- ProblemHighlightType.LIKE_UNUSED_SYMBOL,
- textRange,
- RemoveFix("Remove unused local '${name.text}'"),
- RenameToUnderlineFix())
+ "Unused local : '${name.text}'",
+ ProblemHighlightType.LIKE_UNUSED_SYMBOL,
+ textRange,
+ RemoveFix("Remove unused local '${name.text}'"),
+ RenameToUnderlineFix())
} else {
holder.registerProblem(name,
- "Unused local : '${name.text}'",
- ProblemHighlightType.LIKE_UNUSED_SYMBOL,
- RenameToUnderlineFix())
+ "Unused local : '${name.text}'",
+ ProblemHighlightType.LIKE_UNUSED_SYMBOL,
+ RenameToUnderlineFix())
}
}
}
@@ -94,10 +95,10 @@ class RemoveUnusedLocal : LocalInspectionTool() {
val textRange = TextRange(offset, offset + name.textLength)
holder.registerProblem(o,
- "Unused local function : '${name.text}'",
- ProblemHighlightType.LIKE_UNUSED_SYMBOL,
- textRange,
- RemoveFix("Remove unused local function : '${name.text}'"))
+ "Unused local function : '${name.text}'",
+ ProblemHighlightType.LIKE_UNUSED_SYMBOL,
+ textRange,
+ RemoveFix("Remove unused local function : '${name.text}'"))
}
}
}
@@ -126,4 +127,4 @@ class RemoveUnusedLocal : LocalInspectionTool() {
element.delete()
}
}
-}
+}
\ No newline at end of file
diff --git a/src/main/java/com/tang/intellij/lua/debugger/app/LuaAppSettingsEditor.java b/src/main/java/com/tang/intellij/lua/debugger/app/LuaAppSettingsEditor.java
index 83cf380a1..ee25161a7 100644
--- a/src/main/java/com/tang/intellij/lua/debugger/app/LuaAppSettingsEditor.java
+++ b/src/main/java/com/tang/intellij/lua/debugger/app/LuaAppSettingsEditor.java
@@ -60,14 +60,18 @@ public class LuaAppSettingsEditor extends SettingsEditor
private EnvironmentVariablesTextFieldWithBrowseButton myEnvironments;
private ComboBox outputCharset;
private JCheckBox showConsoleWindowCheckBox;
- private Project project;
+ private final Project project;
LuaAppSettingsEditor(Project project) {
this.project = project;
- FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor();
- myProgram.addBrowseFolderListener("Choose Program", "Choose program file", project, descriptor);
- descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
- myWorkingDir.addBrowseFolderListener("Choose Working Dir", "Choose working dir", project, descriptor);
+ FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor()
+ .withTitle("Choose Program")
+ .withDescription("Choose program file");
+ myProgram.addBrowseFolderListener(project, descriptor);
+ descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor()
+ .withTitle("Choose Working Dir")
+ .withDescription("Choose working dir");
+ myWorkingDir.addBrowseFolderListener(project, descriptor);
DebuggerType[] debuggerTypes = new DebuggerType[] { DebuggerType.Mob };
/*if (SystemInfoRt.isWindows)
@@ -162,4 +166,4 @@ protected void hyperlinkActivated(HyperlinkEvent hyperlinkEvent) {
}
});
}
-}
+}
\ No newline at end of file
diff --git a/src/main/java/com/tang/intellij/lua/editor/formatter/LuaCodeStyleSettingsProvider.kt b/src/main/java/com/tang/intellij/lua/editor/formatter/LuaCodeStyleSettingsProvider.kt
index 0d10ec203..8a22f7576 100644
--- a/src/main/java/com/tang/intellij/lua/editor/formatter/LuaCodeStyleSettingsProvider.kt
+++ b/src/main/java/com/tang/intellij/lua/editor/formatter/LuaCodeStyleSettingsProvider.kt
@@ -19,7 +19,7 @@ package com.tang.intellij.lua.editor.formatter
import com.intellij.application.options.CodeStyleAbstractConfigurable
import com.intellij.application.options.CodeStyleAbstractPanel
import com.intellij.application.options.TabbedLanguageCodeStylePanel
-import com.intellij.openapi.options.Configurable
+import com.intellij.psi.codeStyle.CodeStyleConfigurable
import com.intellij.psi.codeStyle.CodeStyleSettings
import com.intellij.psi.codeStyle.CodeStyleSettingsProvider
import com.intellij.psi.codeStyle.CustomCodeStyleSettings
@@ -30,8 +30,11 @@ import com.tang.intellij.lua.lang.LuaLanguage
* Created by tangzx on 2017/2/22.
*/
class LuaCodeStyleSettingsProvider : CodeStyleSettingsProvider() {
- override fun createSettingsPage(settings: CodeStyleSettings, originalSettings: CodeStyleSettings): Configurable {
- return object : CodeStyleAbstractConfigurable(settings, originalSettings, "EmmyLua") {
+ override fun createConfigurable(
+ settings: CodeStyleSettings,
+ modelSettings: CodeStyleSettings
+ ): CodeStyleConfigurable {
+ return object : CodeStyleAbstractConfigurable(settings, modelSettings, "EmmyLua") {
override fun getHelpTopic() = "reference.settingsdialog.codestyle.lua"
@@ -53,7 +56,7 @@ class LuaCodeStyleSettingsProvider : CodeStyleSettingsProvider() {
override fun getConfigurableDisplayName() = LuaLanguage.INSTANCE.displayName
- override fun createCustomSettings(settings: CodeStyleSettings): CustomCodeStyleSettings? {
+ override fun createCustomSettings(settings: CodeStyleSettings): CustomCodeStyleSettings {
return LuaCodeStyleSettings(settings)
}
-}
+}
\ No newline at end of file
diff --git a/src/main/java/com/tang/intellij/lua/editor/formatter/LuaFormattingModelBuilder.kt b/src/main/java/com/tang/intellij/lua/editor/formatter/LuaFormattingModelBuilder.kt
index 7220275fa..9d379c63f 100644
--- a/src/main/java/com/tang/intellij/lua/editor/formatter/LuaFormattingModelBuilder.kt
+++ b/src/main/java/com/tang/intellij/lua/editor/formatter/LuaFormattingModelBuilder.kt
@@ -19,7 +19,6 @@ package com.tang.intellij.lua.editor.formatter
import com.intellij.formatting.*
import com.intellij.lang.ASTNode
import com.intellij.openapi.util.TextRange
-import com.intellij.psi.PsiElement
import com.intellij.psi.PsiFile
import com.intellij.psi.codeStyle.CodeStyleSettings
import com.tang.intellij.lua.editor.formatter.blocks.LuaScriptBlock
@@ -32,17 +31,20 @@ import com.tang.intellij.lua.psi.LuaTypes.*
* Created by tangzx on 2016/12/3.
*/
class LuaFormattingModelBuilder : FormattingModelBuilder {
- override fun createModel(element: PsiElement, settings: CodeStyleSettings): FormattingModel {
+
+ override fun createModel(formattingContext: FormattingContext): FormattingModel {
+ val settings = formattingContext.codeStyleSettings
+ val element = formattingContext.psiElement
val commonSettings = settings.getCommonSettings(LuaLanguage.INSTANCE)
val luaSettings = settings.getCustomSettings(LuaCodeStyleSettings::class.java)
val ctx = LuaFormatContext(commonSettings, luaSettings, createSpaceBuilder(settings))
return FormattingModelProvider.createFormattingModelForPsiFile(element.containingFile,
- LuaScriptBlock(element,
- Wrap.createWrap(WrapType.NONE, false),
- Alignment.createAlignment(),
- Indent.getNoneIndent(),
- ctx),
- settings)
+ LuaScriptBlock(element,
+ Wrap.createWrap(WrapType.NONE, false),
+ Alignment.createAlignment(),
+ Indent.getNoneIndent(),
+ ctx),
+ settings)
}
private fun createSpaceBuilder(settings: CodeStyleSettings): SpacingBuilder {
@@ -50,36 +52,36 @@ class LuaFormattingModelBuilder : FormattingModelBuilder {
val commonSettings = settings.getCommonSettings(LuaLanguage.INSTANCE)
return SpacingBuilder(settings, LuaLanguage.INSTANCE)
- .before(END).lineBreakInCode()
- .after(DO).lineBreakInCode()
- .after(THEN).lineBreakInCode()
- .around(ELSE).lineBreakInCode()
- .before(ELSEIF).lineBreakInCode()
- .after(LOCAL).spaces(1) //local
- .around(COLON).none()
- //.around(CONCAT).spaces(if (luaCodeStyleSettings.SPACE_AROUND_CONCAT_OPERATOR) 1 else 0)
- .before(COMMA).spaces(if (commonSettings.SPACE_BEFORE_COMMA) 1 else 0)
- .after(COMMA).spaces(if (commonSettings.SPACE_AFTER_COMMA) 1 else 0) //,
- .between(LCURLY, TABLE_FIELD).spaces(if (luaCodeStyleSettings.SPACE_INSIDE_INLINE_TABLE) 1 else 0) // {1, 2 }
- .between(TABLE_FIELD, RCURLY).spaces(if (luaCodeStyleSettings.SPACE_INSIDE_INLINE_TABLE) 1 else 0) // { 1, 2}
- .before(TABLE_FIELD_SEP).none() // { 1, 2 }
- .after(TABLE_FIELD_SEP).spaces(if (luaCodeStyleSettings.SPACE_AFTER_TABLE_FIELD_SEP) 1 else 0) // { 1,2 }
- .before(BLOCK).blankLines(0)
- .afterInside(RPAREN, FUNC_BODY).lineBreakInCode()
- .between(FUNCTION, FUNC_BODY).none()
- .between(FUNCTION, NAME_DEF).spaces(1) //functionname()
- .around(BINARY_OP).spaces(if (luaCodeStyleSettings.SPACE_AROUND_BINARY_OPERATOR) 1 else 0)
- .around(UNARY_OP).none()
- .around(ASSIGN).lineBreakOrForceSpace(false, commonSettings.SPACE_AROUND_ASSIGNMENT_OPERATORS) // = 号两头不能换行
- .around(LuaParserDefinition.KEYWORD_TOKENS).spaces(1)
- .around(LBRACK).none() // [
- .before(RBRACK).none() // ]
- .after(LPAREN).none() // no spaces after (
- .before(RPAREN).none() // no spaces before )
- .before(SEMI).spaces(0)
+ .before(END).lineBreakInCode()
+ .after(DO).lineBreakInCode()
+ .after(THEN).lineBreakInCode()
+ .around(ELSE).lineBreakInCode()
+ .before(ELSEIF).lineBreakInCode()
+ .after(LOCAL).spaces(1) //local
+ .around(COLON).none()
+ //.around(CONCAT).spaces(if (luaCodeStyleSettings.SPACE_AROUND_CONCAT_OPERATOR) 1 else 0)
+ .before(COMMA).spaces(if (commonSettings.SPACE_BEFORE_COMMA) 1 else 0)
+ .after(COMMA).spaces(if (commonSettings.SPACE_AFTER_COMMA) 1 else 0) //,
+ .between(LCURLY, TABLE_FIELD).spaces(if (luaCodeStyleSettings.SPACE_INSIDE_INLINE_TABLE) 1 else 0) // {1, 2 }
+ .between(TABLE_FIELD, RCURLY).spaces(if (luaCodeStyleSettings.SPACE_INSIDE_INLINE_TABLE) 1 else 0) // { 1, 2}
+ .before(TABLE_FIELD_SEP).none() // { 1, 2 }
+ .after(TABLE_FIELD_SEP).spaces(if (luaCodeStyleSettings.SPACE_AFTER_TABLE_FIELD_SEP) 1 else 0) // { 1,2 }
+ .before(BLOCK).blankLines(0)
+ .afterInside(RPAREN, FUNC_BODY).lineBreakInCode()
+ .between(FUNCTION, FUNC_BODY).none()
+ .between(FUNCTION, NAME_DEF).spaces(1) //functionname()
+ .around(BINARY_OP).spaces(if (luaCodeStyleSettings.SPACE_AROUND_BINARY_OPERATOR) 1 else 0)
+ .around(UNARY_OP).none()
+ .around(ASSIGN).lineBreakOrForceSpace(false, commonSettings.SPACE_AROUND_ASSIGNMENT_OPERATORS) // = 号两头不能换行
+ .around(LuaParserDefinition.KEYWORD_TOKENS).spaces(1)
+ .around(LBRACK).none() // [
+ .before(RBRACK).none() // ]
+ .after(LPAREN).none() // no spaces after (
+ .before(RPAREN).none() // no spaces before )
+ .before(SEMI).spaces(0)
}
override fun getRangeAffectingIndent(psiFile: PsiFile, i: Int, astNode: ASTNode): TextRange? {
return null
}
-}
+}
\ No newline at end of file
diff --git a/src/main/java/com/tang/intellij/lua/errorreporting/error-report.kt b/src/main/java/com/tang/intellij/lua/errorreporting/error-report.kt
index 7389827e3..68ccd0451 100644
--- a/src/main/java/com/tang/intellij/lua/errorreporting/error-report.kt
+++ b/src/main/java/com/tang/intellij/lua/errorreporting/error-report.kt
@@ -17,12 +17,11 @@
package com.tang.intellij.lua.errorreporting
import com.intellij.CommonBundle
-import com.intellij.diagnostic.AbstractMessage
-import com.intellij.diagnostic.IdeErrorsDialog
-import com.intellij.diagnostic.ReportMessages
import com.intellij.ide.DataManager
import com.intellij.ide.plugins.PluginManagerCore
+import com.intellij.ide.plugins.PluginUtil
import com.intellij.idea.IdeaLogger
+import com.intellij.notification.NotificationGroupManager
import com.intellij.notification.NotificationListener
import com.intellij.notification.NotificationType
import com.intellij.openapi.actionSystem.CommonDataKeys
@@ -59,144 +58,156 @@ import javax.crypto.spec.IvParameterSpec
import javax.crypto.spec.SecretKeySpec
private object AnonymousFeedback {
- private const val tokenFile = "errorreporting/token.bin"
- private const val gitRepoUser = "EmmyLua"
- private const val gitRepo = "EmmyLua-ErrorReport"
- private const val issueLabel = "pending"
+ private const val tokenFile = "errorreporting/token.bin"
+ private const val gitRepoUser = "EmmyLua"
+ private const val gitRepo = "EmmyLua-ErrorReport"
+ private const val issueLabel = "pending"
- /**
- * Makes a connection to GitHub. Checks if there is an issue that is a duplicate and based on this, creates either a
- * new issue or comments on the duplicate (if the user provided additional information).
- *
- * @param environmentDetails Information collected by [getKeyValuePairs]
- * @return The report info that is then used in [GitHubErrorReporter] to show the user a balloon with the link
- * of the created issue.
- */
- fun sendFeedback(environmentDetails: MutableMap): SubmittedReportInfo {
- val logger = Logger.getInstance(javaClass.name)
- try {
- val resource: URL? = javaClass.classLoader.getResource(tokenFile)
- if (resource == null) {
- logger.info("Could not find token file")
- throw IOException("Could not decrypt access token")
- }
- val gitAccessToken = decrypt(resource)
- val client = GitHubClient()
- client.setOAuth2Token(gitAccessToken)
- val repoID = RepositoryId(gitRepoUser, gitRepo)
- val issueService = IssueService(client)
- var newGibHubIssue = createNewGibHubIssue(environmentDetails)
- val duplicate = findFirstDuplicate(newGibHubIssue.title, issueService, repoID)
- var isNewIssue = true
- if (duplicate != null) {
- issueService.createComment(repoID, duplicate.number, generateGitHubIssueBody(environmentDetails, false))
- newGibHubIssue = duplicate
- isNewIssue = false
- } else newGibHubIssue = issueService.createIssue(repoID, newGibHubIssue)
- return SubmittedReportInfo(newGibHubIssue.htmlUrl, ErrorReportBundle.message(
- if (isNewIssue) "git.issue.text" else "git.issue.duplicate.text", newGibHubIssue.htmlUrl, newGibHubIssue.number.toLong()),
- if (isNewIssue) SubmissionStatus.NEW_ISSUE else SubmissionStatus.DUPLICATE)
- } catch (e: Exception) {
- e.printStackTrace()
- return SubmittedReportInfo(null,
- ErrorReportBundle.message("report.error.connection.failure"),
- SubmissionStatus.FAILED)
- }
- }
+ /**
+ * Makes a connection to GitHub. Checks if there is an issue that is a duplicate and based on this, creates either a
+ * new issue or comments on the duplicate (if the user provided additional information).
+ *
+ * @param environmentDetails Information collected by [getKeyValuePairs]
+ * @return The report info that is then used in [GitHubErrorReporter] to show the user a balloon with the link
+ * of the created issue.
+ */
+ fun sendFeedback(environmentDetails: MutableMap): SubmittedReportInfo {
+ val logger = Logger.getInstance(javaClass.name)
+ try {
+ val resource: URL? = javaClass.classLoader.getResource(tokenFile)
+ if (resource == null) {
+ logger.info("Could not find token file")
+ throw IOException("Could not decrypt access token")
+ }
+ val gitAccessToken = decrypt(resource)
+ val client = GitHubClient()
+ client.setOAuth2Token(gitAccessToken)
+ val repoID = RepositoryId(gitRepoUser, gitRepo)
+ val issueService = IssueService(client)
+ var newGibHubIssue = createNewGibHubIssue(environmentDetails)
+ val duplicate = findFirstDuplicate(newGibHubIssue.title, issueService, repoID)
+ var isNewIssue = true
+ if (duplicate != null) {
+ issueService.createComment(repoID, duplicate.number, generateGitHubIssueBody(environmentDetails, false))
+ newGibHubIssue = duplicate
+ isNewIssue = false
+ } else newGibHubIssue = issueService.createIssue(repoID, newGibHubIssue)
+ return SubmittedReportInfo(newGibHubIssue.htmlUrl, ErrorReportBundle.message(
+ if (isNewIssue) "git.issue.text" else "git.issue.duplicate.text", newGibHubIssue.htmlUrl, newGibHubIssue.number.toLong()),
+ if (isNewIssue) SubmissionStatus.NEW_ISSUE else SubmissionStatus.DUPLICATE)
+ } catch (e: Exception) {
+ e.printStackTrace()
+ return SubmittedReportInfo(null,
+ ErrorReportBundle.message("report.error.connection.failure"),
+ SubmissionStatus.FAILED)
+ }
+ }
- private fun findFirstDuplicate(uniqueTitle: String, service: IssueService, repo: RepositoryId): Issue? {
- val searchParameters = HashMap(2)
- searchParameters[IssueService.FILTER_STATE] = IssueService.STATE_OPEN
- return service.pageIssues(repo, searchParameters).flatten().firstOrNull { it.title == uniqueTitle }
- }
+ private fun findFirstDuplicate(uniqueTitle: String, service: IssueService, repo: RepositoryId): Issue? {
+ val searchParameters = HashMap(2)
+ searchParameters[IssueService.FILTER_STATE] = IssueService.STATE_OPEN
+ return service.pageIssues(repo, searchParameters).flatten().firstOrNull { it.title == uniqueTitle }
+ }
- private fun createNewGibHubIssue(details: MutableMap) = Issue().apply {
- val errorMessage = details.remove("error.message")?.takeIf(String::isNotBlank) ?: "Unspecified error"
- title = ErrorReportBundle.message("git.issue.title", details.remove("error.hash").orEmpty(), errorMessage)
- body = generateGitHubIssueBody(details, true)
- labels = listOf(Label().apply { name = issueLabel })
- }
+ private fun createNewGibHubIssue(details: MutableMap) = Issue().apply {
+ val errorMessage = details.remove("error.message")?.takeIf(String::isNotBlank) ?: "Unspecified error"
+ title = ErrorReportBundle.message("git.issue.title", details.remove("error.hash").orEmpty(), errorMessage)
+ body = generateGitHubIssueBody(details, true)
+ labels = listOf(Label().apply { name = issueLabel })
+ }
- private fun generateGitHubIssueBody(details: MutableMap, includeStacktrace: Boolean) =
- buildString {
- val errorDescription = details.remove("error.description").orEmpty()
- val stackTrace = details.remove("error.stacktrace")?.takeIf(String::isNotBlank) ?: "invalid stacktrace"
- if (errorDescription.isNotEmpty()) append(errorDescription).appendLine("\n\n----------------------\n")
- for ((key, value) in details) append("- ").append(key).append(": ").appendLine(value)
- if (includeStacktrace) appendLine("\n```").appendLine(stackTrace).appendLine("```")
- }
+ private fun generateGitHubIssueBody(details: MutableMap, includeStacktrace: Boolean) =
+ buildString {
+ val errorDescription = details.remove("error.description").orEmpty()
+ val stackTrace = details.remove("error.stacktrace")?.takeIf(String::isNotBlank) ?: "invalid stacktrace"
+ if (errorDescription.isNotEmpty()) append(errorDescription).appendLine("\n\n----------------------\n")
+ for ((key, value) in details) append("- ").append(key).append(": ").appendLine(value)
+ if (includeStacktrace) appendLine("\n```").appendLine(stackTrace).appendLine("```")
+ }
}
private const val initVector = "RandomInitVector"
private const val key = "GitHubErrorToken"
private fun decrypt(file: URL): String {
- val cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING")
- cipher.init(Cipher.DECRYPT_MODE,
- SecretKeySpec(key.toByteArray(charset("UTF-8")), "AES"),
- IvParameterSpec(initVector.toByteArray(charset("UTF-8"))))
- return String(cipher.doFinal(Base64.getDecoder().decode(file.openStream().use {
- ObjectInputStream(it).use(ObjectInputStream::readObject) as String
- })))
+ val cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING")
+ cipher.init(Cipher.DECRYPT_MODE,
+ SecretKeySpec(key.toByteArray(charset("UTF-8")), "AES"),
+ IvParameterSpec(initVector.toByteArray(charset("UTF-8"))))
+ return String(cipher.doFinal(Base64.getDecoder().decode(file.openStream().use {
+ ObjectInputStream(it).use(ObjectInputStream::readObject) as String
+ })))
}
class GitHubErrorReporter : LuaErrorReportSubmitter() {
- override fun getReportActionText() = ErrorReportBundle.message("report.error.to.plugin.vendor")
- override fun doSubmit(
- events: Array?,
- additionalInfo: String?,
- parentComponent: Component,
- consumer: Consumer): Boolean {
- // TODO improve
- val event = events?.firstOrNull { it.throwable != null } ?: return false
- return doSubmit(event, parentComponent, consumer, additionalInfo)
- }
+ override fun getReportActionText() = ErrorReportBundle.message("report.error.to.plugin.vendor")
+ override fun doSubmit(
+ events: Array?,
+ additionalInfo: String?,
+ parentComponent: Component,
+ consumer: Consumer): Boolean {
+ // TODO improve
+ val event = events?.firstOrNull { it.throwable != null } ?: return false
+ return doSubmit(event, parentComponent, consumer, additionalInfo)
+ }
- private fun doSubmit(
- event: IdeaLoggingEvent,
- parent: Component,
- callback: Consumer,
- description: String?): Boolean {
- val dataContext = DataManager.getInstance().getDataContext(parent)
- val bean = GitHubErrorBean(
- event.throwable,
- IdeaLogger.ourLastActionId.orEmpty(),
- description ?: "",
- event.message ?: event.throwable.message.toString())
- IdeErrorsDialog.findPluginId(event.throwable)?.let { pluginId ->
- PluginManagerCore.getPlugin(pluginId)?.let { ideaPluginDescriptor ->
- if (!ideaPluginDescriptor.isBundled) {
- bean.pluginName = ideaPluginDescriptor.name
- bean.pluginVersion = ideaPluginDescriptor.version
- }
- }
- }
+ private fun doSubmit(
+ event: IdeaLoggingEvent,
+ parent: Component,
+ callback: Consumer,
+ description: String?): Boolean {
+ val dataContext = DataManager.getInstance().getDataContext(parent)
+ val bean = GitHubErrorBean(
+ event.throwable,
+ IdeaLogger.ourLastActionId.orEmpty(),
+ description ?: "",
+ event.message ?: event.throwable.message.toString())
+ PluginUtil.getInstance().findPluginId(event.throwable)?.let { pluginId ->
+ PluginManagerCore.getPlugin(pluginId)?.let { ideaPluginDescriptor ->
+ if (!ideaPluginDescriptor.isBundled) {
+ bean.pluginName = ideaPluginDescriptor.name
+ bean.pluginVersion = ideaPluginDescriptor.version
+ }
+ }
+ }
- (event.data as? AbstractMessage)?.let { bean.attachments = it.includedAttachments }
- val project = CommonDataKeys.PROJECT.getData(dataContext)
- val reportValues = getKeyValuePairs(
- project,
- bean,
- ApplicationInfo.getInstance() as ApplicationInfoEx,
- ApplicationNamesInfo.getInstance())
- val notifyingCallback = CallbackWithNotification(callback, project)
- val task = AnonymousFeedbackTask(project, ErrorReportBundle.message(
- "report.error.progress.dialog.text"), true, reportValues, notifyingCallback)
- if (project == null) task.run(EmptyProgressIndicator()) else ProgressManager.getInstance().run(task)
- return true
- }
+ // fix compatibility verification problems: internal API usages
+ // (event.data as? AbstractMessage)?.let { bean.attachments = it.includedAttachments }
+ val project = CommonDataKeys.PROJECT.getData(dataContext)
+ val reportValues = getKeyValuePairs(
+ project,
+ bean,
+ ApplicationInfo.getInstance() as ApplicationInfoEx,
+ ApplicationNamesInfo.getInstance())
+ val notifyingCallback = CallbackWithNotification(callback, project)
+ val task = AnonymousFeedbackTask(project, ErrorReportBundle.message(
+ "report.error.progress.dialog.text"), true, reportValues, notifyingCallback)
+ if (project == null) task.run(EmptyProgressIndicator()) else ProgressManager.getInstance().run(task)
+ return true
+ }
- internal class CallbackWithNotification(
- private val consumer: Consumer,
- private val project: Project?) : Consumer {
- override fun consume(reportInfo: SubmittedReportInfo) {
- consumer.consume(reportInfo)
- if (reportInfo.status == SubmissionStatus.FAILED) ReportMessages.GROUP.createNotification(ReportMessages.ERROR_REPORT,
- reportInfo.linkText, NotificationType.ERROR, null).setImportant(false).notify(project)
- else ReportMessages.GROUP.createNotification(ReportMessages.ERROR_REPORT, reportInfo.linkText,
- NotificationType.INFORMATION, NotificationListener.URL_OPENING_LISTENER).setImportant(false).notify(project)
- }
- }
+ internal class CallbackWithNotification(
+ private val consumer: Consumer,
+ private val project: Project?) : Consumer {
+ override fun consume(reportInfo: SubmittedReportInfo) {
+ consumer.consume(reportInfo)
+ if (reportInfo.status == SubmissionStatus.FAILED)
+ NotificationGroupManager
+ .getInstance()
+ .getNotificationGroup("Error Report")
+ .createNotification(reportInfo.linkText, NotificationType.ERROR)
+ .setImportant(false)
+ .notify(project)
+ else
+ NotificationGroupManager
+ .getInstance()
+ .getNotificationGroup("Error Report")
+ .createNotification(reportInfo.linkText, NotificationType.INFORMATION)
+ .setListener(NotificationListener.URL_OPENING_LISTENER)
+ .setImportant(false)
+ .notify(project)
+ }
+ }
}
/**
@@ -205,78 +216,78 @@ class GitHubErrorReporter : LuaErrorReportSubmitter() {
* @author patrick (17.06.17).
*/
class GitHubErrorBean(
- throwable: Throwable,
- val lastAction: String,
- val description: String,
- val message: String) {
- val exceptionHash: String
- val stackTrace: String
- init {
- val trace = throwable.stackTrace
- exceptionHash = Arrays.hashCode(trace).toString()
- val sw = StringWriter()
- throwable.printStackTrace(PrintWriter(sw))
- stackTrace = sw.toString()
- }
- var pluginName = ""
- var pluginVersion = ""
- var attachments: List = emptyList()
+ throwable: Throwable,
+ val lastAction: String,
+ val description: String,
+ val message: String) {
+ val exceptionHash: String
+ val stackTrace: String
+ init {
+ val trace = throwable.stackTrace
+ exceptionHash = Arrays.hashCode(trace).toString()
+ val sw = StringWriter()
+ throwable.printStackTrace(PrintWriter(sw))
+ stackTrace = sw.toString()
+ }
+ var pluginName = ""
+ var pluginVersion = ""
+ var attachments: List = emptyList()
}
/**
* Messages and strings used by the error reporter
*/
private object ErrorReportBundle {
- @NonNls private const val BUNDLE = "errorreporting.report-bundle"
- private val bundle: ResourceBundle by lazy { ResourceBundle.getBundle(BUNDLE) }
+ @NonNls private const val BUNDLE = "errorreporting.report-bundle"
+ private val bundle: ResourceBundle by lazy { ResourceBundle.getBundle(BUNDLE) }
- @JvmStatic
- fun message(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any) =
- CommonBundle.message(bundle, key, *params)
+ @JvmStatic
+ fun message(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any) =
+ CommonBundle.message(bundle, key, *params)
}
private class AnonymousFeedbackTask(
- project: Project?, title: String, canBeCancelled: Boolean,
- private val params: MutableMap,
- private val callback: Consumer) : Task.Backgroundable(project, title, canBeCancelled) {
- override fun run(indicator: ProgressIndicator) {
- indicator.isIndeterminate = true
- callback.consume(AnonymousFeedback.sendFeedback(params))
- }
+ project: Project?, title: String, canBeCancelled: Boolean,
+ private val params: MutableMap,
+ private val callback: Consumer) : Task.Backgroundable(project, title, canBeCancelled) {
+ override fun run(indicator: ProgressIndicator) {
+ indicator.isIndeterminate = true
+ callback.consume(AnonymousFeedback.sendFeedback(params))
+ }
}
/**
* Collects information about the running IDEA and the error
*/
private fun getKeyValuePairs(
- project: Project?,
- error: GitHubErrorBean,
- appInfo: ApplicationInfoEx,
- namesInfo: ApplicationNamesInfo): MutableMap {
- PluginManagerCore.getPlugin(PluginId.findId("com.tang"))?.run {
- if (error.pluginName.isBlank()) error.pluginName = name
- if (error.pluginVersion.isBlank()) error.pluginVersion = version
- }
- val params = mutableMapOf(
- "error.description" to error.description,
- // TODO
- // "Lua Version" to (project?.run { /* get lua sdk version here */ } ?: "Unknown"),
- "Plugin Name" to error.pluginName,
- "Plugin Version" to error.pluginVersion,
- "OS Name" to SystemInfo.OS_NAME,
- "Java Version" to SystemInfo.JAVA_VERSION,
- "App Name" to namesInfo.productName,
- "App Full Name" to namesInfo.fullProductName,
- "App Version name" to appInfo.versionName,
- "Is EAP" to appInfo.isEAP.toString(),
- "App Build" to appInfo.build.asString(),
- "App Version" to appInfo.fullVersion,
- "Last Action" to error.lastAction,
- "error.message" to error.message,
- "error.stacktrace" to error.stackTrace,
- "error.hash" to error.exceptionHash)
- for (attachment in error.attachments) {
- params["Attachment ${attachment.name}"] = attachment.encodedBytes
- }
- return params
-}
+ project: Project?,
+ error: GitHubErrorBean,
+ appInfo: ApplicationInfoEx,
+ namesInfo: ApplicationNamesInfo): MutableMap {
+ PluginManagerCore.getPlugin(PluginId.findId("com.tang"))?.run {
+ if (error.pluginName.isBlank()) error.pluginName = name
+ if (error.pluginVersion.isBlank()) error.pluginVersion = version
+ }
+ val params = mutableMapOf(
+ "error.description" to error.description,
+ // TODO
+ // "Lua Version" to (project?.run { /* get lua sdk version here */ } ?: "Unknown"),
+ "Plugin Name" to error.pluginName,
+ "Plugin Version" to error.pluginVersion,
+ "OS Name" to SystemInfo.OS_NAME,
+ "Java Version" to SystemInfo.JAVA_VERSION,
+ "App Name" to namesInfo.productName,
+ "App Full Name" to namesInfo.fullProductName,
+ "App Version name" to appInfo.versionName,
+ "Is EAP" to appInfo.isEAP.toString(),
+ "App Build" to appInfo.build.asString(),
+ "App Version" to appInfo.fullVersion,
+ "Last Action" to error.lastAction,
+ "error.message" to error.message,
+ "error.stacktrace" to error.stackTrace,
+ "error.hash" to error.exceptionHash)
+ for (attachment in error.attachments) {
+ params["Attachment ${attachment.name}"] = attachment.encodedBytes
+ }
+ return params
+}
\ No newline at end of file
diff --git a/src/main/java/com/tang/intellij/lua/hierarchy/call/LuaCallHierarchyBrowser.kt b/src/main/java/com/tang/intellij/lua/hierarchy/call/LuaCallHierarchyBrowser.kt
index 473838539..6686daf03 100644
--- a/src/main/java/com/tang/intellij/lua/hierarchy/call/LuaCallHierarchyBrowser.kt
+++ b/src/main/java/com/tang/intellij/lua/hierarchy/call/LuaCallHierarchyBrowser.kt
@@ -62,9 +62,9 @@ class LuaCallHierarchyBrowser(element: PsiElement) : CallHierarchyBrowserBase(el
}
override fun createHierarchyTreeStructure(typeName: String, psiElement: PsiElement): HierarchyTreeStructure? =
- when (typeName) {
- getCallerType() -> LuaCallerFunctionTreeStructure(myProject, psiElement)
- getCallerType() -> LuaCalleeFunctionTreeStructure(myProject, psiElement)
- else -> null
- }
+ when (typeName) {
+ getCallerType() -> LuaCallerFunctionTreeStructure(myProject, psiElement)
+ getCallerType() -> LuaCalleeFunctionTreeStructure(myProject, psiElement)
+ else -> null
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/tang/intellij/lua/lang/LuaFileTypeDetector.kt b/src/main/java/com/tang/intellij/lua/lang/LuaFileTypeDetector.kt
index 40705c3a2..b49d80400 100644
--- a/src/main/java/com/tang/intellij/lua/lang/LuaFileTypeDetector.kt
+++ b/src/main/java/com/tang/intellij/lua/lang/LuaFileTypeDetector.kt
@@ -23,7 +23,6 @@ import com.intellij.openapi.util.io.FileUtil
import com.intellij.openapi.vfs.VirtualFile
class LuaFileTypeDetector : FileTypeRegistry.FileTypeDetector {
- override fun getVersion() = 1
override fun detect(file: VirtualFile, firstBytes: ByteSequence, firstCharsIfText: CharSequence?): FileType? {
return if (FileUtil.isHashBangLine(firstCharsIfText, "lua")) LuaFileType.INSTANCE else null
diff --git a/src/main/java/com/tang/intellij/lua/lang/LuaParserDefinition.kt b/src/main/java/com/tang/intellij/lua/lang/LuaParserDefinition.kt
index ebb821fa2..7c07f1062 100644
--- a/src/main/java/com/tang/intellij/lua/lang/LuaParserDefinition.kt
+++ b/src/main/java/com/tang/intellij/lua/lang/LuaParserDefinition.kt
@@ -70,21 +70,17 @@ class LuaParserDefinition : ParserDefinition {
return LuaPsiFile(viewProvider)
}
- override fun spaceExistanceTypeBetweenTokens(left: ASTNode, right: ASTNode): ParserDefinition.SpaceRequirements {
- return ParserDefinition.SpaceRequirements.MAY
- }
-
override fun createElement(node: ASTNode): PsiElement {
val type = node.elementType
if (type === LuaElementType.DOC_COMMENT)
return LuaCommentImpl(node)
return if (type is LuaDocElementType
- || type === LuaElementType.DOC_TABLE_DEF
- || type === LuaElementType.DOC_TABLE_FIELD_DEF
- || type === LuaElementType.CLASS_DEF
- || type === LuaElementType.CLASS_FIELD_DEF
- || type === LuaElementType.TYPE_DEF
- || type === LuaElementType.DOC_ALIAS) {
+ || type === LuaElementType.DOC_TABLE_DEF
+ || type === LuaElementType.DOC_TABLE_FIELD_DEF
+ || type === LuaElementType.CLASS_DEF
+ || type === LuaElementType.CLASS_FIELD_DEF
+ || type === LuaElementType.TYPE_DEF
+ || type === LuaElementType.DOC_ALIAS) {
LuaDocTypes.Factory.createElement(node)
} else LuaTypes.Factory.createElement(node)
}
@@ -92,73 +88,73 @@ class LuaParserDefinition : ParserDefinition {
companion object {
val WHITE_SPACES = TokenSet.create(TokenType.WHITE_SPACE)
val COMMENTS = TokenSet.create(
- LuaTypes.SHORT_COMMENT,
- LuaTypes.BLOCK_COMMENT,
- LuaTypes.DOC_COMMENT,
- LuaTypes.REGION,
- LuaTypes.ENDREGION
+ LuaTypes.SHORT_COMMENT,
+ LuaTypes.BLOCK_COMMENT,
+ LuaTypes.DOC_COMMENT,
+ LuaTypes.REGION,
+ LuaTypes.ENDREGION
)
val STRINGS = TokenSet.create(LuaTypes.STRING)
val KEYWORD_TOKENS = TokenSet.create(
- LuaTypes.AND,
- LuaTypes.BREAK,
- LuaTypes.DO,
- LuaTypes.ELSE,
- LuaTypes.ELSEIF,
- LuaTypes.END,
- LuaTypes.FOR,
- LuaTypes.FUNCTION,
- LuaTypes.IF,
- LuaTypes.IN,
- LuaTypes.LOCAL,
- LuaTypes.NOT,
- LuaTypes.OR,
- LuaTypes.REPEAT,
- LuaTypes.RETURN,
- LuaTypes.THEN,
- LuaTypes.UNTIL,
- LuaTypes.WHILE,
-
- //lua5.3
- LuaTypes.DOUBLE_COLON,
- LuaTypes.GOTO
+ LuaTypes.AND,
+ LuaTypes.BREAK,
+ LuaTypes.DO,
+ LuaTypes.ELSE,
+ LuaTypes.ELSEIF,
+ LuaTypes.END,
+ LuaTypes.FOR,
+ LuaTypes.FUNCTION,
+ LuaTypes.IF,
+ LuaTypes.IN,
+ LuaTypes.LOCAL,
+ LuaTypes.NOT,
+ LuaTypes.OR,
+ LuaTypes.REPEAT,
+ LuaTypes.RETURN,
+ LuaTypes.THEN,
+ LuaTypes.UNTIL,
+ LuaTypes.WHILE,
+
+ //lua5.3
+ LuaTypes.DOUBLE_COLON,
+ LuaTypes.GOTO
)
val LUA52_BIN_OP_SET = TokenSet.create(
- LuaTypes.BIT_AND,
- LuaTypes.BIT_LTLT,
- LuaTypes.BIT_OR,
- LuaTypes.BIT_RTRT,
- LuaTypes.BIT_TILDE,
- LuaTypes.DOUBLE_DIV
+ LuaTypes.BIT_AND,
+ LuaTypes.BIT_LTLT,
+ LuaTypes.BIT_OR,
+ LuaTypes.BIT_RTRT,
+ LuaTypes.BIT_TILDE,
+ LuaTypes.DOUBLE_DIV
)
val LUA52_UNARY_OP_SET = TokenSet.create(
- LuaTypes.BIT_TILDE
+ LuaTypes.BIT_TILDE
)
val PRIMITIVE_TYPE_SET = TokenSet.create(
- LuaTypes.FALSE,
- LuaTypes.NIL,
- LuaTypes.TRUE
+ LuaTypes.FALSE,
+ LuaTypes.NIL,
+ LuaTypes.TRUE
)
val DOC_TAG_TOKENS = TokenSet.create(
- LuaDocTypes.TAG_NAME_PARAM,
- LuaDocTypes.TAG_NAME_RETURN,
- LuaDocTypes.TAG_NAME_CLASS,
- LuaDocTypes.TAG_NAME_MODULE,
- LuaDocTypes.TAG_NAME_TYPE,
- LuaDocTypes.TAG_NAME_FIELD,
- LuaDocTypes.TAG_NAME_LANGUAGE,
- LuaDocTypes.TAG_NAME_OVERLOAD,
- LuaDocTypes.TAG_NAME_PRIVATE,
- LuaDocTypes.TAG_NAME_PROTECTED,
- LuaDocTypes.TAG_NAME_PUBLIC,
- LuaDocTypes.TAG_NAME_SEE,
- LuaDocTypes.TAG_NAME_GENERIC,
- LuaDocTypes.TAG_NAME_VARARG,
- LuaDocTypes.TAG_NAME_ALIAS
+ LuaDocTypes.TAG_NAME_PARAM,
+ LuaDocTypes.TAG_NAME_RETURN,
+ LuaDocTypes.TAG_NAME_CLASS,
+ LuaDocTypes.TAG_NAME_MODULE,
+ LuaDocTypes.TAG_NAME_TYPE,
+ LuaDocTypes.TAG_NAME_FIELD,
+ LuaDocTypes.TAG_NAME_LANGUAGE,
+ LuaDocTypes.TAG_NAME_OVERLOAD,
+ LuaDocTypes.TAG_NAME_PRIVATE,
+ LuaDocTypes.TAG_NAME_PROTECTED,
+ LuaDocTypes.TAG_NAME_PUBLIC,
+ LuaDocTypes.TAG_NAME_SEE,
+ LuaDocTypes.TAG_NAME_GENERIC,
+ LuaDocTypes.TAG_NAME_VARARG,
+ LuaDocTypes.TAG_NAME_ALIAS
)
val DOC_KEYWORD_TOKENS = TokenSet.create(
- LuaDocTypes.FUN,
- LuaDocTypes.VARARG
+ LuaDocTypes.FUN,
+ LuaDocTypes.VARARG
)
val FILE = LuaFileElementType()
}
diff --git a/src/main/java/com/tang/intellij/lua/luacheck/LuaCheckActions.kt b/src/main/java/com/tang/intellij/lua/luacheck/LuaCheckActions.kt
deleted file mode 100644
index a431e4703..000000000
--- a/src/main/java/com/tang/intellij/lua/luacheck/LuaCheckActions.kt
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2017. tangzx(love.tangzx@qq.com)
- *
- * 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.luacheck
-
-import com.intellij.openapi.actionSystem.AnAction
-import com.intellij.openapi.actionSystem.AnActionEvent
-import com.intellij.openapi.actionSystem.CommonDataKeys
-import com.intellij.openapi.options.ShowSettingsUtil
-import com.tang.intellij.lua.lang.LuaFileType
-
-class LuaCheckGroup : AnAction() {
- override fun actionPerformed(event: AnActionEvent) {
- val project = event.getData(CommonDataKeys.PROJECT)!!
- val file = event.getData(CommonDataKeys.VIRTUAL_FILE)
- if (file != null) {
- val settings = LuaCheckSettings.getInstance()
- if (settings.valid) {
- runLuaCheck(project, file)
- } else {
- ShowSettingsUtil.getInstance().showSettingsDialog(project, LuaCheckSettingsPanel::class.java)
- }
- }
- }
-
- override fun update(event: AnActionEvent) {
- val presentation = event.presentation
- val project = event.getData(CommonDataKeys.PROJECT)
- if (project == null) {
- presentation.isEnabled = false
- presentation.isVisible = false
- } else {
- val file = event.getData(CommonDataKeys.VIRTUAL_FILE)
- presentation.isVisible = file != null && (file.isDirectory || file.fileType == LuaFileType.INSTANCE)
- presentation.isEnabled = true
- }
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/tang/intellij/lua/luacheck/LuaCheckInvoker.kt b/src/main/java/com/tang/intellij/lua/luacheck/LuaCheckInvoker.kt
deleted file mode 100644
index 2404e5357..000000000
--- a/src/main/java/com/tang/intellij/lua/luacheck/LuaCheckInvoker.kt
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright (c) 2017. tangzx(love.tangzx@qq.com)
- *
- * 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.luacheck
-
-import com.intellij.execution.configurations.GeneralCommandLine
-import com.intellij.execution.process.OSProcessHandler
-import com.intellij.execution.process.ProcessEvent
-import com.intellij.execution.process.ProcessListener
-import com.intellij.execution.process.ProcessNotCreatedException
-import com.intellij.openapi.application.ApplicationManager
-import com.intellij.openapi.options.ShowSettingsUtil
-import com.intellij.openapi.progress.ProgressIndicator
-import com.intellij.openapi.progress.ProgressManager
-import com.intellij.openapi.project.Project
-import com.intellij.openapi.util.Key
-import com.intellij.openapi.vfs.VfsUtil
-import com.intellij.openapi.vfs.VirtualFile
-import com.intellij.openapi.vfs.VirtualFileVisitor
-import com.intellij.openapi.wm.ToolWindowManager
-import com.intellij.psi.PsiFile
-import com.intellij.psi.impl.PsiManagerEx
-import com.intellij.util.execution.ParametersListUtil
-import com.tang.intellij.lua.lang.LuaFileType
-import org.intellij.lang.annotations.Language
-import java.io.File
-
-private val DEFAULT_ARGS = arrayOf("--codes", "--ranges")
-
-private fun applyDefaultArgs(strArgs: String?): List {
- val list:MutableList = mutableListOf()
- if (strArgs != null) {
- val array = ParametersListUtil.parseToArray(strArgs)
- list.addAll(array)
- }
- list.addAll(DEFAULT_ARGS)
- return list.distinct()
-}
-
-fun runLuaCheck(project: Project, file: VirtualFile) {
- ToolWindowManager.getInstance(project).getToolWindow("LuaCheck")?.show {
- var dir: VirtualFile = file.parent
- val list: MutableList> = mutableListOf()
- if (file.isDirectory) {
- val dirPath = file.canonicalPath!!
- dir = file
- VfsUtil.visitChildrenRecursively(dir, object: VirtualFileVisitor() {
- override fun visitFile(vf: VirtualFile): Boolean {
- if (vf.fileType == LuaFileType.INSTANCE) {
- val psiFile = PsiManagerEx.getInstance(project).findFile(vf)
- if (psiFile != null) {
- val path = vf.canonicalPath!!
- list.add(Pair(path.substring(dirPath.length + 1), psiFile))
- }
- }
- return true
- }
- })
- } else {
- val psiFile = PsiManagerEx.getInstance(project).findFile(file)
- if (psiFile != null)
- list.add(Pair(psiFile.name, psiFile))
- }
-
- ProgressManager.getInstance().runProcessWithProgressSynchronously({
- val indicator = ProgressManager.getInstance().progressIndicator
- runLuaCheck(project, list.toTypedArray(), dir, indicator)
- }, "LuaCheck", true, project)
- }
-}
-
-private fun showSettingsPanel(project: Project) {
- ApplicationManager.getApplication().invokeLater {
- ShowSettingsUtil.getInstance().showSettingsDialog(project, LuaCheckSettingsPanel::class.java)
- }
-}
-
-private fun runLuaCheck(project: Project,
- fileList: Array>,
- dir: VirtualFile,
- indicator: ProgressIndicator) {
- val checkView = project.getService(LuaCheckView::class.java)
- val panel = checkView.panel
- val builder = panel.builder
- builder.clear()
-
- var idx = 0
- for ((first, second) in fileList) {
- if (indicator.isCanceled) {
- break
- }
- indicator.text = second.name
- indicator.fraction = idx.toDouble() / fileList.size
- idx++
- try {
- runLuaCheckInner(first, second, dir, builder)
- } catch (e: ProcessNotCreatedException) {
- showSettingsPanel(project)
- break
- }
- }
-
- ApplicationManager.getApplication().invokeLater { builder.performUpdate() }
-}
-
-private fun runLuaCheckInner(relativeFilePath: String,
- file: PsiFile,
- dir: VirtualFile,
- builder: LuaCheckTreeBuilder) {
- val settings = LuaCheckSettings.getInstance()
- val cmd = GeneralCommandLine(settings.luaCheck)
- val args = settings.luaCheckArgs
- cmd.addParameters(applyDefaultArgs(args))
- cmd.addParameter(relativeFilePath)
- cmd.workDirectory = File(dir.path)
-
- val fileNode = builder.addFile(file)
-
- val handler = OSProcessHandler(cmd)
- @Language("RegExp")
- val reg = "(.+?):(\\d+):(\\d+)-(\\d+):(.+)\\n".toRegex()
- handler.addProcessListener(object : ProcessListener {
- override fun onTextAvailable(event: ProcessEvent, key: Key<*>) {
- //print(event.text)
- val matchResult = reg.find(event.text)
- if (matchResult != null) {
- //val matchGroup = matchResult.groups[1]!!
- val lineGroup = matchResult.groups[2]!!
- val colSGroup = matchResult.groups[3]!!
- val colEGroup = matchResult.groups[4]!!
- val descGroup = matchResult.groups[5]!!
-
- builder.addLCItem(LCRecordData(
- lineGroup.value.toInt() - 1,
- colSGroup.value.toInt() - 1,
- colEGroup.value.toInt() - colSGroup.value.toInt() + 1,
- descGroup.value), fileNode)
- }
- }
-
- override fun processTerminated(event: ProcessEvent) {
-
- }
-
- override fun processWillTerminate(event: ProcessEvent, p1: Boolean) {
-
- }
-
- override fun startNotified(event: ProcessEvent) {
-
- }
- })
- handler.startNotify()
- handler.waitFor()
-}
\ No newline at end of file
diff --git a/src/main/java/com/tang/intellij/lua/luacheck/LuaCheckNodes.kt b/src/main/java/com/tang/intellij/lua/luacheck/LuaCheckNodes.kt
deleted file mode 100644
index e850cd5f0..000000000
--- a/src/main/java/com/tang/intellij/lua/luacheck/LuaCheckNodes.kt
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2017. tangzx(love.tangzx@qq.com)
- *
- * 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.luacheck
-
-import com.intellij.icons.AllIcons
-import com.intellij.ide.projectView.PresentationData
-import com.intellij.ide.projectView.ViewSettings
-import com.intellij.ide.projectView.impl.nodes.PsiFileNode
-import com.intellij.ide.util.treeView.AbstractTreeNode
-import com.intellij.openapi.fileEditor.OpenFileDescriptor
-import com.intellij.openapi.project.Project
-import com.intellij.psi.PsiFile
-
-class LCRootNode(project: Project) : AbstractTreeNode(project, project) {
- private val myChildren: ArrayList> = arrayListOf()
- override fun getChildren() = myChildren
-
- override fun update(data: PresentationData) {
-
- }
-
- fun clear() {
- myChildren.clear()
- }
-
- fun append(child: AbstractTreeNode<*>) {
- myChildren.add(child)
- }
-}
-
-class LCPsiFileNode(project: Project, file: PsiFile) : PsiFileNode(project, file, ViewSettings.DEFAULT) {
- private val myChildren: ArrayList> = arrayListOf()
-
- override fun getChildrenImpl() = myChildren
-
- fun append(child: AbstractTreeNode<*>) {
- myChildren.add(child)
- }
-}
-
-data class LCRecordData(val line:Int, val col:Int, val len:Int, val desc:String)
-class LCRecord(project: Project, val file:PsiFile, val record: LCRecordData) : AbstractTreeNode(project, record) {
- override fun update(presentationData: PresentationData) {
- presentationData.presentableText = "(${record.line}, ${record.col}) ${record.desc}"
- presentationData.setIcon(AllIcons.General.TodoDefault)
- }
-
- override fun getChildren(): Collection> {
- return emptyList()
- }
-
- override fun canNavigate() = true
-
- override fun navigate(requestFocus: Boolean) {
- getNavigator().navigate(requestFocus)
- }
-
- fun getNavigator():OpenFileDescriptor {
- return OpenFileDescriptor(project!!, file.virtualFile, record.line, record.col)
- }
-
- override fun isAlwaysLeaf() = true
-}
\ No newline at end of file
diff --git a/src/main/java/com/tang/intellij/lua/luacheck/LuaCheckPanel.kt b/src/main/java/com/tang/intellij/lua/luacheck/LuaCheckPanel.kt
deleted file mode 100644
index 5cfe17ede..000000000
--- a/src/main/java/com/tang/intellij/lua/luacheck/LuaCheckPanel.kt
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Copyright (c) 2017. tangzx(love.tangzx@qq.com)
- *
- * 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.luacheck
-
-import com.intellij.find.FindModel
-import com.intellij.find.impl.FindInProjectUtil
-import com.intellij.icons.AllIcons
-import com.intellij.ide.CommonActionsManager
-import com.intellij.ide.TreeExpander
-import com.intellij.ide.projectView.TreeStructureProvider
-import com.intellij.ide.util.treeView.AbstractTreeBuilder
-import com.intellij.ide.util.treeView.AbstractTreeStructureBase
-import com.intellij.ide.util.treeView.NodeDescriptor
-import com.intellij.ide.util.treeView.NodeRenderer
-import com.intellij.openapi.actionSystem.*
-import com.intellij.openapi.application.ApplicationManager
-import com.intellij.openapi.project.Project
-import com.intellij.openapi.ui.SimpleToolWindowPanel
-import com.intellij.psi.PsiDocumentManager
-import com.intellij.psi.PsiFile
-import com.intellij.ui.AutoScrollToSourceHandler
-import com.intellij.ui.OnePixelSplitter
-import com.intellij.ui.components.JBScrollPane
-import com.intellij.usageView.UsageInfo
-import com.intellij.usages.impl.UsagePreviewPanel
-import com.intellij.util.EditSourceOnDoubleClickHandler
-import com.intellij.util.PlatformIcons
-import java.awt.GridLayout
-import javax.swing.JComponent
-import javax.swing.JPanel
-import javax.swing.JTree
-import javax.swing.tree.DefaultMutableTreeNode
-import javax.swing.tree.DefaultTreeModel
-
-/**
- * LuaCheckPanel
- * Created by tangzx on 2017/7/12.
- */
-class LuaCheckPanel(val project: Project) : SimpleToolWindowPanel(false), DataProvider {
- private val rootNode = DefaultMutableTreeNode()
- private val treeModel = DefaultTreeModel(rootNode)
- private val tree: JTree = JTree(treeModel)
- val builder:LuaCheckTreeBuilder = LuaCheckTreeBuilder(tree, treeModel, project)
- private val treeExpander = MyTreeExpander()
- private var myUsagePreviewPanel: UsagePreviewPanel? = null
-
- inner class MyShowPackagesAction : ToggleAction("Group By Packages", null, PlatformIcons.GROUP_BY_PACKAGES) {
- override fun isSelected(actionEvent: AnActionEvent): Boolean {
- return builder.arePackagesShown
- }
-
- override fun setSelected(actionEvent: AnActionEvent, state: Boolean) {
- builder.arePackagesShown = state
- }
- }
-
- inner class MyPreviewAction internal constructor() : ToggleAction("Preview Source", null, AllIcons.Actions.PreviewDetails) {
-
- override fun isSelected(actionEvent: AnActionEvent): Boolean {
- return builder.showPreview
- }
-
- override fun setSelected(actionEvent: AnActionEvent, state: Boolean) {
- myUsagePreviewPanel?.isVisible = state
- builder.showPreview = state
- if (state) {
- updatePreview()
- }
- }
- }
-
- inner class MyTreeExpander : TreeExpander {
- override fun collapseAll() {
- builder.collapseAll()
- }
-
- override fun canExpand() = true
-
- override fun expandAll() {
- builder.expandAll()
- }
-
- override fun canCollapse() = true
- }
-
- inner class MyAutoScrollToSourceHandler : AutoScrollToSourceHandler() {
- override fun isAutoScrollMode() = builder.isAutoScrollMode
-
- override fun setAutoScrollMode(value: Boolean) {
- builder.isAutoScrollMode = value
- }
- }
-
- fun init() {
- tree.cellRenderer = NodeRenderer()
- tree.isRootVisible = false
- tree.selectionModel.addTreeSelectionListener {
- ApplicationManager.getApplication().invokeLater { updatePreview() }
- }
-
- EditSourceOnDoubleClickHandler.install(tree)
- //auto scroll source handler
- val handler = MyAutoScrollToSourceHandler()
- handler.install(tree)
-
- //toolbar
- val toolBarPanel = JPanel(GridLayout())
- setToolbar(toolBarPanel)
- val group = DefaultActionGroup()
- group.add(CommonActionsManager.getInstance().createExpandAllAction(treeExpander, this))
- group.add(CommonActionsManager.getInstance().createCollapseAllAction(treeExpander, this))
- group.add(MyShowPackagesAction())
- group.add(handler.createToggleAction())
- group.add(MyPreviewAction())
- toolBarPanel.add(ActionManager.getInstance().createActionToolbar(ActionPlaces.TODO_VIEW_TOOLBAR, group, false).component)
-
- builder.initRootNode()
-
- //preview
- myUsagePreviewPanel = UsagePreviewPanel(project, FindInProjectUtil.setupViewPresentation(false, FindModel()))
- myUsagePreviewPanel?.isVisible = builder.showPreview
-
- setContent(createCenterComponent())
- }
-
- private fun createCenterComponent(): JComponent {
- val splitter = OnePixelSplitter()
- val jbScrollPane = JBScrollPane(tree)
- jbScrollPane.border = null
- splitter.firstComponent = jbScrollPane//ScrollPaneFactory.createScrollPane(tree, false)
- splitter.secondComponent = myUsagePreviewPanel
- return splitter
- }
-
- private fun updatePreview() {
- val treePath = tree.selectionPath
- treePath ?: return
-
- val list: MutableList = mutableListOf()
- val node = treePath.lastPathComponent as DefaultMutableTreeNode
- val userdata = node.userObject
- if (userdata is NodeDescriptor<*>) {
- val data = userdata.element
- if (data is LCRecord) {
- val document = PsiDocumentManager.getInstance(project).getDocument(data.file)
- document ?: return
-
- val startOffset = document.getLineStartOffset(data.record.line) + data.record.col
- list.add(UsageInfo(data.file, startOffset, startOffset + data.record.len))
- }
- }
-
- myUsagePreviewPanel?.updateLayout(if (list.isEmpty()) null else list)
- }
-
- override fun getData(dataId: String): Any? {
- if (CommonDataKeys.NAVIGATABLE.`is`(dataId)) {
- val path = tree.selectionPath
- if (path != null && !builder.showPreview) {
- val node = path.lastPathComponent as DefaultMutableTreeNode
- val userObject = node.userObject
- if (userObject is NodeDescriptor<*>) {
- val element = userObject.element
- if (element is LCRecord) {
- return element.getNavigator()
- }
- }
- }
- }
- return super.getData(dataId)
- }
-}
-
-class LuaCheckTreeBuilder(tree: JTree, model: DefaultTreeModel, val project: Project)
- : AbstractTreeBuilder(tree, model, LuaCheckTreeStructure(project), null, false) {
- var isAutoScrollMode: Boolean = false
- var arePackagesShown: Boolean = true
- var showPreview: Boolean = false
-
- override fun initRootNode() {
- super.initRootNode()
- performUpdate()
- }
-
- fun clear() {
- val root = rootElement as LCRootNode
- root.clear()
- }
-
- fun addFile(file: PsiFile): LCPsiFileNode {
- val root = rootElement as LCRootNode
- val fileNode = LCPsiFileNode(project, file)
- root.append(fileNode)
- return fileNode
- }
-
- fun addLCItem(item: LCRecordData, fileNode: LCPsiFileNode) {
- fileNode.append(LCRecord(project, fileNode.value, item))
- }
-
- fun performUpdate() {
- queueUpdateFrom(rootNode, true)
- }
-
- fun collapseAll() {
- var rc = tree.rowCount - 1
- while (rc >= 0) {
- tree.collapseRow(rc)
- rc--
- }
- }
-
- fun expandAll() {
- ui.expandAll { }
- }
-}
-
-class LuaCheckTreeStructure(project: Project) : AbstractTreeStructureBase(project) {
- val root: LCRootNode = LCRootNode(project)
-
- override fun commit() { }
-
- override fun getProviders(): List {
- return emptyList()
- }
-
- override fun getRootElement(): Any = root
-
- override fun hasSomethingToCommit(): Boolean = false
-
- override fun isAlwaysLeaf(element: Any): Boolean {
- return element is LCRecord
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/tang/intellij/lua/luacheck/LuaCheckSettings.kt b/src/main/java/com/tang/intellij/lua/luacheck/LuaCheckSettings.kt
deleted file mode 100644
index b595fbeba..000000000
--- a/src/main/java/com/tang/intellij/lua/luacheck/LuaCheckSettings.kt
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2017. tangzx(love.tangzx@qq.com)
- *
- * 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.luacheck
-
-import com.intellij.openapi.application.ApplicationManager
-import com.intellij.openapi.components.PersistentStateComponent
-import com.intellij.openapi.components.State
-import com.intellij.openapi.components.Storage
-import com.intellij.openapi.util.text.StringUtil
-import com.intellij.util.xmlb.XmlSerializerUtil
-
-@State(name = "LuaCheckSettings", storages = [Storage("emmy.xml")])
-class LuaCheckSettings : PersistentStateComponent {
- var luaCheck:String? = null
- var luaCheckArgs:String? = null
-
- override fun getState(): LuaCheckSettings = this
-
- override fun loadState(settings: LuaCheckSettings) {
- XmlSerializerUtil.copyBean(settings, this)
- }
-
- val valid: Boolean get() {
- if (StringUtil.isEmpty(luaCheck))
- return false
-
- return true
- }
-
- companion object {
- @JvmStatic fun getInstance(): LuaCheckSettings {
- return ApplicationManager.getApplication().getService(LuaCheckSettings::class.java)
- }
- }
-}
diff --git a/src/main/java/com/tang/intellij/lua/luacheck/LuaCheckSettingsPanel.form b/src/main/java/com/tang/intellij/lua/luacheck/LuaCheckSettingsPanel.form
deleted file mode 100644
index ce60757a6..000000000
--- a/src/main/java/com/tang/intellij/lua/luacheck/LuaCheckSettingsPanel.form
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
diff --git a/src/main/java/com/tang/intellij/lua/luacheck/LuaCheckSettingsPanel.java b/src/main/java/com/tang/intellij/lua/luacheck/LuaCheckSettingsPanel.java
deleted file mode 100644
index e21c6e0e8..000000000
--- a/src/main/java/com/tang/intellij/lua/luacheck/LuaCheckSettingsPanel.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (c) 2017. tangzx(love.tangzx@qq.com)
- *
- * 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.luacheck;
-
-import com.intellij.ide.BrowserUtil;
-import com.intellij.openapi.options.Configurable;
-import com.intellij.openapi.options.ConfigurationException;
-import com.intellij.openapi.options.SearchableConfigurable;
-import com.intellij.openapi.ui.TextFieldWithBrowseButton;
-import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.ui.HoverHyperlinkLabel;
-import com.intellij.ui.HyperlinkAdapter;
-import com.intellij.ui.RawCommandLineEditor;
-import com.tang.intellij.lua.LuaBundle;
-import org.jetbrains.annotations.Nls;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import javax.swing.*;
-import javax.swing.event.HyperlinkEvent;
-
-/**
- * lua check settings panel
- * Created by Administrator on 2017/7/13.
- */
-public class LuaCheckSettingsPanel implements SearchableConfigurable, Configurable.NoScroll {
- private JPanel myPanel;
- private RawCommandLineEditor myCmdLine;
- private TextFieldWithBrowseButton myLuaCheck;
- private HoverHyperlinkLabel luaCheckReleasePageLink;
- private HoverHyperlinkLabel commandLineOptionsLink;
- private LuaCheckSettings settings = LuaCheckSettings.getInstance();
-
- public LuaCheckSettingsPanel() {
- myLuaCheck.setText(settings.getLuaCheck());
- myCmdLine.setText(settings.getLuaCheckArgs());
- }
-
- @NotNull
- @Override
- public String getId() {
- return "luacheck";
- }
-
- @Nls
- @Override
- public String getDisplayName() {
- return "LuaCheck";
- }
-
- @Nullable
- @Override
- public JComponent createComponent() {
- return myPanel;
- }
-
- @Override
- public boolean isModified() {
- return !StringUtil.equals(settings.getLuaCheck(), myLuaCheck.getText()) ||
- !StringUtil.equals(settings.getLuaCheckArgs(), myCmdLine.getText());
- }
-
- @Override
- public void apply() {
- settings.setLuaCheck(myLuaCheck.getText());
- settings.setLuaCheckArgs(myCmdLine.getText());
- }
-
- private void createUIComponents() {
- luaCheckReleasePageLink = new HoverHyperlinkLabel(LuaBundle.message("ui.luacheck.download"));
- luaCheckReleasePageLink.addHyperlinkListener(new HyperlinkAdapter() {
- @Override
- protected void hyperlinkActivated(HyperlinkEvent hyperlinkEvent) {
- BrowserUtil.browse("https://github.com/lunarmodules/luacheck");
- }
- });
- commandLineOptionsLink = new HoverHyperlinkLabel(LuaBundle.message("ui.luacheck.command_line_options"));
- commandLineOptionsLink.addHyperlinkListener(new HyperlinkAdapter() {
- @Override
- protected void hyperlinkActivated(HyperlinkEvent hyperlinkEvent) {
- BrowserUtil.browse("http://luacheck.readthedocs.io/en/stable/cli.html#command-line-options");
- }
- });
- }
-}
diff --git a/src/main/java/com/tang/intellij/lua/luacheck/LuaCheckToolWindowFactory.kt b/src/main/java/com/tang/intellij/lua/luacheck/LuaCheckToolWindowFactory.kt
deleted file mode 100644
index 8c953a89e..000000000
--- a/src/main/java/com/tang/intellij/lua/luacheck/LuaCheckToolWindowFactory.kt
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2017. tangzx(love.tangzx@qq.com)
- *
- * 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.luacheck
-
-import com.intellij.openapi.project.DumbService
-import com.intellij.openapi.project.Project
-import com.intellij.openapi.wm.ToolWindow
-import com.intellij.openapi.wm.ToolWindowFactory
-
-/**
- * ToolWindowFactory
- * Created by tangzx on 2017/7/11.
- */
-class LuaCheckToolWindowFactory : ToolWindowFactory {
- override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) {
- DumbService.getInstance(project).runWhenSmart {
- val checkView = project.getService(LuaCheckView::class.java)
- checkView.init(toolWindow)
- }
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/tang/intellij/lua/luacheck/LuaCheckView.kt b/src/main/java/com/tang/intellij/lua/luacheck/LuaCheckView.kt
deleted file mode 100644
index b7a0f7dd2..000000000
--- a/src/main/java/com/tang/intellij/lua/luacheck/LuaCheckView.kt
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2017. tangzx(love.tangzx@qq.com)
- *
- * 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.luacheck
-
-import com.intellij.openapi.project.Project
-import com.intellij.openapi.wm.ToolWindow
-import com.intellij.ui.content.ContentFactory
-
-/**
- * LuaCheckView
- * Created by tangzx on 2017/7/12.
- */
-class LuaCheckView(val project: Project) {
- val panel: LuaCheckPanel by lazy { LuaCheckPanel(project) }
-
- fun init(toolWindow: ToolWindow) {
- panel.init()
- val contentFactory = ContentFactory.getInstance()
- val content = contentFactory.createContent(panel, "", false)
- toolWindow.contentManager.addContent(content)
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/tang/intellij/lua/project/LuaSdkType.kt b/src/main/java/com/tang/intellij/lua/project/LuaSdkType.kt
index 849190ed7..18ca734ce 100644
--- a/src/main/java/com/tang/intellij/lua/project/LuaSdkType.kt
+++ b/src/main/java/com/tang/intellij/lua/project/LuaSdkType.kt
@@ -41,7 +41,7 @@ class LuaSdkType : SdkType("Lua SDK") {
override fun getVersionString(sdk: Sdk) = "1.0"
override fun createAdditionalDataConfigurable(sdkModel: SdkModel, sdkModificator: SdkModificator): AdditionalDataConfigurable? =
- null
+ null
override fun getPresentableName() = "Lua SDK"
@@ -51,10 +51,8 @@ class LuaSdkType : SdkType("Lua SDK") {
override fun getIcon(): Icon = LuaIcons.FILE
- override fun getIconForAddAction(): Icon = LuaIcons.FILE
-
companion object {
val instance: LuaSdkType
get() = SdkType.findInstance(LuaSdkType::class.java)
}
-}
+}
\ No newline at end of file
diff --git a/src/main/java/com/tang/intellij/lua/project/LuaSettingsPanel.java b/src/main/java/com/tang/intellij/lua/project/LuaSettingsPanel.java
index 41541d3b2..548b544f5 100644
--- a/src/main/java/com/tang/intellij/lua/project/LuaSettingsPanel.java
+++ b/src/main/java/com/tang/intellij/lua/project/LuaSettingsPanel.java
@@ -34,6 +34,7 @@
import javax.swing.text.BadLocationException;
import javax.swing.text.PlainDocument;
import java.nio.charset.Charset;
+import java.util.Arrays;
import java.util.Objects;
import java.util.SortedMap;
@@ -122,7 +123,7 @@ public boolean isModified() {
settings.getAttachDebugCaptureStd() != captureStd.isSelected() ||
settings.getAttachDebugDefaultCharsetName() != defaultCharset.getSelectedItem() ||
settings.getLanguageLevel() != languageLevel.getSelectedItem() ||
- !ArrayUtil.equals(settings.getAdditionalSourcesRoot(), additionalRoots.getRoots(), String::compareTo);
+ !Arrays.equals(settings.getAdditionalSourcesRoot(), additionalRoots.getRoots(), String::compareTo);
}
@Override
diff --git a/src/main/java/com/tang/intellij/lua/project/LuaSourceRootManager.kt b/src/main/java/com/tang/intellij/lua/project/LuaSourceRootManager.kt
index f289ca7e8..1930bb1bd 100644
--- a/src/main/java/com/tang/intellij/lua/project/LuaSourceRootManager.kt
+++ b/src/main/java/com/tang/intellij/lua/project/LuaSourceRootManager.kt
@@ -17,6 +17,7 @@
package com.tang.intellij.lua.project
import com.intellij.openapi.components.PersistentStateComponent
+import com.intellij.openapi.components.Service
import com.intellij.openapi.components.State
import com.intellij.openapi.components.Storage
import com.intellij.openapi.module.ModuleManager
@@ -31,13 +32,14 @@ interface LuaSourceRootListener {
fun onChanged()
}
+@Service(Service.Level.PROJECT)
@State(name = "LuaSourceRootManager", storages = [(Storage("emmy.xml"))])
class LuaSourceRootManager(val project: Project) : PersistentStateComponent {
companion object {
val TOPIC: Topic = Topic.create("lua project source root changes", LuaSourceRootListener::class.java)
fun getInstance(project: Project): LuaSourceRootManager {
- return project.getComponent(LuaSourceRootManager::class.java)
+ return project.getService(LuaSourceRootManager::class.java)
}
}
diff --git a/src/main/java/com/tang/intellij/lua/psi/LuaPsiFile.kt b/src/main/java/com/tang/intellij/lua/psi/LuaPsiFile.kt
index 0e8cf2306..6e549416e 100644
--- a/src/main/java/com/tang/intellij/lua/psi/LuaPsiFile.kt
+++ b/src/main/java/com/tang/intellij/lua/psi/LuaPsiFile.kt
@@ -31,7 +31,6 @@ import com.tang.intellij.lua.lang.LuaFileType
import com.tang.intellij.lua.lang.LuaLanguage
import com.tang.intellij.lua.project.LuaSettings
import com.tang.intellij.lua.stubs.LuaFileStub
-import com.tang.intellij.lua.util.Strings
/**
* Created by tangzx on 2015/11/15.
@@ -48,8 +47,7 @@ open class LuaPsiFile(fileViewProvider: FileViewProvider) : PsiFileBase(fileView
if (stub is LuaFileStub)
return stub.uid
val file = originalFile
- val contents = file.viewProvider.contents
- val hashCode = Strings.stringHashCode(contents, 0, contents.length)
+ val hashCode = file.viewProvider.contents.length
return "$name[$hashCode]"
}
diff --git a/src/main/java/com/tang/intellij/lua/refactoring/move/LuaMoveFileHandler.kt b/src/main/java/com/tang/intellij/lua/refactoring/move/LuaMoveFileHandler.kt
index 20ae6253b..36fe8fe45 100644
--- a/src/main/java/com/tang/intellij/lua/refactoring/move/LuaMoveFileHandler.kt
+++ b/src/main/java/com/tang/intellij/lua/refactoring/move/LuaMoveFileHandler.kt
@@ -60,7 +60,7 @@ class LuaMoveFileHandler : MoveFileHandler() {
return usages
}
- override fun retargetUsages(usageInfos: MutableList, oldToNewMap: MutableMap) {
+ override fun retargetUsages(usageInfos: MutableList, oldToNewMap: MutableMap) {
for (usageInfo in usageInfos) {
val reference = usageInfo.reference
if (reference is LuaRequireReference) {
diff --git a/src/main/java/com/tang/intellij/lua/spellchecker/LuaSpellBundledDictionaryProvider.kt b/src/main/java/com/tang/intellij/lua/spellchecker/LuaSpellBundledDictionaryProvider.kt
deleted file mode 100644
index 4826c2f84..000000000
--- a/src/main/java/com/tang/intellij/lua/spellchecker/LuaSpellBundledDictionaryProvider.kt
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (c) 2017. tangzx(love.tangzx@qq.com)
- *
- * 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.spellchecker
-
-import com.intellij.spellchecker.BundledDictionaryProvider
-
-class LuaSpellBundledDictionaryProvider : BundledDictionaryProvider {
- override fun getBundledDictionaries() = arrayOf("/spellchecker/lua.dic")
-}
\ No newline at end of file
diff --git a/src/main/java/com/tang/intellij/lua/spellchecker/LuaSpellcheckingStrategy.kt b/src/main/java/com/tang/intellij/lua/spellchecker/LuaSpellcheckingStrategy.kt
deleted file mode 100644
index 4105f7ab5..000000000
--- a/src/main/java/com/tang/intellij/lua/spellchecker/LuaSpellcheckingStrategy.kt
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2017. tangzx(love.tangzx@qq.com)
- *
- * 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.spellchecker
-
-import com.intellij.psi.PsiElement
-import com.intellij.psi.PsiNameIdentifierOwner
-import com.intellij.spellchecker.inspections.PlainTextSplitter
-import com.intellij.spellchecker.tokenizer.*
-import com.tang.intellij.lua.lang.LuaLanguage
-import com.tang.intellij.lua.psi.LuaLiteralExpr
-import com.tang.intellij.lua.psi.LuaLiteralKind
-import com.tang.intellij.lua.psi.kind
-
-class LuaSpellcheckingStrategy : SpellcheckingStrategy() {
- override fun isMyContext(element: PsiElement): Boolean {
- return element.language is LuaLanguage
- }
-
- override fun getTokenizer(element: PsiElement): Tokenizer<*> {
- return when (element) {
- is LuaLiteralExpr -> StringLiteralTokenizer
- is PsiNameIdentifierOwner -> IdentifierOwnerTokenizer
- else -> super.getTokenizer(element)
- }
- }
-}
-
-private object IdentifierOwnerTokenizer : PsiIdentifierOwnerTokenizer() {
- override fun tokenize(element: PsiNameIdentifierOwner, consumer: TokenConsumer) {
- val id = element.nameIdentifier
- if (id !is LuaLiteralExpr)
- super.tokenize(element, consumer)
- }
-}
-
-private object StringLiteralTokenizer : EscapeSequenceTokenizer() {
-
- override fun tokenize(element: LuaLiteralExpr, consumer: TokenConsumer) {
- if (element.kind == LuaLiteralKind.String) {
- consumer.consumeToken(element, PlainTextSplitter.getInstance())
- }
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/tang/intellij/lua/usages/UsageTypeProvider.kt b/src/main/java/com/tang/intellij/lua/usages/UsageTypeProvider.kt
index 2ad9e9121..63cde3650 100644
--- a/src/main/java/com/tang/intellij/lua/usages/UsageTypeProvider.kt
+++ b/src/main/java/com/tang/intellij/lua/usages/UsageTypeProvider.kt
@@ -28,7 +28,7 @@ class UsageTypeProvider : UsageTypeProviderEx {
val FUNCTION_CALL = UsageType { "Function call" }
}
- override fun getUsageType(element: PsiElement?, targets: Array): UsageType? {
+ override fun getUsageType(element: PsiElement, targets: Array): UsageType? {
if (element is LuaPsiElement) {
val parent = element.parent
if (parent is LuaCallExpr)
diff --git a/src/main/resources/!!DONT_UNZIP_ME!!.txt b/src/main/resources/!!DONT_UNZIP_ME!!.txt
deleted file mode 100644
index ef23af0f2..000000000
--- a/src/main/resources/!!DONT_UNZIP_ME!!.txt
+++ /dev/null
@@ -1 +0,0 @@
-Don't unzip me! Please install EmmyLua plugin use this whole zip file.
\ No newline at end of file
diff --git a/src/main/resources/META-INF/emmylua-core.xml b/src/main/resources/META-INF/emmylua-core.xml
index 51b81430f..6e671b37d 100644
--- a/src/main/resources/META-INF/emmylua-core.xml
+++ b/src/main/resources/META-INF/emmylua-core.xml
@@ -63,9 +63,6 @@
-
-
-
diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml
index 1daa2e082..bf1f27e5a 100644
--- a/src/main/resources/META-INF/plugin.xml
+++ b/src/main/resources/META-INF/plugin.xml
@@ -17,7 +17,7 @@
com.tang
EmmyLua
- 1.3.6
+ 1.4.0
tangzx
Custom Languages
1.4.15
+
+ - [NEW] compatible with IDEA243
+
+ 1.4.14
+
+ - [NEW] compatible with IDEA242
+
+ 1.4.12
+
+ - [NEW] compatible with IDEA241
+
+ 1.4.9
+
+ - [NEW] compatible with IDEA233
+
+ 1.4.2
+
+ - [NEW] rewrite the index system, fix IDE freeze/crash issues!
+ - [NEW] compatible with IDEA232
+
1.3.7
- [NEW] compatible with IDEA222
@@ -103,7 +124,7 @@
]]>
-
+
com.intellij.java
From 515709db0d84262caea5394faaf4be4a7bffb304 Mon Sep 17 00:00:00 2001
From: ale <345036769@qq.com>
Date: Thu, 8 Jan 2026 23:26:11 +0800
Subject: [PATCH 2/2] use typestring
---
build.gradle.kts | 10 +-
.../lua/psi/impl/LuaCallExprImpl.java | 84 ++++++++-
.../lua/debugger/emmy/EmmyDebugProcessBase.kt | 3 +-
.../tang/intellij/lua/psi/LuaPsiImplUtil.kt | 174 +++++++++++++++++-
src/main/resources/std/Lua50/builtin.lua | 57 +++++-
src/main/resources/std/Lua51/builtin.lua | 57 +++++-
src/main/resources/std/Lua52/builtin.lua | 57 +++++-
src/main/resources/std/Lua53/builtin.lua | 57 +++++-
src/main/resources/std/Lua54/builtin.lua | 57 +++++-
9 files changed, 537 insertions(+), 19 deletions(-)
diff --git a/build.gradle.kts b/build.gradle.kts
index 41c46fba8..1b9c32a7e 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -94,11 +94,11 @@ fun getRev(): String {
task("downloadEmmyDebugger", type = Download::class) {
src(arrayOf(
- "https://github.com/leinlin/EmmyLuaDebugger/releases/download/${emmyDebuggerVersion}/darwin-arm64.zip",
- "https://github.com/leinlin/EmmyLuaDebugger/releases/download/${emmyDebuggerVersion}/darwin-x64.zip",
- "https://github.com/leinlin/EmmyLuaDebugger/releases/download/${emmyDebuggerVersion}/linux-x64.zip",
- "https://github.com/leinlin/EmmyLuaDebugger/releases/download/${emmyDebuggerVersion}/win32-x64.zip",
- "https://github.com/leinlin/EmmyLuaDebugger/releases/download/${emmyDebuggerVersion}/win32-x86.zip"
+ "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")
diff --git a/gen/com/tang/intellij/lua/psi/impl/LuaCallExprImpl.java b/gen/com/tang/intellij/lua/psi/impl/LuaCallExprImpl.java
index c257b1b4f..05ef720ad 100644
--- a/gen/com/tang/intellij/lua/psi/impl/LuaCallExprImpl.java
+++ b/gen/com/tang/intellij/lua/psi/impl/LuaCallExprImpl.java
@@ -2,6 +2,9 @@
package com.tang.intellij.lua.psi.impl;
import java.util.List;
+
+import com.tang.intellij.lua.ty.TyAliasSubstitutor;
+import groovy.lang.Tuple4;
import org.jetbrains.annotations.*;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
@@ -58,9 +61,88 @@ public ITy guessParentType(@NotNull SearchContext context) {
}
@Override
+ @NotNull
+ public ITy guessType(SearchContext context) {
+ ITy ty = SearchContext.Companion.infer(this, context);
+ String typeName = ty.getDisplayName();
+ boolean isDynamic = false;
+ Tuple4 t;
+ do
+ {
+ t = getStringArgByTypeName(typeName, "UseArgString");
+ isDynamic = t.getV1();
+ if(isDynamic) break;
+
+ t = getStringArgByTypeName(typeName, "UseArgName");
+ isDynamic = t.getV1();
+ if (isDynamic) break;
+
+ t = getStringArgByTypeName(typeName, "UseArgFullName");
+ isDynamic = t.getV1();
+ if (isDynamic) break;
+
+ }while (false);
+
+ if(isDynamic) {
+ ty = LuaPsiImplUtilKt.newType((String)t.getV2(), ty, (String)t.getV3(), (String)t.getV4());
+ }
+
+ ty = TyAliasSubstitutor.Companion.substitute(ty, context);
+ return ty;
+ }
+
+ @Nullable
+ public Tuple4 getStringArgByTypeName(String typeName, String argType) {
+ int start = 0;
+ int index = 0;
+ String replaceStr = "";
+ String str = "";
+ Boolean result = false;
+
+ if ((start = typeName.indexOf(argType)) >= 0) {
+ int length = argType.length();
+ replaceStr = argType;
+ if(start + length < typeName.length())
+ {
+ index = typeName.charAt(start + length) - '1';
+ replaceStr = argType + Integer.toString(index + 1);
+ }
+
+ if(index >= 0 && index <= 9)
+ {
+ result = true;
+ if (argType == "UseArgString")
+ {
+ PsiElement p = LuaPsiImplUtilKt.getStringArgByIndex(this, index);
+ str = LuaPsiImplUtilKt.getStringValue(p);
+ }
+ else if (argType == "UseArgName")
+ {
+ PsiElement p = LuaPsiImplUtilKt.getParamNameByIndex(this, index);
+ str = LuaPsiImplUtilKt.getParamStringValue(p);
+ }
+ else if (argType == "UseArgFullName")
+ {
+ PsiElement p = LuaPsiImplUtilKt.getParamNameByIndex(this, index);
+ str = LuaPsiImplUtilKt.getParamAllStringValue(p);
+ }
+ if (str != "") {
+ typeName = typeName.replace(replaceStr, str);
+ }
+ }
+ }
+ return new Tuple4(result, typeName, replaceStr, str);
+ }
+
+
@Nullable
public PsiElement getFirstStringArg() {
- return LuaPsiImplUtilKt.getFirstStringArg(this);
+ return LuaPsiImplUtilKt.getStringArgByIndex(this, 0);
+ }
+
+ @Nullable
+ public PsiElement getFirstParamArg() {
+ return LuaPsiImplUtilKt.getParamNameByIndex(this, 0);
}
@Override
diff --git a/src/main/java/com/tang/intellij/lua/debugger/emmy/EmmyDebugProcessBase.kt b/src/main/java/com/tang/intellij/lua/debugger/emmy/EmmyDebugProcessBase.kt
index 69fba873e..657253edf 100644
--- a/src/main/java/com/tang/intellij/lua/debugger/emmy/EmmyDebugProcessBase.kt
+++ b/src/main/java/com/tang/intellij/lua/debugger/emmy/EmmyDebugProcessBase.kt
@@ -45,6 +45,7 @@ abstract class EmmyDebugProcessBase(session: XDebugSession) : LuaDebugProcess(se
override fun sessionInitialized() {
super.sessionInitialized()
+ session.setPauseActionSupported(true)
ApplicationManager.getApplication().executeOnPooledThread {
setupTransporter()
}
@@ -69,6 +70,7 @@ abstract class EmmyDebugProcessBase(session: XDebugSession) : LuaDebugProcess(se
registerBreakpoint(position, breakpoint)
}
}
+ session.setPauseActionSupported(true);
// send ready
transporter?.send(Message(MessageCMD.ReadyReq))
}
@@ -208,7 +210,6 @@ abstract class EmmyDebugProcessBase(session: XDebugSession) : LuaDebugProcess(se
override fun getEditorsProvider(): XDebuggerEditorsProvider {
return editorsProvider
}
-
fun addEvalResultHandler(handler: IEvalResultHandler) {
evalHandlers.add(handler)
}
diff --git a/src/main/java/com/tang/intellij/lua/psi/LuaPsiImplUtil.kt b/src/main/java/com/tang/intellij/lua/psi/LuaPsiImplUtil.kt
index 47b661d82..d244cf1d2 100644
--- a/src/main/java/com/tang/intellij/lua/psi/LuaPsiImplUtil.kt
+++ b/src/main/java/com/tang/intellij/lua/psi/LuaPsiImplUtil.kt
@@ -33,6 +33,7 @@ import com.tang.intellij.lua.comment.psi.LuaDocTagVararg
import com.tang.intellij.lua.comment.psi.api.LuaComment
import com.tang.intellij.lua.lang.LuaIcons
import com.tang.intellij.lua.lang.type.LuaString
+import com.tang.intellij.lua.psi.impl.*
import com.tang.intellij.lua.search.SearchContext
import com.tang.intellij.lua.stubs.LuaClassMemberStub
import com.tang.intellij.lua.stubs.LuaFuncBodyOwnerStub
@@ -188,26 +189,137 @@ fun guessParentType(callExpr: LuaCallExpr, context: SearchContext): ITy {
return callExpr.expr.guessType(context)
}
+fun getStringValue(valueExpr: PsiElement): String {
+ if (valueExpr is LuaLiteralExprImpl)
+ {
+ return valueExpr.stringValue
+ }
+ else
+ {
+ if (valueExpr is LuaNameExpr)
+ {
+ val declaration = resolve(valueExpr as LuaNameExpr, SearchContext.get(valueExpr.project))
+ if (declaration is LuaNameExprImpl)
+ {
+ return declaration.text
+ }
+ else if(declaration is LuaNameDefImpl)
+ {
+ val exp = declaration?.parent?.parent?.lastChild?.lastChild
+ if (exp != null)
+ {
+ return getStringValue(exp)
+ }
+ }
+ }
+ else if (valueExpr is LuaIndexExpr)
+ {
+ val declaration = resolve(valueExpr as LuaIndexExpr, SearchContext.get(valueExpr.project))
+ if (declaration is LuaTableFieldImpl)
+ {
+ val strExp = declaration?.lastChild
+ if (strExp != null)
+ {
+ return getStringValue(strExp)
+ }
+ }
+ else if (declaration is LuaIndexExprImpl)
+ {
+ val exp = declaration?.parent?.parent?.lastChild?.lastChild
+ if (exp != null)
+ {
+ return getStringValue(exp)
+ }
+ }
+ }
+ }
+
+ return "";
+}
+
+fun getParamStringValue(valueExpr: PsiElement): String {
+ if (valueExpr is LuaNameExpr)
+ {
+ return valueExpr.text;
+ }
+ else if(valueExpr is LuaIndexExpr)
+ {
+ return valueExpr.lastChild.text;
+ }
+ return "";
+}
+
+fun getParamAllStringValue(valueExpr: PsiElement): String {
+ if (valueExpr is LuaNameExpr)
+ {
+ return valueExpr.text;
+ }
+ else if(valueExpr is LuaIndexExpr)
+ {
+ return valueExpr.text;
+ }
+ return "";
+}
+
+/**
+ * 获取第n个字符串参数
+ * @param callExpr callExpr
+ * *
+ * @return String PsiElement
+ */
+fun getStringArgByIndex(callExpr: LuaCallExpr, index: Int): PsiElement? {
+ val args = callExpr.args
+ var path: PsiElement? = null
+
+ when (args) {
+ is LuaSingleArg -> {
+ val expr = args.expr
+ if (expr is LuaLiteralExpr && index == 0) path = expr
+ }
+ is LuaListArgs -> args.exprList.let { list ->
+ if (list.isNotEmpty() && list.size > index) {
+ if (list[index] is LuaLiteralExpr) {
+ val valueExpr = list[index] as LuaLiteralExpr
+ if (valueExpr.kind == LuaLiteralKind.String)
+ path = valueExpr
+ }
+ else {
+ val context = SearchContext.get(callExpr.project)
+ if (list[index].guessType((context)).displayName == "string")
+ {
+ path = list[index]
+ }
+ }
+ }
+ }
+ }
+ return path
+}
+
/**
- * 获取第一个字符串参数
+ * 获取第n个参数的名字
* @param callExpr callExpr
* *
* @return String PsiElement
*/
-fun getFirstStringArg(callExpr: LuaCallExpr): PsiElement? {
+fun getParamNameByIndex(callExpr: LuaCallExpr, index: Int): PsiElement? {
val args = callExpr.args
var path: PsiElement? = null
when (args) {
is LuaSingleArg -> {
val expr = args.expr
- if (expr is LuaLiteralExpr) path = expr
+ if (expr is LuaNameExpr && index == 0) path = expr
+ if (expr is LuaIndexExpr && index == 0) path = expr
}
is LuaListArgs -> args.exprList.let { list ->
- if (list.isNotEmpty() && list[0] is LuaLiteralExpr) {
- val valueExpr = list[0] as LuaLiteralExpr
- if (valueExpr.kind == LuaLiteralKind.String)
- path = valueExpr
+ if (list.isNotEmpty() && list.size > index) {
+ if (list[index] is LuaNameExpr) {
+ path = list[index]
+ }
+ else if (list[index] is LuaIndexExpr) {
+ path = list[index]
+ }
}
}
}
@@ -257,6 +369,54 @@ fun guessTypeAt(list: LuaExprList, context: SearchContext): ITy {
return Ty.UNKNOWN
}
+fun getStringValue(typeName: LuaLiteralExpr): String {
+ return typeName.stringValue;
+}
+
+fun getNameExprStringValue(valueExpr: PsiElement): String {
+ val tree = LuaDeclarationTree.get(valueExpr.containingFile)
+ val declaration = tree.find(valueExpr as LuaExpr)?.firstDeclaration?.psi
+ val exp = declaration?.parent?.parent
+ if (exp != null)
+ {
+ val strExp = exp.lastChild.lastChild
+ if(strExp is LuaLiteralExprImpl)
+ {
+ val str = strExp.text
+ return str.substring(1, str.length - 1)
+ }
+ else
+ {
+ return getNameExprStringValue(strExp)
+ }
+
+ }
+ return "";
+}
+
+fun newType(typeName: String, ty: ITy, sourceStr: String, targetStr: String): ITy {
+ if (ty is TyArray) {
+ val t = typeName.substringBefore('[').trim()
+ val ty = TyLazyClass(t)
+ return TyArray(ty);
+ }
+ else if(ty is TySerializedGeneric){
+ val list = mutableListOf();
+ ty.params.forEach {
+ var name = it.displayName
+ if(name.contains(sourceStr))
+ {
+ name = name.replace(sourceStr, targetStr)
+ }
+ list.add(newType(name, it, sourceStr, targetStr))
+ }
+ return TySerializedGeneric(list.toTypedArray(), ty.base)
+ }
+ else {
+ return TyLazyClass(typeName);
+ }
+}
+
fun guessParentType(indexExpr: LuaIndexExpr, context: SearchContext): ITy {
val expr = PsiTreeUtil.getStubChildOfType(indexExpr, LuaExpr::class.java)
return expr?.guessType(context) ?: Ty.UNKNOWN
diff --git a/src/main/resources/std/Lua50/builtin.lua b/src/main/resources/std/Lua50/builtin.lua
index 18e55f3e2..2588c2218 100644
--- a/src/main/resources/std/Lua50/builtin.lua
+++ b/src/main/resources/std/Lua50/builtin.lua
@@ -102,4 +102,59 @@
---
---@class void
----@class self
\ No newline at end of file
+---@class self
+
+---@class UseArgString1
+
+---@class UseArgString2
+
+---@class UseArgString3
+
+---@class UseArgString4
+
+---@class UseArgString5
+
+---@class UseArgString6
+
+---@class UseArgString7
+
+---@class UseArgString8
+
+---@class UseArgString9
+
+
+---@class UseArgName1
+
+---@class UseArgName2
+
+---@class UseArgName3
+
+---@class UseArgName4
+
+---@class UseArgName5
+
+---@class UseArgName6
+
+---@class UseArgName7
+
+---@class UseArgName8
+
+---@class UseArgName9
+
+---@class UseArgFullName1
+
+---@class UseArgFullName2
+
+---@class UseArgFullName3
+
+---@class UseArgFullName4
+
+---@class UseArgFullName5
+
+---@class UseArgFullName6
+
+---@class UseArgFullName7
+
+---@class UseArgFullName8
+
+---@class UseArgFullName9
diff --git a/src/main/resources/std/Lua51/builtin.lua b/src/main/resources/std/Lua51/builtin.lua
index 18e55f3e2..9b73e4b61 100644
--- a/src/main/resources/std/Lua51/builtin.lua
+++ b/src/main/resources/std/Lua51/builtin.lua
@@ -102,4 +102,59 @@
---
---@class void
----@class self
\ No newline at end of file
+---@class self
+
+---@class UseArgString1
+
+---@class UseArgString2
+
+---@class UseArgString3
+
+---@class UseArgString4
+
+---@class UseArgString5
+
+---@class UseArgString6
+
+---@class UseArgString7
+
+---@class UseArgString8
+
+---@class UseArgString9
+
+
+---@class UseArgName1
+
+---@class UseArgName2
+
+---@class UseArgName3
+
+---@class UseArgName4
+
+---@class UseArgName5
+
+---@class UseArgName6
+
+---@class UseArgName7
+
+---@class UseArgName8
+
+---@class UseArgName9
+
+---@class UseArgFullName1
+
+---@class UseArgFullName2
+
+---@class UseArgFullName3
+
+---@class UseArgFullName4
+
+---@class UseArgFullName5
+
+---@class UseArgFullName6
+
+---@class UseArgFullName7
+
+---@class UseArgFullName8
+
+---@class UseArgFullName9
\ No newline at end of file
diff --git a/src/main/resources/std/Lua52/builtin.lua b/src/main/resources/std/Lua52/builtin.lua
index 18e55f3e2..9b73e4b61 100644
--- a/src/main/resources/std/Lua52/builtin.lua
+++ b/src/main/resources/std/Lua52/builtin.lua
@@ -102,4 +102,59 @@
---
---@class void
----@class self
\ No newline at end of file
+---@class self
+
+---@class UseArgString1
+
+---@class UseArgString2
+
+---@class UseArgString3
+
+---@class UseArgString4
+
+---@class UseArgString5
+
+---@class UseArgString6
+
+---@class UseArgString7
+
+---@class UseArgString8
+
+---@class UseArgString9
+
+
+---@class UseArgName1
+
+---@class UseArgName2
+
+---@class UseArgName3
+
+---@class UseArgName4
+
+---@class UseArgName5
+
+---@class UseArgName6
+
+---@class UseArgName7
+
+---@class UseArgName8
+
+---@class UseArgName9
+
+---@class UseArgFullName1
+
+---@class UseArgFullName2
+
+---@class UseArgFullName3
+
+---@class UseArgFullName4
+
+---@class UseArgFullName5
+
+---@class UseArgFullName6
+
+---@class UseArgFullName7
+
+---@class UseArgFullName8
+
+---@class UseArgFullName9
\ No newline at end of file
diff --git a/src/main/resources/std/Lua53/builtin.lua b/src/main/resources/std/Lua53/builtin.lua
index 18e55f3e2..9b73e4b61 100644
--- a/src/main/resources/std/Lua53/builtin.lua
+++ b/src/main/resources/std/Lua53/builtin.lua
@@ -102,4 +102,59 @@
---
---@class void
----@class self
\ No newline at end of file
+---@class self
+
+---@class UseArgString1
+
+---@class UseArgString2
+
+---@class UseArgString3
+
+---@class UseArgString4
+
+---@class UseArgString5
+
+---@class UseArgString6
+
+---@class UseArgString7
+
+---@class UseArgString8
+
+---@class UseArgString9
+
+
+---@class UseArgName1
+
+---@class UseArgName2
+
+---@class UseArgName3
+
+---@class UseArgName4
+
+---@class UseArgName5
+
+---@class UseArgName6
+
+---@class UseArgName7
+
+---@class UseArgName8
+
+---@class UseArgName9
+
+---@class UseArgFullName1
+
+---@class UseArgFullName2
+
+---@class UseArgFullName3
+
+---@class UseArgFullName4
+
+---@class UseArgFullName5
+
+---@class UseArgFullName6
+
+---@class UseArgFullName7
+
+---@class UseArgFullName8
+
+---@class UseArgFullName9
\ No newline at end of file
diff --git a/src/main/resources/std/Lua54/builtin.lua b/src/main/resources/std/Lua54/builtin.lua
index 18e55f3e2..9b73e4b61 100644
--- a/src/main/resources/std/Lua54/builtin.lua
+++ b/src/main/resources/std/Lua54/builtin.lua
@@ -102,4 +102,59 @@
---
---@class void
----@class self
\ No newline at end of file
+---@class self
+
+---@class UseArgString1
+
+---@class UseArgString2
+
+---@class UseArgString3
+
+---@class UseArgString4
+
+---@class UseArgString5
+
+---@class UseArgString6
+
+---@class UseArgString7
+
+---@class UseArgString8
+
+---@class UseArgString9
+
+
+---@class UseArgName1
+
+---@class UseArgName2
+
+---@class UseArgName3
+
+---@class UseArgName4
+
+---@class UseArgName5
+
+---@class UseArgName6
+
+---@class UseArgName7
+
+---@class UseArgName8
+
+---@class UseArgName9
+
+---@class UseArgFullName1
+
+---@class UseArgFullName2
+
+---@class UseArgFullName3
+
+---@class UseArgFullName4
+
+---@class UseArgFullName5
+
+---@class UseArgFullName6
+
+---@class UseArgFullName7
+
+---@class UseArgFullName8
+
+---@class UseArgFullName9
\ No newline at end of file