diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-04-12 04:47:49 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-04-12 04:47:49 +0800 |
commit | 23f9c21952f1ddad594eb54b9d1cfbaf80b929ef (patch) | |
tree | 0e6bdcc85055f1ed7b81e3cf29805cb9c8f10841 /script | |
parent | 6e47a81bc1c43a6188e17d3d77bbc88b7932269c (diff) | |
download | lua-language-server-23f9c21952f1ddad594eb54b9d1cfbaf80b929ef.zip |
fix missed parent
Diffstat (limited to 'script')
-rw-r--r-- | script/parser/luadoc.lua | 2 | ||||
-rw-r--r-- | script/parser/newparser.lua | 26 | ||||
-rw-r--r-- | script/vm/local-id.lua | 4 |
3 files changed, 17 insertions, 15 deletions
diff --git a/script/parser/luadoc.lua b/script/parser/luadoc.lua index f9cd3db0..bbfd3ab4 100644 --- a/script/parser/luadoc.lua +++ b/script/parser/luadoc.lua @@ -1019,6 +1019,7 @@ local function parseVersion() end local version = { type = 'doc.version.unit', + parent = result, start = getStart(), } if tp == 'symbol' then @@ -1257,6 +1258,7 @@ local function buildLuaDoc(comment) type = 'doc.tailcomment', start = cstart + comment.start, finish = comment.finish, + parent = result, text = trimTailComment(text:sub(cstart)), } end diff --git a/script/parser/newparser.lua b/script/parser/newparser.lua index 66df7046..5245b94d 100644 --- a/script/parser/newparser.lua +++ b/script/parser/newparser.lua @@ -628,10 +628,13 @@ local function parseLocalAttrs() break end if not attrs then - attrs = {} + attrs = { + type = 'localattrs', + } end local attr = { type = 'localattr', + parent = attrs, start = getPosition(Tokens[Index], 'left'), finish = getPosition(Tokens[Index], 'right'), } @@ -694,10 +697,7 @@ local function createLocal(obj, attrs) if attrs then obj.attrs = attrs - for i = 1, #attrs do - local attr = attrs[i] - attr.parent = obj - end + attrs.parent = obj end local chunk = Chunk[#Chunk] @@ -1405,7 +1405,7 @@ local function parseName(asAction) } end -local function parseNameOrList() +local function parseNameOrList(parent) local first = parseName() if not first then return nil @@ -1428,6 +1428,7 @@ local function parseNameOrList() type = 'list', start = first.start, finish = first.finish, + parent = parent, [1] = first } end @@ -3266,7 +3267,7 @@ local function parseFor() pushActionIntoCurrentChunk(action) pushChunk(action) skipSpace() - local nameOrList = parseNameOrList() + local nameOrList = parseNameOrList(action) if not nameOrList then missName() end @@ -3292,15 +3293,16 @@ local function parseFor() action.loc = loc end if expList then + expList.parent = action local value = expList[1] if value then - value.parent = action + value.parent = expList action.init = value action.finish = expList[#expList].finish end local max = expList[2] if max then - max.parent = action + max.parent = expList action.max = max action.finish = max.finish else @@ -3312,7 +3314,7 @@ local function parseFor() end local step = expList[3] if step then - step.parent = action + step.parent = expList action.step = step action.finish = step.finish end @@ -3346,6 +3348,7 @@ local function parseFor() type = 'list', start = nameOrList.start, finish = nameOrList.finish, + parent = action, [1] = nameOrList, } else @@ -3359,9 +3362,10 @@ local function parseFor() end action.exps = exps + exps.parent = action for i = 1, #exps do local exp = exps[i] - exp.parent = action + exp.parent = exps end else missExp() diff --git a/script/vm/local-id.lua b/script/vm/local-id.lua index 98b13632..b7a6e6d5 100644 --- a/script/vm/local-id.lua +++ b/script/vm/local-id.lua @@ -121,10 +121,6 @@ function m.compileLocalID(source) return end local root = guide.getRoot(source) - if not root then - log.error('No root?', require 'inspect' (source, { depth = 1 })) - return - end if not root._localIDs then root._localIDs = util.multiTable(2) end |