Open
Conversation
b343110 to
715e4c3
Compare
715e4c3 to
c14bfeb
Compare
joaobispo
requested changes
Aug 22, 2024
Member
There was a problem hiding this comment.
Probably this API, being part of Clava API, should be in the folder src-api/clava/visualization.
Member
There was a problem hiding this comment.
It is possible to add automatic tests? For the web interface is complicated, but for instance, it is possible to have tests for the output of ClavaAstConverter.getCode().
Author
There was a problem hiding this comment.
About the folder, it boils down to the same thing I responded in this comment.
About the automatic tests, I do think that they are possible, just not extremely necessary since almost any problem will be noticeable in the web interface and in the console logs. But I do have some considerations:
- To test
getPrettyHtmlCode, since this function returns HTML code in a string, to better parse and analyze it, I would recommend using JSDOM, which implements utilities to create a headless DOM, allowing us to perform HTML queries (like withquerySelectorAll) in Node.js without a browser. This lets us more easily test the existence of IDs, elements with certain contents, and more. - I would advise (for integration tests) to avoid performing perfect matches in the tests (like
getPrettyHtmlCodereturning an exact string for a given AST), since most methods will produce different results depending on the AST provided and some minor details of the AST converter. For example, modifying the code of a join point slightly would most likely fail a test with perfect matches, and adding a new entry to the information of a join point type should be harmless and not worth testing. Because of this, I would recommend to follow an approach similar to property-based testing, providing some inputs and only expecting the results to follow some properties (e.g.getPrettyHtmlCodeshould have the same code of the woven file after removing the HTML tags, all join points should have at least one corresponding HTML element,getToolAstshould convert all join points and maintain the order, etc.)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds a visualization tool that allows the visual mapping of the source code to the AST. This tool was develop on the context of the summer internship with topic "[CSE01] Visual Mapping of Source Code to Abstract Syntax Tree (AST)", from the INESC TEC Summer Internship 2024 programme.
To be precise, this PR creates the specialization of the tool for Clava. So, this PR must be merged before merging this one.
Changes Made
GenericVisualizationToolandGenericAstConverter, defined in the LARA API, that implements the needed operations for the Clava compiler.How Has This Been Tested
This was mainly tested manually. As the time of writing, I am still doing some final stress testing for possible bugs, so you may see some minor fixes in the future.
To run the tool, in the script fed to Clava, import
VisualizationTooland callawait VisualizationTool.visualize()on the point of execution where you want to analyze the AST.