-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy path__bootstrap.js
More file actions
65 lines (61 loc) · 2.9 KB
/
__bootstrap.js
File metadata and controls
65 lines (61 loc) · 2.9 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache License, Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2024 Datadog, Inc.
"use strict";
import {CodeRegion} from "ext:ddsa_lib/region";
import {DDSA, DDSAPrivate} from "ext:ddsa_lib/ddsa";
import {DDSA_Console} from "ext:ddsa_lib/utility";
import {Digraph} from "ext:ddsa_lib/flow/graph";
import {DxCursor} from "ext:ddsa_lib/dx_cursor";
import {DxGo} from "ext:ddsa_lib/dx_go";
import {FileContext} from "ext:ddsa_lib/context_file";
import {FileContextGo} from "ext:ddsa_lib/context_file_go";
import {FileContextTerraform, TerraformResource} from "ext:ddsa_lib/context_file_tf";
import {FileContextJavaScript, PackageImport} from "ext:ddsa_lib/context_file_js";
import {Fix} from "ext:ddsa_lib/fix";
import {QueryMatch} from "ext:ddsa_lib/query_match";
import {QueryMatchCompat} from "ext:ddsa_lib/query_match_compat";
import {RootContext} from "ext:ddsa_lib/context_root";
import {RuleContext} from "ext:ddsa_lib/context_rule";
import {TreeSitterFieldChildNode, TreeSitterNode} from "ext:ddsa_lib/ts_node";
import {TsLanguageContext} from "ext:ddsa_lib/context_ts_lang";
import {Violation} from "ext:ddsa_lib/violation";
// TODO(JF): These are only used by the Rust runtime, which currently expects them in global scope, but
// these should be hidden inside another object, not `globalThis`.
globalThis.CodeRegion = CodeRegion;
globalThis.DDSA_Console = DDSA_Console;
globalThis.DDSA = DDSA;
globalThis.Digraph = Digraph;
globalThis.DxCursor = DxCursor;
globalThis.DxGo = DxGo;
globalThis.FileContext = FileContext;
globalThis.FileContextGo = FileContextGo;
globalThis.FileContextJavaScript = FileContextJavaScript;
globalThis.PackageImport = PackageImport;
globalThis.FileContextTerraform = FileContextTerraform;
globalThis.Fix = Fix;
globalThis.TerraformResource = TerraformResource;
globalThis.QueryMatch = QueryMatch;
globalThis.QueryMatchCompat = QueryMatchCompat;
globalThis.RootContext = RootContext;
globalThis.RuleContext = RuleContext;
globalThis.TreeSitterNode = TreeSitterNode;
globalThis.TreeSitterFieldChildNode = TreeSitterFieldChildNode;
globalThis.TsLanguageContext = TsLanguageContext;
globalThis.Violation = Violation;
///////////
// Take all exports from `stella_compat.js` and define them within this scope.
// NOTE: This is temporary scaffolding used during the transition to `ddsa_lib::JsRuntime`.
import * as stellaCompat from "ext:ddsa_lib/stella_compat";
for (const [name, obj] of Object.entries(stellaCompat)) {
globalThis[name] = obj;
}
///////////
globalThis.console = new DDSA_Console();
globalThis.ddsa = new DDSA();
// Note: The name "private" is just used to communicate intent -- there is no enforcement preventing rules from using this.
globalThis.__ddsaPrivate__ = new DDSAPrivate();
globalThis.dx = {
cursor: new DxCursor(),
go: new DxGo()
};