(int alignOrIndent, TerminalNode node)
| 314 | } |
| 315 | |
| 316 | public void align(int alignOrIndent, TerminalNode node) { |
| 317 | int[] deltaChild = Trainer.triple(alignOrIndent); |
| 318 | int deltaFromAncestor = deltaChild[0]; |
| 319 | int childIndex = deltaChild[1]; |
| 320 | ParserRuleContext earliestLeftAncestor = earliestAncestorStartingWithToken(node); |
| 321 | ParserRuleContext ancestor = Trainer.getAncestor(earliestLeftAncestor, deltaFromAncestor); |
| 322 | Token start = null; |
| 323 | if ( ancestor==null ) { |
| 324 | // System.err.println("Whoops. No ancestor at that delta"); |
| 325 | } |
| 326 | else { |
| 327 | ParseTree child = ancestor.getChild(childIndex); |
| 328 | if (child instanceof ParserRuleContext) { |
| 329 | start = ((ParserRuleContext) child).getStart(); |
| 330 | } |
| 331 | else if (child instanceof TerminalNode) { |
| 332 | start = ((TerminalNode) child).getSymbol(); |
| 333 | } |
| 334 | else { |
| 335 | // uh oh. |
| 336 | // System.err.println("Whoops. Tried to access invalid child"); |
| 337 | } |
| 338 | } |
| 339 | if ( start!=null ) { |
| 340 | int indentCol = start.getCharPositionInLine(); |
| 341 | charPosInLine = indentCol; |
| 342 | output.append(Tool.spaces(indentCol)); |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | public int[] getFeatures(InputDocument doc, int tokenIndexInStream) { |
| 347 | Token prevToken = doc.tokens.getPreviousRealToken(tokenIndexInStream); |
no test coverage detected