@@ -511,7 +511,7 @@ local function getReturnOfSetMetaTable(args)
511511 node :merge (vm .compileNode (tbl ))
512512 end
513513 if mt then
514- vm .compileByParentNode (mt , ' __index' , function (src )
514+ vm .compileByParentNodeAll (mt , ' __index' , function (src )
515515 for n in vm .compileNode (src ):eachObject () do
516516 if n .type == ' global'
517517 or n .type == ' local'
637637
638638--- @param source parser.object | vm.variable
639639--- @param key string | vm.global | vm.ANY
640- --- @param pushResult fun ( source : parser.object )
641- function vm .compileByParentNode (source , key , pushResult )
640+ --- @return parser.object[] docedResults
641+ --- @return parser.object[] commonResults
642+ function vm .getNodesOfParentNode (source , key )
642643 local parentNode = vm .compileNode (source )
643644 local docedResults = {}
644645 local commonResults = {}
@@ -691,6 +692,16 @@ function vm.compileByParentNode(source, key, pushResult)
691692 end )
692693 end
693694
695+ return docedResults , commonResults
696+ end
697+
698+ -- 遍历所有字段(按照优先级)
699+ --- @param source parser.object | vm.variable
700+ --- @param key string | vm.global | vm.ANY
701+ --- @param pushResult fun ( source : parser.object )
702+ function vm .compileByParentNode (source , key , pushResult )
703+ local docedResults , commonResults = vm .getNodesOfParentNode (source , key )
704+
694705 if # docedResults > 0 then
695706 for _ , res in ipairs (docedResults ) do
696707 pushResult (res )
@@ -703,6 +714,21 @@ function vm.compileByParentNode(source, key, pushResult)
703714 end
704715end
705716
717+ -- 遍历所有字段(无视优先级)
718+ --- @param source parser.object | vm.variable
719+ --- @param key string | vm.global | vm.ANY
720+ --- @param pushResult fun ( source : parser.object )
721+ function vm .compileByParentNodeAll (source , key , pushResult )
722+ local docedResults , commonResults = vm .getNodesOfParentNode (source , key )
723+
724+ for _ , res in ipairs (docedResults ) do
725+ pushResult (res )
726+ end
727+ for _ , res in ipairs (commonResults ) do
728+ pushResult (res )
729+ end
730+ end
731+
706732--- @param list parser.object[]
707733--- @param index integer
708734--- @return vm.node
@@ -1341,8 +1367,10 @@ local compilerSwitch = util.switch()
13411367 end )
13421368 end
13431369
1344- if not hasMarkDoc and source .value then
1345- vm .setNode (source , vm .compileNode (source .value ))
1370+ if source .value then
1371+ if not hasMarkDoc or source .value .type == ' table' then
1372+ vm .setNode (source , vm .compileNode (source .value ))
1373+ end
13461374 end
13471375
13481376 end )
0 commit comments