Open jerrykal opened 7 years ago
@maxbrunsfeld / @Ben3eeE As far as I can tell, this will have to be fixed in tree-sitter-cpp.
As discussed between @Ben3eeE and myself on Slack earlier, there can be an arbitrary amount of whitespace between the operator
keyword and the operator name, e.g. T operator +(const T &l, const T &r);
. Currently this gets parsed as math_expression "+"
.
Note that we must handle the operator
keyword and the operator name (e.g. +
) as two distinct entities, regardless of optional whitespace between. I suggest that the current scope — keyword.control.cpp
— is reasonable for operator
, but not for the entire operator+
expression. The +
should be scoped as entity.name.function.cpp
(or equivalent).
Right now tree-sitter parses the entire: operator+
as operator_name
. If you add a space before the operator and the keyword operator
it parses with ERROR
and math_expression
. operator
is parsed as any identifier.
Am I correct in that it should be parsed as:
operator
a separate node for operator
because it's a keyword. And we want to scope it as keyword.control
operator_name
is just the +
In language-c now operator
is not a keyword and operator_name
is not scoped at all.
Prerequisites
Description
The operator function like
T operator+(const T &l, const T &r);
scope incorrectly.Steps to Reproduce
T operator+(const T &l, const T &r);
operator
and press ⌘+⌥+Pkeyword.control.cpp
notentity.name.function.cpp
Expected behavior: The scope should be
entity.name.function.cpp
.Actual behavior: The scope is
keyword.control.cpp
.Versions
Atom
:1.18.0-beta2
OS
:macOS Sierra