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

Improve call-stmt recovery for partially written method-call-expr #34180

Merged

Conversation

lochana-chathura
Copy link
Member

Purpose

$subject.

Fixes #34104

Approach

N/A

Samples

N/A

Remarks

N/A

Check List

  • Read the Contributing Guide
  • Updated Change Log
  • Checked Tooling Support (#)
  • Added necessary tests
    • Unit Tests
    • Spec Conformance Tests
    • Integration Tests
    • Ballerina By Example Tests
  • Increased Test Coverage
  • Added necessary documentation
    • API documentation
    • Module documentation in Module.md files
    • Ballerina By Examples

@lochana-chathura lochana-chathura added Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Area/Parser Everything related to the ballerina lexer and the parser #Compiler labels Dec 7, 2021
@codecov
Copy link

codecov bot commented Dec 7, 2021

Codecov Report

Merging #34180 (8599083) into master (a33cf20) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master   #34180   +/-   ##
=========================================
  Coverage     74.07%   74.08%           
- Complexity    45908    45909    +1     
=========================================
  Files          3165     3165           
  Lines        179039   179045    +6     
  Branches      23065    23066    +1     
=========================================
+ Hits         132622   132640   +18     
+ Misses        38625    38613   -12     
  Partials       7792     7792           
Impacted Files Coverage Δ
...rina/compiler/internal/parser/BallerinaParser.java 87.78% <100.00%> (+0.01%) ⬆️
...ces/src/main/java/io/ballerina/component/Node.java 80.00% <0.00%> (-20.00%) ⬇️
...s/src/main/java/io/ballerina/utils/ParserUtil.java 21.62% <0.00%> (-2.71%) ⬇️
...alang/langserver/diagnostic/DiagnosticsHelper.java 73.46% <0.00%> (-1.03%) ⬇️
...llerinalang/compiler/util/ImmutableTypeCloner.java 90.05% <0.00%> (-0.54%) ⬇️
.../io/ballerina/projects/ModuleCompilationState.java 43.68% <0.00%> (+0.97%) ⬆️
.../ballerina/runtime/internal/scheduling/Strand.java 80.92% <0.00%> (+1.03%) ⬆️
...llerina/runtime/internal/scheduling/Scheduler.java 74.46% <0.00%> (+1.43%) ⬆️
...ternal/parser/tree/STMethodCallExpressionNode.java 70.00% <0.00%> (+5.00%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a33cf20...8599083. Read the comment docs.

Comment on lines +8795 to 8806
if (expr.kind == SyntaxKind.FIELD_ACCESS) {
STFieldAccessExpressionNode fieldAccessExpr = (STFieldAccessExpressionNode) expr;
funcOrMethodCall = STNodeFactory.createMethodCallExpressionNode(fieldAccessExpr.expression,
fieldAccessExpr.dotToken, fieldAccessExpr.fieldName, openParenToken, arguments, closeParenToken);
funcOrMethodCall = SyntaxErrors.addDiagnostic(funcOrMethodCall,
DiagnosticErrorCode.ERROR_INVALID_EXPRESSION_EXPECTED_CALL_EXPRESSION);
} else if (expr.kind == SyntaxKind.SIMPLE_NAME_REFERENCE || expr.kind == SyntaxKind.QUALIFIED_NAME_REFERENCE) {
STNode funcName = SyntaxErrors.addDiagnostic(expr,
DiagnosticErrorCode.ERROR_INVALID_EXPRESSION_EXPECTED_CALL_EXPRESSION);
funcOrMethodCall = STNodeFactory.createFunctionCallExpressionNode(funcName, openParenToken, arguments,
closeParenToken);
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There can be other cases that we have to special case like this if we r following this method. Instead of this can we create INVALID_EXPRESSION_STATEMENT for invalid call statements which are valid check expressions so that it will also provide Create variable assignment code action?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, the reason we limited call-stmt to function-call and method-call was to avoid complications at compiler phases. (Introduced with #29282) So the tree has to have either a function-call or method-call node. Looping @chiranSachintha

On the other hand if we consider a(), a:b(), b.c() only simple-name-ref, qualified-name-ref and field-access can be in the partially written state.

For the create variable code action with check-expr in other expr scenarios we may have to consider this diagnostics separately.

Copy link
Member Author

@lochana-chathura lochana-chathura Dec 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline, created this issue #34200

Copy link
Contributor

@malinthar malinthar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@lochana-chathura lochana-chathura changed the title Improve call-stmt recovery for partially written method-call-expr [WIP]Improve call-stmt recovery for partially written method-call-expr Dec 8, 2021
@lochana-chathura lochana-chathura changed the title [WIP]Improve call-stmt recovery for partially written method-call-expr Improve call-stmt recovery for partially written method-call-expr Dec 8, 2021
@lochana-chathura lochana-chathura merged commit e397044 into ballerina-platform:master Dec 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area/Parser Everything related to the ballerina lexer and the parser #Compiler Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

VSCode suggestions for streams did not appear with check statement
3 participants