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

[Bug]: NodeFinder returns null for a SimpleNameReferenceNode #38522

Open
DamithaSenevirathne opened this issue Nov 2, 2022 · 6 comments
Open
Labels
Area/SemanticAPI Semantic API Related Issues #Compiler Status/Blocked Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Team/CompilerFETools Semantic API, Formatter, Shell Type/Bug

Comments

@DamithaSenevirathne
Copy link
Contributor

DamithaSenevirathne commented Nov 2, 2022

Description

Consider following code sample

public function main() returns error? {
   ProductClient prodClient = check new("http://example,com");
   string v = prodClient->
}

Here if we try to get the BLangNode related to prodClient using NodeFinder it returns null node

Steps to Reproduce

  1. get the node considering the line position (line position within the prodClient)
  2. get the lineRange() for the considered node (this is a SimpleNameReferenceNode)
  3. try to get bLangNode using nodeFinder.lookup(bLangCompilationUnit, node.lineRange())

Affected Version(s)

No response

OS, DB, other environment details and versions

No response

Related area

-> Compilation

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@IMS94 IMS94 added the Area/SemanticAPI Semantic API Related Issues #Compiler label Jan 24, 2023
@IMS94 IMS94 added the Team/CompilerFETools Semantic API, Formatter, Shell label Jan 24, 2023
@pcnfernando pcnfernando added the Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. label Mar 31, 2023
@pcnfernando pcnfernando moved this to Planned for Sprint in Ballerina Team Main Board Mar 31, 2023
@sanjana sanjana moved this from Planned for Sprint to In Progress in Ballerina Team Main Board Apr 10, 2023
@sanjana
Copy link
Contributor

sanjana commented Apr 11, 2023

The prodClient-> is parsed as a ASYNC_SEND_ACTION node in the BLangNodeBuilder.
This is not yet supported. Awaiting changes from #24849.

@lochana-chathura are there any workarounds temporarily for this?

@lochana-chathura
Copy link
Member

As a temporary workaround, we could set the position of the mocking BLangExpression node to have prodClient->'s position.
Screenshot from 2023-04-11 13-15-43

Then, I guess the null pointer will be gone. You will have the mocking BLangExpression from the NodeFinder.

@sanjana sanjana moved this from In Progress to On Hold in Ballerina Team Main Board Apr 11, 2023
@lochana-chathura
Copy link
Member

Although the null return is gone. I think it won't be helpful get the expectedType since we replace the prodClient-> part with a mocking simple variable node. :(

@lochana-chathura
Copy link
Member

Depends on PR #38245

@DamithaSenevirathne
Copy link
Contributor Author

DamithaSenevirathne commented Apr 11, 2023

This is a requirement for expectedType API implemented in the semantic API, In this case expectedType API is unable to provide the correct expectedType because we are not getting the correct node type. Returning mocking simple variable node won't be helpful in this case.

@sanjana
Copy link
Contributor

sanjana commented Apr 11, 2023

Since the suggested workaround doesn't fulfill the requirement of the Expected Types API, decided to await the changes from #38245. Once it is completed, can check from the Semantic API to validate this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area/SemanticAPI Semantic API Related Issues #Compiler Status/Blocked Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Team/CompilerFETools Semantic API, Formatter, Shell Type/Bug
Projects
None yet
Development

No branches or pull requests

5 participants