Skip to content
This repository was archived by the owner on Aug 29, 2021. It is now read-only.

Highlight #34

Closed
wants to merge 9 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add highlight to literal
  • Loading branch information
MrYurihi committed Jun 23, 2018
commit 407d597abff96b72c239889bf111aeafa1078bcd
9 changes: 8 additions & 1 deletion src/parsers/literal.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CompletionItemKind } from "vscode-languageserver";
import { ReturnHelper } from "../misc_functions";
import { actionFromScope, ReturnHelper } from "../misc_functions";
import { Parser } from "../types";

const parser: Parser = {
Expand All @@ -19,6 +19,13 @@ const parser: Parser = {
if (reader.string.substring(begin, end) === literal) {
reader.cursor = end;
if (reader.peek() === " " || !reader.canRead()) {
helper.addActions(
Copy link
Owner

Choose a reason for hiding this comment

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

This being an action is actually quite awkward, because if there is ambiguity, then what should happen? Text can only be highlighted in one colour.

Additionally, what about in the case of failures. Do we include the mangled scopes. What about if parsing one thing failed with some highlighting, but something else suceeded. How do we prioritise the values.
Maybe helper.merge could manage this if the merge argument fails, but that would make helper.merge O(n) of actions.

actionFromScope({
end: reader.cursor,
scopes: ["argument", "literal"],
start: begin
})
);
return helper.succeed();
Copy link
Owner

Choose a reason for hiding this comment

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

This can be updated to helper.addActions(...).suceed()

}
}
Expand Down