@@ -45,11 +45,10 @@ private static bool IsNamedCommandWithArguments(Ast ast)
45
45
{
46
46
CommandAst commandAst = ast as CommandAst ;
47
47
48
- return
49
- commandAst != null &&
50
- commandAst . InvocationOperator != TokenKind . Dot &&
51
- PesterSymbolReference . GetCommandType ( commandAst . GetCommandName ( ) ) . HasValue &&
52
- commandAst . CommandElements . Count >= 2 ;
48
+ return commandAst != null &&
49
+ commandAst . InvocationOperator != TokenKind . Dot &&
50
+ PesterSymbolReference . GetCommandType ( commandAst . GetCommandName ( ) ) . HasValue &&
51
+ commandAst . CommandElements . Count >= 2 ;
53
52
}
54
53
55
54
/// <summary>
@@ -89,7 +88,11 @@ private static bool IsPesterCommand(CommandAst commandAst)
89
88
private static PesterSymbolReference ConvertPesterAstToSymbolReference ( ScriptFile scriptFile , CommandAst pesterCommandAst )
90
89
{
91
90
string testLine = scriptFile . GetLine ( pesterCommandAst . Extent . StartLineNumber ) ;
92
- string commandName = pesterCommandAst . GetCommandName ( ) ;
91
+ PesterCommandType ? commandName = PesterSymbolReference . GetCommandType ( pesterCommandAst . GetCommandName ( ) ) ;
92
+ if ( commandName == null )
93
+ {
94
+ return null ;
95
+ }
93
96
94
97
// Search for a name for the test
95
98
// If the test has more than one argument for names, we set it to null
@@ -122,7 +125,7 @@ private static PesterSymbolReference ConvertPesterAstToSymbolReference(ScriptFil
122
125
123
126
return new PesterSymbolReference (
124
127
scriptFile ,
125
- commandName ,
128
+ commandName . Value ,
126
129
testLine ,
127
130
testName ,
128
131
pesterCommandAst . Extent
@@ -179,7 +182,7 @@ public class PesterSymbolReference : SymbolReference
179
182
180
183
internal PesterSymbolReference (
181
184
ScriptFile scriptFile ,
182
- string commandName ,
185
+ PesterCommandType commandType ,
183
186
string testLine ,
184
187
string testName ,
185
188
IScriptExtent scriptExtent )
@@ -190,14 +193,14 @@ internal PesterSymbolReference(
190
193
scriptFile . FilePath ,
191
194
testLine )
192
195
{
193
- this . Command = GetCommandType ( commandName ) . Value ;
196
+ this . Command = commandType ;
194
197
this . TestName = testName ;
195
198
}
196
199
197
200
internal static PesterCommandType ? GetCommandType ( string commandName )
198
201
{
199
202
PesterCommandType pesterCommandType ;
200
- if ( ! PesterKeywords . TryGetValue ( commandName , out pesterCommandType ) )
203
+ if ( commandName == null || ! PesterKeywords . TryGetValue ( commandName , out pesterCommandType ) )
201
204
{
202
205
return null ;
203
206
}
0 commit comments