55 references to TokenType
dotnet (14)
Commands\Run\RunCommand.cs (4)
843
parseResult.Tokens.TakeWhile(static t => t.Type !=
TokenType
.DoubleDash)
844
.Any(static t => t is { Type:
TokenType
.Argument, Value: "-" });
869
.TakeWhile(static t => t.Type !=
TokenType
.DoubleDash)
870
.Where(static t => t.Type ==
TokenType
.Argument)
Extensions\ParseResultExtensions.cs (5)
33
token.Type ==
TokenType
.Argument
34
|| token.Type ==
TokenType
.Command
35
|| token.Type ==
TokenType
.Directive)
101
|| parseResult.Tokens.Any(token => token.Type ==
TokenType
.Directive)
171
return optionResult.IdentifierToken ?? new Token($"--{optionResult.Option.Name}",
TokenType
.Option, optionResult.Option);
Program.cs (2)
336
if (parseResult.GetResult(Parser.RootCommand.DotnetSubCommand) is { Tokens: [{ Type:
TokenType
.Argument, Value: { } } unmatchedCommandOrFile] }
342
if (token.Type !=
TokenType
.Argument || token != unmatchedCommandOrFile)
Telemetry\AllowListToSendFirstArgument.cs (1)
29
.Where(t => t.Type.Equals(
TokenType
.Argument)).FirstOrDefault()?.Value ?? null;
Telemetry\AllowListToSendVerbSecondVerbFirstArgument.cs (2)
22
var secondVerb = parseResult.Tokens.Where(s => s.Type ==
TokenType
.Command).Skip(1).FirstOrDefault()?.Value ?? "";
26
var firstArgument = parseResult.Tokens.FirstOrDefault(t => t.Type.Equals(
TokenType
.Argument))?.Value ?? "";
System.CommandLine (41)
Completions\CompletionAction.cs (1)
27
var commandLineToComplete = parseResult.Tokens.LastOrDefault(t => t.Type !=
TokenType
.Directive)?.Value ?? "";
Completions\CompletionContext.cs (2)
54
Token? lastToken = parseResult.Tokens.LastOrDefault(t => t.Type !=
TokenType
.Directive);
83
lastToken?.Type ==
TokenType
.Argument)
Parsing\ParseOperation.cs (15)
50
private bool More(out
TokenType
currentTokenType)
53
currentTokenType = result ? _tokens[_index].Type : (
TokenType
)(-1);
99
while (More(out
TokenType
currentTokenType))
117
if (currentTokenType !=
TokenType
.DoubleDash &&
119
(currentTokenType ==
TokenType
.Argument || currentArgumentIndex > 0 || currentArgumentCount > 0))
123
else if (currentTokenType ==
TokenType
.Command)
127
else if (currentTokenType ==
TokenType
.Option)
131
else if (currentTokenType ==
TokenType
.Argument)
152
while (More(out
TokenType
currentTokenType) &&
153
(currentTokenType ==
TokenType
.Argument ||
260
while (More(out
TokenType
currentTokenType) && currentTokenType ==
TokenType
.Argument)
318
while (More(out
TokenType
currentTokenType) && currentTokenType ==
TokenType
.Directive)
396
if (CurrentToken.Type ==
TokenType
.DoubleDash)
Parsing\StringExtensions.cs (20)
139
case
TokenType
.Option:
143
case
TokenType
.Command:
165
subtoken.Type ==
TokenType
.Option)
181
Token Argument(string value) => new(value,
TokenType
.Argument, default, i);
183
Token CommandArgument(string value, Command command) => new(value,
TokenType
.Argument, command, i);
185
Token OptionArgument(string value, Option option) => new(value,
TokenType
.Argument, option, i);
187
Token Command(string value, Command cmd) => new(value,
TokenType
.Command, cmd, i);
189
Token Option(string value, Option option) => new(value,
TokenType
.Option, option, i);
191
Token DoubleDash() => new("--",
TokenType
.DoubleDash, default, i);
193
Token Directive(string value, Directive? directive) => new(value,
TokenType
.Directive, directive, i);
215
tokenList.Add(new Token(alias.Slice(i + 1).ToString(),
TokenType
.Argument, default, argumentIndex));
222
if (tokensBefore != tokenList.Count && tokenList[tokenList.Count - 1].Type ==
TokenType
.Option)
225
tokenList.Add(new Token(alias.Slice(i).ToString(),
TokenType
.Argument, default, argumentIndex));
240
tokenList.Add(new Token(alias.Slice(index).ToString(),
TokenType
.Argument, default, argumentIndex));
254
if (token.Type ==
TokenType
.Option)
390
tokens[tokenString] = new Token(tokenString,
TokenType
.Directive, directive, Token.ImplicitPosition);
447
tokens.Add(cmd.Name, new Token(cmd.Name,
TokenType
.Command, cmd, Token.ImplicitPosition));
453
tokens.Add(childAlias, new Token(childAlias,
TokenType
.Command, cmd, Token.ImplicitPosition));
462
tokens.Add(option.Name, new Token(option.Name,
TokenType
.Option, option, Token.ImplicitPosition));
471
tokens.Add(childAlias, new Token(childAlias,
TokenType
.Option, option, Token.ImplicitPosition));
Parsing\Token.cs (3)
16
public Token(string? value,
TokenType
type, Symbol symbol)
24
internal Token(string? value,
TokenType
type, Symbol? symbol, int position)
44
public
TokenType
Type { get; }