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

Modernise grammar and fix bugs #415

Merged
merged 20 commits into from
Aug 24, 2016
Merged

Modernise grammar and fix bugs #415

merged 20 commits into from
Aug 24, 2016

Conversation

Alhadis
Copy link
Contributor

@Alhadis Alhadis commented Aug 23, 2016

There's quite a bit happening with this PR, so hopefully my explanations are digestible.

Added: Support for ES6 Unicode escapes

Figure 1

## Fixed: Bugs with constructors

Constructors containing dollar-signs or multiple constructors weren't matched the same way as those who didn't (also fixes #280):

Figure 2

## Fixed: Issues with dollar-signs

Fixes #409: Wrong highlighting for constants with dollar sign:

ANGULAR
ANG$$$$$ULAR

Also fixed an issue I picked up with constants not matching if they begin with an underscore:

_CONSTANT
 CONSTANT

Also fixes #344: Wrong scope on $this and $default:

 this
$this
abc$this

Fixed: "Support constants" only recognised without space

Minor fix:

window.innerWidth
window.  innerWidth

Fixed: Missing highlighting for ES6+ classes

Added highlighting for modern JavaScript classes added in recent versions of the language:

ArrayBuffer
Atomics
DataView
Error
EvalError
Float32Array
Float64Array
Generator
GeneratorFunction
Int16Array
Int32Array
Int8Array
InternalError
Intl
Promise
Proxy
RangeError
ReferenceError
Reflect
SharedArrayBuffer
SIMD
SyntaxError
TypeError
Uint16Array
Uint32Array
Uint8Array
Uint8ClampedArray
URIError

Added: Better DOM support

I wrote a script to generate a regex block from the web interfaces documented on MDN. Note I purposefully omitted any APIs that're deprecated, non-standard, or still considered "experimental".

At the same time, I've also removed support for these keywords, which refer to Netscape-era technologies that've been deprecated since forever:

// Removed properties:
arity
java
sun
netscape

// Removed classes:
Anchor
Applet
Area
Button
Checkbox
FileUpload
Form
Frame
Hidden
Image
JavaArray
JavaClass
JavaObject
JavaPackage
Layer
Link
MimeType
Option
Packages
Password
Radio
Reset
Select
Style
Submit
Textarea

The latter list has been superseded by standardised HTML* classes. For example:

Alhadis added 12 commits August 21, 2016 00:53
This commit fixes a minor bug with scope-matching:

    window.innerWidth      # Ends in support.constant.js
    window.  innerWidth    # Doesn't

Both lines are nonetheless identical in JavaScript.
* Added the full list of standardised web APIs from MDN:
  https://developer.mozilla.org/en-US/docs/Web/API

* Added support for less heard-of ES6+ value types (ArrayBuffer, SIMD …)

* Added "dom" scope for DOM-specific interfaces and objects

* Removed highlighting for non-standard/deprecated properties/classes
* Fixes inconsistent scopes with full-stops (closes #280)
* Fixes "new obj.ct.Class();" stopping at "new obj.ct"
* Fixes "new obj.ct.Cla$$();" not matching due to dollar signs
@MaximSokolov
Copy link
Contributor

Also, there is a conflict with #408

@Alhadis
Copy link
Contributor Author

Alhadis commented Aug 23, 2016

Aaaaand suddenly we have failing specs.

...

... hang on, fixing.

@Alhadis
Copy link
Contributor Author

Alhadis commented Aug 23, 2016

Okay, done. @MaximSokolov, if you need to make any further changes, remember to rebase against my branch.

@winstliu
Copy link
Contributor

This is including some changes from #408 - could you please rebase against master @Alhadis?

@Alhadis
Copy link
Contributor Author

Alhadis commented Aug 23, 2016

Already did.

@@ -705,13 +705,19 @@
'name': 'meta.class.js'
}
{
'match': '(new)\\s+([\\w$]+[\\w.$]*)'
'name': 'meta.class.instance.constructor'
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a .js to the end of this?

@winstliu
Copy link
Contributor

Please keep the specs formatting in line with the existing ones.

@Alhadis
Copy link
Contributor Author

Alhadis commented Aug 23, 2016

I'm guessing you're referring to the columnar-layout of the "Unicode escape sequences" block, right? Fixed.

expect(tokens[2]).toEqual value: '$something', scopes: ['source.js', 'meta.class.instance.constructor.js', 'entity.name.type.instance.js']

{tokens} = grammar.tokenizeLine('var instance = new obj.ct.Cla$s();')
expect(tokens).toEqual [
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm also talking about these specs

@@ -1138,6 +1220,12 @@ describe "Javascript grammar", ->
{tokens} = grammar.tokenizeLine('this.obj.prototype = new El()')
expect(tokens[0]).toEqual value: 'this', scopes: ['source.js', 'variable.language.js']

{tokens} = grammar.tokenizeLine('$this')
expect(tokens[0].value).toEqual '$this'
Copy link
Contributor

Choose a reason for hiding this comment

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

and these

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@50Wliu Can you explain to me exactly what it is you want me to do? I'm really not following here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Keep them in expect(tokens[x]).toEqual value: 'value', scopes: ['scopes'] form.

Copy link
Contributor

Choose a reason for hiding this comment

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

Though I guess you don't really have to change this one, but definitely the one on L159.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed.

@winstliu winstliu merged commit 6e22521 into atom:master Aug 24, 2016
@Alhadis Alhadis deleted the fruit-basket branch August 25, 2016 03:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants