diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-12-28 16:57:46 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-12-28 16:57:46 +0800 |
commit | ebdfb86387f51fd29ec37b6ca586a062b086f525 (patch) | |
tree | e7f84d82687c544f14ea484c067fa561f59672bf /server/src/core/document_symbol.lua | |
parent | 08ad84a4f6c579a12e7a7e92d438f60c5c360044 (diff) | |
download | lua-language-server-ebdfb86387f51fd29ec37b6ca586a062b086f525.zip |
支持部分函数写法
Diffstat (limited to 'server/src/core/document_symbol.lua')
-rw-r--r-- | server/src/core/document_symbol.lua | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/server/src/core/document_symbol.lua b/server/src/core/document_symbol.lua index 4dc0ebac..b67a97db 100644 --- a/server/src/core/document_symbol.lua +++ b/server/src/core/document_symbol.lua @@ -1,4 +1,5 @@ -local hover = require 'core.hover' +local hoverFunction = require 'core.hover_function' +local hoverName = require 'core.hover_name' local SymbolKind = { File = 1, @@ -31,21 +32,34 @@ local SymbolKind = { local function buildFunc(vm, func, nextFunction, nextFinish) local source = func.source - local var = vm.results.sources[source.name] or vm.results.sources[source] - if not var then - return + local name + if source.name then + local var = vm.results.sources[source.name] + if var then + name = hoverName(var, source.name) + else + name = '' + end + else + name = '' end - local hvr = hover(var, source.name or source) - if not hvr then + local hover = hoverFunction(name, func) + if not hover then return end + local selectionRange + if source.name then + selectionRange = { source.name.start, source.name.finish } + else + selectionRange = { source.start, source.start } + end return { - name = hvr.name, + name = name, -- 前端不支持多行 - detail = hvr.label:gsub('[\r\n]', ''), + detail = hover.label:gsub('[\r\n]', ''), kind = SymbolKind.Function, range = { source.start, source.finish }, - selectionRange = { source.name.start, source.name.finish }, + selectionRange = selectionRange, } end |