forked from firefox-devtools/debugger
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinesInScope.js
More file actions
43 lines (34 loc) · 1.06 KB
/
linesInScope.js
File metadata and controls
43 lines (34 loc) · 1.06 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
import { getOutOfScopeLocations } from "../reducers/ast";
import { getSelectedSource } from "../reducers/sources";
import { getSourceLineCount } from "../utils/source";
import { range } from "lodash";
import { flatMap } from "lodash";
import { uniq } from "lodash";
import { without } from "lodash";
function getOutOfScopeLines(outOfScopeLocations: AstLocation[]) {
if (!outOfScopeLocations) {
return null;
}
return uniq(
flatMap(outOfScopeLocations, location =>
range(location.start.line, location.end.line)
)
);
}
export default function getInScopeLines(state: OuterState) {
const source = getSelectedSource(state);
const outOfScopeLocations = getOutOfScopeLocations(state);
if (!source || !source.get("text")) {
return;
}
const linesOutOfScope = getOutOfScopeLines(
outOfScopeLocations,
source.toJS()
);
const sourceNumLines = getSourceLineCount(source.toJS());
const sourceLines = range(1, sourceNumLines + 1);
if (!linesOutOfScope) {
return sourceLines;
}
return without(sourceLines, ...linesOutOfScope);
}