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

Symbols create a tooling gap #13056

Closed
sethladd opened this issue Sep 5, 2013 · 19 comments
Closed

Symbols create a tooling gap #13056

sethladd opened this issue Sep 5, 2013 · 19 comments
Assignees
Labels
analyzer-refactoring area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. closed-not-planned Closed as we don't intend to take action on the reported issue type-enhancement A request for a change that isn't a bug

Comments

@sethladd
Copy link
Contributor

sethladd commented Sep 5, 2013

Symbols are often used to refer to fields or classes. Currently, the tools aren't able to give good feedback or assistance when symbols are used. e.g. if a symbol that is meant to refer to a field name, the tools have no way to detect if the symbol was misspelled, and no way to help refactor-rename.

We now have symbols, which are often used to represent names in Dart code, I'm concerned we're losing some tooling ability.

e.g. this is common in Polymer.dart code:

    bindProperty(this, const Symbol('timestamp'),
        () => notifyProperty(this, const Symbol('second')));

The first symbol is the name of a field, the second symbol is the name of a getter. If I rename my field, the symbol is left untouched. And if I misspell the symbol name...

This lies at the intersection of tooling, API design, and maybe language. Do you think we can do better here? Should the API be changed or should the tools help here?

@anders-sandholm
Copy link
Contributor

Added Area-Tools label.

@DartBot
Copy link

DartBot commented Sep 30, 2013

This comment was originally written by @seaneagan


mailing list discussion:

https://groups.google.com/a/dartlang.org/d/msg/misc/a0Fk1XSn6Fc/1DJvkLIkjc4J

Refining some ideas from there:

  1. Symbol literal extensions:

symbolLiteral:
  librarySymbolLiteral libraryMemberSymbolLiteral?
| librarySymbolLiteral? classSymbolLiteral classMemberSymbolLiteral?
| classMemberSymbolLiteral

librarySymbolLiteral: ‘#’ identifier (‘.’ identifier)*

classSymbolLiteral: ‘#’ qualified

classMemberSymbolLiteral: ‘#’ operator | (identifier '='?)

libraryMemberSymbolLiteral: ‘#’ identifier '='?

Examples:

#MyClass
#MyClass#myMember
#MyClass#+
#MyClass#staticMethod
#my.lib.name
#my.lib.name#topLevel
#my.lib.name#MyClass#myMember

Dot-less library identifiers could still conflict with class or member identifiers, but at least class identifiers have different naming conventions (UpperCamelCase).

  1. More explicit Symbol constructors:

class Symbol {
  const Symbol.fromType(Type type, [Symbol member]);
  const Symbol.fromLibrary(Symbol libraryName, [Symbol member]);
  //...
}

Examples:

const Symbol.fromType(MyClass)
const Symbol.fromType(MyClass, #myMember)
const Symbol.fromType(MyClass, #+)
const Symbol.fromType(MyClass, #staticMethod)
const Symbol.fromLibrary(#my.lib.name)
const Symbol.fromLibrary(#my.lib.name, #topLevel)

which could be improved a tiny bit with first class libraries.

@DartBot
Copy link

DartBot commented Dec 5, 2013

This comment was originally written by greg.lo...@gmail.com


I just caught by doing a refactor rename of a field, and forgot to update the name of a symbol in my code. I understand, that it usually will not be possible to rename these automatically as the symbol could refer to any number of methods/getters in the code.

But perhaps the editor could provide a warning if there are symbols with a matching name which may need to be updated.

@sethladd
Copy link
Contributor Author

sethladd commented Dec 5, 2013

Removed Area-Tools label.
Added Area-Editor label.

@DartBot
Copy link

DartBot commented Dec 25, 2013

This comment was originally written by @zoechi


I guess https://code.google.com/p/dart/issues/detail?id=15793 could be solved with this one too if Symbol would expose a name property to get the string back from the symbol.

@clayberg
Copy link

clayberg commented Jan 2, 2014

Set owner to @scheglov.
Added this to the 1.2 milestone.
Removed Priority-Unassigned label.
Added Priority-Medium label.

@clayberg
Copy link

Removed this from the 1.2 milestone.
Added this to the 1.3 milestone.

@scheglov
Copy link
Contributor

scheglov commented Apr 2, 2014

Removed this from the 1.3 milestone.
Added this to the 1.4 milestone.

@kasperl
Copy link

kasperl commented May 8, 2014

Removed this from the 1.4 milestone.
Added this to the 1.5 milestone.

@kasperl
Copy link

kasperl commented Jun 4, 2014

Removed this from the 1.5 milestone.
Added this to the 1.6 milestone.

@kasperl
Copy link

kasperl commented Jul 10, 2014

Removed this from the 1.6 milestone.
Added Oldschool-Milestone-1.6 label.

@sethladd
Copy link
Contributor Author

Added NotPlanned label.

@DartBot
Copy link

DartBot commented Jul 22, 2014

This comment was originally written by @Andersmholmgren


Oh no :-(. How come?

@scheglov
Copy link
Contributor

@sethladd
Copy link
Contributor Author

Did you mean to set Oldschool-Milestone-7 ?


Removed Oldschool-Milestone-1.7 label.

@scheglov
Copy link
Contributor

It was "Oldschool-Milestone-1.6", so I just moved it to the next version when we possibly could do it.

@scheglov
Copy link
Contributor

I somehow lost this Oldschool-Milestone-1.7 label.


Added Oldschool-Milestone-1.7 label.

@sethladd
Copy link
Contributor Author

:) Oldschool was just a housekeeping thing. We're want to avoid pushing issues from milestone to milestone, so best to leave milestone off for now. Thanks for reopening and recategorizing!


Removed Oldschool-Milestone-1.7 label.

@scheglov
Copy link
Contributor

Added NotPlanned label.

@sethladd sethladd added Type-Enhancement area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. analyzer-refactoring closed-not-planned Closed as we don't intend to take action on the reported issue labels Feb 19, 2015
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed type-enhancement labels Mar 1, 2016
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-refactoring area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. closed-not-planned Closed as we don't intend to take action on the reported issue type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

7 participants