forked from jasder/antlr
Use isEmpty() instead of comparing size() with 0
This commit is contained in:
parent
2f0029a040
commit
3b9940b02a
|
@ -119,7 +119,7 @@ public class ATN {
|
|||
}
|
||||
|
||||
public DecisionState getDecisionState(int decision) {
|
||||
if ( decisionToState.size()>0 ) {
|
||||
if ( !decisionToState.isEmpty() ) {
|
||||
return decisionToState.get(decision);
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -87,7 +87,7 @@ public class TraceTree implements Tree {
|
|||
states.add(0, p.state);
|
||||
p = p.parent;
|
||||
}
|
||||
if ( states.size()==0 ) return null;
|
||||
if ( states.isEmpty() ) return null;
|
||||
return states;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ public class AnalysisPipeline {
|
|||
// LEFT-RECURSION CHECK
|
||||
LeftRecursionDetector lr = new LeftRecursionDetector(g, g.atn);
|
||||
lr.check();
|
||||
if ( lr.listOfRecursiveCycles.size()>0 ) return; // bail out
|
||||
if ( !lr.listOfRecursiveCycles.isEmpty() ) return; // bail out
|
||||
|
||||
// BUILD DFA FOR EACH DECISION
|
||||
if ( !g.isLexer() ) processParser();
|
||||
|
|
|
@ -63,7 +63,7 @@ public class LeftRecursionDetector {
|
|||
check(g.getRule(start.ruleIndex), start, new HashSet<ATNState>());
|
||||
}
|
||||
//System.out.println("cycles="+listOfRecursiveCycles);
|
||||
if ( listOfRecursiveCycles.size()>0 ) {
|
||||
if ( !listOfRecursiveCycles.isEmpty() ) {
|
||||
g.tool.errMgr.leftRecursionCycles(g.fileName, listOfRecursiveCycles);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ public class ATNPrinter {
|
|||
StringBuilder buf = new StringBuilder();
|
||||
ATNState s = null;
|
||||
|
||||
while ( work.size()>0 ) {
|
||||
while ( !work.isEmpty() ) {
|
||||
s = work.remove(0);
|
||||
if ( marked.contains(s) ) continue;
|
||||
int n = s.getNumberOfTransitions();
|
||||
|
|
|
@ -426,14 +426,14 @@ public class OutputModelController {
|
|||
public void setRoot(OutputModelObject root) { this.root = root; }
|
||||
|
||||
public RuleFunction getCurrentRuleFunction() {
|
||||
if ( currentRule.size()>0 ) return currentRule.peek();
|
||||
if ( !currentRule.isEmpty() ) return currentRule.peek();
|
||||
return null;
|
||||
}
|
||||
|
||||
public void pushCurrentRule(RuleFunction r) { currentRule.push(r); }
|
||||
|
||||
public RuleFunction popCurrentRule() {
|
||||
if ( currentRule.size()>0 ) return currentRule.pop();
|
||||
if ( !currentRule.isEmpty() ) return currentRule.pop();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ public class RuleFunction extends OutputModelObject {
|
|||
super(factory);
|
||||
this.name = r.name;
|
||||
this.rule = r;
|
||||
if ( r.modifiers!=null && r.modifiers.size()>0 ) {
|
||||
if ( r.modifiers!=null && !r.modifiers.isEmpty() ) {
|
||||
this.modifiers = new ArrayList<String>();
|
||||
for (GrammarAST t : r.modifiers) modifiers.add(t.getText());
|
||||
}
|
||||
|
|
|
@ -115,5 +115,5 @@ public class StructDecl extends Decl {
|
|||
extensionMembers.add(member);
|
||||
}
|
||||
|
||||
public boolean isEmpty() { return attrs.size()==0; }
|
||||
public boolean isEmpty() { return attrs.isEmpty(); }
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ public class ToolANTLRParser extends ANTLRParser {
|
|||
RecognitionException e)
|
||||
{
|
||||
String msg = getParserErrorMessage(this, e);
|
||||
if ( paraphrases.size()>0 ) {
|
||||
if ( !paraphrases.isEmpty() ) {
|
||||
String paraphrase = (String)paraphrases.peek();
|
||||
msg = msg+" while "+paraphrase;
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ public class RuleCollector extends GrammarTreeVisitor {
|
|||
int numAlts = block.getChildCount();
|
||||
Rule r = new Rule(g, ID.getText(), rule, numAlts);
|
||||
r.mode = currentModeName;
|
||||
if ( modifiers.size()>0 ) r.modifiers = modifiers;
|
||||
if ( !modifiers.isEmpty() ) r.modifiers = modifiers;
|
||||
rules.put(r.name, r);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -187,7 +187,7 @@ public class DOTGenerator {
|
|||
List<ATNState> work = new LinkedList<ATNState>();
|
||||
|
||||
work.add(startState);
|
||||
while ( work.size()>0 ) {
|
||||
while ( !work.isEmpty() ) {
|
||||
ATNState s = work.get(0);
|
||||
if ( markedStates.contains(s) ) { work.remove(0); continue; }
|
||||
markedStates.add(s);
|
||||
|
|
|
@ -274,7 +274,7 @@ public class ErrorManager {
|
|||
format = new STGroupFile(fileName, "UTF-8");
|
||||
format.load();
|
||||
|
||||
if ( initSTListener.errors.size()>0 ) {
|
||||
if ( !initSTListener.errors.isEmpty() ) {
|
||||
rawError("ANTLR installation corrupted; can't load messages format file:\n"+
|
||||
initSTListener.toString());
|
||||
panic();
|
||||
|
|
|
@ -78,7 +78,7 @@ public class LeftRecursiveRule extends Rule {
|
|||
LeftRecursiveRuleAltInfo altInfo = recOpAlts.getElement(i);
|
||||
if ( altInfo.altLabel==null ) alts.add(altInfo.originalAltAST);
|
||||
}
|
||||
if ( alts.size()==0 ) return null;
|
||||
if ( alts.isEmpty() ) return null;
|
||||
return alts;
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ public class LeftRecursiveRule extends Rule {
|
|||
altInfo.altLabel));
|
||||
}
|
||||
}
|
||||
if ( labels.size()==0 ) return null;
|
||||
if ( labels.isEmpty() ) return null;
|
||||
return labels;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -184,7 +184,7 @@ public class Rule implements AttributeResolver {
|
|||
for (int i=1; i<=numberOfAlts; i++) {
|
||||
refs.addAll(alt[i].labelDefs.keySet());
|
||||
}
|
||||
if ( refs.size()==0 ) return null;
|
||||
if ( refs.isEmpty() ) return null;
|
||||
return refs;
|
||||
}
|
||||
|
||||
|
@ -219,7 +219,7 @@ public class Rule implements AttributeResolver {
|
|||
labels.add(new Triple<Integer,AltAST,String>(i,alt[i].ast,altLabel.getText()));
|
||||
}
|
||||
}
|
||||
if ( labels.size()==0 ) return null;
|
||||
if ( labels.isEmpty() ) return null;
|
||||
return labels;
|
||||
}
|
||||
|
||||
|
@ -229,7 +229,7 @@ public class Rule implements AttributeResolver {
|
|||
GrammarAST altLabel = alt[i].ast.altLabel;
|
||||
if ( altLabel==null ) alts.add(alt[i].ast);
|
||||
}
|
||||
if ( alts.size()==0 ) return null;
|
||||
if ( alts.isEmpty() ) return null;
|
||||
return alts;
|
||||
}
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ public class GrammarAST extends CommonTree {
|
|||
List<GrammarAST> work = new LinkedList<GrammarAST>();
|
||||
work.add(this);
|
||||
GrammarAST t;
|
||||
while ( work.size()>0 ) {
|
||||
while ( !work.isEmpty() ) {
|
||||
t = work.remove(0);
|
||||
if ( types.contains(t.getType()) ) nodes.add(t);
|
||||
if ( t.children!=null ) work.addAll((Collection)t.children);
|
||||
|
|
|
@ -861,7 +861,7 @@ public abstract class BaseTest {
|
|||
foundMsg = m;
|
||||
}
|
||||
}
|
||||
assertTrue("no error; "+expectedMessage.errorType+" expected", equeue.errors.size()>0);
|
||||
assertTrue("no error; "+expectedMessage.errorType+" expected", !equeue.errors.isEmpty());
|
||||
assertTrue("too many errors; "+equeue.errors, equeue.errors.size()<=1);
|
||||
assertNotNull("couldn't find expected error: "+expectedMessage.errorType, foundMsg);
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue