@codua/codeoutline-win32-x64 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -95,7 +95,12 @@ On Linux, decoding GBK sources needs the GBK module of the system iconv. Minimal
95
95
 
96
96
  ## Supported languages
97
97
 
98
- C, C++, C#, Go, Java, JavaScript / TypeScript (including JSX/TSX), Lua, Python, and Rust.
98
+ C, C++, C#, Go, Java, JavaScript / TypeScript (including JSX/TSX), Kotlin (`.kt` / `.kts`), Lua, Python, and Rust.
99
+
100
+ Kotlin includes declarations, constructor properties, extension functions, expression bodies,
101
+ package imports (including aliases), and ordinary, generic and trailing-lambda calls.
102
+ Resolution is heuristic: compiler-generated members, implicit lambda receivers, string-template
103
+ expressions, Java interop and coroutine/framework dispatch are not modeled.
99
104
 
100
105
  ## Command line
101
106
 
package/README.zh-CN.md CHANGED
@@ -95,7 +95,10 @@ Linux 上解码 GBK 源码需要系统 iconv 的 GBK 模块;EL8/EL9 最小安
95
95
 
96
96
  ## 支持的语言
97
97
 
98
- C、C++、C#、Go、Java、JavaScript / TypeScript(含 JSX/TSX)、Lua、Python、Rust。
98
+ C、C++、C#、Go、Java、JavaScript / TypeScript(含 JSX/TSX)、Kotlin(`.kt` / `.kts`)、Lua、Python、Rust。
99
+
100
+ Kotlin 支持声明、主构造器属性、扩展函数、表达式函数体、包导入与别名,以及普通、泛型和尾随 lambda 调用。
101
+ 关系解析仍是启发式的;不建模编译器生成成员、lambda 隐式接收者、字符串模板内的表达式、Java 互操作或协程/框架分派。
99
102
 
100
103
  ## 命令行
101
104
 
package/bin/xnet.exe CHANGED
Binary file
package/build-info.json CHANGED
@@ -1 +1 @@
1
- {"runtimeCommit":"d33491598d199b1a2f5fd3d9840c5b17d49b1e13","runtimeBuild":"b9b847244c68283df56e7858fe3daaafd35b756f0ff67cfa379f998133ddf29d","lua":"LuaJIT 2.1.1774896198","sourceCommit":"712ae1301adb30662b47b97a0e52a12a89904632","sourceDirty":false,"target":"win32-x64","note":"Release build from a clean checkout","version":"0.2.0","releaseReady":true,"sha256":{"README.md":"d32bf957c4155af5f2332f17d54d5df3bcea772caae4838f4be8c6231aeb5130","scripts/codeoutline/completion.lua":"23c0ed81fedc3b73939012f8084e2e25526c0eb5294f8c9bbe425a2688697b2e","scripts/codeoutline/mcp.lua":"f14a2d0b9625544ad32309358121a5ff304839780f52d5c1c8ec548d56c5e901","scripts/codeoutline/version.lua":"740f4f7d6a6b07669f1dff8cc474836e7a1e664217d55bc6154029dd94fc2b2b","scripts/codeoutline/lang/cpp.lua":"47e3dc18cbc8b9a93567897e9ff69a026434a1971fe1dcc3e07d3af03c54a4f2","scripts/codeoutline/control.lua":"b67a2e382e021f0793ef313aa4e71faab76f6cb77ca127f499d01ae96f36a8db","scripts/codeoutline/navigation.lua":"0c9b2fa983bb5331ae8d6f1ea822d561043aa962513c6ab9c066598dadc2b454","bin/xnet.exe":"3762a02254b6115e5021f013c1f96909fb72c4f2dc2ea62f51c3852ade958915","scripts/codeoutline/lang/csharp.lua":"4bfa8555955c7de98ea12d36ee6f7d817c40cb87e77350fe2af4783517190a3d","scripts/codeoutline/daemon.lua":"06863991135cc9a85f07bca8310296f0df9e415b3e2de97ae006393e777b009b","scripts/codeoutline/parse.lua":"45c94531d10428a72bd1af413903d15d61364e8907386803f4459cff16e08dc6","codeoutline":"3d3970e488e077e8acd67d174b506a361d43578b3360c7b29f2ec3f0103ba899","scripts/codeoutline/lang/go.lua":"3a62d4dc451b0d2f7f2aefd5e77d11449a5d725f59379728eba8dda0aacc13f3","scripts/codeoutline/documents.lua":"98b9462f331ea0e8da4c994e151ab3eb09f9828b616c241b4e3bc7dea571804d","scripts/codeoutline/parse_pool.lua":"acaafe74a568ec450e428f4a1a2ff704834588bba0f8b808e4c7a1d552861941","codeoutline.cmd":"607b60c6d107becdb6793df8f41aaf2cff944baf69f5ece59dba990d0f24c13b","THIRD_PARTY.md":"a0d596a8600c5244b27c1426a81b4ec7046d213d733ec6b4287a4b1e8db501b5","scripts/xupgate/client.lua":"967c29c1eeebd8596458025ab3237816a91591cca64236ea0e7ba1762814e6ba","scripts/codeoutline/lang/java.lua":"0ea34298770cb3431f4bc3521c4d2ecf363d55e768d6cd30b3f11ad05d7e8f0d","scripts/codeoutline/explore.lua":"addd618a2e89c7c20465eb238765c2447fceb7fb798de9a2684103db8bb88f5c","scripts/codeoutline/parse_worker.lua":"c5f1745d15332c5040b1e97f6da08f2f456d9afe7c2491275cc97d7113b75e45","DISTRIBUTION.md":"da4a1048fc9b44670fd6fcef97e7d92ac3f50d3523da1773930c49f7e2c38dc3","README.zh-CN.md":"bdb11239e497570b8cff2b5c9705eb26bef20fe90be477e4ea29d35af4b8ad8b","keys/update-ca.crt":"d9b5ec3d4628de9c5559871f39841a5f84d47c53ded4d58d6e3bba2b4c669a02","scripts/codeoutline/lang/js.lua":"62570ddc38c974991763e11770059880b87ec87f14578891df9d935af6cb4786","scripts/codeoutline/graph.lua":"2a24de940ea916078f62f1878f56386189619f80254ef23da8cfce2427977c50","scripts/codeoutline/path.lua":"407bd960c1ad04e5006b321ce33263393bb40eee5dee5c123be9b36d3ad10937","lib/xhttp_codec.lua":"a5b0f127105ba6dbd4a518a214ca55e22c7510e6b2fc8c25c325898d8346ef8c","scripts/xupgate/common.lua":"86267648c0dbbd3a05f90de4d6e1dbee53ba57bf4801783c2ae636224b1f228c","LICENSE":"1b63179362acd482b4a9a07ca526b3fce6d9103dcded361de2159ade174568b6","scripts/codeoutline/lang/lua.lua":"eff0b2297b94cd14ee2240d5c287792fa213f83582c078de780f72a4588124c0","scripts/codeoutline/http.lua":"3d957628ecc9592d57cc68a61e5d4229a71da501eb8fb3aa0bbb5e1cd772adf0","scripts/codeoutline/service.lua":"537b7ef657fc122a85ddf7275e242d225efc65d5316bf863cd3f3132657d3b3e","licenses/libdeflate.txt":"41b60f2caab6bffdd5ba360687bd23ca653c0a1235c00380ecffc939b4cd8d75","scripts/xupgate/proxy.lua":"5bf532e7005f44555d6a5277336e5ad395af060585c13a1cdc2441de50e0dcff","licenses/lua-cmsgpack.txt":"8edfdc5282278a1268d8a6ee52f9245f1a5fe3d1c8065be00330196b1de49873","scripts/codeoutline/lang/python.lua":"1ae8f1658e25220ec4d952c17ed817bfc92d0c45d4585d3dd4716d5585b60cc6","scripts/codeoutline/lang/c.lua":"9cd8abbdfda6cae5d6c04a9ae68bbd9f7589b217e88b7682917106e80df9b0c5","scripts/codeoutline/text.lua":"75f9af87ff5ce62def74f69d8972a6b11ff660723fc5cf515369ee3012ff0675","scripts/codeoutline/cli.lua":"f7ac4addd32ced58069954cb81edd4836c6043bb5d143683b80bd7b11554c733","keys/update-public.pem":"7ff853339e19631b20ed3fa2cf221daa31c581e2e84d161b344b8f06de6562a8","licenses/mbedtls.txt":"9b405ef4c89342f5eae1dd828882f931747f71001cfba7d114801039b52ad09b","scripts/codeoutline/lang/rust.lua":"294cee85786caaa5f29dedd5058877c7a4786349431faf33b36357ef69406a9e","scripts/codeoutline/index_worker.lua":"8d34748ce1d74384f8f4cf89bfd7a27dcfb6c4d51b6b4936aa9d232814194a8a","scripts/codeoutline/updater.lua":"267c4b6e9704fce710f44d1bfceac69c1857e34e064d8444d7890f0e10d921c7","scripts/xupgate/signature.lua":"f07de8a4093d08cc69d3c1d8296d23318c5d81344ece788d4453a9b3b700f000","licenses/xnet2lua.txt":"1aa8af3df70f60f1ebf2d23e14c27af1606057ad9c32a9a0d15fd76cff257532","scripts/codeoutline/command.lua":"7a0a623b5e965449638938549be8587f9c9490b2a7653877e089a0cc1bb1071c","scripts/codeoutline/lsp.lua":"b9c9df2a790344bb8bdc48bd024e912b012750e3bfdbe37750de5add989385da","scripts/xupgate/http_codec.lua":"a5b0f127105ba6dbd4a518a214ca55e22c7510e6b2fc8c25c325898d8346ef8c","scripts/codeoutline/update_sequence.lua":"058174a2eaeae38b1883c721191be942c1e074ea867ae4b422dcb25e2daac9e3","scripts/xupgate/http_client.lua":"a189506c3d0fcc454f5e001fdeecdd6349a1019ea0970d11ce2fbfdf035166d6","licenses/luajit.txt":"1b10a02c9474cb908da2d87bc908edd8798f9ad28d9a8c53fbd05c13227f7394","scripts/codeoutline/common.lua":"f54b5bda7986b5f31789a500a043d4119df2816bd6fac764127019319ed88a71","scripts/codeoutline/main.lua":"fff7b1577ab85625714c841773eee07b028fccd86aa9743f15a7ad5fd7a7353b","scripts/codeoutline/xscan.lua":"bd95a1b0b7022d029a41aab615897502478b5834612505e8d299343cb5ca8ef9","scripts/codeoutline/update_worker.lua":"7e2ec28e4b911d7b90fd97d0a4c0e2f5b295d1a9200c5c7250e47a99139ca550","scripts/codeoutline/index.lua":"2606625844ecc9e40b49f400a87b11708eb13fbec76b5f1a30a6b656b09fd2a4"},"updateSequence":10}
1
+ {"target":"win32-x64","note":"Release build from a clean checkout","updateSequence":11,"releaseReady":true,"sha256":{"codeoutline":"3d3970e488e077e8acd67d174b506a361d43578b3360c7b29f2ec3f0103ba899","scripts/codeoutline/lang/lua.lua":"784df7e7895cc7d9f56598d6485664f8ce55abc6374ae0bcc22ba7738439726e","scripts/codeoutline/graph.lua":"361091b354be3fc890d5e8b1a334fbf4daa3ee463fbb5ea5053c75ed66271163","scripts/codeoutline/path.lua":"407bd960c1ad04e5006b321ce33263393bb40eee5dee5c123be9b36d3ad10937","keys/update-ca.crt":"d9b5ec3d4628de9c5559871f39841a5f84d47c53ded4d58d6e3bba2b4c669a02","THIRD_PARTY.md":"a0d596a8600c5244b27c1426a81b4ec7046d213d733ec6b4287a4b1e8db501b5","README.md":"f858e6acadfb3f7d07e166c5b3c76dc3a3a2140edee6853e95aabe6d39026fc2","scripts/codeoutline/lang/python.lua":"1ae8f1658e25220ec4d952c17ed817bfc92d0c45d4585d3dd4716d5585b60cc6","scripts/codeoutline/http.lua":"3d957628ecc9592d57cc68a61e5d4229a71da501eb8fb3aa0bbb5e1cd772adf0","scripts/codeoutline/service.lua":"537b7ef657fc122a85ddf7275e242d225efc65d5316bf863cd3f3132657d3b3e","README.zh-CN.md":"fea0ffb9835e1b78925b1aa0a6a3019591e376d23e94da5b4f58773601e2d7da","DISTRIBUTION.md":"da4a1048fc9b44670fd6fcef97e7d92ac3f50d3523da1773930c49f7e2c38dc3","licenses/mbedtls.txt":"9b405ef4c89342f5eae1dd828882f931747f71001cfba7d114801039b52ad09b","scripts/codeoutline/lang/rust.lua":"294cee85786caaa5f29dedd5058877c7a4786349431faf33b36357ef69406a9e","scripts/codeoutline/index.lua":"dbe88bc5f60b8230e2b69f31c5ffc86e02caea3fb4022ea49ee6210ae2b6a440","scripts/codeoutline/text.lua":"75f9af87ff5ce62def74f69d8972a6b11ff660723fc5cf515369ee3012ff0675","scripts/codeoutline/cli.lua":"f7ac4addd32ced58069954cb81edd4836c6043bb5d143683b80bd7b11554c733","licenses/lua-cmsgpack.txt":"8edfdc5282278a1268d8a6ee52f9245f1a5fe3d1c8065be00330196b1de49873","scripts/xupgate/common.lua":"86267648c0dbbd3a05f90de4d6e1dbee53ba57bf4801783c2ae636224b1f228c","scripts/codeoutline/lsp.lua":"b9c9df2a790344bb8bdc48bd024e912b012750e3bfdbe37750de5add989385da","scripts/codeoutline/index_worker.lua":"8d34748ce1d74384f8f4cf89bfd7a27dcfb6c4d51b6b4936aa9d232814194a8a","scripts/codeoutline/updater.lua":"267c4b6e9704fce710f44d1bfceac69c1857e34e064d8444d7890f0e10d921c7","scripts/codeoutline/lang/c.lua":"9cd8abbdfda6cae5d6c04a9ae68bbd9f7589b217e88b7682917106e80df9b0c5","LICENSE":"1b63179362acd482b4a9a07ca526b3fce6d9103dcded361de2159ade174568b6","scripts/codeoutline/command.lua":"7a0a623b5e965449638938549be8587f9c9490b2a7653877e089a0cc1bb1071c","scripts/codeoutline/lua_bindings.lua":"3f781dfa3d88b0ff4446eb956a861098411873805f5b54536814900a8febad5f","scripts/codeoutline/indirect.lua":"c715b87261d5ad30a84af78ab8dcc468390ab0ea896dce88f8651f7f850be091","scripts/codeoutline/update_sequence.lua":"b73b8749b7b726c05d6931405c2a86f88b908f24cdb40390c2f0e744fbaad162","licenses/libdeflate.txt":"41b60f2caab6bffdd5ba360687bd23ca653c0a1235c00380ecffc939b4cd8d75","scripts/codeoutline/lang/cpp.lua":"47e3dc18cbc8b9a93567897e9ff69a026434a1971fe1dcc3e07d3af03c54a4f2","scripts/codeoutline/common.lua":"dda47a9143ee61086781befc046df24a7317faf9c3fe9a8fd9fbf7b28dd8ed0e","scripts/codeoutline/main.lua":"fff7b1577ab85625714c841773eee07b028fccd86aa9743f15a7ad5fd7a7353b","scripts/codeoutline/js_evidence.lua":"ddb9f8a4f22b1f7fd397a75c6c5660d434133b5148dbf396586bb5b443161776","scripts/codeoutline/update_worker.lua":"7e2ec28e4b911d7b90fd97d0a4c0e2f5b295d1a9200c5c7250e47a99139ca550","scripts/xupgate/proxy.lua":"5bf532e7005f44555d6a5277336e5ad395af060585c13a1cdc2441de50e0dcff","scripts/codeoutline/lang/csharp.lua":"4bfa8555955c7de98ea12d36ee6f7d817c40cb87e77350fe2af4783517190a3d","scripts/codeoutline/completion.lua":"dde4a55ccbc4824f68d7f4c48efd57bddca9c1b371bff2398d85f2930bd53d92","scripts/codeoutline/mcp.lua":"f14a2d0b9625544ad32309358121a5ff304839780f52d5c1c8ec548d56c5e901","scripts/codeoutline/js_resolution.lua":"76be5143d2d5ff5b381c1cde0c1039fa26cb035f309a0aba7c3683efdcdd4b58","scripts/codeoutline/version.lua":"3a5f21a9e5dfaf64c4bb7bc7fc581297a5e0f0b3c07742edc758f884740b2c98","lib/xhttp_codec.lua":"a5b0f127105ba6dbd4a518a214ca55e22c7510e6b2fc8c25c325898d8346ef8c","bin/xnet.exe":"8785c409c74e33a2f464ee8589193c0e2a1e708b9f2cc2099e74d5f80c53cd23","scripts/codeoutline/control.lua":"b67a2e382e021f0793ef313aa4e71faab76f6cb77ca127f499d01ae96f36a8db","scripts/codeoutline/navigation.lua":"5e51ca4a0020607fc45e30209eba4d3cd6089fbc21304e49bd308c60e1cd4899","codeoutline.cmd":"607b60c6d107becdb6793df8f41aaf2cff944baf69f5ece59dba990d0f24c13b","scripts/codeoutline/xscan.lua":"bd95a1b0b7022d029a41aab615897502478b5834612505e8d299343cb5ca8ef9","keys/update-public.pem":"7ff853339e19631b20ed3fa2cf221daa31c581e2e84d161b344b8f06de6562a8","scripts/codeoutline/lang/java.lua":"0ea34298770cb3431f4bc3521c4d2ecf363d55e768d6cd30b3f11ad05d7e8f0d","scripts/codeoutline/daemon.lua":"06863991135cc9a85f07bca8310296f0df9e415b3e2de97ae006393e777b009b","scripts/codeoutline/parse.lua":"cf325eb88e4ac89bdd6a0cbe33fa97f9df9c657f5685febbb7004c77cdd2749c","scripts/xupgate/signature.lua":"f07de8a4093d08cc69d3c1d8296d23318c5d81344ece788d4453a9b3b700f000","licenses/xnet2lua.txt":"1aa8af3df70f60f1ebf2d23e14c27af1606057ad9c32a9a0d15fd76cff257532","scripts/xupgate/http_codec.lua":"a5b0f127105ba6dbd4a518a214ca55e22c7510e6b2fc8c25c325898d8346ef8c","scripts/codeoutline/lang/js.lua":"62570ddc38c974991763e11770059880b87ec87f14578891df9d935af6cb4786","scripts/codeoutline/documents.lua":"320a7d40fd5c0fef03a18df586848059a65c0f4e7ab4b218e9e84561eb5a7007","scripts/codeoutline/parse_pool.lua":"acaafe74a568ec450e428f4a1a2ff704834588bba0f8b808e4c7a1d552861941","scripts/xupgate/http_client.lua":"a189506c3d0fcc454f5e001fdeecdd6349a1019ea0970d11ce2fbfdf035166d6","licenses/luajit.txt":"1b10a02c9474cb908da2d87bc908edd8798f9ad28d9a8c53fbd05c13227f7394","scripts/xupgate/client.lua":"967c29c1eeebd8596458025ab3237816a91591cca64236ea0e7ba1762814e6ba","scripts/codeoutline/lang/kotlin.lua":"cefaad1c412cb42ea6b2027ad9f81ad38d8d821f05c1cfde7f89c600d745a708","scripts/codeoutline/explore.lua":"83cf6f5be4d97a929444b58d6ce741cd31a27342438b64cb06daf3d6e1362942","scripts/codeoutline/parse_worker.lua":"c5f1745d15332c5040b1e97f6da08f2f456d9afe7c2491275cc97d7113b75e45","scripts/codeoutline/lang/go.lua":"3a62d4dc451b0d2f7f2aefd5e77d11449a5d725f59379728eba8dda0aacc13f3"},"runtimeCommit":"d33491598d199b1a2f5fd3d9840c5b17d49b1e13","runtimeBuild":"b9b847244c68283df56e7858fe3daaafd35b756f0ff67cfa379f998133ddf29d","lua":"LuaJIT 2.1.1774896198","version":"0.2.1","sourceCommit":"c5aa041e8a886ac11b3e695f86cb9ec94b4e1760","sourceDirty":false}
package/package.json CHANGED
@@ -1 +1 @@
1
- {"repository":{"url":"git+https://github.com/1dao/codeoutline.git","type":"git"},"files":["bin/","lib/","keys/","scripts/","licenses/","LICENSE","codeoutline","codeoutline.cmd","build-info.json","*.md"],"name":"@codua/codeoutline-win32-x64","version":"0.2.0","publishConfig":{"access":"public"},"description":"CodeOutline native runtime and Lua implementation for win32-x64","os":["win32"],"cpu":["x64","arm64"],"license":"BSD-2-Clause"}
1
+ {"publishConfig":{"access":"public"},"description":"CodeOutline native runtime and Lua implementation for win32-x64","cpu":["x64","arm64"],"license":"BSD-2-Clause","os":["win32"],"repository":{"url":"git+https://github.com/1dao/codeoutline.git","type":"git"},"name":"@codua/codeoutline-win32-x64","version":"0.2.1","files":["bin/","lib/","keys/","scripts/","licenses/","LICENSE","codeoutline","codeoutline.cmd","build-info.json","*.md"]}
@@ -24,7 +24,7 @@ local text = require('codeoutline.text')
24
24
 
25
25
  function M.new(path, language, opts)
26
26
  return { path = path, language = language, nodes = {}, refs = {}, imports = {},
27
- ranges = not opts or opts.ranges ~= false }
27
+ ranges = not opts or opts.ranges ~= false, collect_dispatch = opts and opts.dispatch }
28
28
  end
29
29
 
30
30
  -- Collapse a token span into a one-line signature.
@@ -132,16 +132,25 @@ end
132
132
  -- Drop parser-internal fields so the result is plain data.
133
133
  function M.finish(r, T)
134
134
  M.assign_refs(r)
135
+ if T then require('codeoutline.js_evidence').collect(r, T) end
136
+ if T then require('codeoutline.indirect').collect(r, T) end
137
+ r.collect_dispatch = nil
135
138
  local name, from, kind, line, recv = {}, {}, {}, {}, {}
139
+ local js_receiver = r.js_imports and {}
140
+ local lua_binding = r.lua_imports and {}
136
141
  local start, stop = r.ranges and T and {}, r.ranges and T and {}
137
142
  for i, ref in ipairs(r.refs) do
138
143
  name[i], from[i], kind[i], line[i], recv[i] = ref.name, ref.from, ref.kind, ref.line, ref.recv or false
144
+ if js_receiver then js_receiver[i] = ref.js_receiver or '' end
145
+ if lua_binding then lua_binding[i] = ref.lua_binding or '' end
139
146
  if start then
140
147
  local named = T:text(ref.tok) == ref.name
141
148
  start[i], stop[i] = named and T.s[ref.tok] - 1 or false, named and T.e[ref.tok] or false
142
149
  end
143
150
  end
144
151
  r.refs = { name = name, from = from, kind = kind, line = line, recv = recv, start = start or nil, stop = stop or nil }
152
+ r.refs.js_receiver = js_receiver
153
+ r.refs.lua_binding = lua_binding
145
154
  for i, n in ipairs(r.nodes) do
146
155
  n.ti, n.tj = nil, nil
147
156
  if not r.ranges then
@@ -38,7 +38,7 @@ end
38
38
  local WRAPPERS = {}
39
39
  for word in ([[Option Box Rc Arc RefCell Cell Mutex RwLock Weak unique_ptr shared_ptr weak_ptr Ptr Ref
40
40
  Optional Nullable Promise Future Lazy]]):gmatch('%S+') do WRAPPERS[word] = true end
41
- local TYPE_AFTER = { go = true, rust = true, typescript = true, javascript = true, python = true }
41
+ local TYPE_AFTER = { go = true, rust = true, typescript = true, javascript = true, python = true, kotlin = true }
42
42
  local DYNAMIC = { lua = true, python = true, javascript = true, typescript = true }
43
43
 
44
44
  -- Full parses of type files, keyed by the index record they correspond to.
@@ -109,7 +109,7 @@ local function declared(node, language)
109
109
  rest = rest:sub(#params + 1):gsub('^%s+', '')
110
110
  if rest:sub(1, 1) == '(' then rest = rest:match('^%((.-)[,%)]') or '' end
111
111
  return normalize(rest)
112
- elseif language == 'typescript' or language == 'javascript' then
112
+ elseif language == 'typescript' or language == 'javascript' or language == 'kotlin' then
113
113
  local after = sig:match('%)%s*:%s*([^{=]+)$')
114
114
  return after and normalize(after)
115
115
  elseif language == 'lua' then
@@ -311,12 +311,13 @@ local function declarations(T, a, b, language, skip, out)
311
311
  local k = i + 1
312
312
  while T.k[k] == 'id' do add(k); if is(T, k + 1, ',') then k = k + 2 else break end end
313
313
  elseif kw(T, i, 'as') and T.k[i + 1] == 'id' then add(i + 1) end
314
- elseif language == 'javascript' or language == 'typescript' then
315
- if (kw(T, i, 'let') or kw(T, i, 'const') or kw(T, i, 'var')) and T.k[i + 1] == 'id' then
314
+ elseif language == 'javascript' or language == 'typescript' or language == 'kotlin' then
315
+ if (kw(T, i, 'let') or kw(T, i, 'const') or kw(T, i, 'var') or kw(T, i, 'val')) and T.k[i + 1] == 'id' then
316
316
  local k, type = i + 2, nil
317
317
  if is(T, k, ':') then
318
318
  local e = k + 1
319
- while e <= b and not is(T, e, '=') and not is(T, e, ';') and not is(T, e, ',') do e = e + 1 end
319
+ while e <= b and not is(T, e, '=') and not is(T, e, ';') and not is(T, e, ',')
320
+ and not (language == 'kotlin' and e > k + 1 and T:line(e) > T:eline(e - 1)) do e = e + 1 end
320
321
  type = span(T, k + 1, e - 1); k = e
321
322
  end
322
323
  add(i + 1, type, is(T, k, '=') and k + 1 or nil)
@@ -470,7 +471,7 @@ function Completion:types(name, f)
470
471
  for _, id in ipairs(found) do
471
472
  local q = self.V.nodes[id].qualified
472
473
  local family = graph.family(self.V.files[self.V.node_file[id]].language)
473
- for _, cid in ipairs(self.V.by_name[name] or {}) do
474
+ for _, cid in ipairs(self.V.by_name[self.V.nodes[id].name] or {}) do
474
475
  local c = self.V.nodes[cid]
475
476
  if not set[cid] and accept[c.kind] and c.qualified == q
476
477
  and graph.family(self.V.files[self.V.node_file[cid]].language) == family then
@@ -662,6 +663,7 @@ function Completion:self_types()
662
663
  if owner then return { self.V.id_of[self.f][owner] } end
663
664
  if not fn then return {} end
664
665
  local node = self.rec.nodes[fn]
666
+ if self.language == 'kotlin' and node.receiver then return self:types(normalize(node.receiver)) end
665
667
  local prefix = node.qualified:match('^(.*)::[%w_]+$') or node.qualified:match('^(.*)[%.:][%w_]+$')
666
668
  if not prefix and self.language == 'go' then
667
669
  prefix = (node.sig or ''):match('^func%s*%(%s*[%w_]*%s*%*?%s*([%w_]+)')
@@ -854,10 +856,31 @@ function M.complete(req)
854
856
  end
855
857
  for alias in pairs(self.aliases) do entries[#entries + 1] = { name = alias, kind = 'namespace', detail = 'module' } end
856
858
  for _, node in ipairs(self.rec.nodes) do
857
- if not node.parent and not node.qualified:find('[%.:]') then
859
+ if not node.parent and (self.language == 'kotlin' or not node.qualified:find('[%.:]')) then
858
860
  entries[#entries + 1] = { name = node.name, kind = node.kind, node = node, file = f }
859
861
  end
860
862
  end
863
+ if self.language == 'kotlin' then
864
+ local direct = navigation.deps(V, f)
865
+ for g in pairs(direct) do
866
+ if self:expired() then break end
867
+ local rec = V.files[g]
868
+ if rec.language == 'kotlin' then
869
+ for _, node in ipairs(rec.nodes) do
870
+ local visible = not node.parent and rec.package == self.rec.package and node.name or nil
871
+ for _, imp in ipairs(self.rec.imports) do
872
+ if node.qualified == imp.path then visible = imp.alias or node.name
873
+ elseif imp.path:sub(-2) == '.*' and graph.owner(node.qualified) == imp.path:sub(1, -3) then
874
+ visible = node.name
875
+ end
876
+ end
877
+ if visible and not node.static then
878
+ entries[#entries + 1] = { name = visible, kind = node.kind, node = node, file = g }
879
+ end
880
+ end
881
+ end
882
+ end
883
+ end
861
884
  if self.language == 'c' or self.language == 'cpp' then
862
885
  -- Use actual includes (including transitive headers), not paired
863
886
  -- implementation files, whose private symbols are not visible here.
@@ -122,7 +122,7 @@ function Doc:offset(position)
122
122
  return p
123
123
  end
124
124
 
125
- local extensions = { javascript = 'js', typescript = 'ts', python = 'py', csharp = 'cs', rust = 'rs', cpp = 'cpp' }
125
+ local extensions = { javascript = 'js', typescript = 'ts', python = 'py', csharp = 'cs', rust = 'rs', cpp = 'cpp', kotlin = 'kt' }
126
126
  local function parser_name(doc)
127
127
  local name = doc.path or ('document.' .. (extensions[doc.language] or doc.language or 'txt'))
128
128
  if not parse.language(name) and doc.language then name = 'document.' .. (extensions[doc.language] or doc.language) end
@@ -79,7 +79,7 @@ local function segments(name)
79
79
  end
80
80
 
81
81
  local SOURCE_EXT = {}
82
- for e in ('c h py pyi java lua cpp cc cxx hpp hh hxx'):gmatch('%a+') do SOURCE_EXT[e] = true end
82
+ for e in ('c h py pyi java kt kts lua cpp cc cxx hpp hh hxx'):gmatch('%a+') do SOURCE_EXT[e] = true end
83
83
 
84
84
  -- Query -> candidate terms: qualified chains, identifiers, file names.
85
85
  local function terms(query)
@@ -479,6 +479,7 @@ function M.run(G, idx, query, opts)
479
479
  if not seen_in[src] and #callers < M.LIST_CAP then
480
480
  seen_in[src] = true
481
481
  callers[#callers + 1] = string.format('%s (%s:%d)', G.nodes[src].name, G.files[G.node_file[src]].path, inn[i + 1])
482
+ .. (inn[i + 2]:match('^indirect:') and (' [' .. inn[i + 2] .. ']') or '')
482
483
  end
483
484
  end
484
485
  for i = 1, #out, graph.EDGE do
@@ -486,6 +487,7 @@ function M.run(G, idx, query, opts)
486
487
  if not seen_out[dst] and #callees < M.LIST_CAP then
487
488
  seen_out[dst] = true
488
489
  callees[#callees + 1] = G.nodes[dst].name .. ' (' .. graph.where(G, dst) .. ')'
490
+ .. (out[i + 2]:match('^indirect:') and (' [' .. out[i + 2] .. ']') or '')
489
491
  end
490
492
  end
491
493
  if #callers > 0 or #callees > 0 then
@@ -27,6 +27,8 @@
27
27
  -- to MAX_TIES targets instead of guessing.
28
28
 
29
29
  local control = require('codeoutline.control')
30
+ local js_resolution = require('codeoutline.js_resolution')
31
+ local lua_bindings = require('codeoutline.lua_bindings')
30
32
  local M = {}
31
33
 
32
34
  M.EDGE = 3
@@ -66,7 +68,7 @@ local function push3(t, k, a, b, c)
66
68
  end
67
69
 
68
70
  -- Files a file depends on, resolved from its #include / import records.
69
- local function resolve_deps(G, f)
71
+ local function resolve_deps(G, f, js_context)
70
72
  local rec = G.files[f]
71
73
  local deps = {}
72
74
  local function add(g) if g and g ~= f then deps[g] = true end end
@@ -125,19 +127,7 @@ local function resolve_deps(G, f)
125
127
  -- require 'a.b' -> a/b.lua or a/b/init.lua anywhere under the root
126
128
  -- (package.path prefixes like scripts/?.lua vary per project);
127
129
  -- dofile/loadfile take a path.
128
- local wants
129
- if imp.kind == 'require' then
130
- local sub = path:gsub('%.', '/')
131
- wants = { sub .. '.lua', sub .. '/init.lua' }
132
- else
133
- wants = { (path:gsub('\\', '/'):gsub('^%./', '')) }
134
- end
135
- for _, want in ipairs(wants) do
136
- for _, g in ipairs(G.by_base[basename(want)] or {}) do
137
- local p = G.files[g].path
138
- if p == want or p:sub(-(#want + 1)) == '/' .. want then add(g) end
139
- end
140
- end
130
+ for _, g in ipairs(lua_bindings.modules(G, imp, js_context and js_context.lua)) do add(g) end
141
131
  elseif rec.language == 'go' then
142
132
  -- import "github.com/org/repo/pkg/sub": the package is the directory
143
133
  -- whose path ends with the longest matching suffix of the import
@@ -155,22 +145,7 @@ local function resolve_deps(G, f)
155
145
  if hit then break end
156
146
  end
157
147
  elseif rec.language == 'javascript' or rec.language == 'typescript' then
158
- -- relative specifiers only; bare package names live in node_modules
159
- if path:sub(1, 1) == '.' then
160
- local base = here
161
- local rel = path
162
- while true do
163
- if rel:sub(1, 2) == './' then rel = rel:sub(3)
164
- elseif rel:sub(1, 3) == '../' then base = dirname(base); rel = rel:sub(4)
165
- else break end
166
- end
167
- local stemp = (base ~= '' and (base .. '/') or '') .. rel
168
- stemp = stemp:gsub('%.[mc]?js$', '') -- TS sources imported as ./x.js
169
- for _, ext in ipairs({ '', '.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs', '.mts',
170
- '/index.ts', '/index.tsx', '/index.js', '/index.mjs' }) do
171
- add(G.file_index[stemp .. ext])
172
- end
173
- end
148
+ add(js_resolution.module(G, f, path, js_context))
174
149
  elseif rec.language == 'csharp' then
175
150
  for _, g in ipairs(G.ns_files[path] or {}) do add(g) end
176
151
  elseif rec.language == 'rust' then
@@ -202,9 +177,12 @@ local function resolve_deps(G, f)
202
177
  if found then break end
203
178
  end
204
179
  end
205
- elseif rec.language == 'java' then
180
+ elseif rec.language == 'java' or rec.language == 'kotlin' then
206
181
  if path:sub(-2) == '.*' then
207
182
  for _, g in ipairs(G.pkg_files[path:sub(1, -3)] or {}) do add(g) end
183
+ if rec.language == 'kotlin' then
184
+ for _, id in ipairs(G.by_owner[path:sub(1, -3)] or {}) do add(G.node_file[id]) end
185
+ end
208
186
  else
209
187
  for _, id in ipairs(G.by_qualified[path] or {}) do add(G.node_file[id]) end
210
188
  end
@@ -212,7 +190,7 @@ local function resolve_deps(G, f)
212
190
  end
213
191
  -- Java: the whole package is visible without imports; Go: the whole
214
192
  -- directory is one package; C#: the file's own namespaces.
215
- if rec.language == 'java' and rec.package then
193
+ if (rec.language == 'java' or rec.language == 'kotlin') and rec.package then
216
194
  for _, g in ipairs(G.pkg_files[rec.package] or {}) do add(g) end
217
195
  elseif rec.language == 'go' then
218
196
  for _, g in ipairs(G.dir_files[here] or {}) do add(g) end
@@ -291,7 +269,7 @@ local function score(G, f, src_id, ref_kind, recv, cid, deps, paired, owner)
291
269
  -- method project-wide (str.format -> some format()) is mostly wrong,
292
270
  -- so only local candidates qualify.
293
271
  return nil
294
- elseif ref_kind == 'call' and G.files[f].language == 'java' and src_id then
272
+ elseif ref_kind == 'call' and (G.files[f].language == 'java' or G.files[f].language == 'kotlin') and src_id then
295
273
  -- unqualified call inside a class: implicit this
296
274
  if owner and c.parent and G.id_of[cf][c.parent] == owner then s = s + 30 end
297
275
  end
@@ -305,10 +283,31 @@ local function is_decl(node) return node.kind == 'prototype' or node.decl end
305
283
  local scored_ids, scored_vals = {}, {}
306
284
 
307
285
  -- accept overrides the node kinds the ref kind may bind to (navigation only).
308
- local function resolve_ref(G, f, src_id, name, kind, recv, deps, paired, accept)
286
+ local function resolve_ref(G, f, src_id, name, kind, recv, deps, paired, accept, evidence, js_context)
309
287
  if kind == 'annotation' then return nil end
310
288
  accept = accept or (kind == 'new' and NEWABLE) or (kind == 'ref' and VALUE) or CALLABLE
289
+ if evidence == '' then evidence = nil end
290
+ local exact = js_resolution.resolve(G, f, name, kind, recv, evidence, js_context)
291
+ if exact == nil then exact = lua_bindings.resolve(G, f, name, evidence, js_context and js_context.lua) end
292
+ if exact ~= nil then
293
+ local result = {}
294
+ for _, id in ipairs(exact) do if accept[G.nodes[id].kind] then result[#result + 1] = id end end
295
+ return result
296
+ end
311
297
  local cands = G.by_name[name]
298
+ if G.files[f].language == 'kotlin' and not recv then
299
+ for _, imp in ipairs(G.files[f].imports) do
300
+ if (imp.alias or imp.path:match('([^.]+)$')) == name then
301
+ cands = {}
302
+ -- by_name also includes unsaved LSP overlays; by_qualified is
303
+ -- a resident index and may still name the masked disk nodes.
304
+ for _, id in ipairs(G.by_name[imp.path:match('([^.]+)$')] or {}) do
305
+ if G.nodes[id].qualified == imp.path then cands[#cands + 1] = id end
306
+ end
307
+ break
308
+ end
309
+ end
310
+ end
312
311
  if not cands then return nil end
313
312
  -- Score first: score() rejects other languages and statics of other
314
313
  -- files, so "is there a real definition?" is only asked among the
@@ -316,7 +315,7 @@ local function resolve_ref(G, f, src_id, name, kind, recv, deps, paired, accept)
316
315
  -- same-named nodes let a Python `def work` hide the C prototype of
317
316
  -- `work`, after which the Python def was filtered out too.)
318
317
  local self_call = kind == 'member_call' and src_id and (recv == 'self' or recv == 'this' or recv == 'cls')
319
- local owner = (self_call or (kind == 'call' and src_id and G.files[f].language == 'java'))
318
+ local owner = (self_call or (kind == 'call' and src_id and (G.files[f].language == 'java' or G.files[f].language == 'kotlin')))
320
319
  and owner_class(G, src_id) or nil
321
320
  -- score() rejects an unknown-receiver member call to an unrelated file;
322
321
  -- checking placement first skips most candidates of common method names.
@@ -488,6 +487,7 @@ end
488
487
  -- build is simply discarded.
489
488
  function M.build(idx)
490
489
  local G = M.new()
490
+ G.root = idx.root
491
491
  local paths = {}
492
492
  for rel in pairs(idx.files) do paths[#paths + 1] = rel end
493
493
  table.sort(paths)
@@ -509,10 +509,13 @@ function M.query(symbols, opts)
509
509
  local Q = setmetatable({ out = {}, inn = {},
510
510
  stats = { expanded = 0, incoming_scans = 0, resolved_refs = 0 }, incomplete = false }, { __index = symbols })
511
511
  local dependencies, references = {}, {}
512
+ local js_context = js_resolution.context(symbols)
513
+ js_context.lua = lua_bindings.context(symbols)
514
+ local indirect = require('codeoutline.indirect').query(symbols, opts.dispatch_rules)
512
515
  local function deps(f)
513
516
  local entry = dependencies[f]
514
517
  if not entry then
515
- local direct, paired = resolve_deps(symbols, f)
518
+ local direct, paired = resolve_deps(symbols, f, js_context)
516
519
  entry = { direct, paired }; dependencies[f] = entry
517
520
  end
518
521
  return entry[1], entry[2]
@@ -523,7 +526,7 @@ function M.query(symbols, opts)
523
526
  local direct, paired = deps(f)
524
527
  Q.stats.resolved_refs = Q.stats.resolved_refs + 1
525
528
  return resolve_ref(symbols, f, ids[refs.from[i]], refs.name[i], refs.kind[i],
526
- refs.recv[i] or nil, direct, paired)
529
+ refs.recv[i] or nil, direct, paired, nil, refs.lua_binding and refs.lua_binding[i] or refs.js_receiver and refs.js_receiver[i], js_context)
527
530
  end
528
531
  setmetatable(Q.out, { __index = function(cache, id)
529
532
  control.check()
@@ -541,6 +544,11 @@ function M.query(symbols, opts)
541
544
  references[f] = grouped
542
545
  end
543
546
  local edges = {}
547
+ for _, edge in ipairs(indirect.outgoing(id)) do
548
+ edges[#edges + 1] = edge.target
549
+ edges[#edges + 1] = edge.line
550
+ edges[#edges + 1] = edge.kind
551
+ end
544
552
  for _, i in ipairs(grouped[id] or {}) do
545
553
  control.check()
546
554
  for _, dst in ipairs(targets(f, i) or {}) do
@@ -563,19 +571,34 @@ function M.query(symbols, opts)
563
571
  if not found then return end
564
572
  local incoming = {}
565
573
  for id in pairs(wanted) do incoming[id] = {} end
574
+ local indirect_incoming = indirect.incoming(wanted)
575
+ for _, f in ipairs(symbols.file_order) do
576
+ for _, src in ipairs(symbols.id_of[f]) do
577
+ for _, edge in ipairs(indirect_incoming[src] or {}) do
578
+ if wanted[edge.target] then push3(incoming, edge.target, src, edge.line, edge.kind) end
579
+ end
580
+ end
581
+ end
566
582
  self.stats.incoming_scans = self.stats.incoming_scans + 1
567
583
  -- Hot loop over every reference: numeric loops, hoisted fields, and the
568
584
  -- selective name test first. Checkpoints run per file and per chunk.
569
585
  local files = symbols.files
570
586
  for _, f in ipairs(symbols.file_order) do
571
587
  control.check()
588
+ local aliases = {}
589
+ for _, binding in ipairs(files[f].js_imports or {}) do aliases[binding.local_name] = true end
590
+ if files[f].language == 'kotlin' then
591
+ for _, imp in ipairs(files[f].imports) do
592
+ if imp.alias and names[imp.path:match('([^.]+)$')] then aliases[imp.alias] = true end
593
+ end
594
+ end
572
595
  local refs = files[f].refs
573
596
  local ref_names, froms = refs.name, refs.from
574
597
  local count = #ref_names
575
598
  for first = 1, count, 4096 do
576
599
  if first > 1 then control.check() end
577
600
  for i = first, math.min(count, first + 4095) do
578
- if names[ref_names[i]] and froms[i] > 0 then
601
+ if (names[ref_names[i]] or aliases[ref_names[i]] or aliases[refs.recv[i]] or (refs.lua_binding and refs.lua_binding[i] ~= '')) and froms[i] > 0 then
579
602
  for _, dst in ipairs(targets(f, i) or {}) do
580
603
  if wanted[dst] then
581
604
  push3(incoming, dst, symbols.id_of[f][froms[i]], refs.line[i], refs.kind[i])
@@ -27,8 +27,8 @@ local INDEX_PARSE = { ranges = false }
27
27
  -- rebuilds stale caches instead of silently reusing old parse results.
28
28
  M.VERSION = (function()
29
29
  local parts = {}
30
- for _, m in ipairs({ 'xscan', 'text', 'common', 'parse', 'lang.c', 'lang.cpp', 'lang.lua', 'lang.python',
31
- 'lang.java', 'lang.go', 'lang.js', 'lang.csharp', 'lang.rust' }) do
30
+ for _, m in ipairs({ 'xscan', 'text', 'common', 'indirect', 'js_evidence', 'lua_bindings', 'parse', 'lang.c', 'lang.cpp', 'lang.lua', 'lang.python',
31
+ 'lang.java', 'lang.kotlin', 'lang.go', 'lang.js', 'lang.csharp', 'lang.rust' }) do
32
32
  local file = package.searchpath and package.searchpath('codeoutline.' .. m, package.path)
33
33
  local h = file and io.open(file, 'rb')
34
34
  if h then parts[#parts + 1] = h:read('a'); h:close() end