2
2
* Copyright (c) Red Hat. All rights reserved.
3
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
4
*--------------------------------------------------------------------------------------------*/
5
- import { setupTextDocument , TEST_URI , configureLanguageService } from './utils/testHelper' ;
5
+ import { setupTextDocument , TEST_URI , configureLanguageService } from './utils/testHelper' ;
6
6
import { createExpectedSymbolInformation , createExpectedDocumentSymbol } from './utils/verifyError' ;
7
7
import { DocumentSymbol , SymbolKind } from 'vscode-languageserver-types' ;
8
8
import assert = require( 'assert' ) ;
@@ -16,7 +16,7 @@ suite('Document Symbols Tests', () => {
16
16
17
17
function parseNonHierarchicalSetup ( content : string ) {
18
18
const testTextDocument = setupTextDocument ( content ) ;
19
- return languageService . findDocumentSymbols ( testTextDocument ) ;
19
+ return languageService . findDocumentSymbols ( testTextDocument ) ;
20
20
}
21
21
22
22
it ( 'Document is empty' , done => {
@@ -298,6 +298,47 @@ suite('Document Symbols Tests', () => {
298
298
) ;
299
299
} ) ;
300
300
301
+ it ( 'Document Symbols with complex mapping and aliases' , ( ) => {
302
+ const content = `
303
+ version: 0.0.1
304
+ structure:
305
+ ? &root root
306
+ :
307
+ element: div
308
+ conditions:
309
+ ? *root
310
+ :
311
+ style:
312
+ height: 41
313
+ ` ;
314
+
315
+ const symbols = parseHierarchicalSetup ( content ) ;
316
+
317
+ assert . equal ( symbols . length , 3 ) ;
318
+ assert . deepEqual (
319
+ symbols [ 0 ] ,
320
+ createExpectedDocumentSymbol ( 'version' , SymbolKind . String , 1 , 12 , 1 , 26 , 1 , 12 , 1 , 19 )
321
+ ) ;
322
+
323
+ const element = createExpectedDocumentSymbol ( 'element' , SymbolKind . String , 5 , 16 , 5 , 28 , 5 , 16 , 5 , 23 , ) ;
324
+ const root1 = createExpectedDocumentSymbol ( 'root' , SymbolKind . Module , 3 , 22 , 5 , 28 , 3 , 22 , 3 , 26 , [ element ] ) ;
325
+
326
+ const height = createExpectedDocumentSymbol ( 'height' , SymbolKind . Number , 10 , 18 , 10 , 28 , 10 , 18 , 10 , 24 ) ;
327
+ const style = createExpectedDocumentSymbol ( 'style' , SymbolKind . Module , 9 , 16 , 10 , 28 , 9 , 16 , 9 , 21 , [ height ] ) ;
328
+ const root2 = createExpectedDocumentSymbol ( 'root' , SymbolKind . Module , 7 , 17 , 10 , 28 , 7 , 17 , 7 , 21 , [ style ] ) ;
329
+
330
+ assert . deepEqual (
331
+ symbols [ 1 ] ,
332
+ createExpectedDocumentSymbol ( 'structure' , SymbolKind . Module , 2 , 12 , 5 , 28 , 2 , 12 , 2 , 21 , [ root1 ] )
333
+ ) ;
334
+
335
+ assert . deepEqual (
336
+ symbols [ 2 ] ,
337
+ createExpectedDocumentSymbol ( 'conditions' , SymbolKind . Module , 6 , 12 , 10 , 28 , 6 , 12 , 6 , 22 , [ root2 ] )
338
+ ) ;
339
+
340
+ } ) ;
341
+
301
342
} ) ;
302
343
303
344
} ) ;
0 commit comments