Skip to content

Commit

Permalink
Fix member accesses in codemirror highlighter. (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Loitsch authored Sep 28, 2021
1 parent 3994f2d commit 47c5770
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions code_mirror/toit.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,11 +398,24 @@
return null;
}

function tryIdentifier(stream, state) {
function tryPostfixMemberOrIdentifier(stream, state) {
return tryIdentifier(stream, state, true);
}

function tryIdentifier(stream, state, allowPrefixedDot) {
// If we allow a prefixed dot, consume it (but put it back if
// it's not followed by an identifier).
if (allowPrefixedDot && stream.match(".")) {
if (!stream.match(IDENTIFIER, false)) {
stream.backUp(1);
return null;
}
return "dot";
}
if (!stream.match(IDENTIFIER)) return null;
var id = stream.current();
if (isKeyword(id)) return "keyword";
if (isSpecialVar(id)) return "special_var"
if (isSpecialVar(id)) return "special_var";
if (isAtom(id)) return "atom";
if (id.match(CONSTANT_HEURISTIC)) {
return "constant";
Expand Down Expand Up @@ -913,6 +926,10 @@
tryOperator(stream, state) ||
tryString(stream, state) ||
tryIsAs(stream, state) ||
// In theory we need to check whether the postfix member is
// prefixed by another expression but for the syntax highlighter we
// just assume that was the case.
tryPostfixMemberOrIdentifier(stream, state) ||
tryIdentifier(stream, state) ||
tryPrimitive(stream, state) ||
tryDelimited(stream, state) ||
Expand Down

0 comments on commit 47c5770

Please sign in to comment.