forked from firefox-devtools/debugger
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
99 lines (83 loc) · 2.53 KB
/
index.js
File metadata and controls
99 lines (83 loc) · 2.53 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// @flow
import { workerUtils } from "devtools-utils";
const { WorkerDispatcher } = workerUtils;
import type { AstSource, AstLocation, AstPosition } from "./types";
import type { SourceLocation, SourceId, SourceContent } from "../../types";
import type { SourceScope } from "./getScopes/visitor";
import type { SymbolDeclarations } from "./getSymbols";
export class ParserDispatcher extends WorkerDispatcher {
async findOutOfScopeLocations(
sourceId: string,
position: AstPosition
): Promise<AstLocation[]> {
return this.invoke("findOutOfScopeLocations", sourceId, position);
}
async getNextStep(
sourceId: SourceId,
pausedPosition: AstPosition
): Promise<?SourceLocation> {
return this.invoke("getNextStep", sourceId, pausedPosition);
}
async clearState(): Promise<void> {
return this.invoke("clearState");
}
async getScopes(location: SourceLocation): Promise<SourceScope[]> {
return this.invoke("getScopes", location);
}
async getSymbols(sourceId: string): Promise<SymbolDeclarations> {
return this.invoke("getSymbols", sourceId);
}
async setSource(sourceId: SourceId, content: SourceContent): Promise<void> {
const astSource: AstSource = {
id: sourceId,
text: content.type === "wasm" ? "" : content.value,
contentType: content.contentType || null,
isWasm: content.type === "wasm"
};
return this.invoke("setSource", astSource);
}
async hasSyntaxError(input: string): Promise<string | false> {
return this.invoke("hasSyntaxError", input);
}
async mapExpression(
expression: string,
mappings: {
[string]: string | null
} | null,
bindings: string[],
shouldMapBindings?: boolean,
shouldMapAwait?: boolean
): Promise<{ expression: string }> {
return this.invoke(
"mapExpression",
expression,
mappings,
bindings,
shouldMapBindings,
shouldMapAwait
);
}
async clear() {
await this.clearState();
}
}
export type {
SourceScope,
BindingData,
BindingLocation,
BindingLocationType,
BindingDeclarationLocation,
BindingMetaValue,
BindingType
} from "./getScopes";
export type { AstLocation, AstPosition } from "./types";
export type {
ClassDeclaration,
SymbolDeclaration,
SymbolDeclarations,
IdentifierDeclaration,
FunctionDeclaration
} from "./getSymbols";