clemos / haxe-sublime-bundle

Sublime Text bundle for Haxe programming language
Apache License 2.0
237 stars 86 forks source link

Syntax highlighted types #100

Closed dpeek closed 9 years ago

dpeek commented 11 years ago

Not sure about the current syntax highlighting for some types, but not other. Looks like there is a hand picked selection:

\b(Array|ArrayAccess|Bool|Class|Date|DateTools|Dynamic|EReg|Enum|Float|Hash|Int|IntHash|IntIter|Iterable|Iterator|Lambda|List|Math|Null|Reflect|Std|String|StringBuf|StringTools|Type|UInt|ValueType|Void|Xml|XmlType|TBool|TInt|TFloat|TFunction|TObject|TEnum|TClass|TNull|TUnknown|Float2|Float3|Float4|Matrix|M44|M33|M43|M34|Texture|CubeTexture|Color|Map)\b

Perhaps a regex matching things that look like types would be better? Something like this?

([a-z]+\.)*(\b[A-Z][a-zA-Z0-9]+\b)(\.\b[A-Z]\w+\b)?

Tested here with the following very basic data set:

SOME_THING
SomeThing
foo.bar.SomeThing
foo.bar.THING
foo.bar.MyEnum.MyEnumValue
MyEnum.MyEnumValue
Sys.println("something")
class SomethingElse
class FOOBAR
foo.bar.SomeClass.someMethod
clemos commented 11 years ago

There are actually two regexp already :

So I believe it's fine to keep both. Now I'd accept any pull request that would possibly improve these regexps for better capturing, or give proper naming to selectors to improve highlighting (we try to stick to TM's "standard" as much as possible).