JetBrains / JetBrains/Grammar-Kit

Explicit output paths as global attributes

Open
#445 0 comments 0 reactions 1 assignee Claimed by @maxmedvedev View on GitHub
waiting for feedback
Dominant language
Java
Stars
771
Forks
137
Avg merge
11h 14m
Merged PRs (30d)
1

Description

I’m considering adding explicit output paths as global attribures:

* parserOutputPath
* psiOutputPath
* elementTypeHolderOutputPath
* syntaxElementTypeHolderOutputPath (syntax-api only)
* elementTypeConverterFactoryOutputPath (syntax-api only)

The paths will be relative to the grammar file by default and will point to a source root.
I.e., the generator will use `//com/my/plugin/package/Parser.java` path.

Also it will be possible to override them via CLI interface:
New format: ` [--parser-output PATH] [--psi-output PATH] …`
The current format: ` [] …`

Looking for your feedback.

FAQ:

1. **Why do we even need that?**
1\. Sometimes different generated files should go to different folders. It’s impossible now
2\. Currently, output paths are inferred by GK by clever but tricky heuristics. It’s hard to predict them.

2. **We already specify the FQNs of all those classes. Let’s replace them with a path.**
We still need to know the FQN to correctly generate the parser file. We can’t infer it from a path

3. **Why can’t we just add CLI parameters?**
Probably we can, but still a lot of clients in IntelliJ and probably outside use a UI plugin action to generate parsers.

4. **Why do we need CLI parameters if one can specify everything in the grammar file?**
Valid question. It might be convenient to be able to generate parser code manually with a UI action while working in IJ
At the same time, it might be convenient to override paths when generating code on CI.

5. **What about input parameters?**
They are out of the scope of this task, also to the best of my knowledge they don’t bring any value:
In UI mode, the generator is able to find input class anywhere in the project sources.
In CLI mode, the generator looks for input classes in its classpath, so paths would have no effect here. Addressing this issue is out of scope. Stay tuned.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.