private void AddHistory(Lexeme lexeme, bool setTrivia = true) { Debug.Assert(m_valuableCursor == m_valuableHistory.Count); m_fullHistory.Add(lexeme); int fullCursor = m_fullHistory.Count(); if (setTrivia) { int lastTriviaStartIndex = m_lastNotSkippedLexemeIndex + 1; int lastTriviaLength = fullCursor - 1 - lastTriviaStartIndex; if (lastTriviaLength < 0) { lastTriviaLength = 0; } lexeme.SetTrivia(new LexemeRange(m_fullHistory, lastTriviaStartIndex, lastTriviaLength)); m_lastNotSkippedLexemeIndex = fullCursor - 1; m_valuableHistory.Add(fullCursor - 1); m_valuableCursor = m_valuableHistory.Count; } }