Skip to content

Commit

Permalink
[NFC] Reformat all code
Browse files Browse the repository at this point in the history
  • Loading branch information
0x8000-0000 committed Apr 25, 2020
1 parent 543c7f7 commit 1ec8e7b
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 65 deletions.
8 changes: 4 additions & 4 deletions src/main/java/net/signbit/samx/AttributeVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ public String toString()

boolean isEmpty = true;

if ((!classAttributes.isEmpty()) || (idAttribute != null) || (nameAttribute != null))
if ((! classAttributes.isEmpty()) || (idAttribute != null) || (nameAttribute != null))
{
builder.append(' ');
}

if (!classAttributes.isEmpty())
if (! classAttributes.isEmpty())
{
if (docBookMode)
{
Expand Down Expand Up @@ -134,7 +134,7 @@ public String toString()

if (idAttribute != null)
{
if (!isEmpty)
if (! isEmpty)
{
builder.append(' ');
}
Expand All @@ -155,7 +155,7 @@ public String toString()

if (nameAttribute != null)
{
if (!isEmpty)
if (! isEmpty)
{
builder.append(' ');
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/net/signbit/samx/GridVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public String getContent(SamXParserVisitor<StringBuilder> visitor)

public boolean hasContent()
{
return flow != null && (!flow.getText().isEmpty());
return flow != null && (! flow.getText().isEmpty());
}

public Object renderContent(SamXParserVisitor<Object> visitor)
Expand Down Expand Up @@ -148,7 +148,7 @@ else if (ggec.spanGridElement() != null)
GridCell gc = new GridCell(ggec.spanGridElement().attribute(), ggec.spanGridElement().optionalFlow());
gc.setSpan(ggec.spanGridElement().MUL_COLSEP().getText());

for (int ii = 0; ii < gc.colSpan; ++ii)
for (int ii = 0; ii < gc.colSpan; ++ ii)
{
cells.add(gc);
}
Expand Down Expand Up @@ -203,7 +203,7 @@ static class GeneralGridGroup
columnWidths = new int[localColumnCount];
isInteger = new boolean[localColumnCount];

for (int ii = 0; ii < localColumnCount; ++ii)
for (int ii = 0; ii < localColumnCount; ++ ii)
{
isInteger[ii] = true;
}
Expand All @@ -214,7 +214,7 @@ static class GeneralGridGroup
{
if (visitor != null)
{
for (int ii = 0; ii < ggr.cells.size(); ++ii)
for (int ii = 0; ii < ggr.cells.size(); ++ ii)
{
final GridCell gc = ggr.cells.get(ii);

Expand All @@ -234,7 +234,7 @@ static class GeneralGridGroup
columnWidths[ii] = thisWidth;
}

if (!VisitorUtils.isInteger(content))
if (! VisitorUtils.isInteger(content))
{
isInteger[ii] = false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/signbit/samx/HtmlPrinterVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ public String visitText(SamXParser.TextContext ctx)

for (ParseTree pt : ctx.children)
{
if (!firstToken)
if (! firstToken)
{
final Interval pos = pt.getSourceInterval();
if (pos.a <= pos.b)
{
final List<Token> precedingWhitespace = tokenStream.getHiddenTokensToLeft(pos.a, SamXLexer.WHITESPACE);
if ((precedingWhitespace != null) && (!precedingWhitespace.isEmpty()))
if ((precedingWhitespace != null) && (! precedingWhitespace.isEmpty()))
{
builder.append(' ');
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/signbit/samx/PlainTextVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public StringBuilder visitText(SamXParser.TextContext ctx)

for (ParseTree tn : ctx.children)
{
if (!firstToken)
if (! firstToken)
{
addSpaceIfPresentInInput(builder, tn);
}
Expand All @@ -70,7 +70,7 @@ private void addSpaceIfPresentInInput(StringBuilder builder, ParseTree tn)
if (pos.a <= pos.b)
{
final List<Token> precedingTokens = tokenStream.getHiddenTokensToLeft(pos.a, SamXLexer.WHITESPACE);
if ((precedingTokens != null) && (!precedingTokens.isEmpty()))
if ((precedingTokens != null) && (! precedingTokens.isEmpty()))
{
builder.append(' ');
}
Expand Down
52 changes: 26 additions & 26 deletions src/main/java/net/signbit/samx/PrettyPrinterVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public PrettyPrinterVisitor(BufferedTokenStream tokenStream)

private void addIndent(StringBuilder builder)
{
for (int ii = 0; ii < indentLevel; ++ii)
for (int ii = 0; ii < indentLevel; ++ ii)
{
builder.append(indentString);
}
Expand Down Expand Up @@ -85,7 +85,7 @@ private StringBuilder wrapText(String rawText, int wrapLength, boolean indentFir
StringTokenizer tokenizer = new StringTokenizer(paragraphText, '\n');
while (tokenizer.hasNext())
{
if (!indentFirst)
if (! indentFirst)
{
indentFirst = true;
}
Expand Down Expand Up @@ -175,7 +175,7 @@ public StringBuilder visitListElement(SamXParser.ListElementContext ctx)
ArrayList<SamXParser.BlockContext> blocks = new ArrayList<>(ctx.block());

boolean joined = false;
if (!blocks.isEmpty())
if (! blocks.isEmpty())
{
if (ctx.separator == null)
{
Expand Down Expand Up @@ -205,7 +205,7 @@ public StringBuilder visitListElement(SamXParser.ListElementContext ctx)
builder.append(wrapText(firstLineFlow.toString(), wrapLength, false));
indentLevel--;

if (!blocks.isEmpty())
if (! blocks.isEmpty())
{
if ((ctx.separator != null) || joined)
{
Expand Down Expand Up @@ -260,7 +260,7 @@ public StringBuilder visitRecordSet(SamXParser.RecordSetContext ctx)
boolean[] isInteger = new boolean[ctx.headerRow().NAME().size()];

ArrayList<String> headerElements = visitHeaderRowElements(ctx.headerRow());
for (int ii = 0; ii < headerElements.size(); ++ii)
for (int ii = 0; ii < headerElements.size(); ++ ii)
{
columnWidths[ii + 1] = headerElements.get(ii).length();
isInteger[ii] = true;
Expand All @@ -283,7 +283,7 @@ public StringBuilder visitRecordSet(SamXParser.RecordSetContext ctx)
}
}

for (int ii = 0; ii < headerElements.size(); ++ii)
for (int ii = 0; ii < headerElements.size(); ++ ii)
{
final String value = rowElements.get(ii + 1);
final int length = value.length();
Expand All @@ -292,9 +292,9 @@ public StringBuilder visitRecordSet(SamXParser.RecordSetContext ctx)
columnWidths[ii + 1] = length;
}

if ((value != null) && (!value.isEmpty()))
if ((value != null) && (! value.isEmpty()))
{
if (!VisitorUtils.isInteger(value))
if (! VisitorUtils.isInteger(value))
{
isInteger[ii] = false;
}
Expand All @@ -315,7 +315,7 @@ public StringBuilder visitRecordSet(SamXParser.RecordSetContext ctx)
{
builder.append(String.format("%1$-" + columnWidths[0] + "s", ""));
}
for (int ii = 0; ii < headerElements.size(); ++ii)
for (int ii = 0; ii < headerElements.size(); ++ ii)
{
builder.append(" | ");
if (ii != (headerElements.size() - 1))
Expand All @@ -336,15 +336,15 @@ public StringBuilder visitRecordSet(SamXParser.RecordSetContext ctx)
{
builder.append(' ');

for (int jj = 0; jj < columnWidths[0]; ++jj)
for (int jj = 0; jj < columnWidths[0]; ++ jj)
{
builder.append(' ');
}

for (int ii = 0; ii < headerElements.size(); ++ii)
for (int ii = 0; ii < headerElements.size(); ++ ii)
{
builder.append("+---");
for (int jj = 1; jj < columnWidths[ii + 1]; ++jj)
for (int jj = 1; jj < columnWidths[ii + 1]; ++ jj)
{
builder.append('-');
}
Expand All @@ -356,7 +356,7 @@ public StringBuilder visitRecordSet(SamXParser.RecordSetContext ctx)
{
builder.append(String.format("%1$-" + columnWidths[0] + "s", rowData.get(0)));
}
for (int ii = 0; ii < headerElements.size(); ++ii)
for (int ii = 0; ii < headerElements.size(); ++ ii)
{
builder.append(" | ");
if (isInteger[ii])
Expand Down Expand Up @@ -477,7 +477,7 @@ public StringBuilder visitFlow(SamXParser.FlowContext ctx)
StringBuilder childBuilder = visit(tn);
if (childBuilder != null)
{
if (!firstToken)
if (! firstToken)
{
addSpaceIfPresentInInput(builder, tn);
}
Expand All @@ -495,7 +495,7 @@ private void addSpaceIfPresentInInput(StringBuilder builder, ParseTree tn)
if (pos.a <= pos.b)
{
final List<Token> precedingTokens = tokenStream.getHiddenTokensToLeft(pos.a, SamXLexer.WHITESPACE);
if ((precedingTokens != null) && (!precedingTokens.isEmpty()))
if ((precedingTokens != null) && (! precedingTokens.isEmpty()))
{
builder.append(' ');
}
Expand Down Expand Up @@ -683,7 +683,7 @@ public StringBuilder visitCodeBlock(SamXParser.CodeBlockContext ctx)

final int codeLineIndent = VisitorUtils.getTokenIndent(ecc, tokenStream);

for (int ii = codeBlockIndent; ii < codeLineIndent; ++ii)
for (int ii = codeBlockIndent; ii < codeLineIndent; ++ ii)
{
builder.append(' ');
}
Expand Down Expand Up @@ -858,7 +858,7 @@ private void visitNestedBlock(StringBuilder builder, List<SamXParser.BlockContex
}
}

if (!lastChildHadNewline)
if (! lastChildHadNewline)
{
builder.append('\n');
}
Expand Down Expand Up @@ -947,7 +947,7 @@ private String renderGridElement(SamXParser.GridElementContext gec)
builder.append(visit(ac));
}

if (!gec.attribute().isEmpty())
if (! gec.attribute().isEmpty())
{
builder.append(' ');
}
Expand Down Expand Up @@ -1010,7 +1010,7 @@ public StringBuilder visitGeneralGrid(SamXParser.GeneralGridContext ctx)

int conditionColumnWidth = body.conditionColumnWidth;
int columnWidths[] = new int[body.columnCount];
for (int ii = 0; ii < body.columnCount; ++ii)
for (int ii = 0; ii < body.columnCount; ++ ii)
{
columnWidths[ii] = body.columnWidths[ii];
}
Expand All @@ -1029,7 +1029,7 @@ public StringBuilder visitGeneralGrid(SamXParser.GeneralGridContext ctx)
conditionColumnWidth = header.conditionColumnWidth;
}

for (int ii = 0; ii < body.columnCount; ++ii)
for (int ii = 0; ii < body.columnCount; ++ ii)
{
if (columnWidths[ii] < header.columnWidths[ii])
{
Expand All @@ -1052,7 +1052,7 @@ public StringBuilder visitGeneralGrid(SamXParser.GeneralGridContext ctx)
conditionColumnWidth = footer.conditionColumnWidth;
}

for (int ii = 0; ii < body.columnCount; ++ii)
for (int ii = 0; ii < body.columnCount; ++ ii)
{
if (columnWidths[ii] < footer.columnWidths[ii])
{
Expand Down Expand Up @@ -1095,11 +1095,11 @@ public StringBuilder visitGeneralGrid(SamXParser.GeneralGridContext ctx)
private void renderGeneralTableSeparator(int conditionColumnWidth, int[] columnWidths, int columnCount, StringBuilder builder)
{
addIndent(builder);
for (int jj = 0; jj < conditionColumnWidth + 1; ++jj)
for (int jj = 0; jj < conditionColumnWidth + 1; ++ jj)
{
builder.append(' ');
}
for (int jj = 0; jj < columnCount; ++jj)
for (int jj = 0; jj < columnCount; ++ jj)
{
builder.append('+');
for (int kk = 0; kk < columnWidths[jj] + 2; kk++)
Expand All @@ -1122,15 +1122,15 @@ private void renderGeneralTableGroup(int conditionColumnWidth, int[] columnWidth
builder.append(String.format("%1$-" + conditionColumnWidth + "s", attributeCondition));
}

for (int jj = 0; jj < gridGroup.columnCount; ++jj)
for (int jj = 0; jj < gridGroup.columnCount; ++ jj)
{
final GridVisitor.GridCell gc = ggr.cells.get(jj);
if (gc.colSpan > 0)
{
builder.append(" |");
int columnWidth = columnWidths[jj];
final int colSpan = gc.colSpan;
for (int kk = 1; kk < colSpan; ++kk)
for (int kk = 1; kk < colSpan; ++ kk)
{
columnWidth += columnWidths[jj + kk] + 2;
ggr.cells.get(jj + kk).colSpan = 0;
Expand All @@ -1140,7 +1140,7 @@ private void renderGeneralTableGroup(int conditionColumnWidth, int[] columnWidth
{
builder.append('-');
columnWidth--;
for (int kk = 1; kk < gc.rowSpan; ++kk)
for (int kk = 1; kk < gc.rowSpan; ++ kk)
{
builder.append('-');
columnWidth--;
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/net/signbit/samx/RendererVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public Object visitComparisonCondition(SamXParser.ComparisonConditionContext ctx
result = Boolean.TRUE;
}

if ((!configuredValue.equals(value)) && (operator.charAt(0) == '!'))
if ((! configuredValue.equals(value)) && (operator.charAt(0) == '!'))
{
result = Boolean.TRUE;
}
Expand Down Expand Up @@ -188,7 +188,7 @@ public Object visitNotBelongsToSetCondition(SamXParser.NotBelongsToSetConditionC
HashSet<String> potentialValues = (HashSet<String>) visit(ctx.nameList());
if (potentialValues != null)
{
if (!potentialValues.contains(configuredValue))
if (! potentialValues.contains(configuredValue))
{
return Boolean.TRUE;
}
Expand All @@ -203,7 +203,7 @@ public boolean isDisabled(SamXParser.ConditionContext cc)
if (cc != null)
{
Object enabled = visit(cc);
return !Boolean.TRUE.equals(enabled);
return ! Boolean.TRUE.equals(enabled);
}
else
{
Expand All @@ -218,7 +218,7 @@ public boolean isDisabled(ParserRuleContext prc)
if ((metadata != null) && (metadata.condition() != null))
{
Object enabled = visit(metadata.condition());
return !Boolean.TRUE.equals(enabled);
return ! Boolean.TRUE.equals(enabled);
}
else
{
Expand Down Expand Up @@ -295,7 +295,7 @@ void addIndent()
{
if (writeIndent)
{
for (int ii = 0; ii < indentLevel; ++ii)
for (int ii = 0; ii < indentLevel; ++ ii)
{
append(" ");
}
Expand All @@ -304,7 +304,7 @@ void addIndent()

void addIndent(StringBuilder builder)
{
for (int ii = 0; ii < indentLevel; ++ii)
for (int ii = 0; ii < indentLevel; ++ ii)
{
builder.append(" ");
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/signbit/samx/VisitorUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public static boolean compareFilesExceptWhitespace(String originalString, String

int commonSubstring = 0;

while ((!original.isExhausted()) && (!pretty.isExhausted()))
while ((! original.isExhausted()) && (! pretty.isExhausted()))
{
if (original.advancePastWhitespace())
{
Expand Down
Loading

0 comments on commit 1ec8e7b

Please sign in to comment.