public Node addRootNode(Node topOfAST) { final int endPosition; if (lexer.isEndSeen()) { endPosition = lexer.getLineOffset(); } else { endPosition = -1; } ISourcePosition position; CoverageData coverageData = configuration.finishCoverage(lexer.getFile(), lexer.lineno()); if (result.getBeginNodes().isEmpty()) { if (topOfAST == null) { topOfAST = NilImplicitNode.NIL; position = lexer.getPosition(); } else { position = topOfAST.getPosition(); } } else { position = topOfAST != null ? topOfAST.getPosition() : result.getBeginNodes().get(0).getPosition(); BlockNode newTopOfAST = new BlockNode(position); for (Node beginNode : result.getBeginNodes()) { appendToBlock(newTopOfAST, beginNode); } // Add real top to new top (unless this top is empty [only begin/end nodes or truly empty]) if (topOfAST != null) newTopOfAST.add(topOfAST); topOfAST = newTopOfAST; } return new RootNode(position, result.getScope(), topOfAST, lexer.getFile(), endPosition, coverageData != null); }
public Node addRootNode(Node topOfAST) { final int endPosition; if (lexer.isEndSeen()) { endPosition = lexer.getLineOffset(); } else { endPosition = -1; } ISourcePosition position; CoverageData coverageData = configuration.finishCoverage(lexer.getFile(), lexer.lineno()); if (result.getBeginNodes().isEmpty()) { if (topOfAST == null) { topOfAST = NilImplicitNode.NIL; position = lexer.getPosition(); } else { position = topOfAST.getPosition(); } } else { position = topOfAST != null ? topOfAST.getPosition() : result.getBeginNodes().get(0).getPosition(); BlockNode newTopOfAST = new BlockNode(position); for (Node beginNode : result.getBeginNodes()) { appendToBlock(newTopOfAST, beginNode); } // Add real top to new top (unless this top is empty [only begin/end nodes or truly empty]) if (topOfAST != null) newTopOfAST.add(topOfAST); topOfAST = newTopOfAST; } return new RootNode(position, result.getScope(), topOfAST, lexer.getFile(), endPosition, coverageData != null); }