@@ -97,7 +97,7 @@ await symbolsService.ScanForReferencesOfSymbol(
9797 symbolReference ,
9898 workspace . ExpandScriptReferences ( scriptFile ) ) . ConfigureAwait ( true ) ;
9999
100- return symbols . OrderBy ( symbol => symbol . ScriptRegion . StartOffset ) . ToList ( ) ;
100+ return symbols . OrderBy ( symbol => symbol . ScriptRegion . ToRange ( ) . Start ) . ToList ( ) ;
101101 }
102102
103103 private IReadOnlyList < SymbolReference > GetOccurrences ( ScriptRegion scriptRegion )
@@ -107,11 +107,11 @@ private IReadOnlyList<SymbolReference> GetOccurrences(ScriptRegion scriptRegion)
107107 GetScriptFile ( scriptRegion ) ,
108108 scriptRegion . StartLineNumber ,
109109 scriptRegion . StartColumnNumber )
110- . OrderBy ( symbol => symbol . ScriptRegion . StartOffset )
110+ . OrderBy ( symbol => symbol . ScriptRegion . ToRange ( ) . Start )
111111 . ToArray ( ) ;
112112 }
113113
114- private List < SymbolReference > FindSymbolsInFile ( ScriptRegion scriptRegion ) => symbolsService . FindSymbolsInFile ( GetScriptFile ( scriptRegion ) ) ;
114+ private IEnumerable < SymbolReference > FindSymbolsInFile ( ScriptRegion scriptRegion ) => symbolsService . FindSymbolsInFile ( GetScriptFile ( scriptRegion ) ) . OrderBy ( symbol => symbol . ScriptRegion . ToRange ( ) . Start ) ;
115115
116116 [ Fact ]
117117 public async Task FindsParameterHintsOnCommand ( )
@@ -310,8 +310,8 @@ public async Task FindsReferencesOnEnum()
310310 // TODO: Remove definitions from references.
311311 List < SymbolReference > referencesResult = await GetReferences ( FindsReferencesOnTypeSymbolsData . EnumSourceDetails ) . ConfigureAwait ( true ) ;
312312 Assert . Equal ( 4 , referencesResult . Count ) ;
313- Assert . Equal ( 25 , referencesResult [ 1 ] . ScriptRegion . StartLineNumber ) ;
314- Assert . Equal ( 19 , referencesResult [ 1 ] . ScriptRegion . StartColumnNumber ) ;
313+ Assert . Equal ( 25 , referencesResult [ 0 ] . ScriptRegion . StartLineNumber ) ;
314+ Assert . Equal ( 19 , referencesResult [ 0 ] . ScriptRegion . StartColumnNumber ) ;
315315 }
316316
317317 [ Fact ]
@@ -365,8 +365,8 @@ public async Task FindsReferencesOnTypeConstraint()
365365 // TODO: Remove definitions from references.
366366 List < SymbolReference > referencesResult = await GetReferences ( FindsReferencesOnTypeSymbolsData . TypeConstraintSourceDetails ) . ConfigureAwait ( true ) ;
367367 Assert . Equal ( 4 , referencesResult . Count ) ;
368- Assert . Equal ( 25 , referencesResult [ 1 ] . ScriptRegion . StartLineNumber ) ;
369- Assert . Equal ( 19 , referencesResult [ 1 ] . ScriptRegion . StartColumnNumber ) ;
368+ Assert . Equal ( 25 , referencesResult [ 0 ] . ScriptRegion . StartLineNumber ) ;
369+ Assert . Equal ( 19 , referencesResult [ 0 ] . ScriptRegion . StartColumnNumber ) ;
370370 }
371371
372372 [ Fact ]
@@ -559,68 +559,68 @@ public async Task FindsDetailsWithSignatureForMethod()
559559 [ Fact ]
560560 public void FindsSymbolsInFile ( )
561561 {
562- List < SymbolReference > symbolsResult = FindSymbolsInFile ( FindSymbolsInMultiSymbolFile . SourceDetails ) ;
562+ IEnumerable < SymbolReference > symbolsResult = FindSymbolsInFile ( FindSymbolsInMultiSymbolFile . SourceDetails ) ;
563563
564- Assert . Equal ( 4 , symbolsResult . Count ( symbolReference => symbolReference . SymbolType == SymbolType . Function ) ) ;
565- Assert . Equal ( 3 , symbolsResult . Count ( symbolReference => symbolReference . SymbolType == SymbolType . Variable ) ) ;
566- Assert . Single ( symbolsResult . Where ( symbolReference => symbolReference . SymbolType == SymbolType . Workflow ) ) ;
567- Assert . Single ( symbolsResult . Where ( symbolReference => symbolReference . SymbolType == SymbolType . Class ) ) ;
568- Assert . Single ( symbolsResult . Where ( symbolReference => symbolReference . SymbolType == SymbolType . Property ) ) ;
569- Assert . Single ( symbolsResult . Where ( symbolReference => symbolReference . SymbolType == SymbolType . Constructor ) ) ;
570- Assert . Single ( symbolsResult . Where ( symbolReference => symbolReference . SymbolType == SymbolType . Method ) ) ;
571- Assert . Single ( symbolsResult . Where ( symbolReference => symbolReference . SymbolType == SymbolType . Enum ) ) ;
572- Assert . Single ( symbolsResult . Where ( symbolReference => symbolReference . SymbolType == SymbolType . EnumMember ) ) ;
564+ Assert . Equal ( 7 , symbolsResult . Count ( symbolReference => symbolReference . SymbolType == SymbolType . Function ) ) ;
565+ Assert . Equal ( 13 , symbolsResult . Count ( symbolReference => symbolReference . SymbolType == SymbolType . Variable ) ) ;
573566
574567 SymbolReference firstFunctionSymbol = symbolsResult . First ( r => r . SymbolType == SymbolType . Function ) ;
575568 Assert . Equal ( "AFunction" , firstFunctionSymbol . SymbolName ) ;
576569 Assert . Equal ( 7 , firstFunctionSymbol . ScriptRegion . StartLineNumber ) ;
577570 Assert . Equal ( 10 , firstFunctionSymbol . ScriptRegion . StartColumnNumber ) ;
578571
579572 SymbolReference lastVariableSymbol = symbolsResult . Last ( r => r . SymbolType == SymbolType . Variable ) ;
580- Assert . Equal ( "$Script:ScriptVar2 " , lastVariableSymbol . SymbolName ) ;
581- Assert . Equal ( 3 , lastVariableSymbol . ScriptRegion . StartLineNumber ) ;
582- Assert . Equal ( 1 , lastVariableSymbol . ScriptRegion . StartColumnNumber ) ;
573+ Assert . Equal ( "$param3 " , lastVariableSymbol . SymbolName ) ;
574+ Assert . Equal ( 32 , lastVariableSymbol . ScriptRegion . StartLineNumber ) ;
575+ Assert . Equal ( 50 , lastVariableSymbol . ScriptRegion . StartColumnNumber ) ;
583576
584- SymbolReference firstWorkflowSymbol = symbolsResult . First ( r => r . SymbolType == SymbolType . Workflow ) ;
577+ SymbolReference firstWorkflowSymbol =
578+ Assert . Single ( symbolsResult . Where ( symbolReference => symbolReference . SymbolType == SymbolType . Workflow ) ) ;
585579 Assert . Equal ( "AWorkflow" , firstWorkflowSymbol . SymbolName ) ;
586580 Assert . Equal ( 23 , firstWorkflowSymbol . ScriptRegion . StartLineNumber ) ;
587581 Assert . Equal ( 10 , firstWorkflowSymbol . ScriptRegion . StartColumnNumber ) ;
588582
589- SymbolReference firstClassSymbol = symbolsResult . First ( r => r . SymbolType == SymbolType . Class ) ;
583+ SymbolReference firstClassSymbol =
584+ Assert . Single ( symbolsResult . Where ( symbolReference => symbolReference . SymbolType == SymbolType . Class ) ) ;
590585 Assert . Equal ( "AClass" , firstClassSymbol . SymbolName ) ;
591586 Assert . Equal ( 25 , firstClassSymbol . ScriptRegion . StartLineNumber ) ;
592587 Assert . Equal ( 7 , firstClassSymbol . ScriptRegion . StartColumnNumber ) ;
593588
594- SymbolReference firstPropertySymbol = symbolsResult . First ( r => r . SymbolType == SymbolType . Property ) ;
595- Assert . Equal ( "AProperty" , firstPropertySymbol . SymbolName ) ;
589+ SymbolReference firstPropertySymbol =
590+ Assert . Single ( symbolsResult . Where ( symbolReference => symbolReference . SymbolType == SymbolType . Property ) ) ;
591+ Assert . Equal ( "AClass.AProperty" , firstPropertySymbol . SymbolName ) ;
596592 Assert . Equal ( 26 , firstPropertySymbol . ScriptRegion . StartLineNumber ) ;
597593 Assert . Equal ( 13 , firstPropertySymbol . ScriptRegion . StartColumnNumber ) ;
598594
599- SymbolReference firstConstructorSymbol = symbolsResult . First ( r => r . SymbolType == SymbolType . Constructor ) ;
600- Assert . Equal ( "AClass([string]$AParameter)" , firstConstructorSymbol . SymbolName ) ;
595+ SymbolReference firstConstructorSymbol =
596+ Assert . Single ( symbolsResult . Where ( symbolReference => symbolReference . SymbolType == SymbolType . Constructor ) ) ;
597+ Assert . Equal ( "AClass.AClass([string]$AParameter)" , firstConstructorSymbol . SymbolName ) ;
601598 Assert . Equal ( 28 , firstConstructorSymbol . ScriptRegion . StartLineNumber ) ;
602599 Assert . Equal ( 5 , firstConstructorSymbol . ScriptRegion . StartColumnNumber ) ;
603600
604- SymbolReference firstMethodSymbol = symbolsResult . First ( r => r . SymbolType == SymbolType . Method ) ;
605- Assert . Equal ( "AMethod([string]$param1, [int]$param2, $param3)" , firstMethodSymbol . SymbolName ) ;
601+ SymbolReference firstMethodSymbol =
602+ Assert . Single ( symbolsResult . Where ( symbolReference => symbolReference . SymbolType == SymbolType . Method ) ) ;
603+ Assert . Equal ( "AClass.AMethod([string]$param1, [int]$param2, $param3)" , firstMethodSymbol . SymbolName ) ;
606604 Assert . Equal ( 32 , firstMethodSymbol . ScriptRegion . StartLineNumber ) ;
607605 Assert . Equal ( 11 , firstMethodSymbol . ScriptRegion . StartColumnNumber ) ;
608606
609- SymbolReference firstEnumSymbol = symbolsResult . First ( r => r . SymbolType == SymbolType . Enum ) ;
607+ SymbolReference firstEnumSymbol =
608+ Assert . Single ( symbolsResult . Where ( symbolReference => symbolReference . SymbolType == SymbolType . Enum ) ) ;
610609 Assert . Equal ( "AEnum" , firstEnumSymbol . SymbolName ) ;
611610 Assert . Equal ( 37 , firstEnumSymbol . ScriptRegion . StartLineNumber ) ;
612611 Assert . Equal ( 6 , firstEnumSymbol . ScriptRegion . StartColumnNumber ) ;
613612
614- SymbolReference firstEnumMemberSymbol = symbolsResult . First ( r => r . SymbolType == SymbolType . EnumMember ) ;
615- Assert . Equal ( "AValue" , firstEnumMemberSymbol . SymbolName ) ;
613+ SymbolReference firstEnumMemberSymbol =
614+ Assert . Single ( symbolsResult . Where ( symbolReference => symbolReference . SymbolType == SymbolType . EnumMember ) ) ;
615+ Assert . Equal ( "AEnum.AValue" , firstEnumMemberSymbol . SymbolName ) ;
616616 Assert . Equal ( 38 , firstEnumMemberSymbol . ScriptRegion . StartLineNumber ) ;
617617 Assert . Equal ( 5 , firstEnumMemberSymbol . ScriptRegion . StartColumnNumber ) ;
618618 }
619619
620620 [ Fact ]
621621 public void FindsSymbolsWithNewLineInFile ( )
622622 {
623- List < SymbolReference > symbols = FindSymbolsInFile ( FindSymbolsInNewLineSymbolFile . SourceDetails ) ;
623+ IEnumerable < SymbolReference > symbols = FindSymbolsInFile ( FindSymbolsInNewLineSymbolFile . SourceDetails ) ;
624624
625625 SymbolReference firstFunctionSymbol =
626626 Assert . Single ( symbols . Where ( symbolReference => symbolReference . SymbolType == SymbolType . Function ) ) ;
@@ -670,7 +670,7 @@ public void FindsSymbolsInDSCFile()
670670 {
671671 Skip . If ( ! s_isWindows , "DSC only works properly on Windows." ) ;
672672
673- List < SymbolReference > symbolsResult = FindSymbolsInFile ( FindSymbolsInDSCFile . SourceDetails ) ;
673+ IEnumerable < SymbolReference > symbolsResult = FindSymbolsInFile ( FindSymbolsInDSCFile . SourceDetails ) ;
674674
675675 Assert . Single ( symbolsResult . Where ( symbolReference => symbolReference . SymbolType == SymbolType . Configuration ) ) ;
676676 SymbolReference firstConfigurationSymbol = symbolsResult . First ( r => r . SymbolType == SymbolType . Configuration ) ;
@@ -682,7 +682,7 @@ public void FindsSymbolsInDSCFile()
682682 [ Fact ]
683683 public void FindsSymbolsInPesterFile ( )
684684 {
685- List < PesterSymbolReference > symbolsResult = FindSymbolsInFile ( FindSymbolsInPesterFile . SourceDetails ) . OfType < PesterSymbolReference > ( ) . ToList ( ) ;
685+ IEnumerable < PesterSymbolReference > symbolsResult = FindSymbolsInFile ( FindSymbolsInPesterFile . SourceDetails ) . OfType < PesterSymbolReference > ( ) ;
686686 Assert . Equal ( 12 , symbolsResult . Count ( r => r . SymbolType == SymbolType . Function ) ) ;
687687
688688 Assert . Equal ( 1 , symbolsResult . Count ( r => r . Command == PesterCommandType . Describe ) ) ;
@@ -737,14 +737,14 @@ public void FindsSymbolsInPesterFile()
737737 [ Fact ]
738738 public void LangServerFindsSymbolsInPSDFile ( )
739739 {
740- List < SymbolReference > symbolsResult = FindSymbolsInFile ( FindSymbolsInPSDFile . SourceDetails ) ;
741- Assert . Equal ( 3 , symbolsResult . Count ) ;
740+ IEnumerable < SymbolReference > symbolsResult = FindSymbolsInFile ( FindSymbolsInPSDFile . SourceDetails ) ;
741+ Assert . Equal ( 3 , symbolsResult . Count ( ) ) ;
742742 }
743743
744744 [ Fact ]
745745 public void FindsSymbolsInNoSymbolsFile ( )
746746 {
747- List < SymbolReference > symbolsResult = FindSymbolsInFile ( FindSymbolsInNoSymbolsFile . SourceDetails ) ;
747+ IEnumerable < SymbolReference > symbolsResult = FindSymbolsInFile ( FindSymbolsInNoSymbolsFile . SourceDetails ) ;
748748 Assert . Empty ( symbolsResult ) ;
749749 }
750750 }
0 commit comments