public IEnumerable <CodeModel.Tokens.Token> TokensAtPos() { var modelPos = _pos + _posOffset; if (_snapshot != null && _model.Snapshot != null) { modelPos = _snapshot.TranslateOffsetToSnapshot(modelPos, _model.Snapshot); } return(_model.FindTokens(modelPos)); }
public void SetSource(string source, int offset, VsText.ITextSnapshot snapshot, CodeModel.CodeModel model) { _source = source; _pos = 0; _posOffset = offset; _length = _source.Length; _snapshot = snapshot; _model = model; var transStart = snapshot.TranslateOffsetToSnapshot(offset, _model.Snapshot); var transEnd = snapshot.TranslateOffsetToSnapshot(offset + source.Length, _model.Snapshot); _tokenMap = new Dictionary <int, Token>(); foreach (var token in _model.File.FindDownward(transStart, transEnd - transStart)) { var snapStart = _model.Snapshot.TranslateOffsetToSnapshot(token.Span.Start, snapshot); _tokenMap[snapStart] = token; } }