MCPcopy Create free account
hub / github.com/antlr/codebuff / getPrecedingNL

Method getPrecedingNL

src/org/antlr/codebuff/Trainer.java:375–384  ·  view source on GitHub ↗
(CommonTokenStream tokens, int i)

Source from the content-addressed store, hash-verified

373 }
374
375 public static int getPrecedingNL(CommonTokenStream tokens, int i) {
376 int precedingNL = 0;
377 List<Token> previousWS = getPreviousWS(tokens, i);
378 if ( previousWS!=null ) {
379 for (Token ws : previousWS) {
380 precedingNL += Tool.count(ws.getText(), '\n');
381 }
382 }
383 return precedingNL;
384 }
385
386 // if we have non-ws tokens like comments, we only count ws not in comments
387 public static List<Token> getPreviousWS(CommonTokenStream tokens, int i) {

Callers 1

getInjectWSCategoryMethod · 0.95

Calls 3

getPreviousWSMethod · 0.95
countMethod · 0.95
getTextMethod · 0.65

Tested by

no test coverage detected