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