Skip to content

Commit

Permalink
Move identifier check down.
Browse files Browse the repository at this point in the history
Also replaced some non-null assertion operators to prevent failures when they are, in fact, null.
  • Loading branch information
connorshea committed May 26, 2019
1 parent 4639744 commit 5bdb252
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,12 @@ function colorRuby(x: Parser.SyntaxNode, editor: vscode.TextEditor) {
colors.push([x.children[3], 'entity.name.function'])
} else if (variables.includes(x.type)) {
colors.push([x, 'variable'])
} else if (x.type == 'call' && x.lastChild!.type == 'identifier') {
colors.push([x.lastChild!, 'entity.name.function'])
// Method parameters
} else if (x.type == 'identifier' && x.parent!.type == 'method_parameters') {
colors.push([x, 'variable.parameter'])
} else if (x.type == 'method_call' && x.firstChild!.type == 'identifier') {
colors.push([x.firstChild!, 'entity.name.function'])
} else if (x.type == 'call' && x.lastChild && x.lastChild.type == 'identifier') {
colors.push([x.lastChild, 'entity.name.function'])
} else if (x.type == 'method_call' && x.firstChild && x.firstChild.type == 'identifier') {
colors.push([x.firstChild, 'entity.name.function'])
} else if (x.type == 'end') {
if (control.includes(x.parent!.type)) {
if (x.parent && control.includes(x.parent.type)) {
colors.push([x, 'keyword.control'])
} else {
colors.push([x, 'keyword'])
Expand All @@ -157,6 +154,9 @@ function colorRuby(x: Parser.SyntaxNode, editor: vscode.TextEditor) {
colors.push([x, 'entity.name.type'])
} else if (x.type == 'symbol') {
colors.push([x, 'constant.language'])
// Method parameters
} else if (x.type == 'identifier' && x.parent && x.parent.type == 'method_parameters') {
colors.push([x, 'variable.parameter'])
}
for (const child of x.children) {
scan(child)
Expand Down

0 comments on commit 5bdb252

Please sign in to comment.