superpowers / superpowers-game

:video_game: Make 2D and 3D games in live collaboration with Superpowers
http://superpowers-html5.com/
Other
402 stars 93 forks source link

[BUG] Syntax Highlighting doesn't work when fields are initialized within a class definition or when "extends Sup.Behavior" keyword is used #189

Open notexplosive opened 6 years ago

notexplosive commented 6 years ago

So this has been a longstanding issue but it looks like no one has filed a proper bug for it.

Consider the following snippet

class biz {}
class foobar extends biz{
  foo(){
    let bar = 100
    return bar
  }
}

If you pasted this into Superpowers as it's own script, the return bar line would highlight bar because it recognizes bar is a variable that was declared within scope. This is good, I like this! (note: github does not do this aforementioned highlighting, you'll have to fire up SP and see for yourself)

However if I add private baz = 5; or some variant to the foobar class then this syntax highlighting breaks for some reason. (note: private baz; with no assignment does NOT break). However more troubling is that if I change the extends call to a class that contains a . like say Sup.Behavior it also breaks. Considering that most use cases involve extending from Sup.Behavior this is rather frustrating. As a workaround you can declare let SupBehavior = Sup.Behavior and then only extend from that and only assign to your private/public fields in awake() but that's kind of silly.

Thank you.