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

feat: LSP hover for integer literals #7368

Merged
merged 11 commits into from
Feb 18, 2025
Merged

feat: LSP hover for integer literals #7368

merged 11 commits into from
Feb 18, 2025

Conversation

asterite
Copy link
Collaborator

@asterite asterite commented Feb 13, 2025

Description

Problem

No existing issue, just something Rust Analyzer does that I thought would be nice to have.

Summary

(it's better to review this commit by commit as the first one just moves things around)

Now hovering over an integer literal will show its inferred type together with its decimal value and hexadecimal value (Rust Analyzer also shows the binary (0b...) literal but I omitted that because Noir doesn't have such literals).

lsp-hover-integer

Additional Context

This PR also makes it easier for later PRs to provide hover over types and other AST nodes, to for example explain what Expr is, what i32 is, etc. (also similar to Rust Analyzer, which I think is nice because you can learn a lot of the language through the editor hover).

Documentation

Check one:

  • No documentation needed.
  • Documentation included in this PR.
  • [For Experimental Features] Documentation to be submitted in a separate PR.

PR Checklist

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

@asterite asterite requested a review from a team February 13, 2025 14:40
Copy link
Contributor

@michaeljklein michaeljklein left a comment

Choose a reason for hiding this comment

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

Please add a few sanity-check tests for this since we could change a representation and end up showing the wrong hex/decimal value (I'm thinking of the upcoming #7324 changes).

Otherwise LGTM

@asterite
Copy link
Collaborator Author

I think when we change to SignedField we'll have to unpack that to pass it to the visitor, or make the visitor use SignedField. I'm not sure it could break without first stopping to compile 🤔

What would the test be like?

Copy link
Member

@TomAFrench TomAFrench left a comment

Choose a reason for hiding this comment

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

LGTM, one nit on odd-length hexadecimal.

Agree that if we're changing how we're representing signed integers then this will break rather than failing silently. Maybe we could add another case within hover_on_integer_literal which points at a negative value.

Beyond that, I think the most we'd want to test for this is a couple of sanity checks that we get the expected formatted string given a (FieldElement, bool) input (to catch stuff like odd-length hex strings, etc.)

@asterite asterite force-pushed the ab/lsp-hover-integer branch from 42569f2 to cb0721d Compare February 17, 2025 17:08
@asterite
Copy link
Collaborator Author

I think the most we'd want to test for this is a couple of sanity checks that we get the expected formatted string given a (FieldElement, bool)

Any numbers in particular that we should test? The logic mostly relies on format strings.

@TomAFrench
Copy link
Member

🤷 Not really... something positive, something negative and zero.

@TomAFrench
Copy link
Member

LGTM, the failures are unrelated to this PR. @michaeljklein can you remove the block on this?

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Test Suite Duration'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20.

Benchmark suite Current: 18e17e7 Previous: 582f56e Ratio
AztecProtocol_aztec-packages_noir-projects_noir-protocol-circuits_crates_blob 67 s 51 s 1.31

This comment was automatically generated by workflow using github-action-benchmark.

CC: @TomAFrench

@jfecher jfecher enabled auto-merge February 18, 2025 21:10
@jfecher jfecher added this pull request to the merge queue Feb 18, 2025
Merged via the queue into master with commit 967ab5f Feb 18, 2025
103 checks passed
@jfecher jfecher deleted the ab/lsp-hover-integer branch February 18, 2025 21:34
TomAFrench added a commit that referenced this pull request Feb 19, 2025
* master:
  fix(performance): Remove redundant slice access check from brillig (#7434)
  chore(docs): updating tutorials and other nits to beta.2 (#7405)
  feat: LSP hover for integer literals (#7368)
  feat(experimental): Compile match expressions (#7312)
  feat(acir_field): Add little-endian byte serialization for FieldElement (#7258)
  feat: allow unquoting TraitConstraint in trait impl position (#7395)
  feat(brillig): Hoist shared constants across functions to the global space (#7216)
  feat(LSP): auto-import via visible reexport (#7409)
  fix(brillig): Brillig entry point analysis and function specialization through duplication (#7277)
  chore: redo typo PR by maximevtush (#7425)
  fix(ssa): Accurately mark binary ops for hoisting and check Div/Mod against induction variable lower bound (#7396)
  feat!: remove bigint from stdlib (#7411)
AztecBot added a commit to AztecProtocol/aztec-packages that referenced this pull request Feb 19, 2025
…m brillig (noir-lang/noir#7434)

chore(docs): updating tutorials and other nits to beta.2 (noir-lang/noir#7405)
feat: LSP hover for integer literals (noir-lang/noir#7368)
feat(experimental): Compile match expressions (noir-lang/noir#7312)
feat(acir_field): Add little-endian byte serialization for FieldElement (noir-lang/noir#7258)
feat: allow unquoting TraitConstraint in trait impl position (noir-lang/noir#7395)
feat(brillig): Hoist shared constants across functions to the global space (noir-lang/noir#7216)
feat(LSP): auto-import via visible reexport (noir-lang/noir#7409)
fix(brillig): Brillig entry point analysis and function specialization through duplication (noir-lang/noir#7277)
chore: redo typo PR by maximevtush (noir-lang/noir#7425)
fix(ssa): Accurately mark binary ops for hoisting and check Div/Mod against induction variable lower bound (noir-lang/noir#7396)
feat!: remove bigint from stdlib (noir-lang/noir#7411)
chore: bump aztec-packages commit (noir-lang/noir#7415)
chore: deprecate `merkle` module of stdlib (noir-lang/noir#7413)
chore(ci): lock aztec-packages commit in CI (noir-lang/noir#7414)
feat: while statement (noir-lang/noir#7280)
AztecBot added a commit to AztecProtocol/aztec-packages that referenced this pull request Feb 19, 2025
…oir-lang/noir#7434)

chore(docs): updating tutorials and other nits to beta.2 (noir-lang/noir#7405)
feat: LSP hover for integer literals (noir-lang/noir#7368)
feat(experimental): Compile match expressions (noir-lang/noir#7312)
feat(acir_field): Add little-endian byte serialization for FieldElement (noir-lang/noir#7258)
feat: allow unquoting TraitConstraint in trait impl position (noir-lang/noir#7395)
feat(brillig): Hoist shared constants across functions to the global space (noir-lang/noir#7216)
feat(LSP): auto-import via visible reexport (noir-lang/noir#7409)
fix(brillig): Brillig entry point analysis and function specialization through duplication (noir-lang/noir#7277)
chore: redo typo PR by maximevtush (noir-lang/noir#7425)
fix(ssa): Accurately mark binary ops for hoisting and check Div/Mod against induction variable lower bound (noir-lang/noir#7396)
feat!: remove bigint from stdlib (noir-lang/noir#7411)
chore: bump aztec-packages commit (noir-lang/noir#7415)
chore: deprecate `merkle` module of stdlib (noir-lang/noir#7413)
chore(ci): lock aztec-packages commit in CI (noir-lang/noir#7414)
feat: while statement (noir-lang/noir#7280)
TomAFrench added a commit to AztecProtocol/aztec-packages that referenced this pull request Feb 19, 2025
Automated pull of development from the
[noir](https://github.com/noir-lang/noir) programming language, a
dependency of Aztec.
BEGIN_COMMIT_OVERRIDE
fix(performance): Remove redundant slice access check from brillig
(noir-lang/noir#7434)
chore(docs): updating tutorials and other nits to beta.2
(noir-lang/noir#7405)
feat: LSP hover for integer literals
(noir-lang/noir#7368)
feat(experimental): Compile match expressions
(noir-lang/noir#7312)
feat(acir_field): Add little-endian byte serialization for FieldElement
(noir-lang/noir#7258)
feat: allow unquoting TraitConstraint in trait impl position
(noir-lang/noir#7395)
feat(brillig): Hoist shared constants across functions to the global
space (noir-lang/noir#7216)
feat(LSP): auto-import via visible reexport
(noir-lang/noir#7409)
fix(brillig): Brillig entry point analysis and function specialization
through duplication (noir-lang/noir#7277)
chore: redo typo PR by maximevtush
(noir-lang/noir#7425)
fix(ssa): Accurately mark binary ops for hoisting and check Div/Mod
against induction variable lower bound
(noir-lang/noir#7396)
feat!: remove bigint from stdlib
(noir-lang/noir#7411)
chore: bump aztec-packages commit
(noir-lang/noir#7415)
chore: deprecate `merkle` module of stdlib
(noir-lang/noir#7413)
chore(ci): lock aztec-packages commit in CI
(noir-lang/noir#7414)
feat: while statement (noir-lang/noir#7280)
END_COMMIT_OVERRIDE

---------

Co-authored-by: Tom French <tom@tomfren.ch>
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.

4 participants