haxe icon indicating copy to clipboard operation
haxe copied to clipboard

No completion for module-level stuff

Open RblSb opened this issue 4 years ago • 10 comments

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

RblSb avatar Jul 05 '21 05:07 RblSb

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?

RblSb avatar Jul 05 '21 05:07 RblSb

I guess compiler considers it less relevant than thousands of js externs with F and o in class names.

RealyUniqueName avatar Jul 05 '21 08:07 RealyUniqueName

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.

Simn avatar Jul 05 '21 08:07 Simn

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...

RblSb avatar Jul 05 '21 08:07 RblSb

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.

RealyUniqueName avatar Jul 06 '21 15:07 RealyUniqueName

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

haxiomic avatar Sep 01 '21 19:09 haxiomic

What is best way to debug completion responses to detect if something is compiler or ide fault?

RblSb avatar Oct 08 '21 23:10 RblSb

@RblSb checkout this repro project and tweak you your needs https://github.com/HaxeFoundation/haxe/files/7093766/haxe-module-level-display.zip

haxiomic avatar Oct 09 '21 06:10 haxiomic

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.

RblSb avatar Oct 16 '21 09:10 RblSb

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:

  1. Something need more filtering (--display "src/Main.hx"@29 still returns empty <list>, even if there is module-level results)
  2. Selecting field from SomeClass.| makes import SomeClass.someConstant; instead of simple completion.
  3. @haxiomic issue is different: if you change SomeClass.hx to 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).

RblSb avatar Mar 18 '22 02:03 RblSb