added support for comments in the API rules and filter expressions

This commit is contained in:
Gani Georgiev
2023-12-02 16:37:04 +02:00
parent aaab643629
commit d3713a9d7c
40 changed files with 130 additions and 105 deletions
@@ -52,6 +52,7 @@
syntaxHighlighting,
bracketMatching,
StreamLanguage,
syntaxTree,
} from "@codemirror/language";
import { defaultKeymap, history, historyKeymap } from "@codemirror/commands";
import { searchKeymap, highlightSelectionMatches } from "@codemirror/search";
@@ -348,6 +349,12 @@
return null;
}
// skip for comments
let nodeBefore = syntaxTree(context.state).resolveInner(context.pos, -1);
if (nodeBefore?.type?.name == "comment") {
return null;
}
let options = [
{ label: "false" },
{ label: "true" },
@@ -396,6 +403,8 @@
regex: /true|false|null/,
token: "atom",
},
// comments
{ regex: /\/\/.*/, token: "comment" },
// double quoted string
{ regex: /"(?:[^\\]|\\.)*?(?:"|$)/, token: "string" },
// single quoted string
@@ -431,6 +440,9 @@
{ regex: CommonHelper.escapeRegExp("@yearEnd"), token: "keyword" },
{ regex: CommonHelper.escapeRegExp("@request.method"), token: "keyword" },
],
meta: {
lineComment: "//",
},
})
);
}
@@ -40,7 +40,7 @@
<i
class="ri-information-line link-hint"
use:tooltip={{
text: "Usually it should be safe to be always enabled as most providers will just ignore the extra query parameters if PKCE is not supported by their APIs.",
text: "Usually it should be safe to be always enabled as most providers will just ignore the extra query parameters if they don't support PKCE.",
position: "right",
}}
/>