-
Notifications
You must be signed in to change notification settings - Fork 64
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
Code and location from children #1411
Merged
Merged
Conversation
This file contains 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
The quality gate fails because I cannot test it without using the function in a frontend, which I will add and then test in #1388. And unfortunately cannot add with the Fluent Node DSL as I need access to rawNodes and a valid frontend unless I heavily restructure the code just to make it testable and jump through some more hoops. |
KuechA
reviewed
Jan 15, 2024
cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/NodeBuilder.kt
Outdated
Show resolved
Hide resolved
oxisto
reviewed
Jan 15, 2024
oxisto
reviewed
Jan 15, 2024
oxisto
reviewed
Jan 15, 2024
oxisto
reviewed
Jan 15, 2024
cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/NodeBuilder.kt
Outdated
Show resolved
Hide resolved
cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/NodeBuilder.kt
Outdated
Show resolved
Hide resolved
cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/NodeBuilder.kt
Outdated
Show resolved
Hide resolved
cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/NodeBuilder.kt
Outdated
Show resolved
Hide resolved
oxisto
approved these changes
Jan 16, 2024
oxisto
force-pushed
the
feature/codeAlocation-from-children
branch
from
January 16, 2024 07:29
b6cb824
to
dd971d7
Compare
Quality Gate failedFailed conditions 11.6% Coverage on New Code (required ≥ 75%) |
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.
This PR allows the setting of a node's code and location region as the code and location of its children.
Sometimes, when we translate a parent node in the language-specific AST with its children into the CPG AST, we have to set a specific intermediate Node between that has no language-specific AST that can give it a proper code and location.
This PR provides the function
codeAndLocationFromChildren(frontend: LanguageFrontend<S, *>, parentNode: S)
that is purely optional and can be used in language frontends to cover the use-case mentioned above and set the region of the node to the start and end region of its children. The code is then extracted from the language-specific AST parent using the newly determined location region.The function modifies the base node, meaning it should be used after construction:
newBlock(...).codecodeAndLocationFromChildren()
or before returning the node if the children are processed and returned after construction:
return block..codecodeAndLocationFromChildren()