From 9f7b34c41ac18002c6e658e5c08aba8080d1f7e3 Mon Sep 17 00:00:00 2001 From: Aiday Marlen Kyzy Date: Mon, 6 Jan 2025 17:04:10 +0100 Subject: [PATCH] adding code --- .../src/languageFeatures/documentSymbol.ts | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/extensions/typescript-language-features/src/languageFeatures/documentSymbol.ts b/extensions/typescript-language-features/src/languageFeatures/documentSymbol.ts index ef2d47ef942..34ab46e48eb 100644 --- a/extensions/typescript-language-features/src/languageFeatures/documentSymbol.ts +++ b/extensions/typescript-language-features/src/languageFeatures/documentSymbol.ts @@ -35,6 +35,10 @@ const getSymbolKind = (kind: string): vscode.SymbolKind => { class TypeScriptDocumentSymbolProvider implements vscode.DocumentSymbolProvider { + private readonly _namespaceLineHeightDecorationType: vscode.TextEditorDecorationType = vscode.window.createTextEditorDecorationType({ lineHeight: 100 }); + private readonly _classLineHeightDecorationType: vscode.TextEditorDecorationType = vscode.window.createTextEditorDecorationType({ lineHeight: 70 }); + private readonly _methodLineHeightDecorationType: vscode.TextEditorDecorationType = vscode.window.createTextEditorDecorationType({ lineHeight: 50 }); + public constructor( private readonly client: ITypeScriptServiceClient, private readonly cachedResponse: CachedResponse, @@ -57,6 +61,33 @@ class TypeScriptDocumentSymbolProvider implements vscode.DocumentSymbolProvider for (const item of response.body.childItems) { TypeScriptDocumentSymbolProvider.convertNavTree(document.uri, result, item); } + + const activeTextEditor = vscode.window.activeTextEditor; + if (activeTextEditor) { + const namespaceRanges: vscode.Range[] = []; + const classRanges: vscode.Range[] = []; + const methodRanges: vscode.Range[] = []; + + for (const res of result) { + switch (res.kind) { + case (vscode.SymbolKind.Namespace): { + namespaceRanges.push(new vscode.Range(res.range.start.line, 1, res.range.start.line, 1)); + break; + } + case (vscode.SymbolKind.Class): { + classRanges.push(new vscode.Range(res.range.start.line, 1, res.range.start.line, 1)); + break; + } + case (vscode.SymbolKind.Method): { + methodRanges.push(new vscode.Range(res.range.start.line, 1, res.range.start.line, 1)); + break; + } + } + } + activeTextEditor.setDecorations(this._namespaceLineHeightDecorationType, namespaceRanges); + activeTextEditor.setDecorations(this._classLineHeightDecorationType, classRanges); + activeTextEditor.setDecorations(this._methodLineHeightDecorationType, methodRanges); + } return result; }