haxe
haxe copied to clipboard
No completion for module-level stuff
src/Foo.hx
function hi():Void {
trace("hi");
}
src/client/Main.hx
package client;
function main() {
Fo| // or Foo.|
}
build.hxml
--class-path src
--main client.Main
# -D analyzer-optimize
# --dce full
# --interp
--js main.js
Works with --interp. Works with class Foo + public static Project: test.zip
Also, for interp on completion for Foo.h<tab> you will get import Foo.hi; ... hi| instead of simple Foo.hi|. I don't think that this behaviour is better for most cases, what do you think, @Gama11?
I guess compiler considers it less relevant than thousands of js externs with F and o in class names.
Hmm, that shouldn't be the case because the term starts with Fo, which is supposed to rank higher than these letters randomly appearing in other places.
Any other name instead of Foo doesn't work too. You also do not need client subfolder, feels like it's just doesn't work for js...
Compiler actually emits data for "Foo.hi" in completion resposnse (even with --js).
It looks like this:
...}, {
"kind": "Type",
"args": {
"path": {
"pack": [],
"moduleName": "Foo",
"typeName": "hi",
"importStatus": 1
},
"kind": 8,
"meta": [],
"pos": {
"file": "src/Foo.hx",
"min": 0,
"max": 36
},
"params": [],
"isExtern": false,
"isFinal": true,
"isAbstract": false,
"doc": null
},
"index": 318
}, {...
I guess from this point it's responsibility of an ide to sort completion items accordingly.
I have the same problem with my sublime text plugin, like vshaxe, I cannot get completion for module-level statics
When I try to use --display on a test project (attached) the module level fields are missing, I get back:
<list>
<i n="someStatic" k="var"><t>Int</t><d></d></i>
<i n="AnotherClass" k="type"><t>AnotherClass</t><d></d></i>
</list>
After running
--main Main
--js main.js
-D display-details
--display "Main.hx"@27
When I expect to get a list of module level variables and functions
Am I missing something with the display arguments? Also, is there a display arg for json 👀?
Attached repro project to demonstrate the above haxe-module-level-display.zip
Tested with haxe 4.2.3
What is best way to debug completion responses to detect if something is compiler or ide fault?
@RblSb checkout this repro project and tweak you your needs https://github.com/HaxeFoundation/haxe/files/7093766/haxe-module-level-display.zip
Thanks, not sure if completion handles module fields + class in single file, so it can be different case.
In my case only with module field, --display still returns empty <list></list>, when there is completion for non-js targets, maybe vshaxe has some fallback for basic completion request. There is enough layers of implementation, so i cannot find related code to these two problems without leads. And about my second post in this thread, this completion behavior should be related to https://github.com/HaxeFoundation/haxe/issues/9459.
Want to confirm Simn's guess that my problem seems about "too much completion items, so after ide filtering there is no useful items" for js target, because "haxe.maxCompletionItems": 2000 in vscode settings will return completion results back for this sample:
Main.hx
function main() {
SomeClass.|
}
SomeClass.hx
function moduleFn() {}
final someConstant = 42;
--class-path src
--main Main
--js build/main.js
Summarizing problems:
- Something need more filtering (
--display "src/Main.hx"@29still returns empty<list>, even if there is module-level results) - Selecting field from
SomeClass.|makesimport SomeClass.someConstant;instead of simple completion. - @haxiomic issue is different: if you change
SomeClass.hxto this:
function moduleFn() {}
final someConstant = 42;
class SomeClass {
public static var foo = 1;
}
Then SomeClass.| will only suggest SomeClass.foo result (not as auto-import).