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

Non-virtual, non-comment "end tags" #34749

Open
StokeMasterJack opened this Issue Oct 10, 2018 · 0 comments

Comments

Projects
None yet
2 participants
@StokeMasterJack

StokeMasterJack commented Oct 10, 2018

This is a Dart feature, but would be mostly applicable to Flutter. It would also be useful for other frameworks where one is building deeply nested trees in dart code.

Instead of this:

ButtonsView(
  onDeal: onDeal,
  onHit: onHit,
  onStay: onStay,
) //ButtonsView 

I propose this:

ButtonsView(
  onDeal: onDeal,
  onHit: onHit,
  onStay: onStay,
)ButtonsView

Note the )ButtonsView. This what I am calling an end tag, for lack of a better name.

These end tags would be easy to read by humans. And a parser would just replace the ")ButtonsView" with ")".

Benefits

  • Deeply nested constructor trees (or function call trees) will be easier to read
  • IDE and Dart Analyzer can provide more useful assistance
  • End tags are visible outside of IDE. i.e. code in an email, blog post or github
  • This is not a new concept. Visual Basic had end tags for certain statements (End If). And of course XML has this.
  • This feature may satisfy those pushing for JSX-like syntax.

Other points

  • I would make it optional by default for backward compatibility.
  • Default dartfmt behavior: automatically add the end tag any time the open and close parentheses are not on the same line. And omit it if they are on the same line.
  • It could be configured in analysis_options.yaml to cause a warning or error if end tags (non-same-line) are missing.
  • It doesn't have to be exactly this syntax. For example, you could use: /ButtonsView or </ButtonsView>. But I like )ButtonsView because it is clear that the end tag is ending an arg list.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment