Skip to content

Commit a40b5b6

Browse files
Renamed Start to Index
Start may imply position in string, and this is position in the args array or response file.
1 parent 7facb86 commit a40b5b6

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/System.CommandLine/Parsing/Location.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@ internal static Location CreateResponse(string responseSourceName, int start, Lo
2929
internal static Location FromOuterLocation(string text, int start, Location outerLocation, int offset = 0)
3030
=> new(text, outerLocation.Source, start, outerLocation, offset);
3131

32-
public Location(string text, string source, int start, Location? outerLocation, int offset = 0)
32+
public Location(string text, string source, int index, Location? outerLocation, int offset = 0)
3333
{
3434
Text = text;
3535
Source = source;
36-
Start = start;
36+
Index = index;
3737
Length = text.Length;
3838
Offset = offset;
3939
OuterLocation = outerLocation;
4040
}
4141

4242
public string Text { get; }
4343
public string Source { get; }
44-
public int Start { get; }
44+
public int Index { get; }
4545
public int Offset { get; }
4646
public int Length { get; }
4747
public Location? OuterLocation { get; }
@@ -50,7 +50,7 @@ public bool IsImplicit
5050
=> Source == Implicit;
5151

5252
public override string ToString()
53-
=> $"{(OuterLocation is null ? "" : OuterLocation.ToString() + "; ")}{Text} from {Source}[{Start}, {Length}, {Offset}]";
53+
=> $"{(OuterLocation is null ? "" : OuterLocation.ToString() + "; ")}{Text} from {Source}[{Index}, {Length}, {Offset}]";
5454

5555
}
5656
}

src/System.CommandLine/Parsing/StringExtensions.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ internal static void Tokenize(
7878
var maxSkippedPositions = configuration.PreProcessedLocations is null
7979
|| !configuration.PreProcessedLocations.Any()
8080
? 0
81-
: configuration.PreProcessedLocations.Max(x => x.Start);
81+
: configuration.PreProcessedLocations.Max(x => x.Index);
8282

8383

8484
var validTokens = GetValidTokens(rootCommand);
@@ -111,7 +111,7 @@ internal static void Tokenize(
111111

112112
if (i <= maxSkippedPositions
113113
&& configuration.PreProcessedLocations is not null
114-
&& configuration.PreProcessedLocations.Any(x => x.Start == i))
114+
&& configuration.PreProcessedLocations.Any(x => x.Index == i))
115115
{
116116
continue;
117117
}
@@ -229,7 +229,7 @@ static bool TryUnbundle(ReadOnlySpan<char> alias,
229229
{
230230
string value = alias.Slice(i + 1).ToString();
231231
tokenList.Add(Argument(value,
232-
Location.FromOuterLocation(value, outerLocation.Start, outerLocation, i + 1)));
232+
Location.FromOuterLocation(value, outerLocation.Index, outerLocation, i + 1)));
233233
return true;
234234
}
235235

@@ -241,15 +241,15 @@ static bool TryUnbundle(ReadOnlySpan<char> alias,
241241
// Invalid_char_in_bundle_causes_rest_to_be_interpreted_as_value
242242
string value = alias.Slice(i).ToString();
243243
tokenList.Add(Argument(value,
244-
Location.FromOuterLocation(value, outerLocation.Start, outerLocation, i)));
244+
Location.FromOuterLocation(value, outerLocation.Index, outerLocation, i)));
245245
return true;
246246
}
247247

248248
return false;
249249
}
250250

251251
tokenList.Add(new CliToken(candidate, found.TokenType, found.Symbol,
252-
Location.FromOuterLocation(candidate, outerLocation.Start, outerLocation, i + 1)));
252+
Location.FromOuterLocation(candidate, outerLocation.Index, outerLocation, i + 1)));
253253

254254
if (i != alias.Length - 1 && ((CliOption)found.Symbol).Greedy)
255255
{
@@ -260,7 +260,7 @@ static bool TryUnbundle(ReadOnlySpan<char> alias,
260260
}
261261

262262
string value = alias.Slice(index).ToString();
263-
tokenList.Add(Argument(value, Location.FromOuterLocation(value, outerLocation.Start, outerLocation, index)));
263+
tokenList.Add(Argument(value, Location.FromOuterLocation(value, outerLocation.Index, outerLocation, index)));
264264
return true;
265265
}
266266
}

0 commit comments

Comments
 (0)