Skip to content

Commit b634dfa

Browse files
committed
Fix property symbols tests
1 parent 2729e83 commit b634dfa

File tree

2 files changed

+36
-17
lines changed

2 files changed

+36
-17
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,13 @@ public override AstVisitAction VisitMemberExpression(MemberExpressionAst memberE
195195
return AstVisitAction.Continue;
196196
}
197197

198-
// TODO: It's too bad we can't get the member's real symbol and reuse its display string.
198+
// TODO: It's too bad we can't get the property's real symbol and reuse its display string.
199199
return _action(new SymbolReference(
200200
SymbolType.Property,
201201
#pragma warning disable CS8604 // Possible null reference argument.
202-
memberName,
202+
"$" + memberName,
203203
#pragma warning restore CS8604
204-
"(method) " + memberName,
204+
"(property) " + memberName,
205205
memberExpressionAst.Member.Extent,
206206
memberExpressionAst.Extent,
207207
_file,
@@ -216,6 +216,7 @@ public override AstVisitAction VisitInvokeMemberExpression(InvokeMemberExpressio
216216
return AstVisitAction.Continue;
217217
}
218218

219+
// TODO: It's too bad we can't get the member's real symbol and reuse its display string.
219220
return _action(new SymbolReference(
220221
SymbolType.Method,
221222
#pragma warning disable CS8604 // Possible null reference argument.

test/PowerShellEditorServices.Test/Language/SymbolsServiceTests.cs

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -613,25 +613,43 @@ public async Task FindsPropertyDefinition()
613613
[Fact]
614614
public async Task FindsReferencesOnProperty()
615615
{
616-
List<SymbolReference> symbols = await GetReferences(FindsReferencesOnTypeSymbolsData.PropertySourceDetails).ConfigureAwait(true);
617-
SymbolReference symbol = Assert.Single(symbols);
618-
Assert.Equal("SuperClass.SomeProp", symbol.SymbolName);
619-
Assert.Equal(SymbolType.Property, symbol.SymbolType);
620-
AssertIsRegion(symbol.NameRegion, 17, 10, 17, 19);
621-
AssertIsRegion(symbol.ScriptRegion, 17, 5, 17, 19);
622-
// TODO: This should also find $o.SomeProp
616+
IEnumerable<SymbolReference> symbols = await GetReferences(FindsReferencesOnTypeSymbolsData.PropertySourceDetails).ConfigureAwait(true);
617+
Assert.Collection(symbols,
618+
(i) =>
619+
{
620+
Assert.Equal("$SomeProp", i.SymbolName);
621+
Assert.Equal("[int] $SomeProp", i.DisplayString);
622+
Assert.Equal(SymbolType.Property, i.SymbolType);
623+
Assert.True(i.IsDeclaration);
624+
},
625+
(i) =>
626+
{
627+
Assert.Equal("$SomeProp", i.SymbolName);
628+
Assert.Equal("(property) SomeProp", i.DisplayString);
629+
Assert.Equal(SymbolType.Property, i.SymbolType);
630+
Assert.False(i.IsDeclaration);
631+
});
623632
}
624633

625634
[Fact]
626635
public void FindsOccurrencesOnProperty()
627636
{
628-
IReadOnlyList<SymbolReference> symbols = GetOccurrences(FindsOccurrencesOnTypeSymbolsData.PropertySourceDetails);
629-
SymbolReference symbol = Assert.Single(symbols);
630-
Assert.Equal("SuperClass.SomePropWithDefault", symbol.SymbolName);
631-
Assert.Equal(SymbolType.Property, symbol.SymbolType);
632-
AssertIsRegion(symbol.NameRegion, 15, 13, 15, 33);
633-
AssertIsRegion(symbol.ScriptRegion, 15, 5, 15, 61);
634-
// TODO: This should also find the $this.SomePropWithDefault reference.
637+
IEnumerable<SymbolReference> symbols = GetOccurrences(FindsOccurrencesOnTypeSymbolsData.PropertySourceDetails);
638+
Assert.Collection(symbols,
639+
(i) =>
640+
{
641+
Assert.Equal("$SomePropWithDefault", i.SymbolName);
642+
Assert.Equal("[string] $SomePropWithDefault", i.DisplayString);
643+
Assert.Equal(SymbolType.Property, i.SymbolType);
644+
Assert.True(i.IsDeclaration);
645+
},
646+
(i) =>
647+
{
648+
Assert.Equal("$SomePropWithDefault", i.SymbolName);
649+
Assert.Equal("(property) SomePropWithDefault", i.DisplayString);
650+
Assert.Equal(SymbolType.Property, i.SymbolType);
651+
Assert.False(i.IsDeclaration);
652+
});
635653
}
636654

637655
[Fact]

0 commit comments

Comments
 (0)