1-
21import * as vscode from 'vscode' ;
32import { findSections , SectionMatch } from './utils/findSections' ;
43
4+ // 1. Document Symbol Provider Class ----
55/**
66 * Document Symbol Provider for code organizer
77 * Detects comment sections with pattern: # Section Name ----
88 */
99export class CodeOrganizerDocumentSymbolProvider implements vscode . DocumentSymbolProvider {
1010
11+ //// 1.1 Child Symbol Processing ----
1112 /**
1213 * Helper method to add child symbols to a parent symbol (recursive)
1314 */
@@ -18,14 +19,18 @@ export class CodeOrganizerDocumentSymbolProvider implements vscode.DocumentSymbo
1819 document : vscode . TextDocument ,
1920 processedIds : Set < string > = new Set ( )
2021 ) : void {
22+
23+ ////// 1.1.1 Recursion Prevention ----
2124 // Prevent infinite recursion by tracking processed parent unique IDs
2225 if ( processedIds . has ( parentMatch . uniqueId ) ) {
2326 return ;
2427 }
2528 processedIds . add ( parentMatch . uniqueId ) ;
2629
30+ ////// 1.1.2 Child Filtering ----
2731 const children = allMatches . filter ( item => item . parentName === parentMatch . uniqueId ) ;
2832
33+ ////// 1.1.3 Child Symbol Creation ----
2934 if ( children . length > 0 ) {
3035 for ( let j = 0 ; j < children . length ; j ++ ) {
3136 const child = children [ j ] ;
@@ -43,7 +48,6 @@ export class CodeOrganizerDocumentSymbolProvider implements vscode.DocumentSymbo
4348 vscode . SymbolKind . Module , range , range
4449 ) ;
4550
46-
4751 // Recursively add children to this child symbol with updated processed set
4852 this . addChildSymbols ( childSymbol , child , allMatches , document , new Set ( processedIds ) ) ;
4953
@@ -52,6 +56,7 @@ export class CodeOrganizerDocumentSymbolProvider implements vscode.DocumentSymbo
5256 }
5357 }
5458
59+ //// 1.2 Main Symbol Provider Method ----
5560 /**
5661 * Main method called by VS Code when it needs symbols for a file
5762 */
@@ -60,14 +65,13 @@ export class CodeOrganizerDocumentSymbolProvider implements vscode.DocumentSymbo
6065 token : vscode . CancellationToken
6166 ) : vscode . DocumentSymbol [ ] {
6267
63-
64- // Setup
68+ ////// 1.2.1 Document Processing ----
6569 const text = document . getText ( ) ;
66- const all_matches : SectionMatch [ ] = findSections ( text ) ;
70+ const languageId = document . languageId ;
71+ const all_matches : SectionMatch [ ] = findSections ( text , languageId ) ;
6772 const matches = all_matches . filter ( ( item : SectionMatch ) => item . depth === 1 ) ;
6873
69-
70- // Generate symbols
74+ ////// 1.2.2 Symbol Generation ----
7175 const symbols : vscode . DocumentSymbol [ ] = [ ] ;
7276 for ( let i = 0 ; i < matches . length ; i ++ ) {
7377 const match = matches [ i ] ;
0 commit comments