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

[Improvement]: Improve code modifier task to run syntax analysis task within itself #42987

Closed
TharmiganK opened this issue Jun 26, 2024 · 2 comments

Comments

@TharmiganK
Copy link
Contributor

Description

Need to know, whether we can improve the code modifier tasks to address the issue described below

Describe your problem(s)

We would like to have two code modifier tasks within the code modifier:

  • ModifierTaskA
  • ModifierTaskB

Both of these modifiers are modifying a same parent node(for example: ServiceDeclarationNode)

For both of these modifiers, we need to run two syntax node analysis tasks to obtain two context maps which has the information for the code modifications:

  • AnalysisTaskA for ModifierTaskA
  • AnalysisTaskB for ModifierTaskB

The context information should be stored using a key which should be unique to the parent node we are modifying. Currently we use the hash code of the parent symbol.

Since the syntax node analysis tasks are running independent of the code modifier tasks, the context map is generated with the reference to the unmodified parent node. But when we run ModifierTaskB after ModifierTaskA, due to the modification done by ModifierTaskA the hash code is changed. Hence the ModifierTaskB is failing.

Describe your solution(s)

What we expect here is a dependency between code modifier task and code analysis task. I had a offline discussion with @gayaldassanayake and he said the syntax analysis tasks are running during a single syntax tree traversal. So if we need to have a dependency then we need to traverse the syntax tree again.

I wanted to know whether there is a better way to achieve this. Will a code modifier task for syntax node resolve this issue (in this case, we do not need to have the context map?

Related area

-> Other Area

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@ballerina-bot ballerina-bot added the needTriage The issue has to be inspected and labeled manually label Jun 26, 2024
@TharmiganK
Copy link
Contributor Author

@azinneera @gayaldassanayake Appreciate your inputs on this

@Dilhasha Dilhasha added Area/ProjectAPI and removed needTriage The issue has to be inspected and labeled manually labels Jun 26, 2024
@Dilhasha Dilhasha self-assigned this Jun 26, 2024
@azinneera azinneera added this to the 2201.10.0 milestone Jul 2, 2024
@Dilhasha
Copy link
Contributor

This requirement will be addressed with the resource support for Ballerina projects which is tracked in #43041

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

4 participants