diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-05-25 17:30:44 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-05-25 17:30:44 +0800 |
commit | 123d904a16f49764f36cabef97c2be0f2acca34c (patch) | |
tree | 23f0e0cf4cc5655cd0488089731ce450917b7084 /script/parser | |
parent | 1fdf8d070c67ea572316515aa36708b7967b83f9 (diff) | |
download | lua-language-server-123d904a16f49764f36cabef97c2be0f2acca34c.zip |
cleanup
Diffstat (limited to 'script/parser')
-rw-r--r-- | script/parser/guide.lua | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/script/parser/guide.lua b/script/parser/guide.lua index c0ecf4e3..35c53120 100644 --- a/script/parser/guide.lua +++ b/script/parser/guide.lua @@ -818,4 +818,60 @@ function m.getKeyName(obj) return m.getKeyNameOfLiteral(obj) end +function m.getKeyTypeOfLiteral(obj) + if not obj then + return nil + end + local tp = obj.type + if tp == 'field' + or tp == 'method' then + return 'string' + elseif tp == 'string' then + return 'string' + elseif tp == 'number' then + return 'number' + elseif tp == 'boolean' then + return 'boolean' + end +end + +function m.getKeyType(obj) + if not obj then + return nil + end + local tp = obj.type + if tp == 'getglobal' + or tp == 'setglobal' then + return 'string' + elseif tp == 'local' + or tp == 'getlocal' + or tp == 'setlocal' then + return 'local' + elseif tp == 'getfield' + or tp == 'setfield' + or tp == 'tablefield' then + return 'string' + elseif tp == 'getmethod' + or tp == 'setmethod' then + return 'string' + elseif tp == 'getindex' + or tp == 'setindex' + or tp == 'tableindex' then + return m.getKeyTypeOfLiteral(obj.index) + elseif tp == 'field' + or tp == 'method' + or tp == 'doc.see.field' then + return 'string' + elseif tp == 'doc.class' then + return 'string' + elseif tp == 'doc.alias' then + return 'string' + elseif tp == 'doc.field' then + return 'string' + elseif tp == 'dummy' then + return 'string' + end + return m.getKeyTypeOfLiteral(obj) +end + return m |