INRIA / spoon

Spoon is a metaprogramming library to analyze and transform Java source code. :spoon: is made with :heart:, :beers: and :sparkles:. It parses source files to build a well-designed AST with powerful analysis and transformation API.
http://spoon.gforge.inria.fr/
Other
1.75k stars 351 forks source link

feature: add a web visualization of the Spoon model #3198

Open monperrus opened 4 years ago

monperrus commented 4 years ago

today, we have two visualizations of a Spoon model with Swing and JavaFX.

the limitation is that it requires potential users to have Java and Spoon installed.

to overcome this, we could have a web-based UI: you paste Java code in a text area and you navigate in the spoon model in the browser.

requirements:

arnobl commented 4 years ago

In fact, the JavaFX tool does not require Java: it uses latest Java bundling tools to slice a JVM and produce an executable app that does not require a JVM installed.

Anyway, a web version would be great.

surli commented 4 years ago

to overcome this, we could have a web-based UI: you paste Java code in a text area and you navigate in the spoon model in the browser.

What would be the usecase for such UI except the "wow" effect (which would be quite nice for talking about Spoon)?

If the usecase is indeed only pasting a piece of Java code and getting the representation, I guess we could have a very simple web API in which we could send code and receive a serialized representation of the model to manipulate in Javascript.

But would that be enough? For example, if the usecase is more to be able to get a visual representation of a Java Github repository, then the API will be quite different.

arnobl commented 4 years ago

What would be the usecase for such UI

Having at least the same features than the JavaFX app, but without downloading binaries. Be able to log information (what do guys parse, log potential crashes)

monperrus commented 4 years ago

Yes, the "wow" effect, for minimizing the bar to enter in the Spoon world, and to recruit new users.

nharrand commented 4 years ago

See astexplorer. It might be worth trying to integrate spoon to this project.

monperrus commented 4 years ago

nice!

Egor18 commented 4 years ago

As far as I understand, all of the parsers in astexplorer are written in Javascript (even Scala parser uses Scala.js to transpile its code to Javascript) and published in npm as dependencies.

Even though it's possible to create a small js library, which gets the JSON-serialized ast from Spoon for a given code snippet, honestly I don't think that the maintainers would really like the idea of installing java and spoon jar on their server in addition to that library.

But in any case, we can start with adding JSON-serialized ast.

monperrus commented 4 years ago

For the record, the code for having a JSON AST is not in this repo but in https://github.com/SpoonLabs/gumtree-spoon-ast-diff/

See #1526

quentinLeDilavrec commented 4 years ago

See astexplorer. It might be worth trying to integrate spoon to this project.

For the record, the code for having a JSON AST is not in this repo but in https://github.com/SpoonLabs/gumtree-spoon-ast-diff/

See #1526

I have a prototype here https://github.com/quentinLeDilavrec/astexplorer using a slightly modified version of gumtree https://github.com/quentinLeDilavrec/gumtree-spoon-ast-diff.

And it also does more than just showing the spoon ast. It also shows evolutions mined by gumtree alongside a diff editor (I've added an "Evolve" tab in addition to the original parse and transform tabs ).

monperrus commented 4 years ago

I have a prototype here https://github.com/quentinLeDilavrec/astexplorer

Nice! Could you deploy it somewhere such that we can play with it?