Change definition of getFactoryNodeInternal#19359
Open
jeongsoolee09 wants to merge 5 commits intomainfrom
Open
Change definition of getFactoryNodeInternal#19359jeongsoolee09 wants to merge 5 commits intomainfrom
getFactoryNodeInternal#19359jeongsoolee09 wants to merge 5 commits intomainfrom
Conversation
Some variants of AMD module such as [sap.ui.define])(https://sdk.openui5.org/api/sap.ui#methods/sap.ui.define) can accept a boolean as its last parameter. Therefore, explicitly state the index of the factory method parameter as `1`.
An additional parameter may be anywhere in the parameter list and shift around the exact index of the callback argument in the parameter list. So, "dynamically" determine the index by type-checking a parameter in the parameter list. Note 1: There may be multiple matches since we're using `_` (don't care) as the argument index. Note 2: We could have used DataFlow::InvokeNode.getCallback if the supertype were not CallExpr, but jumping to data flow node is an overkill here.
asgerf
reviewed
Apr 24, 2025
| result = TValueNode(this.getLastArgument()) | ||
| exists(Function factoryFunction | factoryFunction = this.getArgument(_) | | ||
| result = TValueNode(factoryFunction) | ||
| ) |
Contributor
There was a problem hiding this comment.
The restriction to Function here is too restrictive as we may need to follow some local flow steps before we get to the function (see the recursive case below). Some tests are failing because of this. Could you try simply changing getLastArgument() to getArgument(_)?
Contributor
Author
There was a problem hiding this comment.
I've changed the construction of TValueNode to TValueNode(this.getArgument(_)).
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.
What this PR Contributes
Some variants of AMD module such as sap.ui.define can accept an additional parameter, making it the last parameter in some cases.
However, the additional parameter can technically be anywhere in the parameter list and shift around the exact index of
the callback argument in the parameter list as a result. Therefore, dynamically determine the index of the factory method parameter.
Note 1: There may be multiple matches since we're using
_(don't care) as the argument index.Note 2: We could have used
DataFlow::InvokeNode.getCallbackif the supertype were notCallExpr, but jumping to data flow node is an overkill here.