コード例 #1
0
        public async void VsTextViewCreated(VisualStudio.TextManager.Interop.IVsTextView textViewAdapter)
        {
            // TODO: We should probably only track text views in Python projects or loose files.
            var textView = _services.EditorAdaptersFactoryService.GetWpfTextView(textViewAdapter);

            if (textView != null)
            {
                var analyzer = _services.AnalysisEntryService.GetVsAnalyzer(textView, null);
                var bi       = _services.GetBufferInfo(textView.TextBuffer);
                if (analyzer != null && bi != null && bi.AnalysisEntry == null)
                {
                    var entry = await analyzer.AnalyzeFileAsync(bi.Filename);

                    if (bi.TrySetAnalysisEntry(entry, null) != entry)
                    {
                        // Failed to start analyzing
                        Debug.Fail("Failed to analyze xaml file");
                        return;
                    }
                    await entry.EnsureCodeSyncedAsync(bi.Buffer);

                    textView.Closed += TextView_Closed;
                }
            }
        }
コード例 #2
0
        public void VsTextViewCreated(VisualStudio.TextManager.Interop.IVsTextView textViewAdapter)
        {
            ITextView textView = AdapterService.GetWpfTextView(textViewAdapter);

            if (textView != null)
            {
                BraceMatcher.WatchBraceHighlights(textView, IronRubyToolsPackage.ComponentModel);
            }
        }
コード例 #3
0
        public async void VsTextViewCreated(VisualStudio.TextManager.Interop.IVsTextView textViewAdapter)
        {
            var textView = _editorAdaptersFactory.GetWpfTextView(textViewAdapter);

            if (textView == null)
            {
                return;
            }

            // Only track text views in Python projects (we don't get called for loose files)
            // For example, we may get called for xaml files in UWP projects, in which case we do nothing
            if (!IsInPythonProject(textView))
            {
                return;
            }

            // Load Python services now that we know we'll need them
            if (_services == null)
            {
                _services = _site.GetComponentModel().GetService <PythonEditorServices>();
                if (_services == null)
                {
                    return;
                }
            }

            var bi = _services.GetBufferInfo(textView.TextBuffer);

            if (bi == null)
            {
                return;
            }

            var entry = bi.AnalysisEntry ?? await AnalyzeXamlFileAsync(textView, bi);

            for (int retries = 3; retries > 0 && entry == null; --retries)
            {
                // Likely in the process of changing analyzer, so we'll delay slightly and retry.
                await Task.Delay(100);

                entry = bi.AnalysisEntry ?? await AnalyzeXamlFileAsync(textView, bi);
            }

            if (entry == null)
            {
                Debug.Fail($"Failed to analyze XAML file {bi.Filename}");
                return;
            }

            if (bi.TrySetAnalysisEntry(entry, null) != entry)
            {
                // Failed to start analyzing
                Debug.Fail("Failed to analyze xaml file");
                return;
            }
            await entry.EnsureCodeSyncedAsync(bi.Buffer);
        }
コード例 #4
0
        public void VsTextViewCreated(VisualStudio.TextManager.Interop.IVsTextView textViewAdapter)
        {
            var textView = _adaptersFactory.GetWpfTextView(textViewAdapter);
            IntellisenseController controller;

            if (textView.Properties.TryGetProperty <IntellisenseController>(typeof(IntellisenseController), out controller))
            {
                controller.AttachKeyboardFilter();
            }
        }
コード例 #5
0
        internal IPythonAnalyzer PythonAnalyzer = null;                 // Set by MEF

        public void VsTextViewCreated(VisualStudio.TextManager.Interop.IVsTextView textViewAdapter)
        {
            // TODO: We should probably only track text views in Python projects or loose files.
            ITextView textView = AdapterService.GetWpfTextView(textViewAdapter);

            if (textView != null)
            {
                PythonAnalyzer.AnalyzeTextView(textView);
            }
        }
コード例 #6
0
        public void VsTextViewCreated(VisualStudio.TextManager.Interop.IVsTextView textViewAdapter)
        {
            // TODO: We should probably only track text views in Python projects or loose files.
            ITextView textView = AdapterService.GetWpfTextView(textViewAdapter);

            if (textView != null)
            {
                var analyzer = textView.GetAnalyzer(_serviceProvider);
                if (analyzer != null)
                {
                    var monitorResult = analyzer.MonitorTextBuffer(textView, textView.TextBuffer);
                    textView.Closed += TextView_Closed;
                }
            }
        }
コード例 #7
0
    public void VsTextViewCreated(VisualStudio.TextManager.Interop.IVsTextView textViewAdapter)
    {
        var textView = _adaptersFactory.GetWpfTextView(textViewAdapter);

        var myContent = ContentTypeRegistryService.GetContentType(MyContentType);

        if (myContent == null)
        {
            ContentTypeRegistryService.AddContentType(MyContentType, new[] { "csharp" });
            myContent = ContentTypeRegistryService.GetContentType(MyContentType);
        }

        // some kind of check if the content type is not already MyContentType.
        textView.TextBuffer.ChangeContentType(myContent, null);
    }
コード例 #8
0
        internal IVsEditorAdaptersFactoryService AdapterService = null; // Set by MEF

        public void VsTextViewCreated(VisualStudio.TextManager.Interop.IVsTextView textViewAdapter)
        {
            // TODO: We should probably only track text views in Python projects or loose files.
            ITextView textView = AdapterService.GetWpfTextView(textViewAdapter);

            if (textView != null)
            {
                var analyzer = textView.GetAnalyzer();
                if (analyzer != null)
                {
                    var entry = analyzer.MonitorTextBuffer(textView.TextBuffer);

                    textView.Closed += (sender, args) => analyzer.StopMonitoringTextBuffer(entry.BufferParser);
                }
            }
        }
コード例 #9
0
        public void VsTextViewCreated(VisualStudio.TextManager.Interop.IVsTextView textViewAdapter)
        {
            var textView   = _adaptersFactory.GetWpfTextView(textViewAdapter);
            var editFilter = new EditFilter(
                textView,
                _editorOperationsFactory.GetEditorOperations(textView),
                _editorOptionsFactory.GetOptions(textView),
                _compModel.GetService <IIntellisenseSessionStackMapService>().GetStackForTextView(textView),
                _compModel
                );
            IntellisenseController controller;

            if (textView.Properties.TryGetProperty <IntellisenseController>(typeof(IntellisenseController), out controller))
            {
                controller.AttachKeyboardFilter();
            }
            editFilter.AttachKeyboardFilter(textViewAdapter);
        }
コード例 #10
0
        public void VsTextViewCreated(VisualStudio.TextManager.Interop.IVsTextView textViewAdapter)
        {
            // TODO: We should probably only track text views in Python projects or loose files.
            ITextView textView = AdapterService.GetWpfTextView(textViewAdapter);

            if (textView != null)
            {
                var entryService = _serviceProvider.GetEntryService();
                var analyzer     = entryService.GetVsAnalyzer(textView, null);
                if (analyzer != null)
                {
                    var monitorResult = analyzer.MonitorTextBufferAsync(textView.TextBuffer)
                                        .ContinueWith(
                        task => {
                        textView.Closed += TextView_Closed;
                    }
                        );
                }
            }
        }
コード例 #11
0
        public async void VsTextViewCreated(VisualStudio.TextManager.Interop.IVsTextView textViewAdapter)
        {
            // TODO: We should probably only track text views in Python projects or loose files.
            var textView = _services.EditorAdaptersFactoryService.GetWpfTextView(textViewAdapter);

            if (textView == null)
            {
                return;
            }

            var bi = _services.GetBufferInfo(textView.TextBuffer);

            if (bi == null)
            {
                return;
            }

            var entry = bi.AnalysisEntry ?? await AnalyzeXamlFileAsync(textView, bi);

            for (int retries = 3; retries > 0 && entry == null; --retries)
            {
                // Likely in the process of changing analyzer, so we'll delay slightly and retry.
                await Task.Delay(100);

                entry = await AnalyzeXamlFileAsync(textView, bi);
            }

            if (entry == null)
            {
                Debug.Fail($"Failed to analyze XAML file {bi.Filename}");
                return;
            }

            if (bi.TrySetAnalysisEntry(entry, null) != entry)
            {
                // Failed to start analyzing
                Debug.Fail("Failed to analyze xaml file");
                return;
            }
            await entry.EnsureCodeSyncedAsync(bi.Buffer);
        }
コード例 #12
0
        public void VsTextViewCreated(VisualStudio.TextManager.Interop.IVsTextView textViewAdapter)
        {
            // TODO: We should probably only track text views in Python projects or loose files.
            ITextView textView = AdapterService.GetWpfTextView(textViewAdapter);

            if (textView != null)
            {
                var analyzer = _serviceProvider.GetProjectFromFile(textView.GetFilePath())?.GetAnalyzer();
                if (analyzer != null)
                {
                    var monitorResult = analyzer.MonitorTextBufferAsync(textView.TextBuffer)
                                        .ContinueWith(
                        task => {
                        textView.Closed += TextView_Closed;
                        lock (task.Result) {
                            task.Result.AttachedViews++;
                        }
                    }
                        );
                }
            }
        }