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

Spike: Writing a "Composer" that has access to the plugin context #88

Open
pocmo opened this issue Oct 2, 2020 · 0 comments
Open

Spike: Writing a "Composer" that has access to the plugin context #88

pocmo opened this issue Oct 2, 2020 · 0 comments
Labels
experiment Ideas, something to try, ..

Comments

@pocmo
Copy link
Owner

pocmo commented Oct 2, 2020

Currently the Composer (code) is an independent class that writes Kotlin code and outputs it as a string. This string is then used by the plugin and CLI.

What if we'd implement a Composer that knows its inside an IntelliJ / Android Studio plugin and can make use of the environment and tools to write the code to the destination. A big advantage would be that we'd get access to the AST of the surrounding code and could, for example, figure out if a drawable is an image or a vector (#69). Maybe we would also be able to use the internals for generating/writing code and wouldn't need to write a plain string?

Considering the composer is the "backend" and the parser is the "frontend" we may also be able to replace the "frontend" and let IntelliJ parse the XML and give us access to its AST?

A downside of this would be that this would basically reduce this project to the plugin and potentially kill the CLI. But then again, maybe parts of it could also survive in a standalone version. After all projects like detekt also make use of the parts of the Kotlin compiler without being a plugin.

Having a closer look at the Java to Kotlin conversion in the Kotlin plugin may give some hints about what is possible.

@pocmo pocmo added the experiment Ideas, something to try, .. label Oct 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
experiment Ideas, something to try, ..
Projects
None yet
Development

No branches or pull requests

1 participant