-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexclude2.ts
26 lines (20 loc) · 882 Bytes
/
exclude2.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//@ts-nocheck
import "@kusto/language-service-next/bridge"
import "@kusto/language-service-next/Kusto.Language.Bridge"
const exclude = [
Kusto.Language.Syntax.SyntaxKind.ProjectAwayKeyword,
Kusto.Language.Syntax.SyntaxKind.LimitKeyword
]
const origFn = Kusto.Language.Parsing.QueryParser.prototype.ParseQueryOperator;
Kusto.Language.Parsing.QueryParser.prototype.ParseQueryOperator = function() {
const kind = this.PeekToken().Kind;
if (exclude.includes(kind)) return null;
return origFn.call(this);
}
const query ='T | limit 10'
const code = Kusto.Language.KustoCode.Parse(query);
(Bridge as any).toArray(code.GetDiagnostics())
.forEach(d => console.log(d.Severity, d.Code, d.Message, d.Start, d.End));
Kusto.Language.Syntax.SyntaxElement.WalkNodes(code.Syntax,
n => console.log([ '-'.repeat(n.Depth) + '>', n.Kind, n.NameInParent, n.toString()].join(' ') )
);