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