Packages
Packages copied to clipboard
[JavaScript] Make support scopes additive
Currently the syntax prioritizes support scopes at the expense of other roles, such as function calls or constructor calls. For example:
console.error
// ^^^^^ support.function.console - variable.function
console.error(err)
// ^^^^^ support.function.console - variable.function
Meanwhile, non-built-ins produce the desired result:
koñsole.error
// ^^^^^ - support - variable.function
koñsole.error(err)
// ^^^^^ variable.function - support
This is rooted in deep tradition and all, but the current approach makes it impossible to distinguish the use of built-ins as values from calls. Some users care about roles like "call" vs. "value", but not about what's predefined. It would be useful if support scopes were additive, rather than replacements for the base roles.
The variable.function scope doesn't necessarily denote a call, that's what meta.function-call is for, no?
I was under the impression that variable.function has become the de-facto scope for a name that's being invoked as a function. In most languages it's not possible to syntactically differentiate the name of a function that's being used as a value (not called) from any other name, so variable.function isn't really used for that.
meta.function-call is not sufficient for correct highlighting. Consider the following:
someFunc(console.error)
// ^^^^^ meta.function-call support.function
The issue is slightly more general than just function call detection. Support scopes also suppress constructor calls, so you get identical scoping of Array in:
X instanceof Array
X = Array(10)
X = new Array(10)
Which is incorrect, because its roles are: as operand (first class value), as function, as constructor.
There may be other examples. My point is that this isn't limited to function and constructor calls.