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

Control Flow Visualization generated as comment as opposed to new stand alone file #69

Open
Jothianand opened this issue Oct 7, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@Jothianand
Copy link

Dot file is not generated while running the Control Flow Visualization recipe.

After running the recipe, it is adding the diagraph notations to the class but the dot file is not generated.

Have tried with both includeDotfile as true & false, but not generating the file. When includeDotfile is true, its adding diagraph notions and when false, it is not added.

Do we need to use a separate recipe to generate the dot file from the notations added by the recipe ?

---
type: specs.openrewrite.org/v1beta/recipe
name: com.yourorg.ControlFlowVisualizationExample
displayName: Control Flow Visualization example
recipeList:
  - org.openrewrite.analysis.controlflow.ControlFlowVisualization:
      includeDotfile: true
@timtebeek
Copy link
Contributor

It indeed looks like the recipe produces the dot notation as a comment in the code, as opposed to in a separate file, as seen here:

if (dotFileGenerator != null) {
String graphName = methodDeclaration != null ? methodDeclaration.getSimpleName() : b.isStatic() ? "static block" : "init block";
String dotFile = dotFileGenerator.visualizeAsDotfile(graphName, darkMode, controlFlow);
if (isMethodDeclaration) {
getCursor().dropParentUntil(J.MethodDeclaration.class::isInstance).putMessage(CONTROL_FLOW_SUMMARY_CURSOR_MESSAGE, dotFile);
} else {
J.Block b2 = SearchResult.found(b, searchResultText);
return SearchResult.mergingFound(b2, dotFile);
}

We could restructure the recipe to be a Scanning recipe that creates a new file instead of a comment, if you feel that improves the experience. I'd welcome a PR that explores that solution to this issue.

@timtebeek timtebeek added the enhancement New feature or request label Oct 8, 2024
@timtebeek timtebeek moved this to Backlog in OpenRewrite Oct 8, 2024
@timtebeek timtebeek changed the title Unable to generate code flow using Control Flow Visualization recipe Control Flow Visualization generated as comment as opposed to new stand alone file Oct 8, 2024
@Jothianand
Copy link
Author

Thanks @timtebeek for the response.

I feel that the recipe should generate the dot file so that developers can visualise their code flow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Backlog
Development

No branches or pull requests

2 participants