-
-
Notifications
You must be signed in to change notification settings - Fork 96
Expand file tree
/
Copy pathMissingLanguageScopes.tsx
More file actions
80 lines (71 loc) · 1.73 KB
/
Copy pathMissingLanguageScopes.tsx
File metadata and controls
80 lines (71 loc) · 1.73 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
import {
languageScopeSupport,
scopeSupportFacetInfos,
ScopeSupportFacetLevel,
scopeSupportFacets,
type ScopeSupportFacet,
type ScopeType,
type SimpleScopeTypeType,
} from "@cursorless/common";
import React from "react";
export function MissingLanguageScopes(): React.JSX.Element[] {
return Object.keys(languageScopeSupport)
.sort()
.map((languageId) => <Language key={languageId} languageId={languageId} />);
}
function Language({
languageId,
}: {
languageId: string;
}): React.JSX.Element | null {
const scopeSupport = languageScopeSupport[languageId] ?? {};
const unsupportedFacets = scopeSupportFacets.filter(
(facet) => scopeSupport[facet] === ScopeSupportFacetLevel.unsupported,
);
const unspecifiedFacets = scopeSupportFacets.filter(
(facet) => scopeSupport[facet] == null,
);
if (unsupportedFacets.length === 0 && unspecifiedFacets.length === 0) {
return null;
}
return (
<>
<h3>{languageId}</h3>
{renderFacets("Unsupported", unsupportedFacets)}
{renderFacets("Unspecified", unspecifiedFacets)}
</>
);
}
function renderFacets(
title: string,
facets: ScopeSupportFacet[],
): React.JSX.Element | null {
const scopes = Array.from(
new Set(
facets.map((f) =>
serializeScopeType(scopeSupportFacetInfos[f].scopeType),
),
),
).sort();
if (scopes.length === 0) {
return null;
}
return (
<>
{title} ({scopes.length})
<ul>
{scopes.map((scope) => {
return <li key={scope}>{scope}</li>;
})}
</ul>
</>
);
}
function serializeScopeType(
scopeType: SimpleScopeTypeType | ScopeType,
): string {
if (typeof scopeType === "string") {
return scopeType;
}
return scopeType.type;
}