-
Notifications
You must be signed in to change notification settings - Fork 18
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
ImplUtil class not found #23
Comments
PS: it feels as it's not possible with the plugin; keeps saying 'class not found'. And by the feel of it it's not clear how should it work, as the task ( |
+1 |
This still happens for me too :/ |
+1 |
@hurricup We can possibly solve multi-pass problem using Java Annotation Processor API. Pass the list of grammar files to an annotation processor via compiler args and then a universal annotation processor would run in several passes and do its work. We can use Lombok-like Java Compiler API hacks to modify the newly generated files in pass two, or find another way. |
The Gradle plugin for Grammar-Kit does not support the usage of Util classes. JetBrains/gradle-grammar-kit-plugin#23 and JetBrains/gradle-grammar-kit-plugin#3.
The Gradle plugin for Grammar-Kit does not support the usage of Util classes. See the following issues from the Gradle plugin. JetBrains/gradle-grammar-kit-plugin#23 JetBrains/gradle-grammar-kit-plugin#3
I'm wondering if Grammar-Kit could already get enough information from an |
I implemented a PoC for an annotation processor at JojOatXGME/Grammar-Kit-Annotation-Processor. As noted in my last comment, it seems to work without Lombok-like Java Compiler API hacks. I have only tested it with OpenJDK. It is still a bit hacky (see here for example), mostly because Grammar-Kit does not have a proper tooling API which allows for dependency injection. In some cases, the generated files might also miss imports or use incorrect types, but it should be possible to fix if Grammar-Kit would provide the names of all classes it is about to generate before it generates them. |
@JojOatXGME That is awesome. I've never had time to look into the annotation processor API myself. Regarding the "Limitations" section:
|
@gregsh I can create a pull request, but it may take a few weeks because I'm a bit busy. 😄 Did I understand you correctly that the pull request shall target the Grammar-Kit repository directly? Besides that, I think it might be good to test the annotation processor with a few more compilers. (Are there still important Java compilers apart from OpenJDK?) I have not that much experience with annotation processors and the documentations is sometimes a little fuzzy. So I could imagine that some compilers behave a bit differently and introduce new problems.
We would need to capture diagnostic output (e.g. from |
Yes, PR for GK repository. I can do it myself and reference you any way you like.
Got it. Looks trivial.
What needs to be done here? |
I would like to prepare a pull request if you have time to wait for one or two weeks. If you want to work on it right away, you may do it yourself.
Well, that is more complicated. The |
@JojOatXGME I've done some preparations and played with the processor in the "in-ide" (not gradle) mode with Perl5-IDEA plugin. And I've stumbled upon a critical problem that looks like JDK-8159770. The annotation processor is simply not invoked because One way to overcome it is to somehow hack |
@gregsh That is a problem and I do not have a solution for it. However, there seems to be more to the story than just Another topic: After some more research about the different packages, I want to mention that I am actually using non-standard APIs (i.e. |
@JojOatXGME A non-resolvable import statement produces a non-recoverable error. Can you try that? UPD I can send you a patch with my changes integrating the processor and helper in the GK codebase (3 files). |
@gregsh If you send me the patch, I can take a look at it. If it is not too complicated, maybe you can also describe how to reproduce the issue? Regarding non-resolvable imports: I moved the generated class of my attempt to reproduce the issue into another package and inserted an import [ref], but it is still working. If I insert |
@gregsh Looks like a bug (?) of Javac to me. A static or non-static import of a nonexistent class is recoverable. But if you have a static import of a nonexistent member on an existent class, Javac treats it as nonrecoverable. import static pkg.ExistentClass.CONSTANT;
In this example, Javac treats the import as nonrecoverable because it cannot find EDIT: But I also want to mention that importing |
@JojOatXGME I've managed to get JavaC GrammarPlugin working with IntelliJ build system and with Gradle. The required Gradle configuration is commented in Currently, array type annotations are a bit off ( EDIT |
@gregsh I have looked at your commits and left a few comments. Regarding the switch to a compiler plugin: Since we were already using APIs of the compiler API (module I think the biggest takeaway is that it seems impossible to create an annotation processor for Grammar-Kit without non-standard APIs. This means the approach is not compiler independent and does currently not support other compilers (like ecj or Kotlin). I have no idea how difficult it would be to create a similar plugin for Kotlin. Edit: I did try to run your plugin by uncommenting the configuration of you last commit, but I got the following exception. I guess the problem is that I'm running the plugin on Windows, which is using backslashes to separate directories in paths. Stacktrace
|
Fixed that in |
When the README says
NB: plugin does not support two-pass generation, therefore does not suport method mixins.
does this also mean that such constructions:are also not possible to use with a Gradle plugin? if yes, is it possible to provide more extensive explanation in the README? and are there plans/possibilities to support such functionality in the future?
The text was updated successfully, but these errors were encountered: