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

Method getInjectWSCategory

src/org/antlr/codebuff/Trainer.java:265–286  ·  view source on GitHub ↗
(CodeBuffTokenStream tokens, int i)

Source from the content-addressed store, hash-verified

263 }
264
265 public static int getInjectWSCategory(CodeBuffTokenStream tokens, int i) {
266 int precedingNL = getPrecedingNL(tokens, i); // how many lines to inject
267
268 Token curToken = tokens.get(i);
269 Token prevToken = tokens.getPreviousRealToken(i);
270
271 int ws = 0;
272 if ( precedingNL==0 ) {
273 ws = curToken.getCharPositionInLine() -
274 (prevToken.getCharPositionInLine()+prevToken.getText().length());
275 }
276
277 int injectNL_WS = CAT_NO_WS;
278 if ( precedingNL>0 ) {
279 injectNL_WS = nlcat(precedingNL);
280 }
281 else if ( ws>0 ) {
282 injectNL_WS = wscat(ws);
283 }
284
285 return injectNL_WS;
286 }
287
288 // at a newline, are we aligned with a prior sibling (in a list) etc...
289 public static int getAlignmentCategory(InputDocument doc, TerminalNode node, int indentSize) {

Callers 2

getTokenAnalysisMethod · 0.95

Calls 8

getPrecedingNLMethod · 0.95
nlcatMethod · 0.95
wscatMethod · 0.95
getPreviousRealTokenMethod · 0.80
getCharPositionInLineMethod · 0.80
getMethod · 0.65
getTextMethod · 0.65
lengthMethod · 0.45

Tested by

no test coverage detected