11import {
22 Range ,
33 serializeScopeType ,
4- type PlaintextScopeSupportFacet ,
5- type ScopeSupportFacet ,
64 type ScopeSupportFacetInfo ,
75 type ScopeTypeType ,
86} from "@cursorless/common" ;
@@ -11,11 +9,16 @@ import React, { useState } from "react";
119import { Code , type Highlight } from "./Code" ;
1210import { H2 , H3 , H4 } from "./Header" ;
1311import "./ScopeSupport.css" ;
14- import type { Fixture , ScopeTests } from "./types" ;
15- import { getFacetInfo , prettifyFacet , prettifyScopeType } from "./util" ;
12+ import type { FacetValue , Fixture , ScopeTests } from "./types" ;
13+ import {
14+ getFacetInfo ,
15+ isScopeInternal ,
16+ nameComparator ,
17+ prettifyFacet ,
18+ prettifyScopeType ,
19+ } from "./util" ;
1620
1721type RangeType = "content" | "removal" ;
18- type FacetValue = ScopeSupportFacet | PlaintextScopeSupportFacet ;
1922
2023interface Scopes {
2124 public : Scope [ ] ;
@@ -222,7 +225,7 @@ function getScopeFixtures(scopeTests: ScopeTests, languageId: string): Scopes {
222225 languageIds . has ( f . languageId ) ,
223226 ) ;
224227 const scopeMap : Partial < Record < ScopeTypeType , Scope > > = { } ;
225- const facetMap : Partial < Record < string , Facet > > = { } ;
228+ const facetMap : Partial < Record < FacetValue , Facet > > = { } ;
226229
227230 for ( const fixture of fixtures ) {
228231 const info = getFacetInfo ( fixture . languageId , fixture . facet ) ;
@@ -240,8 +243,6 @@ function getScopeFixtures(scopeTests: ScopeTests, languageId: string): Scopes {
240243 } ;
241244 }
242245
243- const facetKey = `${ scopeTypeType } .${ fixture . facet } ` ;
244-
245246 if ( facetMap [ fixture . facet ] == null ) {
246247 const facet = {
247248 facet : fixture . facet ,
@@ -259,10 +260,10 @@ function getScopeFixtures(scopeTests: ScopeTests, languageId: string): Scopes {
259260 const result : Scopes = { public : [ ] , internal : [ ] } ;
260261
261262 Object . values ( scopeMap )
262- . sort ( comparator )
263+ . sort ( nameComparator )
263264 . forEach ( ( scope ) => {
264- scope . facets . sort ( comparator ) ;
265- scope . facets . forEach ( ( f ) => f . fixtures . sort ( comparator ) ) ;
265+ scope . facets . sort ( nameComparator ) ;
266+ scope . facets . forEach ( ( f ) => f . fixtures . sort ( nameComparator ) ) ;
266267 if ( isScopeInternal ( scope . scopeTypeType ) ) {
267268 result . internal . push ( scope ) ;
268269 } else {
@@ -272,18 +273,3 @@ function getScopeFixtures(scopeTests: ScopeTests, languageId: string): Scopes {
272273
273274 return result ;
274275}
275-
276- function comparator ( a : { name : string } , b : { name : string } ) : number {
277- return a . name . localeCompare ( b . name ) ;
278- }
279-
280- function isScopeInternal ( scope : ScopeTypeType ) : boolean {
281- switch ( scope ) {
282- case "disqualifyDelimiter" :
283- case "pairDelimiter" :
284- case "textFragment" :
285- return true ;
286- default :
287- return false ;
288- }
289- }
0 commit comments