Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Sync with language-javascript - #103

Merged
winstliu merged 50 commits into
masterfrom
wl-sync-with-javascript
Sep 4, 2017
Merged

winstliu merged 50 commits into
masterfrom
wl-sync-with-javascript

Conversation

@winstliu

@winstliu winstliu commented Oct 9, 2016 •

Copy link
Copy Markdown
Contributor

This is a pretty large overhaul of language-coffee-script that aims to bring it up-to-date with language-javascript. Things I've ported over include:

  • Functions
  • Function calls
  • Method calls
  • Objects
  • Properties
  • Numbers
  • Operators
  • Begin/end for braces
Before After
coffee-script-before coffee-script-after

Fixes #18 (they should both actually be variable assignments and not functions)
Fixes #25
Fixes #45
Fixes #63
Fixes #79
Fixes #88
Fixes #90
Fixes #97
Fixes #111
Closes #53

TODO:

  • Instance variables aren't being tokenized correctly in parameters (see the fixme in the code).
  • Argument matching terminates at the end of the line instead of attempting to continue in the case of inline functions - Unfixable using regex
  • Similar to above, argument matching does not continue for multiline arguments, even if they're surrounded by parentheses - Unfixable using regex
  • Quoted functions are not recognized ("test": ->)
  • Objects turn into properties if you add an existence check (a.b?.c)
  • Properties don't turn into method calls if you add a standalone @ (console.log @)

/cc @atom/feedback - if some of you could try using this branch for everyday coding, that would be great in order to spot any regressions.
/cc @esdoppio @MaximSokolov @pchaigno

@winstliu

winstliu commented Oct 9, 2016 •

Copy link
Copy Markdown
Contributor Author

Remaining problems:

  • Instance variables aren't being tokenized correctly in parameters (see the fixme in the code).
  • Argument matching terminates at the end of the line instead of attempting to continue in the case of inline functions
  • Similar to above, argument matching does not continue for multiline arguments, even if they're surrounded by parentheses
  • Quoted functions are not recognized ("test": ->)

(this post will be continually edited)
moved to the main pull request description

@winstliu

winstliu commented Oct 9, 2016 •

Copy link
Copy Markdown
Contributor Author

Other than the "messed up" line in #53, everything else is now tagged. After this is merged I'll open a new issue for that.
Fixed in the commits below!

@pchaigno

pchaigno commented Oct 10, 2016 •

Copy link
Copy Markdown
Contributor

It's pretty great overall!
I found a couple constructs that seem broken by this:

  1. Example before (master) in Lightshow
  2. Example with this pull request

Notice a few keywords are not highlighted near the end.

@winstliu

Copy link
Copy Markdown
Contributor Author

Thanks - fixed!
Lightshow

Comment thread grammars/coffeescript.cson Outdated
'captures':
'0':
'name': 'variable.parameter.function.coffee'
'1': # FIXME: Doesn't work yet: the instance_variable include overrides this

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It probably should be

{
  'match': '([a-zA-Z_$][\\w$]*)(\\.\\.\\.)?'
  'captures':
    '1':
      'name': 'variable.parameter.function.coffee'
    '2':
      'name': 'keyword.operator.splat.coffee'
}
{
  'match': '(@(?:[a-zA-Z_$][\\w$]*)?)(\\.\\.\\.)?'
  'captures':
    '1':
      'name': 'variable.parameter.function.readwrite.instance.coffee'
    '2':
      'name': 'keyword.operator.splat.coffee'
}
{
  'include': '$self'
}

'2':
'name': 'variable.other.readwrite.instance.coffee'
'3':
'name': 'keyword.operator.assignment.coffee'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that =, : operators now scoped differently

test = () -> x * x # keyword.operator.assignment
a = 1 + 1 # just keyword.operator

image
Seti syntax

@winstliu winstliu Oct 11, 2016 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bah. Looks like I'll have to update those as well.

Edit: Scratch that, just going to change these scopes back to keyword.operator.

@MaximSokolov

Copy link
Copy Markdown

It also closes #64

@winstliu

Copy link
Copy Markdown
Contributor Author

To be clear, this suffers from the same problems in #64 as language-javascript also can't tokenize those functions.

@winstliu

Copy link
Copy Markdown
Contributor Author

Thanks @MaximSokolov - your fix did work!

Until we can port over the relevant language-javascript changes to
keyword matching.
Operators is still WIP.  Need to extract it into its own section in the
repository.  Just wanted to convert it as easily as possible first.

Also, started work on adding specs to cover all these changes.
@winstliu winstliu mentioned this pull request Feb 7, 2017
@lee-dohm

lee-dohm commented Feb 7, 2017

Copy link
Copy Markdown
Contributor

I've been running this for a couple days and things look good to me 👍

@winstliu

winstliu commented Mar 15, 2017 •

Copy link
Copy Markdown
Contributor Author
console.log not hasScope(beforePrefixScopesArray, "entity.name.tag.css") and prefix.trim() is ":"

^ reminder for me to fix that

Edit: Fixed! deff726

@winstliu

winstliu commented Apr 5, 2017 •

Copy link
Copy Markdown
Contributor Author

stack is incorrectly tokenized as a function:

for currentStack in stack by -1

Edit: fixed in 55dec99

No support for ..:

index = parseInt(match[1..])

Edit: I won't be adding support for splices to this PR.

And add specs for for loops
@winstliu

winstliu commented Jun 16, 2017 •

Copy link
Copy Markdown
Contributor Author
error = new Error("Deprecated function(s) #{deprecations.map(({originName}) -> originName).join ', '}) were called.")

string termination breaks somewhere in there.

Edit: Fixed in 43d6b9d

@winstliu
winstliu merged commit 073f6a1 into master Sep 4, 2017
@winstliu
winstliu deleted the wl-sync-with-javascript branch September 4, 2017 13:19
@winstliu winstliu mentioned this pull request Sep 4, 2017
@Ben3eeE

Ben3eeE commented Sep 4, 2017

Copy link
Copy Markdown

🎉

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.