コード例 #1
0
ファイル: PythonTextBufferInfo.cs プロジェクト: mkolovic/PTVS
        /// <summary>
        /// Returns the first token containing or adjacent to the specified point.
        /// </summary>
        public TokenInfo?GetTokenAtPoint(SnapshotPoint point)
        {
            var line = point.GetContainingLine();
            var pt   = point.ToSourceLocation();

            return(GetLineTokens(line, LanguageVersion)
                   .TakeWhile(t => t.SourceSpan.End >= pt)
                   .OfType <TokenInfo?>()
                   .FirstOrDefault(t => t.Value.SourceSpan.Start <= pt));
        }
コード例 #2
0
        private void AddMissingImports(List <string> importList, SnapshotPoint point)
        {
            if (importList.Count == 0)
            {
                return;
            }

            var bi    = _services.GetBufferInfo(_textView.TextBuffer);
            var entry = bi?.AnalysisEntry;

            if (entry == null)
            {
                return;
            }

            SourceLocation loc;

            try {
                loc = point.ToSourceLocation();
            } catch (ArgumentException ex) {
                Debug.Fail(ex.ToUnhandledExceptionMessage(GetType()));
                return;
            }

            foreach (var import in importList)
            {
                var isMissing = entry.Analyzer.WaitForRequest(
                    entry.Analyzer.IsMissingImportAsync(entry, import, loc),
                    "ExpansionClient.IsMissingImportAsync",
                    false
                    );

                if (isMissing)
                {
                    VsProjectAnalyzer.AddImport(_textView.TextBuffer, null, import);
                }
            }
        }