HaxeFoundation / haxe

Haxe - The Cross-Platform Toolkit
https://haxe.org
6.09k stars 646 forks source link

Completion completely broken with --next in hxml #11067

Open tobil4sk opened 1 year ago

tobil4sk commented 1 year ago

In Haxe 4.2.5, if the hxml contained --next, completion worked normally and it just used the first build found in the hxml.

However, with 4.3.0 development builds since 7ebd72bbe61648193d436106f70ae1a298f82b3c, completion/hovering completely fails as soon as there is a --next flag in the hxml that is followed by anything. Here is a sample hxml:

-main Main
--interp
--next
-main Main
--interp

This is the error that shows up in the vshaxe output:

[Error - 16:14:47] Request textDocument/hover failed.
  Message: {"jsonrpc":"2.0","id":8,"result":{"result":{"documentation":null,"range":{"start":{"line":53,"character":31},"end":{"line":53,"character":38}},"item":{"kind":"Literal","args":{"name":"\"db.db\""},"type":{"kind":"TInst","args":{"path":{"pack":[],"moduleName":"String","typeName":"String","importStatus":0},"params":[]}}},"expected":{"type":{"kind":"TInst","args":{"path":{"typeName":"String","moduleName":"String","pack":[]},"params":[]}}}},"timestamp":1680275687.207117}}Error: Display file does not exist
  Code: -32603 

Verbose output:

Processing Arguments [--cwd,/path/to/project,-D,display-details,--no-output,interp.hxml,--display,{"jsonrpc":"2.0","id":29,"method":"display/hover","params":{"file":"/path/to/project/Test.hx","contents":"function main() {\n\ttrace(\"hello world\");\n}","offset":29}}]
Defines dce=std,display=1,display_details=1,display_stdin=1,eval=1,haxe=4.3.0-rc.1,haxe3=1,haxe4=1,haxe_ver=4.300,interp=1,source_header=Generated by Haxe 4.3.0-rc.1,sys=1,target.name=eval,target.sys=1,target.threaded=1,target.unicode=1,true=1
Using signature db64600cc6f8212c6f9dfe154d2e49e4
Display position: /path/to/project/Test.hx: 29-29
Defines dce=std,eval=1,haxe=4.3.0-rc.1,haxe3=1,haxe4=1,haxe_ver=4.300,interp=1,source_header=Generated by Haxe 4.3.0-rc.1,sys=1,target.name=eval,target.sys=1,target.threaded=1,target.unicode=1,true=1
Using signature db64600cc6f8212c6f9dfe154d2e49e4
Display position: ?: -1--1
> Error: Display file does not exist
Stats = 0 files, 1 classes, 1 methods, 0 macros
Time spent : 0.002s
[Error - 16:23:58] Request textDocument/hover failed.
  Message: {"jsonrpc":"2.0","id":29,"result":{"result":{"documentation":null,"range":{"start":{"line":1,"character":7},"end":{"line":1,"character":20}},"item":{"kind":"Literal","args":{"name":"\"hello world\""},"type":{"kind":"TInst","args":{"path":{"pack":[],"moduleName":"String","typeName":"String","importStatus":0},"params":[]}}},"expected":{"type":{"kind":"TDynamic","args":null},"name":{"name":"v","kind":0,"doc":null}}},"timestamp":1680276238.053253}}Error: Display file does not exist
  Code: -32603 
Simn commented 1 year ago

Oh no...

Simn commented 1 year ago

I'm seeing an error on readClassPaths already:

Processing Arguments [--cwd,c:/Users/simn/Desktop/Newfolder,-D,display-details,--no-output,--times,-D,macro-times,build.hxml,--display,{"jsonrpc":"2.0","id":2,"method":"server/readClassPaths"}]
Defines dce=std,display_details=1,eval=1,haxe=4.3.0-rc.1,haxe3=1,haxe4=1,haxe_ver=4.300,interp=1,macro_times=1,source_header=Generated by Haxe 4.3.0-rc.1+da375d759,sys=1,target.name=eval,target.sys=1,target.threaded=1,target.unicode=1,true=1
Using signature 52ee16b3475adf9153eb4803835ac0a3
Display position: ?: -1--1
 1,evl: changed directories: []
 1,evl: Cached 0 modules
Defines dce=std,eval=1,haxe=4.3.0-rc.1,haxe3=1,haxe4=1,haxe_ver=4.300,interp=1,source_header=Generated by Haxe 4.3.0-rc.1+da375d759,sys=1,target.name=eval,target.sys=1,target.threaded=1,target.unicode=1,true=1
Using signature 52ee16b3475adf9153eb4803835ac0a3
Display position: ?: -1--1
 1,evl: Cached 57 modules
Stats = 0 files, 0 classes, 0 methods, 0 macros
Time spent : 0.006s
Failed - Exception while handling Haxe completion response: Unexpected token  in JSON at position 734
tobil4sk commented 1 year ago

Hm, wasn't happening for me before but now I made a fresh empty project, and it is:

Haxe language server started
Haxe Path: haxe
Using --server-connect
Haxe connected!
Processing Arguments [--display,{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"supportsResolve":true,"exclude":["zpp_nape"],"maxCompletionItems":1000}}]
 0,  x: Cached 0 modules
Completion Response =
{"jsonrpc":"2.0","id":0,"result":{"result":{"methods":["display/definition","server/contexts","server/moduleCreated","server/invalidate","server/module","server/files","initialize","display/completion","typer/compiledTypes","display/references","server/modules","server/memory/context","display/completionItem/resolve","display/typeDefinition","server/memory","display/implementation","display/hover","display/package","display/signatureHelp","server/type","server/typeContexts","server/memory/module","server/readClassPaths","server/configure"],"haxeVersion":{"major":4,"minor":3,"patch":0,"pre":"rc.1","build":null},"protocolVersion":{"major":0,"minor":5,"patch":0}},"timestamp":1680278875.676538}}
Stats = 0 files, 0 classes, 0 methods, 0 macros
Time spent : 0.000s
Processing Arguments [--display,{"jsonrpc":"2.0","id":1,"method":"server/configure","params":{"noModuleChecks":true,"print":{"completion":false,"reusing":false},"legacyCompletion":false}}]
 0,  x: Cached 0 modules
Stats = 0 files, 0 classes, 0 methods, 0 macros
Time spent : 0.000s
Processing Arguments [--no-output,--each,--no-output,build.hxml]
Defines dce=std,eval=1,haxe=4.3.0-rc.1,haxe3=1,haxe4=1,haxe_ver=4.300,interp=1,source_header=Generated by Haxe 4.3.0-rc.1,sys=1,target.name=eval,target.sys=1,target.threaded=1,target.unicode=1,true=1
Using signature db64600cc6f8212c6f9dfe154d2e49e4
Display position: ?: -1--1
Listening on port 6004
 1,evl: Cached 71 modules
Defines dce=std,eval=1,haxe=4.3.0-rc.1,haxe3=1,haxe4=1,haxe_ver=4.300,interp=1,source_header=Generated by Haxe 4.3.0-rc.1,sys=1,target.name=eval,target.sys=1,target.threaded=1,target.unicode=1,true=1
Using signature db64600cc6f8212c6f9dfe154d2e49e4
Display position: ?: -1--1
 1,evl: Cached 57 modules
 1,evl: found 39 directories
Stats = 111 files, 110 classes, 589 methods, 0 macros
Time spent : 0.114s
Processing Arguments [--cwd,/path/to/project,-D,display-details,--no-output,build.hxml,--display,/path/to/project/Main.hx@0@diagnostics]
Defines dce=std,display_details=1,eval=1,haxe=4.3.0-rc.1,haxe3=1,haxe4=1,haxe_ver=4.300,interp=1,source_header=Generated by Haxe 4.3.0-rc.1,sys=1,target.name=eval,target.sys=1,target.threaded=1,target.unicode=1,true=1
Using signature db64600cc6f8212c6f9dfe154d2e49e4
Display position: /path/to/project/Main.hx: 0-0
 1,evl: changed directories: []
 1,evl: Cached 57 modules
Defines dce=std,eval=1,haxe=4.3.0-rc.1,haxe3=1,haxe4=1,haxe_ver=4.300,interp=1,source_header=Generated by Haxe 4.3.0-rc.1,sys=1,target.name=eval,target.sys=1,target.threaded=1,target.unicode=1,true=1
Using signature db64600cc6f8212c6f9dfe154d2e49e4
Display position: ?: -1--1
 1,evl: Cached 57 modules
Stats = 0 files, 0 classes, 0 methods, 0 macros
Time spent : 0.003s
Error parsing diagnostics response: Unexpected token  in JSON at position 2
Processing Arguments [--cwd,/path/to/project,-D,display-details,--no-output,build.hxml,--display,{"jsonrpc":"2.0","id":2,"method":"server/readClassPaths"}]
Defines dce=std,display_details=1,eval=1,haxe=4.3.0-rc.1,haxe3=1,haxe4=1,haxe_ver=4.300,interp=1,source_header=Generated by Haxe 4.3.0-rc.1,sys=1,target.name=eval,target.sys=1,target.threaded=1,target.unicode=1,true=1
Using signature db64600cc6f8212c6f9dfe154d2e49e4
Display position: ?: -1--1
 1,evl: changed directories: []
 1,evl: Cached 0 modules
Defines dce=std,eval=1,haxe=4.3.0-rc.1,haxe3=1,haxe4=1,haxe_ver=4.300,interp=1,source_header=Generated by Haxe 4.3.0-rc.1,sys=1,target.name=eval,target.sys=1,target.threaded=1,target.unicode=1,true=1
Using signature db64600cc6f8212c6f9dfe154d2e49e4
Display position: ?: -1--1
 1,evl: Cached 57 modules
Stats = 0 files, 0 classes, 0 methods, 0 macros
Time spent : 0.002s
Failed - Exception while handling Haxe completion response: Unexpected token  in JSON at position 88

Called from <unknown>.accessSync (node:fs line 250 column 3)
Called from e.accessSync (node:electron/js2c/asar_bundle line 5 column 8277)
Called from <unknown>.exists (/home/HOME/.vscode/extensions/nadako.vshaxe-2.27.0/server/bin/server.js line 1 column 588203)
Called from <unknown>.start (/home/HOME/.vscode/extensions/nadako.vshaxe-2.27.0/server/bin/server.js line 1 column 452216)
Called from <unknown>.restartServer (/home/HOME/.vscode/extensions/nadako.vshaxe-2.27.0/server/bin/server.js line 1 column 282269)
Called from /home/HOME/.vscode/extensions/nadako.vshaxe-2.27.0/server/bin/server.js line 1 column 275532
Called from <unknown>.onDidChangeConfiguration (/home/HOME/.vscode/extensions/nadako.vshaxe-2.27.0/server/bin/server.js line 1 column 267358)
Called from <unknown>.handleNotification (/home/HOME/.vscode/extensions/nadako.vshaxe-2.27.0/server/bin/server.js line 1 column 518353)
Called from <unknown>.handleMessage (/home/HOME/.vscode/extensions/nadako.vshaxe-2.27.0/server/bin/server.js line 1 column 516988)
Called from <unknown>.onData (/home/HOME/.vscode/extensions/nadako.vshaxe-2.27.0/server/bin/server.js line 1 column 520368)
Processing Arguments [--cwd,/path/to/project,-D,display-details,--no-output,build.hxml,--display,{"jsonrpc":"2.0","id":3,"method":"display/package","params":{"file":"/path/to/project/Main.hx"}}]
Defines dce=std,display=1,display_details=1,eval=1,haxe=4.3.0-rc.1,haxe3=1,haxe4=1,haxe_ver=4.300,interp=1,source_header=Generated by Haxe 4.3.0-rc.1,sys=1,target.name=eval,target.sys=1,target.threaded=1,target.unicode=1,true=1
Using signature db64600cc6f8212c6f9dfe154d2e49e4
Display position: /path/to/project/Main.hx: -1--1
Defines dce=std,eval=1,haxe=4.3.0-rc.1,haxe3=1,haxe4=1,haxe_ver=4.300,interp=1,source_header=Generated by Haxe 4.3.0-rc.1,sys=1,target.name=eval,target.sys=1,target.threaded=1,target.unicode=1,true=1
Using signature db64600cc6f8212c6f9dfe154d2e49e4
Display position: ?: -1--1
> Error: Display file does not exist
Stats = 0 files, 0 classes, 0 methods, 0 macros
Time spent : 0.000s
Processing Arguments [--cwd,/path/to/project,-D,display-details,--no-output,build.hxml,--display,/path/to/project/Main.hx@0@diagnostics]
Defines dce=std,display_details=1,eval=1,haxe=4.3.0-rc.1,haxe3=1,haxe4=1,haxe_ver=4.300,interp=1,source_header=Generated by Haxe 4.3.0-rc.1,sys=1,target.name=eval,target.sys=1,target.threaded=1,target.unicode=1,true=1
Using signature db64600cc6f8212c6f9dfe154d2e49e4
Display position: /path/to/project/Main.hx: 0-0
 1,evl: changed directories: []
 1,evl: Cached 57 modules
Defines dce=std,eval=1,haxe=4.3.0-rc.1,haxe3=1,haxe4=1,haxe_ver=4.300,interp=1,source_header=Generated by Haxe 4.3.0-rc.1,sys=1,target.name=eval,target.sys=1,target.threaded=1,target.unicode=1,true=1
Using signature db64600cc6f8212c6f9dfe154d2e49e4
Display position: ?: -1--1
 1,evl: Cached 57 modules
Stats = 0 files, 0 classes, 0 methods, 0 macros
Time spent : 0.003s
Error parsing diagnostics response: Unexpected token  in JSON at position 2
Simn commented 1 year ago

It only happens if you trace("Hello World") because then the output gets messed up... x)

The other problem is probably related to --cwd in some way.

Simn commented 1 year ago

I made it stop after the first compilation if there's a --display. That's not very elegant, but if this is what used to happen anyway then it should be fine.

tobil4sk commented 1 year ago

if this is what used to happen anyway then it should be fine.

Well, this is what it looked like at least, because when hovering over define flags they would always have values from the initial build before the --next. Also, only --cmds from the first batch used to run, although now it seems like all --cmd flags might be ignored during display runs.

But thanks! Completion is working again now. Not sure how I didn't come across this issue earlier...