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

Rename some things that are not lexical tokens, from Token to Origin #5956

Merged
merged 6 commits into from
Dec 3, 2024

Conversation

keyboardDrummer
Copy link
Member

@keyboardDrummer keyboardDrummer commented Dec 3, 2024

This PR extract some refactorings from #5931 to make that PR easier to review.

Description

  • Rename some things that are not lexical tokens, from Token to Origin. In particular, Microsoft.Dafny.IToken is now Microsoft.Dafny.IOrigin. Same renaming is done for classes that inherit from IToken, except Token and RangeToken
  • Extract two classes into separate files, IOrigin and OriginWrapper
  • Note: there are same locations where lexical tokens are handled, particularly in the parser and the formatter, where the name IOrigin does not make sense. That is addressed by this PR: Use Token instead of IToken in lexical token locations #5957

How has this been tested?

Pure refactoring, covered by existing tests

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

Copy link
Member

@MikaelMayer MikaelMayer left a comment

Choose a reason for hiding this comment

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

document.querySelectorAll("button.load-diff-button").forEach(b => b.click()) was my friend for this one ! I like the new taxonomy much more than the previous one, thanks for the refactoring. Just a coment about variable renaming that you can skip if you prefer.

@@ -20,8 +20,8 @@ public MapComprehension(Cloner cloner, MapComprehension original) : base(cloner,
Finite = original.Finite;
}

public MapComprehension(IToken tok, RangeToken rangeToken, bool finite, List<BoundVar> bvars, Expression range, Expression/*?*/ termLeft, Expression termRight, Attributes attrs)
: base(tok, rangeToken, bvars, range, termRight, attrs) {
public MapComprehension(IOrigin tok, RangeToken rangeOrigin, bool finite, List<BoundVar> bvars, Expression range, Expression/*?*/ termLeft, Expression termRight, Attributes attrs)
Copy link
Member

Choose a reason for hiding this comment

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

I'm puzzled as I would that thought that you'd rename tok to origin but not that you'd rename rangeToken to rangeOrigin

Anyway, these are parameter names so I presume they don't wieght a lot.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll fix it in a follow-up. Hope that's OK.

@keyboardDrummer keyboardDrummer merged commit 5670005 into dafny-lang:master Dec 3, 2024
22 checks passed
@keyboardDrummer keyboardDrummer deleted the prepareRename branch December 3, 2024 21:52
keyboardDrummer added a commit that referenced this pull request Dec 3, 2024
This PR extract some refactorings from
#5931 to make that PR easier to
review.

### Description
Use Token instead of IToken in locations where we want to work with a
lexical token. This only makes sense in conjunction with other changes.
Namely I will rename `IToken` to `IOrigin`
(#5956) and make `Token` no
longer inherit from `IOrigin` (future PR).

### How has this been tested?
Covered by existing tests

<small>By submitting this pull request, I confirm that my contribution
is made under the terms of the [MIT
license](https://github.com/dafny-lang/dafny/blob/master/LICENSE.txt).</small>
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