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

Handle virtual and override modifiers #221

Closed
fvictorio opened this issue Jan 31, 2020 · 6 comments · Fixed by #262
Closed

Handle virtual and override modifiers #221

fvictorio opened this issue Jan 31, 2020 · 6 comments · Fixed by #262
Labels
bug Something isn't working
Milestone

Comments

@fvictorio
Copy link
Member

This can't be done at the moment because the parser is not exposing this information. See Consensys/solidity-parser-antlr#2

When that is solver, we should handle these modifiers.

virtual is easy: we should just add the literal virtual after the visibility modifier (at least that's where it's placed in the examples).

override might be followed by some class specifiers, so that should be handled properly. How to do it will depend on how the parser exposes this information.

@mattiaerre mattiaerre added the bug Something isn't working label Feb 12, 2020
@mattiaerre mattiaerre added this to the beta launch milestone Feb 12, 2020
@mattiaerre
Copy link
Member

can we close this issue now @fvictorio ?

@Janther
Copy link
Contributor

Janther commented Mar 3, 2020

@mattiaerre virtual works but override is still not handled

@juanfranblanco
Copy link

juanfranblanco commented Mar 31, 2020

Is there are workaround or setting to avoid prettier deleting keywords? @mattiaerre As this maybe an issue with new keywords introduced in the future, different versions of solidity / antlr

@Janther
Copy link
Contributor

Janther commented Mar 31, 2020

Our plugin reprints the code from the AST that we get from the parser.
Every keyword is handled by a different rule.
So is really difficult to predict how the parser will decide to implement each keyword or how the current parser will react to new syntax.
We are reactive in this sense. We have to wait until the parser evolves before we know how it will affect the printing process.
Currently the only way to avoid prettier to mess with an unsuported keyword is to add the comment prettier-ignore before the line. This will not avoid the parser trying to parse or even failing the parsing process, it will only tell prettier to choose the original text over the AST node.

@Janther
Copy link
Contributor

Janther commented Mar 31, 2020

if the problem continues the whole file could be skipped by adding it to .prettierignore

@juanfranblanco
Copy link

juanfranblanco commented Mar 31, 2020

Ok thanks, I think I will disable it by default for the time being as I just had another issue, and let "advanced" users enable it themselves until things settle a bit. Keep the good work ! juanfranblanco/vscode-solidity#168

Edit: I am just adding a setting to select the formatter None, Prettier and set Prettier as the default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants