Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parsing Haxe code at compile time #62

Closed
lublak opened this issue Feb 20, 2022 · 2 comments
Closed

parsing Haxe code at compile time #62

lublak opened this issue Feb 20, 2022 · 2 comments

Comments

@lublak
Copy link
Contributor

lublak commented Feb 20, 2022

We have first this issue: Simn/hxparse#59
Additionally i get this:
C:\HaxeToolkit\haxe\lib\haxeparser/git/src/haxeparser/HaxeParser.hx:369: character 1 : You cannot use @:build inside a macro : make sure that your type is not used in macro
If i remove just the static function it works.

Another error: C:\HaxeToolkit\haxe\lib\haxeparser/git/src/haxeparser/HaxeParser.hx:369: character 1 : You cannot use @:build inside a macro : make sure that your type is not used in macro used macro

Can i use it at macro level? If not Is there anlternative for it?
Full parsing not just an expression.

Some background Infos:
Technically I need to test a haxe file before using it (Syntax and also to test if the class using some packages that are not allowed in is target. And with the current project. I need to test allot in a big environment (with allot of libraries) so compiling each takes to long.

/*
 Current target is --js
*/
macro function test () {
 if(isValidFile('HelloWorld.hx')) {
    Context.getType('HelloWorld');
  }

 return macro null;
}

My plan was to define this type dynamically and cache any errors.
Context.getType can not be cached for this type of errors.
(https://github.com/HaxeCheckstyle/haxeparser/blob/master/src/haxeparser/DefinitionConverter.hx)

@AlexHaxe
Copy link
Member

I would suggest you write a command line tool that does all of the checking and use it as a pre-build step. that way you can speed up compilation during development and testing because all that extra parsing and checking only needs to happens when those files change and not with every build. it also eliminates issues with cached types.

you could even use checkstyle for your testing needs by writing a new check that blacklists certain full qualified types or packages (in that case: please send your PR to checkstyle).

@AlexHaxe AlexHaxe changed the title Doesn't work at 4.2.4 parsing Haxe code at compile time Feb 21, 2022
@lublak
Copy link
Contributor Author

lublak commented Apr 7, 2022

@AlexHaxe thank you for the answer. I will now use it in a command line tool.
will there actually be a haxelib release? 3.3.0 is already a bit old.

@lublak lublak closed this as completed Apr 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants