emacsorphanage / dart-mode

An Emacs mode for the Dart language
GNU General Public License v3.0
15 stars 2 forks source link

Built in file directives may collide with methods #90

Open bradyt opened 5 years ago

bradyt commented 5 years ago

In list.dart in core, of is the name of a method,

factory List.of(Iterable<E> elements, {bool growable: true}) =>
    new List<E>.from(elements, growable: growable);

whereas at the top the same file, we have

part of dart.core;

dart-mode is incorrectly highlighting the method as a builtin.

bradyt commented 5 years ago

This is a larger problem. As one expert on dart gitter puts it, any word can be scoped into a class member. Then should we make exception on any word that is preceded by a period? Should we also be making sure that no highlighting is done when in a member declaration position? Especially for variables, more so than methods, as it is idiomatic to have a font lock level one where only methods and builtins are highlighted. And variables are not highlighted until level three.

bradyt commented 5 years ago

The case of of is solved at https://github.com/bradyt/dart-mode/commit/bbeadaadff3810da2ab7a7159a3d9e268a39ea3d.

bradyt commented 5 years ago

Another example, is get at https://angulardart.dev/tutorial/toh-pt5.

Future<Hero> get(int id) async =>
    (await getAll()).firstWhere((hero) => hero.id == id);