sublime-better-coffeescript icon indicating copy to clipboard operation
sublime-better-coffeescript copied to clipboard

can't capture the super classes when class has no name.

Open Gerhut opened this issue 11 years ago • 1 comments

image

Thank you for your work.

Gerhut avatar Dec 17 '14 07:12 Gerhut

The current Textmate and Sublime matcher is

(class\b)\s+(@?[a-zA-Z\$_][\w\.]*)?(?:\s+(extends)\s+(@?[a-zA-Z\$\._][\w\.]*))?

https://regex101.com/r/uD2jC1/1 image

It matches the term "extends" as if it's the name of a class, which breaks matching after that.

I think we can add a negative lookahead to the second matcher (currently: (@?[a-zA-Z\$_][\w\.]*)) so that it won't match the phrase "extends".

(class\b)\s+((?!extends)@?[a-zA-Z\$_][\w\.]*)?(?:\s*(extends)\s+(@?[a-zA-Z\$\._][\w\.]*))?

https://regex101.com/r/uD2jC1/3 image

The first problem that comes to mind with this is that it'd mess up if you named your class "extends", but that'd be invalid coffeescript anyway.

markalfred avatar Dec 18 '14 14:12 markalfred