From d99c23af4bf8be944f58b374141dbfb81d48b5f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Thu, 9 Jun 2022 20:00:05 +0800 Subject: #1061 completion for `doc.type.code` --- script/core/completion/completion.lua | 12 ++++++++++++ script/core/hover/description.lua | 3 ++- script/parser/guide.lua | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) (limited to 'script') diff --git a/script/core/completion/completion.lua b/script/core/completion/completion.lua index 009b4297..d7c210c6 100644 --- a/script/core/completion/completion.lua +++ b/script/core/completion/completion.lua @@ -1136,6 +1136,12 @@ local function checkTypingEnum(state, position, defs, str, results) description = def.comment and def.comment.text, kind = define.CompletionItemKind.EnumMember, } + elseif def.type == 'doc.type.code' then + enums[#enums+1] = { + label = def[1], + description = def.comment and def.comment.text, + kind = define.CompletionItemKind.EnumMember, + } end end cleanEnums(enums, str) @@ -1425,6 +1431,12 @@ local function tryCallArg(state, position, results) description = src.comment, kind = define.CompletionItemKind.EnumMember, } + elseif src.type == 'doc.type.code' then + enums[#enums+1] = { + label = src[1], + description = src.comment, + kind = define.CompletionItemKind.EnumMember, + } end if src.type == 'doc.type.function' then local insertText = buildInsertDocFunction(src) diff --git a/script/core/hover/description.lua b/script/core/hover/description.lua index e3c3f412..3fef1a21 100644 --- a/script/core/hover/description.lua +++ b/script/core/hover/description.lua @@ -155,7 +155,8 @@ local function buildEnumChunk(docType, name) types[#types+1] = vm.getInfer(tp):view(guide.getUri(docType)) if tp.type == 'doc.type.string' or tp.type == 'doc.type.integer' - or tp.type == 'doc.type.boolean' then + or tp.type == 'doc.type.boolean' + or tp.type == 'doc.type.code' then enums[#enums+1] = tp end local comment = tryDocClassComment(tp) diff --git a/script/parser/guide.lua b/script/parser/guide.lua index 2bd9066b..83321bac 100644 --- a/script/parser/guide.lua +++ b/script/parser/guide.lua @@ -252,6 +252,7 @@ function m.isLiteral(obj) or tp == 'doc.type.string' or tp == 'doc.type.integer' or tp == 'doc.type.boolean' + or tp == 'doc.type.code' end --- 获取字面量 -- cgit v1.2.3