Map Collection.add to Add instead of AddItem

This commit is contained in:
Sam Harwell 2014-07-04 18:34:46 -05:00
parent fd1cc448b0
commit 0da1f54f19
37 changed files with 125 additions and 125 deletions

View File

@ -86,7 +86,7 @@
-methodMapping java.lang.Appendable.append(java.lang.CharSequence,int,int) AppendRange
-methodMapping java.util.Date.Date(long) Antlr4.Runtime.Sharpen.Extensions.CreateDate
-methodMapping java.lang.Long.signum Antlr4.Runtime.Sharpen.Extensions.Signum
-methodMapping java.util.Collection.add AddItem
-methodMapping java.util.Collection.add Add
-methodMapping java.util.ArrayList.removeElement Remove
-methodMapping java.net.InetAddress.getByName Antlr4.Runtime.Sharpen.Extensions.GetAddressByName
-methodMapping java.net.ServerSocket.ServerSocket Antlr4.Runtime.Sharpen.Extensions.CreateServerSocket

View File

@ -207,7 +207,7 @@ namespace Antlr4.Runtime.Atn
state.atn = this;
state.stateNumber = states.Count;
}
states.AddItem(state);
states.Add(state);
}
public virtual void RemoveState(ATNState state)
@ -219,7 +219,7 @@ namespace Antlr4.Runtime.Atn
public virtual void DefineMode(string name, TokensStartState s)
{
modeNameToStartState.Put(name, s);
modeToStartState.AddItem(s);
modeToStartState.Add(s);
modeToDFA = Arrays.CopyOf(modeToDFA, modeToStartState.Count);
modeToDFA[modeToDFA.Length - 1] = new DFA(s);
DefineDecisionState(s);
@ -227,7 +227,7 @@ namespace Antlr4.Runtime.Atn
public virtual int DefineDecisionState(DecisionState s)
{
decisionToState.AddItem(s);
decisionToState.Add(s);
s.decision = decisionToState.Count - 1;
decisionToDFA = Arrays.CopyOf(decisionToDFA, decisionToState.Count);
decisionToDFA[decisionToDFA.Length - 1] = new DFA(s, s.decision);

View File

@ -310,8 +310,8 @@ namespace Antlr4.Runtime.Atn
}
IDeque<PredictionContext> leftWorkList = new ArrayDeque<PredictionContext>();
IDeque<PredictionContext> rightWorkList = new ArrayDeque<PredictionContext>();
leftWorkList.AddItem(Context);
rightWorkList.AddItem(subconfig.Context);
leftWorkList.Add(Context);
rightWorkList.Add(subconfig.Context);
while (!leftWorkList.IsEmpty())
{
PredictionContext left = leftWorkList.Pop();
@ -402,7 +402,7 @@ namespace Antlr4.Runtime.Atn
builder.Append("rankdir=LR;\n");
IDictionary<PredictionContext, PredictionContext> visited = new IdentityHashMap<PredictionContext, PredictionContext>();
IDeque<PredictionContext> workList = new ArrayDeque<PredictionContext>();
workList.AddItem(Context);
workList.Add(Context);
visited.Put(Context, Context);
while (!workList.IsEmpty())
{

View File

@ -236,7 +236,7 @@ namespace Antlr4.Runtime.Atn
HashSet<ATNState> states = new HashSet<ATNState>();
foreach (ATNConfig c in this.configs)
{
states.AddItem(c.State);
states.Add(c.State);
}
return states;
}
@ -311,7 +311,7 @@ namespace Antlr4.Runtime.Atn
return Sharpen.Collections.ToArray(configs);
}
public virtual bool AddItem(ATNConfig e)
public virtual bool Add(ATNConfig e)
{
return Add(e, null);
}
@ -362,14 +362,14 @@ namespace Antlr4.Runtime.Atn
return true;
}
}
configs.AddItem(e);
configs.Add(e);
if (addKey)
{
mergedConfigs.Put(key, e);
}
else
{
unmerged.AddItem(e);
unmerged.Add(e);
}
UpdatePropertiesForAddedConfig(e);
return true;

View File

@ -80,8 +80,8 @@ namespace Antlr4.Runtime.Atn
BaseSerializedUuid = UUID.FromString("E4178468-DF95-44D0-AD87-F22A5D5FB6D3");
AddedLexerActions = UUID.FromString("AB35191A-1603-487E-B75A-479B831EAF6D");
SupportedUuids = new List<UUID>();
SupportedUuids.AddItem(BaseSerializedUuid);
SupportedUuids.AddItem(AddedLexerActions);
SupportedUuids.Add(BaseSerializedUuid);
SupportedUuids.Add(AddedLexerActions);
SerializedUuid = AddedLexerActions;
}
@ -195,14 +195,14 @@ namespace Antlr4.Runtime.Atn
{
// special case
int loopBackStateNumber = ToInt(data[p++]);
loopBackStateNumbers.AddItem(Tuple.Create((LoopEndState)s, loopBackStateNumber));
loopBackStateNumbers.Add(Tuple.Create((LoopEndState)s, loopBackStateNumber));
}
else
{
if (s is BlockStartState)
{
int endStateNumber = ToInt(data[p++]);
endStateNumbers.AddItem(Tuple.Create((BlockStartState)s, endStateNumber));
endStateNumbers.Add(Tuple.Create((BlockStartState)s, endStateNumber));
}
}
atn.AddState(s);
@ -287,7 +287,7 @@ namespace Antlr4.Runtime.Atn
for (int i_6 = 0; i_6 < nmodes; i_6++)
{
int s = ToInt(data[p++]);
atn.modeToStartState.AddItem((TokensStartState)atn.states[s]);
atn.modeToStartState.Add((TokensStartState)atn.states[s]);
}
atn.modeToDFA = new DFA[nmodes];
for (int i_7 = 0; i_7 < nmodes; i_7++)
@ -304,7 +304,7 @@ namespace Antlr4.Runtime.Atn
int nintervals = ToInt(data[p]);
p++;
IntervalSet set = new IntervalSet();
sets.AddItem(set);
sets.Add(set);
bool containsEof = ToInt(data[p++]) != 0;
if (containsEof)
{
@ -409,7 +409,7 @@ namespace Antlr4.Runtime.Atn
{
int s = ToInt(data[p++]);
DecisionState decState = (DecisionState)atn.states[s];
atn.decisionToState.AddItem(decState);
atn.decisionToState.Add(decState);
decState.decision = i_11 - 1;
}
//
@ -456,7 +456,7 @@ namespace Antlr4.Runtime.Atn
int actionIndex = ((ActionTransition)transition).actionIndex;
LexerCustomAction lexerAction = new LexerCustomAction(ruleIndex, actionIndex);
state_3.SetTransition(i_10, new ActionTransition(transition.target, ruleIndex, legacyLexerActions.Count, false));
legacyLexerActions.AddItem(lexerAction);
legacyLexerActions.Add(lexerAction);
}
}
atn.lexerActions = Sharpen.Collections.ToArray(legacyLexerActions, new ILexerAction[legacyLexerActions.Count]);
@ -761,7 +761,7 @@ namespace Antlr4.Runtime.Atn
{
if (optimizedTransitions != null)
{
optimizedTransitions.AddItem(transition);
optimizedTransitions.Add(transition);
}
continue;
}
@ -771,7 +771,7 @@ namespace Antlr4.Runtime.Atn
{
if (optimizedTransitions != null)
{
optimizedTransitions.AddItem(transition);
optimizedTransitions.Add(transition);
}
continue;
}
@ -780,7 +780,7 @@ namespace Antlr4.Runtime.Atn
optimizedTransitions = new List<Transition>();
for (int j = 0; j < i_1; j++)
{
optimizedTransitions.AddItem(state.GetOptimizedTransition(i_1));
optimizedTransitions.Add(state.GetOptimizedTransition(i_1));
}
}
inlinedCalls++;
@ -788,7 +788,7 @@ namespace Antlr4.Runtime.Atn
ATNState intermediateState = new BasicState();
intermediateState.SetRuleIndex(target.ruleIndex);
atn.AddState(intermediateState);
optimizedTransitions.AddItem(new EpsilonTransition(intermediateState));
optimizedTransitions.Add(new EpsilonTransition(intermediateState));
switch (effective.TransitionType)
{
case TransitionType.Atom:
@ -851,7 +851,7 @@ namespace Antlr4.Runtime.Atn
{
if (optimizedTransitions != null)
{
optimizedTransitions.AddItem(transition);
optimizedTransitions.Add(transition);
}
goto nextTransition_continue;
}
@ -861,7 +861,7 @@ namespace Antlr4.Runtime.Atn
{
if (optimizedTransitions != null)
{
optimizedTransitions.AddItem(transition);
optimizedTransitions.Add(transition);
}
goto nextTransition_continue;
}
@ -872,13 +872,13 @@ namespace Antlr4.Runtime.Atn
optimizedTransitions = new List<Transition>();
for (int j_1 = 0; j_1 < i; j_1++)
{
optimizedTransitions.AddItem(state.GetOptimizedTransition(j_1));
optimizedTransitions.Add(state.GetOptimizedTransition(j_1));
}
}
for (int j_2 = 0; j_2 < intermediate.NumberOfOptimizedTransitions; j_2++)
{
ATNState target = intermediate.GetOptimizedTransition(j_2).target;
optimizedTransitions.AddItem(new EpsilonTransition(target));
optimizedTransitions.Add(new EpsilonTransition(target));
}
nextTransition_continue: ;
}
@ -949,7 +949,7 @@ nextState_break: ;
{
if (!setTransitions.Contains(i_1))
{
optimizedTransitions.AddItem(decision.GetOptimizedTransition(i_1));
optimizedTransitions.Add(decision.GetOptimizedTransition(i_1));
}
}
ATNState blockEndState = decision.GetOptimizedTransition(setTransitions.MinElement).target.GetOptimizedTransition(0).target;
@ -991,7 +991,7 @@ nextState_break: ;
setOptimizedState.SetRuleIndex(decision.ruleIndex);
atn.AddState(setOptimizedState);
setOptimizedState.AddTransition(newTransition);
optimizedTransitions.AddItem(new EpsilonTransition(setOptimizedState));
optimizedTransitions.Add(new EpsilonTransition(setOptimizedState));
removedPaths += decision.NumberOfOptimizedTransitions - optimizedTransitions.Count;
if (decision.IsOptimized)
{
@ -1051,7 +1051,7 @@ nextState_break: ;
}
BitSet reachable = new BitSet(atn.states.Count);
IDeque<ATNState> worklist = new ArrayDeque<ATNState>();
worklist.AddItem(transition.followState);
worklist.Add(transition.followState);
while (!worklist.IsEmpty())
{
ATNState state = worklist.Pop();
@ -1074,7 +1074,7 @@ nextState_break: ;
{
return false;
}
worklist.AddItem(t.target);
worklist.Add(t.target);
}
}
return true;

View File

@ -164,7 +164,7 @@ namespace Antlr4.Runtime.Atn
SetTransition st = (SetTransition)t;
if (!setIndices.ContainsKey(st.set))
{
sets.AddItem(st.set);
sets.Add(st.set);
setIndices.Put(st.set, sets.Count - 1);
}
}

View File

@ -274,7 +274,7 @@ namespace Antlr4.Runtime.Atn
{
optimizedTransitions = new List<Antlr4.Runtime.Atn.Transition>();
}
optimizedTransitions.AddItem(e);
optimizedTransitions.Add(e);
}
public virtual void SetOptimizedTransition(int i, Antlr4.Runtime.Atn.Transition e)

View File

@ -228,7 +228,7 @@ namespace Antlr4.Runtime.Atn
while (!selfWorkList.IsEmpty())
{
PredictionContextCache.IdentityCommutativePredictionContextOperands operands = new PredictionContextCache.IdentityCommutativePredictionContextOperands(selfWorkList.Pop(), otherWorkList.Pop());
if (!visited.AddItem(operands))
if (!visited.Add(operands))
{
continue;
}

View File

@ -283,7 +283,7 @@ namespace Antlr4.Runtime.Atn
{
// System.out.println("_LOOK("+s.stateNumber+", ctx="+ctx);
ATNConfig c = ATNConfig.Create(s, 0, ctx);
if (!lookBusy.AddItem(c))
if (!lookBusy.Add(c))
{
return;
}

View File

@ -448,14 +448,14 @@ namespace Antlr4.Runtime.Atn
PredictionContext context = config.Context;
if (context.IsEmpty)
{
configs.AddItem(config);
configs.Add(config);
return true;
}
else
{
if (context.HasEmpty)
{
configs.AddItem(config.Transform(config.State, PredictionContext.EmptyFull, true));
configs.Add(config.Transform(config.State, PredictionContext.EmptyFull, true));
currentAltReachedAcceptState = true;
}
}
@ -479,7 +479,7 @@ namespace Antlr4.Runtime.Atn
{
if (!currentAltReachedAcceptState || !config.PassedThroughNonGreedyDecision)
{
configs.AddItem(config);
configs.Add(config);
}
}
ATNState p = config.State;

View File

@ -97,7 +97,7 @@ namespace Antlr4.Runtime.Atn
long fallBack = decisions[i].LL_Fallback;
if (fallBack > 0)
{
Ll.AddItem(i);
Ll.Add(i);
}
}
return Ll;

View File

@ -999,7 +999,7 @@ namespace Antlr4.Runtime.Atn
{
if (config_1.ReachesIntoOuterContext || config_1.State is RuleStopState)
{
filteredConfigs.AddItem(config_1);
filteredConfigs.Add(config_1);
}
}
SemanticContext[] altToPred = GetPredsForAmbigAlts(alts, filteredConfigs, maxAlt);
@ -1151,7 +1151,7 @@ namespace Antlr4.Runtime.Atn
{
skippedStopStates = new List<ATNConfig>();
}
skippedStopStates.AddItem(c);
skippedStopStates.Add(c);
}
continue;
}
@ -1350,7 +1350,7 @@ namespace Antlr4.Runtime.Atn
{
// for each transition
ATNState target = p.Transition(ti).target;
reachIntermediate.AddItem(ATNConfig.Create(target, ti + 1, initialContext));
reachIntermediate.Add(ATNConfig.Create(target, ti + 1, initialContext));
}
bool hasMoreContext = remainingGlobalContext != null;
if (!hasMoreContext)
@ -1626,14 +1626,14 @@ namespace Antlr4.Runtime.Atn
// if no (null, i), then no default prediction.
if (ambigAlts != null && ambigAlts.Get(i) && pred == SemanticContext.None)
{
pairs.AddItem(new DFAState.PredPrediction(pred, i));
pairs.Add(new DFAState.PredPrediction(pred, i));
}
else
{
if (pred != SemanticContext.None)
{
containsPredicate = true;
pairs.AddItem(new DFAState.PredPrediction(pred, i));
pairs.Add(new DFAState.PredPrediction(pred, i));
}
}
}
@ -1817,7 +1817,7 @@ namespace Antlr4.Runtime.Atn
continue;
}
}
if (!t.IsEpsilon && !closureBusy.AddItem(c))
if (!t.IsEpsilon && !closureBusy.Add(c))
{
// avoid infinite recursion for EOF* and EOF+
continue;
@ -1830,7 +1830,7 @@ namespace Antlr4.Runtime.Atn
// track how far we dip into outer context. Might
// come in handy and we avoid evaluating context dependent
// preds if this is > 0.
if (!closureBusy.AddItem(c))
if (!closureBusy.Add(c))
{
// avoid infinite recursion for right-recursive rules
continue;
@ -2368,7 +2368,7 @@ namespace Antlr4.Runtime.Atn
ATNConfigSet contextConfigs = new ATNConfigSet();
foreach (ATNConfig config in configs)
{
contextConfigs.AddItem(config.AppendContext(returnContext, contextCache));
contextConfigs.Add(config.AppendContext(returnContext, contextCache));
}
return AddDFAState(dfa, contextConfigs, contextCache);
}

View File

@ -473,7 +473,7 @@ namespace Antlr4.Runtime.Atn
p = p.GetParent(index);
}
localBuffer.Append("]");
result.AddItem(localBuffer.ToString());
result.Add(localBuffer.ToString());
if (last)
{
break;

View File

@ -284,7 +284,7 @@ namespace Antlr4.Runtime.Atn
foreach (ATNConfig c in configs)
{
c = c.Transform(c.State, SemanticContext.None, false);
dup.AddItem(c);
dup.Add(c);
}
configs = dup;
}

View File

@ -150,7 +150,7 @@ namespace Antlr4.Runtime.Atn
if (reachState == null)
{
// no reach on current lookahead symbol. ERROR.
decisions[currentDecision].errors.AddItem(new ErrorInfo(currentDecision, previous, _input, _startIndex, _input.Index));
decisions[currentDecision].errors.Add(new ErrorInfo(currentDecision, previous, _input, _startIndex, _input.Index));
}
currentState = reachState;
return reachState;
@ -185,7 +185,7 @@ namespace Antlr4.Runtime.Atn
if (existingTargetState == Error)
{
SimulatorState state = new SimulatorState(currentState.outerContext, previousD, currentState.useContext, currentState.remainingOuterContext);
decisions[currentDecision].errors.AddItem(new ErrorInfo(currentDecision, state, _input, _startIndex, _input.Index));
decisions[currentDecision].errors.Add(new ErrorInfo(currentDecision, state, _input, _startIndex, _input.Index));
}
}
return existingTargetState;
@ -212,7 +212,7 @@ namespace Antlr4.Runtime.Atn
{
bool fullContext = _llStopIndex >= 0;
int stopIndex = fullContext ? _llStopIndex : _sllStopIndex;
decisions[currentDecision].predicateEvals.AddItem(new PredicateEvalInfo(currentState, currentDecision, _input, _startIndex, stopIndex, pred, result, alt));
decisions[currentDecision].predicateEvals.Add(new PredicateEvalInfo(currentState, currentDecision, _input, _startIndex, stopIndex, pred, result, alt));
}
return result;
}
@ -221,7 +221,7 @@ namespace Antlr4.Runtime.Atn
{
if (prediction != conflictingAltResolvedBySLL)
{
decisions[currentDecision].contextSensitivities.AddItem(new ContextSensitivityInfo(currentDecision, acceptState, _input, startIndex, stopIndex));
decisions[currentDecision].contextSensitivities.Add(new ContextSensitivityInfo(currentDecision, acceptState, _input, startIndex, stopIndex));
}
base.ReportContextSensitivity(dfa, prediction, acceptState, startIndex, stopIndex);
}
@ -258,9 +258,9 @@ namespace Antlr4.Runtime.Atn
// are showing a conflict, hence an ambiguity, but if they resolve
// to different minimum alternatives we have also identified a
// context sensitivity.
decisions[currentDecision].contextSensitivities.AddItem(new ContextSensitivityInfo(currentDecision, currentState, _input, startIndex, stopIndex));
decisions[currentDecision].contextSensitivities.Add(new ContextSensitivityInfo(currentDecision, currentState, _input, startIndex, stopIndex));
}
decisions[currentDecision].ambiguities.AddItem(new AmbiguityInfo(currentDecision, currentState, _input, startIndex, stopIndex));
decisions[currentDecision].ambiguities.Add(new AmbiguityInfo(currentDecision, currentState, _input, startIndex, stopIndex));
base.ReportAmbiguity(dfa, D, startIndex, stopIndex, exact, ambigAlts, configs);
}

View File

@ -297,7 +297,7 @@ namespace Antlr4.Runtime.Atn
}
else
{
operands.AddItem(a);
operands.Add(a);
}
if (b is SemanticContext.AND)
{
@ -305,14 +305,14 @@ namespace Antlr4.Runtime.Atn
}
else
{
operands.AddItem(b);
operands.Add(b);
}
IList<SemanticContext.PrecedencePredicate> precedencePredicates = FilterPrecedencePredicates(operands);
if (!precedencePredicates.IsEmpty())
{
// interested in the transition with the lowest precedence
SemanticContext.PrecedencePredicate reduced = Antlr4.Runtime.Sharpen.Collections.Min(precedencePredicates);
operands.AddItem(reduced);
operands.Add(reduced);
}
opnds = Sharpen.Collections.ToArray(operands, new SemanticContext[operands.Count]);
}
@ -380,7 +380,7 @@ namespace Antlr4.Runtime.Atn
if (evaluated != None)
{
// Reduce the result by skipping true elements
operands.AddItem(evaluated);
operands.Add(evaluated);
}
}
}
@ -429,7 +429,7 @@ namespace Antlr4.Runtime.Atn
}
else
{
operands.AddItem(a);
operands.Add(a);
}
if (b is SemanticContext.OR)
{
@ -437,14 +437,14 @@ namespace Antlr4.Runtime.Atn
}
else
{
operands.AddItem(b);
operands.Add(b);
}
IList<SemanticContext.PrecedencePredicate> precedencePredicates = FilterPrecedencePredicates(operands);
if (!precedencePredicates.IsEmpty())
{
// interested in the transition with the highest precedence
SemanticContext.PrecedencePredicate reduced = Antlr4.Runtime.Sharpen.Collections.Max(precedencePredicates);
operands.AddItem(reduced);
operands.Add(reduced);
}
this.opnds = Sharpen.Collections.ToArray(operands, new SemanticContext[operands.Count]);
}
@ -512,7 +512,7 @@ namespace Antlr4.Runtime.Atn
if (evaluated != null)
{
// Reduce the result by skipping false elements
operands.AddItem(evaluated);
operands.Add(evaluated);
}
}
}
@ -593,7 +593,7 @@ namespace Antlr4.Runtime.Atn
{
result = new List<SemanticContext.PrecedencePredicate>();
}
result.AddItem((SemanticContext.PrecedencePredicate)context);
result.Add((SemanticContext.PrecedencePredicate)context);
iterator.Remove();
}
}

View File

@ -267,7 +267,7 @@ namespace Antlr4.Runtime
{
((IWritableToken)t).TokenIndex = tokens.Count;
}
tokens.AddItem(t);
tokens.Add(t);
if (t.Type == TokenConstants.Eof)
{
fetchedEOF = true;
@ -307,7 +307,7 @@ namespace Antlr4.Runtime
{
break;
}
subset.AddItem(t);
subset.Add(t);
}
return subset;
}
@ -437,7 +437,7 @@ namespace Antlr4.Runtime
IToken t = tokens[i];
if (types == null || types.Get(t.Type))
{
filteredTokens.AddItem(t);
filteredTokens.Add(t);
}
}
if (filteredTokens.IsEmpty())
@ -628,14 +628,14 @@ namespace Antlr4.Runtime
{
if (t.Channel != Lexer.DefaultTokenChannel)
{
hidden.AddItem(t);
hidden.Add(t);
}
}
else
{
if (t.Channel == channel)
{
hidden.AddItem(t);
hidden.Add(t);
}
}
}

View File

@ -150,7 +150,7 @@ namespace Antlr4.Runtime.Dfa
{
// stay sparse and add new entry
keys[insertIndex] = key;
values.AddItem(value);
values.Add(value);
return this;
}
int desiredSize = Count >= MaxSparseSize ? MaxSparseSize * 2 : MaxSparseSize;

View File

@ -506,7 +506,7 @@ outer_break: ;
IToken t = NextToken();
while (t.Type != TokenConstants.Eof)
{
tokens.AddItem(t);
tokens.Add(t);
t = NextToken();
}
return tokens;

View File

@ -90,7 +90,7 @@ namespace Antlr4.Runtime.Misc
/// <code>o</code>
/// to set if not there; return existing value if already
/// there. This method performs the same operation as
/// <see cref="Array2DHashSet{T}.AddItem(object)"/>
/// <see cref="Array2DHashSet{T}.Add(object)"/>
/// aside from
/// the return value.
/// </summary>
@ -270,7 +270,7 @@ namespace Antlr4.Runtime.Misc
System.Diagnostics.Debug.Assert(n == oldSize);
}
public bool AddItem(T t)
public bool Add(T t)
{
T existing = GetOrAdd(t);
return existing == t;

View File

@ -215,7 +215,7 @@ namespace Antlr4.Runtime.Misc
// if disjoint and after r, a future iteration will handle it
// ok, must be after last interval (and disjoint from last interval)
// just add it
intervals.AddItem(addition);
intervals.Add(addition);
}
/// <summary>combine all sets in the array returned the or'd value</summary>
@ -814,7 +814,7 @@ namespace Antlr4.Runtime.Misc
int b = I.b;
for (int v = a; v <= b; v++)
{
values.AddItem(v);
values.Add(v);
}
}
return values;
@ -829,7 +829,7 @@ namespace Antlr4.Runtime.Misc
int b = I.b;
for (int v = a; v <= b; v++)
{
s.AddItem(v);
s.Add(v);
}
}
return s;

View File

@ -47,7 +47,7 @@ namespace Antlr4.Runtime.Misc
elementsForKey = new List<V>();
base.Put(key, elementsForKey);
}
elementsForKey.AddItem(value);
elementsForKey.Add(value);
}
public virtual IList<Tuple<K, V>> GetPairs()
@ -57,7 +57,7 @@ namespace Antlr4.Runtime.Misc
{
foreach (V value in Get(key))
{
pairs.AddItem(Tuple.Create(key, value));
pairs.Add(Tuple.Create(key, value));
}
}
return pairs;

View File

@ -69,7 +69,7 @@ namespace Antlr4.Runtime.Misc
// update list
base.Remove(oldElement);
// now update the set: remove/add
base.AddItem(value);
base.Add(value);
return oldElement;
}
@ -88,13 +88,13 @@ namespace Antlr4.Runtime.Misc
/// Key is object itself. Good for say asking if a certain string is in
/// a list of strings.
/// </remarks>
public override bool AddItem(T value)
public override bool Add(T value)
{
bool result = base.AddItem(value);
bool result = base.Add(value);
if (result)
{
// only track if new element not in set
elements.AddItem(value);
elements.Add(value);
}
return result;
}

View File

@ -77,7 +77,7 @@ namespace Antlr4.Runtime.Misc
list = new List<Tuple<RuleDependency, IAnnotatedElement>>();
recognizerDependencies.Put(recognizerType, list);
}
list.AddItem(dependency);
list.Add(dependency);
}
foreach (KeyValuePair<Type, IList<Tuple<RuleDependency, IAnnotatedElement>>> entry in recognizerDependencies.EntrySet())
{
@ -97,7 +97,7 @@ namespace Antlr4.Runtime.Misc
private static void GetTypesToCheck<_T0>(Type<_T0> clazz, HashSet<Type> result)
{
if (!result.AddItem(clazz))
if (!result.Add(clazz))
{
return;
}
@ -119,7 +119,7 @@ namespace Antlr4.Runtime.Misc
{
lock (checkedTypes)
{
checkedTypes.AddItem(clazz);
checkedTypes.Add(clazz);
}
}
@ -424,7 +424,7 @@ namespace Antlr4.Runtime.Misc
RuleDependency dependency = annotatedElement.GetAnnotation<RuleDependency>();
if (dependency != null)
{
result.AddItem(Tuple.Create(dependency, annotatedElement));
result.Add(Tuple.Create(dependency, annotatedElement));
}
RuleDependencies dependencies = annotatedElement.GetAnnotation<RuleDependencies>();
if (dependencies != null)
@ -433,7 +433,7 @@ namespace Antlr4.Runtime.Misc
{
if (d != null)
{
result.AddItem(Tuple.Create(d, annotatedElement));
result.Add(Tuple.Create(d, annotatedElement));
}
}
}

View File

@ -76,7 +76,7 @@ namespace Antlr4.Runtime.Misc
list = new List<Tuple<RuleDependency, IElement>>();
recognizerDependencies.Put(recognizerType, list);
}
list.AddItem(dependency);
list.Add(dependency);
}
foreach (KeyValuePair<ITypeMirror, IList<Tuple<RuleDependency, IElement>>> entry in recognizerDependencies.EntrySet())
{
@ -409,7 +409,7 @@ namespace Antlr4.Runtime.Misc
}
while (result.Count <= index)
{
result.AddItem(string.Empty);
result.Add(string.Empty);
}
result.Set(index, name);
}
@ -433,7 +433,7 @@ namespace Antlr4.Runtime.Misc
{
continue;
}
result.AddItem(Tuple.Create(dependency, element));
result.Add(Tuple.Create(dependency, element));
}
elements = roundEnv.GetElementsAnnotatedWith(typeof(RuleDependencies));
foreach (IElement element_1 in elements)
@ -445,7 +445,7 @@ namespace Antlr4.Runtime.Misc
}
foreach (RuleDependency dependency in dependencies.Value())
{
result.AddItem(Tuple.Create(dependency, element_1));
result.Add(Tuple.Create(dependency, element_1));
}
}
return result;

View File

@ -101,7 +101,7 @@ namespace Antlr4.Runtime.Misc
if (arg[0] != '-')
{
// input file name
inputFiles.AddItem(arg);
inputFiles.Add(arg);
continue;
}
if (arg.Equals("-tree"))

View File

@ -474,7 +474,7 @@ namespace Antlr4.Runtime
{
_parseListeners = new List<IParseTreeListener>();
}
this._parseListeners.AddItem(listener);
this._parseListeners.Add(listener);
}
/// <summary>
@ -1116,11 +1116,11 @@ namespace Antlr4.Runtime
int ruleIndex = p.RuleIndex;
if (ruleIndex < 0)
{
stack.AddItem("n/a");
stack.Add("n/a");
}
else
{
stack.AddItem(ruleNames[ruleIndex]);
stack.Add(ruleNames[ruleIndex]);
}
p = p.parent;
}
@ -1135,7 +1135,7 @@ namespace Antlr4.Runtime
for (int d = 0; d < _interp.atn.decisionToDFA.Length; d++)
{
DFA dfa = _interp.atn.decisionToDFA[d];
s.AddItem(dfa.ToString(TokenNames, RuleNames));
s.Add(dfa.ToString(TokenNames, RuleNames));
}
return s;
}

View File

@ -172,7 +172,7 @@ namespace Antlr4.Runtime
{
children = new List<IParseTree>();
}
children.AddItem(t);
children.Add(t);
}
public virtual void AddChild(RuleContext ruleInvocation)
@ -181,7 +181,7 @@ namespace Antlr4.Runtime
{
children = new List<IParseTree>();
}
children.AddItem(ruleInvocation);
children.Add(ruleInvocation);
}
/// <summary>
@ -304,7 +304,7 @@ namespace Antlr4.Runtime
{
tokens = new List<ITerminalNode>();
}
tokens.AddItem(tnode);
tokens.Add(tnode);
}
}
}
@ -339,7 +339,7 @@ namespace Antlr4.Runtime
{
contexts = new List<T>();
}
contexts.AddItem(ctxType.Cast(o));
contexts.Add(ctxType.Cast(o));
}
}
if (contexts == null)

View File

@ -50,7 +50,7 @@ namespace Antlr4.Runtime
public _CopyOnWriteArrayList_59()
{
{
this.AddItem(ConsoleErrorListener.Instance);
this.Add(ConsoleErrorListener.Instance);
}
}
}
@ -292,7 +292,7 @@ namespace Antlr4.Runtime
public virtual void AddErrorListener<_T0>(IAntlrErrorListener<_T0> listener)
{
Args.NotNull("listener", listener);
_listeners.AddItem(listener);
_listeners.Add(listener);
}
public virtual void RemoveErrorListener<_T0>(IAntlrErrorListener<_T0> listener)

View File

@ -337,7 +337,7 @@ namespace Antlr4.Runtime
TokenStreamRewriter.RewriteOperation op = new TokenStreamRewriter.InsertBeforeOp(tokens, index, text);
IList<TokenStreamRewriter.RewriteOperation> rewrites = GetProgram(programName);
op.instructionIndex = rewrites.Count;
rewrites.AddItem(op);
rewrites.Add(op);
}
public virtual void Replace(int index, object text)
@ -369,7 +369,7 @@ namespace Antlr4.Runtime
TokenStreamRewriter.RewriteOperation op = new TokenStreamRewriter.ReplaceOp(tokens, from, to, text);
IList<TokenStreamRewriter.RewriteOperation> rewrites = GetProgram(programName);
op.instructionIndex = rewrites.Count;
rewrites.AddItem(op);
rewrites.Add(op);
}
public virtual void Replace(string programName, IToken from, IToken to, object text)
@ -750,7 +750,7 @@ namespace Antlr4.Runtime
// ignore deleted
if (kind.IsInstanceOfType(op))
{
ops.AddItem(kind.Cast(op));
ops.Add(kind.Cast(op));
}
}
return ops;

View File

@ -174,7 +174,7 @@ namespace Antlr4.Runtime.Tree.Pattern
ParseTreeMatch match = Match(t);
if (match.Succeeded)
{
matches.AddItem(match);
matches.Add(match);
}
}
return matches;

View File

@ -559,7 +559,7 @@ namespace Antlr4.Runtime.Tree.Pattern
throw new ArgumentException("Unknown token " + tagChunk.Tag + " in pattern: " + pattern);
}
TokenTagToken t = new TokenTagToken(tagChunk.Tag, ttype, tagChunk.Label);
tokens.AddItem(t);
tokens.Add(t);
}
else
{
@ -571,7 +571,7 @@ namespace Antlr4.Runtime.Tree.Pattern
throw new ArgumentException("Unknown rule " + tagChunk.Tag + " in pattern: " + pattern);
}
int ruleImaginaryTokenType = parser.GetATNWithBypassAlts().ruleToTokenType[ruleIndex];
tokens.AddItem(new RuleTagToken(tagChunk.Tag, ruleImaginaryTokenType, tagChunk.Label));
tokens.Add(new RuleTagToken(tagChunk.Tag, ruleImaginaryTokenType, tagChunk.Label));
}
else
{
@ -587,7 +587,7 @@ namespace Antlr4.Runtime.Tree.Pattern
IToken t = lexer.NextToken();
while (t.Type != TokenConstants.Eof)
{
tokens.AddItem(t);
tokens.Add(t);
t = lexer.NextToken();
}
}
@ -628,14 +628,14 @@ namespace Antlr4.Runtime.Tree.Pattern
{
if (p == pattern.IndexOf(start, p))
{
starts.AddItem(p);
starts.Add(p);
p += start.Length;
}
else
{
if (p == pattern.IndexOf(stop, p))
{
stops.AddItem(p);
stops.Add(p);
p += stop.Length;
}
else
@ -669,13 +669,13 @@ namespace Antlr4.Runtime.Tree.Pattern
if (ntags == 0)
{
string text = Sharpen.Runtime.Substring(pattern, 0, n);
chunks.AddItem(new TextChunk(text));
chunks.Add(new TextChunk(text));
}
if (ntags > 0 && starts[0] > 0)
{
// copy text up to first tag into chunks
string text = Sharpen.Runtime.Substring(pattern, 0, starts[0]);
chunks.AddItem(new TextChunk(text));
chunks.Add(new TextChunk(text));
}
for (int i_1 = 0; i_1 < ntags; i_1++)
{
@ -689,12 +689,12 @@ namespace Antlr4.Runtime.Tree.Pattern
label = Sharpen.Runtime.Substring(tag, 0, colon);
ruleOrToken = Sharpen.Runtime.Substring(tag, colon + 1, tag.Length);
}
chunks.AddItem(new TagChunk(label, ruleOrToken));
chunks.Add(new TagChunk(label, ruleOrToken));
if (i_1 + 1 < ntags)
{
// copy from end of <tag> to start of next
string text = Sharpen.Runtime.Substring(pattern, stops[i_1] + stop.Length, starts[i_1 + 1]);
chunks.AddItem(new TextChunk(text));
chunks.Add(new TextChunk(text));
}
}
if (ntags > 0)
@ -704,7 +704,7 @@ namespace Antlr4.Runtime.Tree.Pattern
{
// copy text from end of last tag to end
string text = Sharpen.Runtime.Substring(pattern, afterLastTag, n);
chunks.AddItem(new TextChunk(text));
chunks.Add(new TextChunk(text));
}
}
// strip out the escape sequences from text chunks but not tags

View File

@ -152,7 +152,7 @@ namespace Antlr4.Runtime.Tree
IList<ITree> kids = new List<ITree>();
for (int i = 0; i < t.ChildCount; i++)
{
kids.AddItem(t.GetChild(i));
kids.Add(t.GetChild(i));
}
return kids;
}
@ -205,7 +205,7 @@ namespace Antlr4.Runtime.Tree
ITerminalNode tnode = (ITerminalNode)t;
if (tnode.Symbol.Type == index)
{
nodes.AddItem(t);
nodes.Add(t);
}
}
else
@ -215,7 +215,7 @@ namespace Antlr4.Runtime.Tree
ParserRuleContext ctx = (ParserRuleContext)t;
if (ctx.RuleIndex == index)
{
nodes.AddItem(t);
nodes.Add(t);
}
}
}
@ -229,7 +229,7 @@ namespace Antlr4.Runtime.Tree
public static IList<IParseTree> Descendants(IParseTree t)
{
IList<IParseTree> nodes = new List<IParseTree>();
nodes.AddItem(t);
nodes.Add(t);
int n = t.ChildCount;
for (int i = 0; i < n; i++)
{

View File

@ -162,7 +162,7 @@ namespace Antlr4.Runtime.Tree.Xpath
}
XPathElement pathElement = GetXPathElement(next, anywhere);
pathElement.invert = invert;
elements.AddItem(pathElement);
elements.Add(pathElement);
i++;
break;
}
@ -171,7 +171,7 @@ namespace Antlr4.Runtime.Tree.Xpath
case XPathLexer.RuleRef:
case XPathLexer.Wildcard:
{
elements.AddItem(GetXPathElement(el, false));
elements.Add(GetXPathElement(el, false));
i++;
break;
}

View File

@ -56,7 +56,7 @@ namespace Antlr4.Runtime.Tree.Xpath
ParserRuleContext ctx = (ParserRuleContext)c;
if ((ctx.RuleIndex == ruleIndex && !invert) || (ctx.RuleIndex != ruleIndex && invert))
{
nodes.AddItem(ctx);
nodes.Add(ctx);
}
}
}

View File

@ -55,7 +55,7 @@ namespace Antlr4.Runtime.Tree.Xpath
ITerminalNode tnode = (ITerminalNode)c;
if ((tnode.Symbol.Type == tokenType && !invert) || (tnode.Symbol.Type != tokenType && invert))
{
nodes.AddItem(tnode);
nodes.Add(tnode);
}
}
}

View File

@ -51,7 +51,7 @@ namespace Antlr4.Runtime.Tree.Xpath
IList<IParseTree> kids = new List<IParseTree>();
foreach (ITree c in Trees.GetChildren(t))
{
kids.AddItem((IParseTree)c);
kids.Add((IParseTree)c);
}
return kids;
}