Skip to content

Commit

Permalink
232: Missing Overrides
Browse files Browse the repository at this point in the history
Added missing Overrides

fixes sirthias#232
  • Loading branch information
Jan Ortner committed Jun 10, 2016
1 parent 2a51455 commit 5bacddc
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 55 deletions.
18 changes: 12 additions & 6 deletions src/main/java/org/pegdown/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ public interface ParseRunnerProvider {

public static ParseRunnerProvider DefaultParseRunnerProvider =
new Parser.ParseRunnerProvider() {
public ParseRunner<Node> get(Rule rule) {
@Override
public ParseRunner<Node> get(Rule rule) {
return new ReportingParseRunner<Node>(rule);
}
};
Expand Down Expand Up @@ -401,7 +402,8 @@ public Rule DefTermInline() {

public Rule Definition() {
SuperNodeCreator itemNodeCreator = new SuperNodeCreator() {
public SuperNode create(Node child) {
@Override
public SuperNode create(Node child) {
return new DefinitionNode(child);
}
};
Expand All @@ -418,11 +420,13 @@ public Rule BulletList() {
if (ext(TASKLISTITEMS)) {
// #185 GFM style task list items [ ] open task, [x] closed task handlings
SuperNodeTaskItemCreator itemNodeCreator = new SuperNodeTaskItemCreator() {
public SuperNode create(Node child) {
@Override
public SuperNode create(Node child) {
return new ListItemNode(child);
}

public SuperNode create(Node child, int taskType, String taskListMarker) {
@Override
public SuperNode create(Node child, int taskType, String taskListMarker) {
return taskType == 0 ? new ListItemNode(child) : new TaskListNode(child, taskType == 2, taskListMarker);
}
};
Expand All @@ -436,7 +440,8 @@ public SuperNode create(Node child, int taskType, String taskListMarker) {
);
} else {
SuperNodeCreator itemNodeCreator = new SuperNodeCreator() {
public SuperNode create(Node child) {
@Override
public SuperNode create(Node child) {
return new ListItemNode(child);
}
};
Expand All @@ -453,7 +458,8 @@ public SuperNode create(Node child) {

public Rule OrderedList() {
SuperNodeCreator itemNodeCreator = new SuperNodeCreator() {
public SuperNode create(Node child) {
@Override
public SuperNode create(Node child) {
return new ListItemNode(child);
}
};
Expand Down
114 changes: 76 additions & 38 deletions src/main/java/org/pegdown/ToHtmlSerializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ public String toHtml(RootNode astRoot) {
return printer.getString();
}

public void visit(RootNode node) {
@Override
public void visit(RootNode node) {
for (ReferenceNode refNode : node.getReferences()) {
visitChildren(refNode);
references.put(normalize(printer.getString()), refNode);
Expand All @@ -89,66 +90,81 @@ public void visit(RootNode node) {
visitChildren(node);
}

public void visit(AbbreviationNode node) {
@Override
public void visit(AbbreviationNode node) {
}

public void visit(AnchorLinkNode node) {
@Override
public void visit(AnchorLinkNode node) {
printLink(linkRenderer.render(node));
}

public void visit(AutoLinkNode node) {
@Override
public void visit(AutoLinkNode node) {
printLink(linkRenderer.render(node));
}

public void visit(BlockQuoteNode node) {
@Override
public void visit(BlockQuoteNode node) {
printIndentedTag(node, "blockquote");
}

public void visit(BulletListNode node) {
@Override
public void visit(BulletListNode node) {
printIndentedTag(node, "ul");
}

public void visit(CodeNode node) {
@Override
public void visit(CodeNode node) {
printTag(node, "code");
}

public void visit(DefinitionListNode node) {
@Override
public void visit(DefinitionListNode node) {
printIndentedTag(node, "dl");
}

public void visit(DefinitionNode node) {
@Override
public void visit(DefinitionNode node) {
printConditionallyIndentedTag(node, "dd");
}

public void visit(DefinitionTermNode node) {
@Override
public void visit(DefinitionTermNode node) {
printConditionallyIndentedTag(node, "dt");
}

public void visit(ExpImageNode node) {
@Override
public void visit(ExpImageNode node) {
String text = printChildrenToString(node);
printImageTag(linkRenderer.render(node, text));
}

public void visit(ExpLinkNode node) {
@Override
public void visit(ExpLinkNode node) {
String text = printChildrenToString(node);
printLink(linkRenderer.render(node, text));
}

public void visit(HeaderNode node) {
@Override
public void visit(HeaderNode node) {
printBreakBeforeTag(node, "h" + node.getLevel());
}

public void visit(HtmlBlockNode node) {
@Override
public void visit(HtmlBlockNode node) {
String text = node.getText();
if (text.length() > 0) printer.println();
printer.print(text);
}

public void visit(InlineHtmlNode node) {
@Override
public void visit(InlineHtmlNode node) {
printer.print(node.getText());
}

public void visit(ListItemNode node) {
@Override
public void visit(ListItemNode node) {
if (node instanceof TaskListNode) {
// vsch: #185 handle GitHub style task list items, these are a bit messy because the <input> checkbox needs to be
// included inside the optional <p></p> first grand-child of the list item, first child is always RootNode
Expand Down Expand Up @@ -178,19 +194,23 @@ public void visit(ListItemNode node) {
}
}

public void visit(MailLinkNode node) {
@Override
public void visit(MailLinkNode node) {
printLink(linkRenderer.render(node));
}

public void visit(OrderedListNode node) {
@Override
public void visit(OrderedListNode node) {
printIndentedTag(node, "ol");
}

public void visit(ParaNode node) {
@Override
public void visit(ParaNode node) {
printBreakBeforeTag(node, "p");
}

public void visit(QuotedNode node) {
@Override
public void visit(QuotedNode node) {
switch (node.getType()) {
case DoubleAngle:
printer.print("&laquo;");
Expand All @@ -210,11 +230,13 @@ public void visit(QuotedNode node) {
}
}

public void visit(ReferenceNode node) {
@Override
public void visit(ReferenceNode node) {
// reference nodes are not printed
}

public void visit(RefImageNode node) {
@Override
public void visit(RefImageNode node) {
String text = printChildrenToString(node);
String key = node.referenceKey != null ? printChildrenToString(node.referenceKey) : text;
ReferenceNode refNode = references.get(normalize(key));
Expand All @@ -228,7 +250,8 @@ public void visit(RefImageNode node) {
} else printImageTag(linkRenderer.render(node, refNode.getUrl(), refNode.getTitle(), text));
}

public void visit(RefLinkNode node) {
@Override
public void visit(RefLinkNode node) {
String text = printChildrenToString(node);
String key = node.referenceKey != null ? printChildrenToString(node.referenceKey) : text;
ReferenceNode refNode = references.get(normalize(key));
Expand All @@ -242,7 +265,8 @@ public void visit(RefLinkNode node) {
} else printLink(linkRenderer.render(node, refNode.getUrl(), refNode.getTitle(), text));
}

public void visit(SimpleNode node) {
@Override
public void visit(SimpleNode node) {
switch (node.getType()) {
case Apostrophe:
printer.print("&rsquo;");
Expand Down Expand Up @@ -270,7 +294,8 @@ public void visit(SimpleNode node) {
}
}

public void visit(StrongEmphSuperNode node) {
@Override
public void visit(StrongEmphSuperNode node) {
if (node.isClosed()) {
if (node.isStrong())
printTag(node, "strong");
Expand All @@ -283,11 +308,13 @@ public void visit(StrongEmphSuperNode node) {
}
}

public void visit(StrikeNode node) {
@Override
public void visit(StrikeNode node) {
printTag(node, "del");
}

public void visit(TableBodyNode node) {
@Override
public void visit(TableBodyNode node) {
printIndentedTag(node, "tbody");
}

Expand All @@ -298,7 +325,8 @@ public void visit(TableCaptionNode node) {
printer.print("</caption>");
}

public void visit(TableCellNode node) {
@Override
public void visit(TableCellNode node) {
String tag = inTableHeader ? "th" : "td";
List<TableColumnNode> columns = currentTableNode.getColumns();
TableColumnNode column = columns.get(Math.min(currentTableColumn, columns.size() - 1));
Expand All @@ -313,7 +341,8 @@ public void visit(TableCellNode node) {
currentTableColumn += node.getColSpan();
}

public void visit(TableColumnNode node) {
@Override
public void visit(TableColumnNode node) {
switch (node.getAlignment()) {
case None:
break;
Expand All @@ -331,24 +360,28 @@ public void visit(TableColumnNode node) {
}
}

public void visit(TableHeaderNode node) {
@Override
public void visit(TableHeaderNode node) {
inTableHeader = true;
printIndentedTag(node, "thead");
inTableHeader = false;
}

public void visit(TableNode node) {
@Override
public void visit(TableNode node) {
currentTableNode = node;
printIndentedTag(node, "table");
currentTableNode = null;
}

public void visit(TableRowNode node) {
@Override
public void visit(TableRowNode node) {
currentTableColumn = 0;
printIndentedTag(node, "tr");
}

public void visit(VerbatimNode node) {
@Override
public void visit(VerbatimNode node) {
VerbatimSerializer serializer = lookupSerializer(node.getType());
serializer.serialize(node, printer);
}
Expand All @@ -361,27 +394,32 @@ protected VerbatimSerializer lookupSerializer(final String type) {
}
}

public void visit(WikiLinkNode node) {
@Override
public void visit(WikiLinkNode node) {
printLink(linkRenderer.render(node));
}

public void visit(TextNode node) {
@Override
public void visit(TextNode node) {
if (abbreviations.isEmpty()) {
printer.print(node.getText());
} else {
printWithAbbreviations(node.getText());
}
}

public void visit(SpecialTextNode node) {
@Override
public void visit(SpecialTextNode node) {
printer.printEncoded(node.getText());
}

public void visit(SuperNode node) {
@Override
public void visit(SuperNode node) {
visitChildren(node);
}

public void visit(Node node) {
@Override
public void visit(Node node) {
for (ToHtmlSerializerPlugin plugin : plugins) {
if (plugin.visit(node, this, printer)) {
return;
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/org/pegdown/ast/AbstractNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ public abstract class AbstractNode implements Node {
private int startIndex;
private int endIndex;

public int getStartIndex() {
@Override
public int getStartIndex() {
return startIndex;
}

public int getEndIndex() {
@Override
public int getEndIndex() {
return endIndex;
}

Expand Down
6 changes: 4 additions & 2 deletions src/main/java/org/pegdown/ast/SimpleNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ public Type getType() {
return type;
}

public List<Node> getChildren() {
@Override
public List<Node> getChildren() {
return ImmutableList.of();
}

public void accept(Visitor visitor) {
@Override
public void accept(Visitor visitor) {
visitor.visit(this);
}

Expand Down
6 changes: 4 additions & 2 deletions src/main/java/org/pegdown/ast/SuperNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ public SuperNode(List<Node> children) {
this.children.addAll(children);
}

public List<Node> getChildren() {
@Override
public List<Node> getChildren() {
return children;
}

public void accept(Visitor visitor) {
@Override
public void accept(Visitor visitor) {
visitor.visit(this);
}

Expand Down
Loading

0 comments on commit 5bacddc

Please sign in to comment.