Skip to content

Commit 93a3113

Browse files
committed
形式上支持泛型类定义
1 parent 67549d6 commit 93a3113

File tree

15 files changed

+501
-325
lines changed

15 files changed

+501
-325
lines changed

EmmyLua-Common/src/main/gen/com/tang/intellij/lua/comment/lexer/_LuaDocLexer.java

Lines changed: 298 additions & 287 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

EmmyLua-Common/src/main/gen/com/tang/intellij/lua/comment/parser/LuaDocParser.java

Lines changed: 81 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

EmmyLua-Common/src/main/gen/com/tang/intellij/lua/comment/psi/LuaDocTagClass.java

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

EmmyLua-Common/src/main/gen/com/tang/intellij/lua/comment/psi/impl/LuaDocTagClassImpl.java

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

EmmyLua-Common/src/main/gen/com/tang/intellij/lua/psi/LuaCallExpr.java

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

EmmyLua-Common/src/main/java/com/tang/intellij/lua/doc.bnf

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,11 @@ tag_field ::= TAG_NAME_FIELD access_modifier? ((('<' class_name_ref '>')? ID nul
212212
}
213213

214214
id_field ::= ID comment_string? {
215-
implements = [
216-
"com.tang.intellij.lua.comment.psi.LuaDocPsiElement"
217-
"com.tang.intellij.lua.psi.LuaClassField"
218-
"com.intellij.psi.PsiNameIdentifierOwner"
219-
]
215+
// implements = [
216+
// "com.tang.intellij.lua.comment.psi.LuaDocPsiElement"
217+
// "com.tang.intellij.lua.psi.LuaClassField"
218+
// "com.intellij.psi.PsiNameIdentifierOwner"
219+
// ]
220220

221221

222222
}
@@ -266,7 +266,12 @@ class_name_ref_list ::= class_name_ref (',' class_name_ref)* {
266266
methods = [getClasses]
267267
}
268268

269-
tag_class ::= (TAG_NAME_CLASS|TAG_NAME_MODULE|TAG_NAME_ENUM|TAG_NAME_INTERFACE) ID (EXTENDS class_name_ref_list)? comment_string? {
269+
270+
private generic_define_list ::= '<' generic_def (',' generic_def)* '>' {
271+
pin = 1
272+
}
273+
274+
tag_class ::= (TAG_NAME_CLASS|TAG_NAME_MODULE|TAG_NAME_ENUM|TAG_NAME_INTERFACE) ID (generic_define_list)? (EXTENDS class_name_ref_list)? comment_string? {
270275
pin = 2
271276
implements = [
272277
"com.tang.intellij.lua.comment.psi.LuaDocPsiElement"

EmmyLua-Common/src/main/java/com/tang/intellij/lua/doc.flex

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,11 @@ SINGLE_QUOTED_STRING='([^\\\']|\\\S|\\[\r\n])*'? //'([^\\'\r\n]|\\[^\r\n])*'?
135135
{ID} { yybegin(xCLASS_EXTEND); return ID; }
136136
}
137137
<xCLASS_EXTEND> {
138-
":" { beginType(); return EXTENDS;}
138+
"<" { _typeLevel++; return LT; }
139+
"," { return COMMA; }
140+
">" { _typeLevel--; return GT; }
141+
{ID} { if (_typeLevel > 0) { _typeReq = false; return ID; } else { yybegin(xCOMMENT_STRING); yypushback(yylength()); } }
142+
":" { if (_typeLevel == 0) {beginType(); return EXTENDS;} else { return EXTENDS; } }
139143
[^] { yybegin(xCOMMENT_STRING); yypushback(yylength()); }
140144
}
141145

EmmyLua-Common/src/main/java/com/tang/intellij/lua/editor/completion/ClassMemberCompletionProvider.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,11 @@ open class ClassMemberCompletionProvider : LuaCompletionProvider() {
268268
)
269269
val ele = handlerProcessor?.process(element, classMember, fnTy) ?: element
270270
completionResultSet.addElement(ele)
271+
271272
// correction completion
272273
if (!isColonStyle && firstParamIsSelf
274+
// 前缀长度大于等于3才显示纠正
275+
&& completionResultSet.prefixMatcher.prefix.length >= 3
273276
&& callType != Ty.STRING
274277
// workaround now
275278
&& callType is TyClass

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ interface IFunSignature {
3434
val paramSignature: String
3535
val tyParameters: Array<TyParameter>
3636
val varargTy: ITy?
37+
val document: String?
3738
fun substitute(substitutor: ITySubstitutor): IFunSignature
3839
fun subTypeOf(other: IFunSignature, context: SearchContext, strict: Boolean): Boolean
3940
}
@@ -183,7 +184,8 @@ class FunSignature(
183184
override val returnTy: ITy,
184185
override val varargTy: ITy?,
185186
params: Array<LuaParamInfo>,
186-
tyParameters: Array<TyParameter> = emptyArray()
187+
tyParameters: Array<TyParameter> = emptyArray(),
188+
override val document: String = ""
187189
) : FunSignatureBase(colonCall, params, tyParameters) {
188190

189191
companion object {
@@ -446,6 +448,8 @@ class TyPsiFunction(private val colonCall: Boolean, val psi: LuaFuncBodyOwner, f
446448

447449
override val varargTy: ITy?
448450
get() = psi.varargType
451+
override val document: String?
452+
get() = null
449453
}
450454
}
451455

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,9 @@ class LuaTextDocumentService(private val workspace: LuaWorkspaceService) : TextD
543543
ParameterInformation("...:${sig.varargTy?.displayName}")
544544
information.parameters.add(paramInfo)
545545
}
546+
if(sig.document != null){
547+
information.documentation = Either.forRight(MarkupContent(MarkupKind.MARKDOWN, sig.document))
548+
}
546549

547550
information.label = sig.displayName
548551
list.add(information)

0 commit comments

Comments
 (0)