17 instantiations of Token
dotnet (1)
Extensions\ParseResultExtensions.cs (1)
171
return optionResult.IdentifierToken ?? new
Token
($"--{optionResult.Option.Name}", TokenType.Option, optionResult.Option);
System.CommandLine (16)
Parsing\StringExtensions.cs (16)
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));
225
tokenList.Add(new
Token
(alias.Slice(i).ToString(), TokenType.Argument, default, argumentIndex));
232
tokenList.Add(new
Token
(found.Value, found.Type, found.Symbol, argumentIndex));
240
tokenList.Add(new
Token
(alias.Slice(index).ToString(), TokenType.Argument, default, argumentIndex));
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));
96 references to Token
Aspire.RuntimeIdentifier.Tool (1)
Program.cs (1)
79
foreach (
var
token in result.Tokens)
crossgen2 (4)
src\runtime\src\coreclr\tools\Common\CommandLineHelpers.cs (4)
28
public static Dictionary<string, string> BuildPathDictionary(IReadOnlyList<
Token
> tokens, bool strict)
32
foreach (
Token
token in tokens)
40
public static List<string> BuildPathList(IReadOnlyList<
Token
> tokens)
44
foreach (
Token
token in tokens)
dotnet (3)
Commands\Run\RunCommand.cs (1)
991
foreach (
var
token in parseResult.Tokens)
Extensions\ParseResultExtensions.cs (1)
164
static
Token
? GetOptionTokenOrDefault(SymbolResult symbolResult)
Program.cs (1)
340
foreach (
var
token in parseResult.Tokens)
dotnet-watch (1)
CommandLine\CommandLineOptions.cs (1)
252
foreach (
var
token in optionResult.Tokens)
ilc (4)
src\runtime\src\coreclr\tools\Common\CommandLineHelpers.cs (4)
28
public static Dictionary<string, string> BuildPathDictionary(IReadOnlyList<
Token
> tokens, bool strict)
32
foreach (
Token
token in tokens)
40
public static List<string> BuildPathList(IReadOnlyList<
Token
> tokens)
44
foreach (
Token
token in tokens)
Microsoft.DotNet.Cli.CommandLine (1)
SpanParsableExtensions.cs (1)
98
foreach (
var
token in tokenizationResult.Tokens)
Microsoft.DotNet.Cli.Definitions (5)
Commands\New\CommandDefinitionExtensions.cs (2)
72
foreach (
var
token in newCommandArgument.Tokens)
102
foreach (
var
token in optionResult.Tokens)
Common\CommonOptions.cs (3)
56
foreach (
var
token in result.Tokens)
309
List<
Token
>? invalid = null;
311
foreach (
var
token in argumentResult.Tokens)
Microsoft.TemplateEngine.Cli (1)
Commands\NewCommandArgs.cs (1)
24
List<
Token
> tokensToEvaluate = new();
NuGet.CommandLine.XPlat (3)
Commands\Package\PackageWithNuGetVersion.cs (1)
27
foreach (
var
token in result.Tokens)
Commands\Package\PackageWithVersionRange.cs (1)
28
foreach (
var
token in result.Tokens)
Commands\Why\WhyCommand.cs (1)
77
var
value = ar.Tokens[0];
System.CommandLine (72)
ArgumentValidation.cs (4)
85
var
token = result.Tokens[i];
110
var
token = result.Tokens[i];
163
var
token = argumentResult.Tokens[i];
185
var
token = result.Tokens[i];
Binding\ArgumentConverter.cs (5)
19
case
Token
singleValue:
22
case IReadOnlyList<
Token
> manyValues:
41
Token
token)
86
IReadOnlyList<
Token
> tokens)
94
var
token = tokens[i];
Completions\CompletionContext.cs (1)
54
Token
? lastToken = parseResult.Tokens.LastOrDefault(t => t.Type != TokenType.Directive);
ParseResult.cs (6)
20
private readonly IReadOnlyList<
Token
> _unmatchedTokens;
30
List<
Token
> tokens,
31
List<
Token
>? unmatchedTokens,
58
_unmatchedTokens = unmatchedTokens is null ? Array.Empty<
Token
>() : unmatchedTokens;
96
public IReadOnlyList<
Token
> Tokens { get; }
393
var
tokenToComplete = parseResult.Tokens.Last(t => t.Value == textCompletionContext.WordToComplete);
Parsing\ArgumentResult.cs (2)
121
Token
toPass = _tokens[numberOfTokens];
134
Token
unmatched = _tokens[numberOfTokens];
Parsing\CommandLineParser.cs (1)
155
out List<
Token
> tokens,
Parsing\CommandResult.cs (2)
16
Token
token,
33
public
Token
IdentifierToken { get; }
Parsing\DirectiveResult.cs (2)
12
internal DirectiveResult(Directive directive,
Token
token, SymbolResultTree symbolResultTree)
33
public
Token
Token { get; }
Parsing\OptionResult.cs (2)
17
Token
? token = null,
40
public
Token
? IdentifierToken { get; }
Parsing\ParseOperation.cs (4)
12
private readonly List<
Token
> _tokens;
26
List<
Token
> tokens,
46
private
Token
CurrentToken => _tokens[_index];
330
var
token = CurrentToken;
Parsing\StringExtensions.cs (23)
33
out List<
Token
> tokens,
44
var tokenList = new List<
Token
>(args.Count);
87
if (knownTokens.TryGetValue($"[{directiveName}]", out
var
directiveToken))
129
if (knownTokens.TryGetValue(arg, out
var
token))
164
knownTokens.TryGetValue(first, out
var
subtoken) &&
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);
220
if (!knownTokens.TryGetValue(candidate.ToString(), out
Token
? found))
252
var
token = tokenList[tokenList.Count - 1];
380
private static Dictionary<string,
Token
> ValidTokens(this Command command)
382
Dictionary<string,
Token
> tokens = new(StringComparer.Ordinal);
390
tokens[tokenString] = new Token(tokenString, TokenType.Directive, directive,
Token
.ImplicitPosition);
445
static void AddCommandTokens(Dictionary<string,
Token
> tokens, Command cmd)
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));
458
static void AddOptionTokens(Dictionary<string,
Token
> tokens, Option option)
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\SymbolResult.cs (4)
14
private protected List<
Token
>? _tokens;
55
public IReadOnlyList<
Token
> Tokens => _tokens is not null ? _tokens : Array.Empty<
Token
>();
57
internal void AddToken(
Token
token) => (_tokens ??= new()).Add(token);
Parsing\SymbolResultTree.cs (2)
12
internal List<
Token
>? UnmatchedTokens;
64
internal void AddUnmatchedToken(
Token
token, CommandResult commandResult, CommandResult rootCommandResult)
Parsing\Token.cs (13)
9
public sealed class Token : IEquatable<
Token
>
52
public override bool Equals(object? obj) => Equals(obj as
Token
);
55
public bool Equals(
Token
? other) => other is not null && Value == other.Value && Type == other.Type && ReferenceEquals(Symbol, other.Symbol);
64
/// Checks if two specified <see cref="
Token
"/> instances have the same value.
66
/// <param name="left">The first <see cref="
Token
"/>.</param>
67
/// <param name="right">The second <see cref="
Token
"/>.</param>
69
public static bool operator ==(
Token
? left,
Token
? right) => left is null ? right is null : left.Equals(right);
72
/// Checks if two specified <see cref="
Token
"/> instances have different values.
74
/// <param name="left">The first <see cref="
Token
"/>.</param>
75
/// <param name="right">The second <see cref="
Token
"/>.</param>
77
public static bool operator !=(
Token
? left,
Token
? right) => left is null ? right is not null : !left.Equals(right);
Parsing\TokenType.cs (1)
7
/// Identifies the type of a <see cref="
Token
"/>.
System.CommandLine.StaticCompletions (1)
CompletionsCommandDefinition.cs (1)
31
var
singleToken = argumentResult.Tokens[0];