public void Invoke(CancellationToken cancellationToken)
        {
            Debug.Assert(!string.IsNullOrEmpty(_name));

            AnalysisEntry entry;

            if (!_source._services.AnalysisEntryService.TryGetAnalysisEntry(_buffer, out entry))
            {
                return;
            }

            VsProjectAnalyzer.AddImport(_buffer, _fromModule, _name);
        }
Example #2
0
        public void Invoke(CancellationToken cancellationToken)
        {
            Debug.Assert(!string.IsNullOrEmpty(_name));

            var entry = _buffer.TryGetAnalysisEntry();

            if (entry == null)
            {
                return;
            }

            VsProjectAnalyzer.AddImport(_buffer, _fromModule, _name);
        }
Example #3
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 {
                var line = point.GetContainingLine();
                loc = new SourceLocation(
                    point.Position,
                    line.LineNumber + 1,
                    point.Position - line.Start + 1
                    );
            } 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(
                        entry,
                        null,
                        import,
                        _textView,
                        _textView.TextBuffer
                        );
                }
            }
        }