MCPcopy Index your code
hub / github.com/antlr/codebuff / getMatchingSymbolStartsLine

Method getMatchingSymbolStartsLine

src/org/antlr/codebuff/Trainer.java:643–663  ·  view source on GitHub ↗
(Corpus corpus,
	                                              InputDocument doc,
	                                              TerminalNode node)

Source from the content-addressed store, hash-verified

641
642
643 public static int getMatchingSymbolStartsLine(Corpus corpus,
644 InputDocument doc,
645 TerminalNode node)
646 {
647 TerminalNode matchingLeftNode = getMatchingLeftSymbol(corpus, doc, node);
648 if ( matchingLeftNode != null ) {
649 Token matchingLeftToken = matchingLeftNode.getSymbol();
650 int i = matchingLeftToken.getTokenIndex();
651 if ( i==0 ) return 1; // first token is considered first on line
652 Token tokenBeforeMatchingToken = doc.tokens.getPreviousRealToken(i);
653// System.out.printf("doc=%s node=%s, pair=%s, before=%s\n",
654// new File(doc.fileName).getName(), node.getSymbol(), matchingLeftToken, tokenBeforeMatchingToken);
655 if ( tokenBeforeMatchingToken!=null ) {
656 return matchingLeftToken.getLine()>tokenBeforeMatchingToken.getLine() ? 1 : 0;
657 }
658 else { // matchingLeftToken must be first in file
659 return 1;
660 }
661 }
662 return NOT_PAIR;
663 }
664
665 public static int getMatchingSymbolEndsLine(Corpus corpus,
666 InputDocument doc,

Callers 1

getContextFeaturesMethod · 0.95

Calls 4

getMatchingLeftSymbolMethod · 0.95
getTokenIndexMethod · 0.80
getPreviousRealTokenMethod · 0.80
getLineMethod · 0.45

Tested by

no test coverage detected