@@ -32,8 +32,7 @@ IEnumerable<SymbolReference> IDocumentSymbolProvider.ProvideDocumentSymbols(
32
32
33
33
return commandAsts . OfType < CommandAst > ( )
34
34
. Where ( IsPesterCommand )
35
- . Select ( ast => ConvertPesterAstToSymbolReference ( scriptFile , ast ) )
36
- . Where ( pesterSymbol => pesterSymbol ? . TestName != null ) ;
35
+ . Select ( ast => ConvertPesterAstToSymbolReference ( scriptFile , ast ) ) ;
37
36
}
38
37
39
38
/// <summary>
@@ -105,20 +104,21 @@ private static PesterSymbolReference ConvertPesterAstToSymbolReference(ScriptFil
105
104
// Check for an explicit "-Name" parameter
106
105
if ( currentCommandElement is CommandParameterAst parameterAst )
107
106
{
107
+ // Found -Name parameter, move to next element which is the argument for -TestName
108
108
i ++ ;
109
- if ( parameterAst . ParameterName == "Name" && i < pesterCommandAst . CommandElements . Count )
109
+
110
+ if ( ! alreadySawName && TryGetTestNameArgument ( pesterCommandAst . CommandElements [ i ] , out testName ) )
110
111
{
111
- testName = alreadySawName ? null : ( pesterCommandAst . CommandElements [ i ] as StringConstantExpressionAst ) ? . Value ;
112
112
alreadySawName = true ;
113
113
}
114
+
114
115
continue ;
115
116
}
116
117
117
118
// Otherwise, if an argument is given with no parameter, we assume it's the name
118
119
// If we've already seen a name, we set the name to null
119
- if ( pesterCommandAst . CommandElements [ i ] is StringConstantExpressionAst testNameStrAst )
120
+ if ( ! alreadySawName && TryGetTestNameArgument ( pesterCommandAst . CommandElements [ i ] , out testName ) )
120
121
{
121
- testName = alreadySawName ? null : testNameStrAst . Value ;
122
122
alreadySawName = true ;
123
123
}
124
124
}
@@ -131,6 +131,19 @@ private static PesterSymbolReference ConvertPesterAstToSymbolReference(ScriptFil
131
131
pesterCommandAst . Extent
132
132
) ;
133
133
}
134
+
135
+ private static bool TryGetTestNameArgument ( CommandElementAst commandElementAst , out string testName )
136
+ {
137
+ testName = null ;
138
+
139
+ if ( commandElementAst is StringConstantExpressionAst testNameStrAst )
140
+ {
141
+ testName = testNameStrAst . Value ;
142
+ return true ;
143
+ }
144
+
145
+ return ( commandElementAst is ExpandableStringExpressionAst ) ;
146
+ }
134
147
}
135
148
136
149
/// <summary>
0 commit comments