private AnchorData FindAnchorSpanOnSameLineAfterToken(TokenData tokenData) { // every token after given token on same line is implicitly dependent to the token. // check whether one of them is an anchor token. AnchorData lastBaseAnchorData = null; while (tokenData.IndexInStream >= 0) { AnchorData tempAnchorData; if (this.anchorBaseTokenMap.TryGetValue(tokenData.Token, out tempAnchorData)) { lastBaseAnchorData = tempAnchorData; } // tokenPairIndex is always 0 <= ... < TokenCount - 1 var tokenPairIndex = tokenData.IndexInStream; if (this.tokenStream.TokenCount - 1 <= tokenPairIndex || this.tokenStream.GetTriviaData(tokenPairIndex).SecondTokenIsFirstTokenOnLine) { return(lastBaseAnchorData); } tokenData = tokenData.GetNextTokenData(); } return(lastBaseAnchorData); }
// this can be called with tokens that are outside of token stream private bool IsFirstTokenOnLine(TokenData tokenData1, TokenData tokenData2) { if (tokenData1.Token.RawKind == 0) { // reached first line inside of tree return(true); } Contract.Requires(tokenData2 == tokenData1.GetNextTokenData()); // see if there are changes for a given token pair return(this.GetTriviaData(tokenData1, tokenData2).SecondTokenIsFirstTokenOnLine); }