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

Integrating SoftParser: Go-to-definition code provider for SoftAST #360

Merged
merged 8 commits into from
Jan 30, 2025

Conversation

simerplaha
Copy link
Member

@simerplaha simerplaha commented Jan 28, 2025

  • Implements Go-to-definition CodeProvider for SoftAST. This first version is only for handling local variables, no scoping or inheritance is handled yet.
  • The test-cases will show the improvements achieved:
    • goToDefinition() - Runs on both Strict and Soft asts.
    • goToDefinitionSoft() Runs only on SoftAST because Strict AST results in parser error. Notice, the number of cases we can handle with SoftAST have increased, showing that go-to-definitions is available even with syntax errors.
    • SoftParser is lazily executed. Node's parser is still the primary parser until the integration is complete.
  • Towards Parser errors prevent CodeProvider execution (completion, goto definition etc) #104.

@simerplaha simerplaha requested a review from tdroxler January 28, 2025 04:04
extends IsParsedAndCompiled
with IsParsed
Copy link
Member

@tdroxler tdroxler Jan 28, 2025

Choose a reason for hiding this comment

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

why do we need both?

    extends IsParsedAndCompiled
       with IsParsed

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right 👍🏼. We don't. Removed.

/** Executes go-to-definition providers for both StrictAST and [[SoftAST]] */
def goToDefinition(settings: GoToDefSetting = testGoToDefSetting)(code: String): List[(URI, LineRange)] = {
goToDefinitionStrict(settings)(code)
goToDefinitionSoft(settings)(code)
Copy link
Member

Choose a reason for hiding this comment

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

both are executed, but only the results of the soft one are returned, is it expected or you miss a ++ ?

Copy link
Member Author

@simerplaha simerplaha Jan 29, 2025

Choose a reason for hiding this comment

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

++ is not required. When a go-to-def test is executed on both Strict and Soft ASTs, they both should return the same result. Running the test already asserts this, but I'll make this explicit by checking it in this function.

// Assert that both go-to-def services (Strict & Soft) return the same result.
resultSoftRanges should contain theSameElementsAs resultStrictRanges
// return either one of the results because they both contain the same result
resultSoft
Copy link
Member

Choose a reason for hiding this comment

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

👍

Base automatically changed from integrate_soft_ast_0_renaming to master January 30, 2025 01:37
…0_provider

# Conflicts:
#	presentation-compiler/src/main/scala/org/alephium/ralph/lsp/pc/sourcecode/SourceCodeState.scala
@simerplaha simerplaha merged commit 3ce4726 into master Jan 30, 2025
3 checks passed
@simerplaha simerplaha deleted the integrate_soft_ast_0_provider branch January 30, 2025 01:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants