Skip to content

Commit 5d46780

Browse files
committed
升级kotlin gradle,修改函数签名显示
1 parent 383ea4c commit 5d46780

File tree

6 files changed

+32
-29
lines changed

6 files changed

+32
-29
lines changed

EmmyLua-Common/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ dependencies {
1818
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
1919
}
2020
buildscript {
21-
ext.kotlin_version = '1.2.30'
21+
ext.kotlin_version = '1.6.0'
2222
repositories {
2323
mavenCentral()
2424
}

EmmyLua-Common/src/main/java/com/tang/intellij/lua/ty/TyFunction.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ abstract class FunSignatureBase(override val colonCall: Boolean,
132132
paramSB.add("...:"+ it.displayName)
133133
}
134134
}
135-
"fun(${paramSB.joinToString(", ")}):${returnTy.displayName}"
135+
"(${paramSB.joinToString(", ")}) -> ${returnTy.displayName}"
136136
}
137137

138138
override val paramSignature: String get() {

EmmyLua-LS/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
buildscript {
2-
ext.kotlin_version = '1.2.31'
2+
ext.kotlin_version = '1.6.0'
33
repositories {
44
mavenCentral()
55
}
@@ -9,8 +9,8 @@ buildscript {
99
}
1010

1111
plugins {
12-
id "org.jetbrains.kotlin.jvm" version "1.2.30"
13-
id 'com.github.johnrengelman.shadow' version '4.0.3'
12+
id "org.jetbrains.kotlin.jvm" version "1.6.0"
13+
id 'com.github.johnrengelman.shadow' version '6.1.0'
1414
}
1515

1616
apply plugin: "java"

EmmyLua-LS/src/main/kotlin/com/tang/vscode/documentation/DocRenderer.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ internal fun renderTy(sb: StringBuilder, ty: ITy) {
8585
}
8686

8787
internal fun renderSignature(sb: StringBuilder, sig: IFunSignature) {
88-
sb.wrap("(", "): ") {
88+
sb.wrap("(", ") -> ") {
8989
var idx = 0
9090
sig.params.forEach {
9191
if (idx++ != 0) sb.append(", ")

EmmyLua-LS/src/main/kotlin/com/tang/vscode/documentation/LuaDocumentationProvider.kt

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,19 @@ class LuaDocumentationProvider : DocumentationProvider {
5151
return null
5252
}
5353

54-
override fun getDocumentationElementForLookupItem(psiManager: PsiManager, obj: Any, element: PsiElement): PsiElement? {
54+
override fun getDocumentationElementForLookupItem(
55+
psiManager: PsiManager,
56+
obj: Any,
57+
element: PsiElement
58+
): PsiElement? {
5559
return null
5660
}
5761

58-
override fun getDocumentationElementForLink(psiManager: PsiManager, link: String, context: PsiElement?): PsiElement? {
62+
override fun getDocumentationElementForLink(
63+
psiManager: PsiManager,
64+
link: String,
65+
context: PsiElement?
66+
): PsiElement? {
5967
return LuaClassIndex.find(link, SearchContext.get(psiManager.project))
6068
}
6169

@@ -67,28 +75,27 @@ class LuaDocumentationProvider : DocumentationProvider {
6775
is LuaDocTagClass -> renderClassDef(sb, element)
6876
is LuaClassMember -> renderClassMember(sb, element)
6977
is LuaNameDef -> { //local xx
70-
sb.wrapLanguage("typescript") {
78+
sb.wrapLanguage("lua") {
7179
sb.append("local ${element.name}:")
7280
val ty = element.guessType(SearchContext.get(element.project))
7381
renderTy(sb, ty)
7482
sb.append("\n")
83+
7584
}
7685

7786
val owner = PsiTreeUtil.getParentOfType(element, LuaCommentOwner::class.java)
7887
owner?.let { renderComment(sb, owner.comment) }
7988
}
8089
is LuaLocalFuncDef -> {
81-
sb.wrapLanguage("typescript") {
90+
sb.wrapLanguage("lua") {
8291
sb.append("local function ${element.name}")
8392
val type = element.guessType(SearchContext.get(element.project)) as ITyFunction
8493
renderSignature(sb, type.mainSignature)
8594
}
8695
renderComment(sb, element.comment)
8796
}
8897
is LuaPsiFile -> {
89-
sb.wrapLanguage("typescript") {
90-
sb.append("module \"${element.virtualFile.path.substringAfter("file:/")}\"")
91-
}
98+
sb.append(element.virtualFile.path.substringAfter("file:/"))
9299
}
93100

94101
}
@@ -104,10 +111,17 @@ class LuaDocumentationProvider : DocumentationProvider {
104111

105112
//base info
106113
if (parentType != null) {
107-
sb.wrapLanguage("typescript") {
114+
sb.wrapLanguage("lua") {
108115
when (ty) {
109116
is TyFunction -> {
110117
sb.append("function ")
118+
if(parentType.displayName != "_G") {
119+
renderTy(sb, parentType)
120+
sb.append(if (ty.isColonCall) ":" else ".")
121+
}
122+
sb.append(classMember.name)
123+
renderSignature(sb, ty.mainSignature)
124+
return@wrapLanguage
111125
}
112126
is TyClass -> {
113127
sb.append("class ")
@@ -120,25 +134,14 @@ class LuaDocumentationProvider : DocumentationProvider {
120134
}
121135
}
122136
renderTy(sb, parentType)
123-
with(sb) {
124-
when (ty) {
125-
is TyFunction -> {
126-
append(if (ty.isColonCall) ":" else ".")
127-
append(classMember.name)
128-
renderSignature(sb, ty.mainSignature)
129-
}
130-
else -> {
131-
append(".${classMember.name}:")
132-
renderTy(sb, ty)
133-
}
134-
}
135-
}
137+
sb.append(".${classMember.name}:")
138+
renderTy(sb, ty)
136139
}
137140
} else {
138141
//NameExpr
139142
if (classMember is LuaNameExpr) {
140143
val nameExpr: LuaNameExpr = classMember
141-
sb.wrapLanguage("typescript") {
144+
sb.wrapLanguage("lua") {
142145
sb.append("global ")
143146
with(sb) {
144147
append(nameExpr.name)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)