diff options
Diffstat (limited to 'script-beta/core')
-rw-r--r-- | script-beta/core/completion.lua | 36 | ||||
-rw-r--r-- | script-beta/core/document-symbol.lua | 28 | ||||
-rw-r--r-- | script-beta/core/keyword.lua | 44 | ||||
-rw-r--r-- | script-beta/core/semantic-tokens.lua | 29 | ||||
-rw-r--r-- | script-beta/core/workspace-symbol.lua | 8 |
5 files changed, 72 insertions, 73 deletions
diff --git a/script-beta/core/completion.lua b/script-beta/core/completion.lua index a8c52cc5..5a18ccaf 100644 --- a/script-beta/core/completion.lua +++ b/script-beta/core/completion.lua @@ -1,4 +1,4 @@ -local ckind = require 'define.CompletionItemKind' +local define = require 'proto.define' local files = require 'files' local guide = require 'parser.guide' local matchKey = require 'core.matchKey' @@ -234,7 +234,7 @@ local function buildFunction(results, source, oop, data) end if snipType == 'Both' or snipType == 'Replace' then local snipData = util.deepCopy(data) - snipData.kind = ckind.Snippet + snipData.kind = define.CompletionItemKind.Snippet snipData.label = snipData.label .. '()' snipData.insertText = buildFunctionSnip(source, oop) snipData.insertTextFormat = 2 @@ -274,7 +274,7 @@ local function checkLocal(ast, word, offset, results) if vm.hasType(source, 'function') then buildFunction(results, source, false, { label = name, - kind = ckind.Function, + kind = define.CompletionItemKind.Function, id = stack(function () return { detail = buildDetail(source), @@ -285,7 +285,7 @@ local function checkLocal(ast, word, offset, results) else results[#results+1] = { label = name, - kind = ckind.Variable, + kind = define.CompletionItemKind.Variable, id = stack(function () return { detail = buildDetail(source), @@ -349,12 +349,12 @@ end local function checkFieldThen(name, src, word, start, offset, parent, oop, results) local value = guide.getObjectValue(src) or src - local kind = ckind.Field + local kind = define.CompletionItemKind.Field if value.type == 'function' then if oop then - kind = ckind.Method + kind = define.CompletionItemKind.Method else - kind = ckind.Function + kind = define.CompletionItemKind.Function end buildFunction(results, src, oop, { label = name, @@ -374,7 +374,7 @@ local function checkFieldThen(name, src, word, start, offset, parent, oop, resul end local literal = guide.getLiteral(value) if literal ~= nil then - kind = ckind.Enum + kind = define.CompletionItemKind.Enum end local textEdit, additionalTextEdits if parent.next and parent.next.index then @@ -462,7 +462,7 @@ local function checkTableField(ast, word, start, results) used[key] = true results[#results+1] = { label = key, - kind = ckind.Property, + kind = define.CompletionItemKind.Property, } end end) @@ -482,7 +482,7 @@ local function checkCommon(word, text, offset, results) if matchKey(word, str) then results[#results+1] = { label = str, - kind = ckind.Text, + kind = define.CompletionItemKind.Text, } end end @@ -527,7 +527,7 @@ local function checkKeyWord(ast, text, start, word, hasSpace, afterLocal, result if not hasSpace then local item = { label = key, - kind = ckind.Keyword, + kind = define.CompletionItemKind.Keyword, } if extra then table.insert(results, #results, item) @@ -566,7 +566,7 @@ local function checkProvideLocal(ast, word, start, results) used[source[1]] = true results[#results+1] = { label = source[1], - kind = ckind.Variable, + kind = define.CompletionItemKind.Variable, } end end) @@ -577,7 +577,7 @@ local function checkProvideLocal(ast, word, start, results) used[source[1]] = true results[#results+1] = { label = source[1], - kind = ckind.Variable, + kind = define.CompletionItemKind.Variable, } end end) @@ -674,7 +674,7 @@ local function checkUri(ast, text, offset, results) end results[#results+1] = { label = label, - kind = ckind.Reference, + kind = define.CompletionItemKind.Reference, description = table.concat(des, '\n'), textEdit = infos.textEdit, } @@ -704,7 +704,7 @@ local function checkLenPlusOne(ast, text, offset, results) end results[#results+1] = { label = label, - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, textEdit = { start = pos, finish = source.finish, @@ -717,7 +717,7 @@ local function checkLenPlusOne(ast, text, offset, results) local newText = label .. ']' results[#results+1] = { label = label, - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, textEdit = { start = pos, finish = source.finish, @@ -837,7 +837,7 @@ local function getCallEnums(source, index) enums[#enums+1] = { label = enum.enum, description = enum.description, - kind = ckind.EnumMember, + kind = define.CompletionItemKind.EnumMember, } end end @@ -870,7 +870,7 @@ local function mergeEnums(a, b, text, arg) mark[label] = true local result = { label = label, - kind = ckind.EnumMember, + kind = define.CompletionItemKind.EnumMember, description = enum.description, textEdit = arg and { start = arg.start, diff --git a/script-beta/core/document-symbol.lua b/script-beta/core/document-symbol.lua index dd58fe82..8cb8f25f 100644 --- a/script-beta/core/document-symbol.lua +++ b/script-beta/core/document-symbol.lua @@ -1,9 +1,9 @@ local await = require 'await' -local files = require 'files' -local guide = require 'parser.guide' -local skind = require 'define.SymbolKind' -local lname = require 'core.hover.name' -local util = require 'utility' +local files = require 'files' +local guide = require 'parser.guide' +local define = require 'proto.define' +local lname = require 'core.hover.name' +local util = require 'utility' local function buildFunctionParams(func) if not func.args then @@ -39,9 +39,9 @@ local function buildFunction(source, symbols) range = { func.start, func.finish } end if source.type == 'setmethod' then - kind = skind.Method + kind = define.SymbolKind.Method else - kind = skind.Function + kind = define.SymbolKind.Function end symbols[#symbols+1] = { name = name, @@ -76,23 +76,23 @@ local function buildValue(source, symbols) details[1] = 'param' range = { source.start, source.finish } sRange = { source.start, source.finish } - kind = skind.Constant + kind = define.SymbolKind.Constant else details[1] = 'local' range = { source.start, source.finish } sRange = { source.start, source.finish } - kind = skind.Variable + kind = define.SymbolKind.Variable end elseif source.type == 'setlocal' then details[1] = 'setlocal' range = { source.start, source.finish } sRange = { source.start, source.finish } - kind = skind.Variable + kind = define.SymbolKind.Variable elseif source.type == 'setglobal' then details[1] = 'global' range = { source.start, source.finish } sRange = { source.start, source.finish } - kind = skind.Class + kind = define.SymbolKind.Class elseif source.type == 'tablefield' then if not source.field then return @@ -100,7 +100,7 @@ local function buildValue(source, symbols) details[1] = 'field' range = { source.field.start, source.field.finish } sRange = { source.field.start, source.field.finish } - kind = skind.Property + kind = define.SymbolKind.Property elseif source.type == 'setfield' then if not source.field then return @@ -108,7 +108,7 @@ local function buildValue(source, symbols) details[1] = 'field' range = { source.field.start, source.field.finish } sRange = { source.field.start, source.field.finish } - kind = skind.Field + kind = define.SymbolKind.Field else return end @@ -172,7 +172,7 @@ local function buildAnonymousFunction(source, used, symbols) symbols[#symbols+1] = { name = '', detail = 'function ()', - kind = skind.Function, + kind = define.SymbolKind.Function, range = { source.start, source.finish }, selectionRange = { source.start, source.start }, valueRange = { source.start, source.finish }, diff --git a/script-beta/core/keyword.lua b/script-beta/core/keyword.lua index 24a7dfa5..1cbeb78d 100644 --- a/script-beta/core/keyword.lua +++ b/script-beta/core/keyword.lua @@ -1,4 +1,4 @@ -local ckind = require 'define.CompletionItemKind' +local define = require 'proto.define' local guide = require 'parser.guide' local keyWordMap = { @@ -6,14 +6,14 @@ local keyWordMap = { if hasSpace then results[#results+1] = { label = 'do .. end', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[$0 end]], } else results[#results+1] = { label = 'do .. end', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[ do @@ -42,14 +42,14 @@ end]], if hasSpace then results[#results+1] = { label = 'elseif .. then', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[$1 then]], } else results[#results+1] = { label = 'elseif .. then', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[elseif $1 then]], } @@ -62,7 +62,7 @@ end]], if hasSpace then results[#results+1] = { label = 'for .. in', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[ ${1:key, value} in ${2:pairs(${3:t})} do @@ -71,7 +71,7 @@ end]] } results[#results+1] = { label = 'for i = ..', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[ ${1:i} = ${2:1}, ${3:10, 1} do @@ -81,7 +81,7 @@ end]] else results[#results+1] = { label = 'for .. in', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[ for ${1:key, value} in ${2:pairs(${3:t})} do @@ -90,7 +90,7 @@ end]] } results[#results+1] = { label = 'for i = ..', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[ for ${1:i} = ${2:1}, ${3:10, 1} do @@ -104,7 +104,7 @@ end]] if hasSpace then results[#results+1] = { label = 'function ()', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[ $1($2) @@ -114,7 +114,7 @@ end]] else results[#results+1] = { label = 'function ()', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[ function $1($2) @@ -129,7 +129,7 @@ end]] if hasSpace then results[#results+1] = { label = 'if .. then', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[ $1 then @@ -139,7 +139,7 @@ end]] else results[#results+1] = { label = 'if .. then', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[ if $1 then @@ -153,7 +153,7 @@ end]] if hasSpace then results[#results+1] = { label = 'in ..', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[ ${1:pairs(${2:t})} do @@ -163,7 +163,7 @@ end]] else results[#results+1] = { label = 'in ..', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[ in ${1:pairs(${2:t})} do @@ -177,7 +177,7 @@ end]] if hasSpace then results[#results+1] = { label = 'local function', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[ function $1($2) @@ -187,7 +187,7 @@ end]] else results[#results+1] = { label = 'local function', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[ local function $1($2) @@ -204,14 +204,14 @@ end]] if hasSpace then results[#results+1] = { label = 'repeat .. until', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[$0 until $1]] } else results[#results+1] = { label = 'repeat .. until', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[ repeat @@ -225,7 +225,7 @@ until $1]] if not hasSpace then results[#results+1] = { label = 'do return end', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[do return $1end]] } @@ -239,7 +239,7 @@ until $1]] if hasSpace then results[#results+1] = { label = 'while .. do', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[ ${1:true} do @@ -249,7 +249,7 @@ end]] else results[#results+1] = { label = 'while .. do', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[ while ${1:true} do diff --git a/script-beta/core/semantic-tokens.lua b/script-beta/core/semantic-tokens.lua index 996ebb98..5c6fa1b5 100644 --- a/script-beta/core/semantic-tokens.lua +++ b/script-beta/core/semantic-tokens.lua @@ -1,8 +1,7 @@ local files = require 'files' local guide = require 'parser.guide' local await = require 'await' -local TokenTypes = require 'define.TokenTypes' -local TokenModifiers = require 'define.TokenModifiers' +local define = require 'proto.define' local vm = require 'vm' local util = require 'utility' @@ -11,8 +10,8 @@ Care['setglobal'] = function (source, results) results[#results+1] = { start = source.start, finish = source.finish, - type = TokenTypes.namespace, - modifieres = TokenModifiers.deprecated, + type = define.TokenTypes.namespace, + modifieres = define.TokenTypes.deprecated, } end Care['getglobal'] = function (source, results) @@ -24,16 +23,16 @@ Care['getglobal'] = function (source, results) results[#results+1] = { start = source.start, finish = source.finish, - type = TokenTypes.namespace, - modifieres = TokenModifiers.static, + type = define.TokenTypes.namespace, + modifieres = define.TokenTypes.static, } end else results[#results+1] = { start = source.start, finish = source.finish, - type = TokenTypes.namespace, - modifieres = TokenModifiers.deprecated, + type = define.TokenTypes.namespace, + modifieres = define.TokenTypes.deprecated, } end end @@ -45,8 +44,8 @@ Care['tablefield'] = function (source, results) results[#results+1] = { start = field.start, finish = field.finish, - type = TokenTypes.property, - modifieres = TokenModifiers.declaration, + type = define.TokenTypes.property, + modifieres = define.TokenTypes.declaration, } end Care['getlocal'] = function (source, results) @@ -56,8 +55,8 @@ Care['getlocal'] = function (source, results) results[#results+1] = { start = source.start, finish = source.finish, - type = TokenTypes.parameter, - modifieres = TokenModifiers.declaration, + type = define.TokenTypes.parameter, + modifieres = define.TokenTypes.declaration, } return end @@ -79,8 +78,8 @@ Care['getlocal'] = function (source, results) results[#results+1] = { start = source.start, finish = source.finish, - type = TokenTypes.interface, - modifieres = TokenModifiers.declaration, + type = define.TokenTypes.interface, + modifieres = define.TokenTypes.declaration, } return end @@ -88,7 +87,7 @@ Care['getlocal'] = function (source, results) results[#results+1] = { start = source.start, finish = source.finish, - type = TokenTypes.variable, + type = define.TokenTypes.variable, } end Care['setlocal'] = Care['getlocal'] diff --git a/script-beta/core/workspace-symbol.lua b/script-beta/core/workspace-symbol.lua index 5248f3c6..fb3dd88f 100644 --- a/script-beta/core/workspace-symbol.lua +++ b/script-beta/core/workspace-symbol.lua @@ -1,7 +1,7 @@ local files = require 'files' local guide = require 'parser.guide' local matchKey = require 'core.matchkey' -local skind = require 'define.SymbolKind' +local define = require 'proto.define' local function buildSource(uri, source, key, results) if source.type == 'local' @@ -11,7 +11,7 @@ local function buildSource(uri, source, key, results) if matchKey(key, name) then results[#results+1] = { name = name, - kind = skind.Variable, + kind = define.SymbolKind.Variable, uri = uri, range = { source.start, source.finish }, } @@ -23,7 +23,7 @@ local function buildSource(uri, source, key, results) if matchKey(key, name) then results[#results+1] = { name = name, - kind = skind.Field, + kind = define.SymbolKind.Field, uri = uri, range = { field.start, field.finish }, } @@ -34,7 +34,7 @@ local function buildSource(uri, source, key, results) if matchKey(key, name) then results[#results+1] = { name = name, - kind = skind.Method, + kind = define.SymbolKind.Method, uri = uri, range = { method.start, method.finish }, } |