@@ -2,6 +2,9 @@ import * as vscode from 'vscode';
22import { getTrees , getRegexNode , toRange } from "../TreeSitter" ;
33import { SyntaxNode } from 'web-tree-sitter' ;
44
5+ export const metaData : vscode . DocumentSymbolProviderMetadata = {
6+ label : "JSON TextMate" ,
7+ } ;
58
69export const SymbolKind : { [ key : string ] : vscode . SymbolKind ; } = {
710 /*
@@ -91,15 +94,16 @@ export const SymbolKind: { [key: string]: vscode.SymbolKind; } = {
9194 ',' : vscode . SymbolKind . Property ,
9295 ':' : vscode . SymbolKind . Property ,
9396 '"' : vscode . SymbolKind . Property ,
94-
97+
9598 'literal' : vscode . SymbolKind . String ,
9699 'backslash' : vscode . SymbolKind . Property ,
97- }
100+ } ;
98101
99102
100103export const DocumentSymbolProvider : vscode . DocumentSymbolProvider = {
101104 provideDocumentSymbols ( document : vscode . TextDocument , token : vscode . CancellationToken ) : vscode . DocumentSymbol [ ] {
102105 // vscode.window.showInformationMessage(JSON.stringify("documentSymbol"));
106+ // const start = performance.now();
103107 const trees = getTrees ( document ) ;
104108 const tree = trees . jsonTree ;
105109
@@ -146,11 +150,18 @@ export const DocumentSymbolProvider: vscode.DocumentSymbolProvider = {
146150
147151 documentSymbol . children . push ( newDocumentSymbol ( childNode ) ) ;
148152 index ++ ;
153+
154+ if ( token . isCancellationRequested ) {
155+ // vscode.window.showInformationMessage(`cancel documentSymbols ${performance.now() - start}ms`);
156+ return ;
157+ }
149158 }
150159
160+
161+ // vscode.window.showInformationMessage(`documentSymbols ${performance.now() - start}ms\n${document.fileName}`);
151162 return [ documentSymbol ] ;
152163 } ,
153- }
164+ } ;
154165
155166function newDocumentSymbol ( node : SyntaxNode ) : vscode . DocumentSymbol {
156167 let text : string ;
0 commit comments