Skip to content

Commit 0739fc1

Browse files
committed
Distinguish properties/enums from variables
1 parent 9e12670 commit 0739fc1

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

src/PowerShellEditorServices/Services/Symbols/Visitors/SymbolVisitor.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ propertyMemberAst.Parent is TypeDefinitionAst typeAst && typeAst.IsEnum
177177

178178
return _action(new SymbolReference(
179179
symbolType,
180-
"var " + propertyMemberAst.Name,
180+
"prop " + propertyMemberAst.Name,
181181
VisitorUtils.GetMemberOverloadName(propertyMemberAst),
182182
VisitorUtils.GetNameExtent(propertyMemberAst),
183183
propertyMemberAst.Extent,
@@ -196,7 +196,7 @@ public override AstVisitAction VisitMemberExpression(MemberExpressionAst memberE
196196
// TODO: It's too bad we can't get the property's real symbol and reuse its display string.
197197
return _action(new SymbolReference(
198198
SymbolType.Property,
199-
"var " + memberName,
199+
"prop " + memberName,
200200
"(property) " + memberName,
201201
memberExpressionAst.Member.Extent,
202202
memberExpressionAst.Extent,

test/PowerShellEditorServices.Test/Language/SymbolsServiceTests.cs

+15-14
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ public async Task FindsReferencesOnMethod()
621621
public async Task FindsPropertyDefinition()
622622
{
623623
SymbolReference symbol = await GetDefinition(FindsTypeSymbolsDefinitionData.PropertySourceDetails).ConfigureAwait(true);
624-
Assert.Equal("var SomePropWithDefault", symbol.Id);
624+
Assert.Equal("prop SomePropWithDefault", symbol.Id);
625625
Assert.Equal("[string] $SomePropWithDefault", symbol.Name);
626626
Assert.Equal(SymbolType.Property, symbol.Type);
627627
Assert.True(symbol.IsDeclaration);
@@ -634,14 +634,14 @@ public async Task FindsReferencesOnProperty()
634634
Assert.Collection(symbols,
635635
(i) =>
636636
{
637-
Assert.Equal("var SomeProp", i.Id);
637+
Assert.Equal("prop SomeProp", i.Id);
638638
Assert.Equal("[int] $SomeProp", i.Name);
639639
Assert.Equal(SymbolType.Property, i.Type);
640640
Assert.True(i.IsDeclaration);
641641
},
642642
(i) =>
643643
{
644-
Assert.Equal("var SomeProp", i.Id);
644+
Assert.Equal("prop SomeProp", i.Id);
645645
Assert.Equal("(property) SomeProp", i.Name);
646646
Assert.Equal(SymbolType.Property, i.Type);
647647
Assert.False(i.IsDeclaration);
@@ -655,14 +655,14 @@ public void FindsOccurrencesOnProperty()
655655
Assert.Collection(symbols,
656656
(i) =>
657657
{
658-
Assert.Equal("var SomePropWithDefault", i.Id);
658+
Assert.Equal("prop SomePropWithDefault", i.Id);
659659
Assert.Equal("[string] $SomePropWithDefault", i.Name);
660660
Assert.Equal(SymbolType.Property, i.Type);
661661
Assert.True(i.IsDeclaration);
662662
},
663663
(i) =>
664664
{
665-
Assert.Equal("var SomePropWithDefault", i.Id);
665+
Assert.Equal("prop SomePropWithDefault", i.Id);
666666
Assert.Equal("(property) SomePropWithDefault", i.Name);
667667
Assert.Equal(SymbolType.Property, i.Type);
668668
Assert.False(i.IsDeclaration);
@@ -673,15 +673,15 @@ public void FindsOccurrencesOnProperty()
673673
public async Task FindsEnumMemberDefinition()
674674
{
675675
SymbolReference symbol = await GetDefinition(FindsTypeSymbolsDefinitionData.EnumMemberSourceDetails).ConfigureAwait(true);
676-
Assert.Equal("var Second", symbol.Id);
676+
Assert.Equal("prop Second", symbol.Id);
677677
// Doesn't include [MyEnum]:: because that'd be redundant in the outline.
678678
Assert.Equal("Second", symbol.Name);
679679
Assert.Equal(SymbolType.EnumMember, symbol.Type);
680680
Assert.True(symbol.IsDeclaration);
681681
AssertIsRegion(symbol.NameRegion, 41, 5, 41, 11);
682682

683683
symbol = await GetDefinition(FindsReferencesOnTypeSymbolsData.EnumMemberSourceDetails).ConfigureAwait(true);
684-
Assert.Equal("var First", symbol.Id);
684+
Assert.Equal("prop First", symbol.Id);
685685
Assert.Equal("First", symbol.Name);
686686
Assert.Equal(SymbolType.EnumMember, symbol.Type);
687687
Assert.True(symbol.IsDeclaration);
@@ -695,14 +695,14 @@ public async Task FindsReferencesOnEnumMember()
695695
Assert.Collection(symbols,
696696
(i) =>
697697
{
698-
Assert.Equal("var First", i.Id);
698+
Assert.Equal("prop First", i.Id);
699699
Assert.Equal("First", i.Name);
700700
Assert.Equal(SymbolType.EnumMember, i.Type);
701701
Assert.True(i.IsDeclaration);
702702
},
703703
(i) =>
704704
{
705-
Assert.Equal("var First", i.Id);
705+
Assert.Equal("prop First", i.Id);
706706
// The reference is just a member invocation, and so indistinguishable from a property.
707707
Assert.Equal("(property) First", i.Name);
708708
Assert.Equal(SymbolType.Property, i.Type);
@@ -732,7 +732,8 @@ public void FindsSymbolsInFile()
732732
Assert.Equal(7, symbols.Count(i => i.Type == SymbolType.Function));
733733
Assert.Equal(8, symbols.Count(i => i.Type == SymbolType.Variable));
734734
Assert.Equal(4, symbols.Count(i => i.Type == SymbolType.Parameter));
735-
Assert.Equal(14, symbols.Count(i => i.Id.StartsWith("var ")));
735+
Assert.Equal(12, symbols.Count(i => i.Id.StartsWith("var ")));
736+
Assert.Equal(2, symbols.Count(i => i.Id.StartsWith("prop ")));
736737

737738
SymbolReference symbol = symbols.First(i => i.Type == SymbolType.Function);
738739
Assert.Equal("fn AFunction", symbol.Id);
@@ -760,7 +761,7 @@ public void FindsSymbolsInFile()
760761
Assert.True(symbol.IsDeclaration);
761762

762763
symbol = Assert.Single(symbols.Where(i => i.Type == SymbolType.Property));
763-
Assert.Equal("var AProperty", symbol.Id);
764+
Assert.Equal("prop AProperty", symbol.Id);
764765
Assert.Equal("[string] $AProperty", symbol.Name);
765766
Assert.True(symbol.IsDeclaration);
766767

@@ -780,7 +781,7 @@ public void FindsSymbolsInFile()
780781
Assert.True(symbol.IsDeclaration);
781782

782783
symbol = Assert.Single(symbols.Where(i => i.Type == SymbolType.EnumMember));
783-
Assert.Equal("var AValue", symbol.Id);
784+
Assert.Equal("prop AValue", symbol.Id);
784785
Assert.Equal("AValue", symbol.Name);
785786
Assert.True(symbol.IsDeclaration);
786787
}
@@ -806,7 +807,7 @@ public void FindsSymbolsWithNewLineInFile()
806807
AssertIsRegion(symbol.ScriptRegion, 8, 5, 10, 6);
807808

808809
symbol = Assert.Single(symbols.Where(i => i.Type == SymbolType.Property));
809-
Assert.Equal("var SomePropWithDefault", symbol.Id);
810+
Assert.Equal("prop SomePropWithDefault", symbol.Id);
810811
AssertIsRegion(symbol.NameRegion, 15, 5, 15, 25);
811812
AssertIsRegion(symbol.ScriptRegion, 12, 5, 15, 40);
812813

@@ -822,7 +823,7 @@ public void FindsSymbolsWithNewLineInFile()
822823
AssertIsRegion(symbol.ScriptRegion, 25, 1, 28, 2);
823824

824825
symbol = Assert.Single(symbols.Where(i => i.Type == SymbolType.EnumMember));
825-
Assert.Equal("var First", symbol.Id);
826+
Assert.Equal("prop First", symbol.Id);
826827
AssertIsRegion(symbol.NameRegion, 27, 5, 27, 10);
827828
AssertIsRegion(symbol.ScriptRegion, 27, 5, 27, 10);
828829
}

0 commit comments

Comments
 (0)