Esempio n. 1
0
        public override void Selected()
        {
            if (blockSelected || IsInCurrentViewContent())
            {
                return;
            }

            if (activated)
            {
                throw new Exception("Editor should be null when document is selected");
            }

            var doc = IdeApp.Workbench.ActiveDocument.ParsedDocument as AspNetParsedDocument;

            if (doc != null)
            {
                proxy = new MonoDevelopProxy(viewContent.Project, doc.Info.InheritedClass);
                System.Diagnostics.Trace.WriteLine("Creating AspNetEdit EditorHost");
                host = new EditorHost(proxy);
                host.Initialise();
                System.Diagnostics.Trace.WriteLine("Created AspNetEdit EditorHost");
                activated = true;

                // Loading the GUI of the Designer
                LoadGui();

                // Loading the doc structure in the DocumentOutlinePad
                BuildTreeStore(doc.XDocument);
                // subscribing to changes in the DOM
                IdeApp.Workbench.ActiveDocument.DocumentParsed += document_OnParsed;
            }
        }
Esempio n. 2
0
        async void ShowMultipleFiles(string[] files)
        {
            var openDocuments = EditorHost.GetOpenDocuments();
            var searchCtx     = Presenter.StartSearch($"Go to files", null, false);

            try {
                var msbuildContentType = ContentTypeRegistry.GetContentType(MSBuildContentType.Name);
                foreach (var file in files)
                {
                    string lineText;
                    try {
                        if (!File.Exists(file))
                        {
                            continue;
                        }
                        if (!openDocuments.TryGetValue(file, out var buf))
                        {
                            buf = BufferFactory.CreateTextBuffer(File.OpenText(file), msbuildContentType);
                        }
                        lineText = buf.CurrentSnapshot.GetLineFromPosition(0).GetText();
                    } catch (Exception ex) {
                        LoggingService.LogError($"Error getting text for file {file}", ex);
                        continue;
                    }
                    var classifiedSpans = ImmutableArray <ClassifiedText> .Empty;
                    classifiedSpans = classifiedSpans.Add(new ClassifiedText(lineText, PredefinedClassificationTypeNames.NaturalLanguage));
                    await searchCtx.OnReferenceFoundAsync(new FoundReference (file, 0, 0, ReferenceUsage.Declaration, classifiedSpans, new TextSpan(-1, 0)));
                }
            } catch (Exception ex) when(!(ex is OperationCanceledException && searchCtx.CancellationToken.IsCancellationRequested))
            {
                LoggingService.LogError($"Error in show multiple imports", ex);
            }
            await searchCtx.OnCompletedAsync();
        }
Esempio n. 3
0
        void DestroyEditorAndSockets()
        {
            if (proxy != null)
            {
                proxy.Dispose();
                proxy = null;
            }

            if (host != null)
            {
                System.Diagnostics.Trace.WriteLine("Disposing AspNetEdit's EditorHost");

                designerFrame.Remove(webKitWindow);
                webKitWindow.Dispose();
                host.Dispose();
                host = null;

                System.Diagnostics.Trace.WriteLine("Disposed AspNetEdit's EditorHost");
            }

            if (IdeApp.Workbench.ActiveDocument != null)
            {
                IdeApp.Workbench.ActiveDocument.DocumentParsed -= document_OnParsed;
            }
        }
Esempio n. 4
0
        protected MainWindowViewModel(IUIServices uiServices)
        {
            _uiServices       = uiServices;
            _editorHostLoader = new EditorHostLoader();
            _editorHost       = _editorHostLoader.EditorHost;
            _classificationFormatMapService = _editorHostLoader.CompositionContainer.GetExportedValue <IClassificationFormatMapService>();

            InitializeViewModelState();

            EnableDisableTddStud10Command = new RelayCommand(
                EnableOrDisable,
                () =>
            {
                return(!string.IsNullOrWhiteSpace(SolutionPath));
            });

            CancelRunCommand = new RelayCommand(
                () =>
            {
                EngineLoader.EnableEngine();
                RaisePropertyChanged(() => IsRunInProgress);
            });

            OpenFileCommand = new RelayCommand(ExecuteOpenFileCommand);

            OpenSolutionCommand = new RelayCommand(ExecuteOpenSolutionCommand);

            SaveAllCommand = new RelayCommand(ExecuteSaveAllCommand);
        }
Esempio n. 5
0
        internal EditorHostLoader()
        {
            var editorHostFactory = new EditorHostFactory();

            editorHostFactory.Add(new AssemblyCatalog(typeof(DefaultKeyProcessorProvider).Assembly));
            editorHostFactory.Add(new AssemblyCatalog(typeof(MarginFactory).Assembly));
            _editorHost = editorHostFactory.CreateEditorHost();
        }
Esempio n. 6
0
        protected void Create(params string[] lines)
        {
            _textBuffer = EditorHost.CreateTextBuffer(lines);

            _asyncTaggerSource    = new TestableAsyncTaggerSource(_textBuffer);
            _asyncTagger          = new AsyncTagger <string, TextMarkerTag>(_asyncTaggerSource);
            _asyncTaggerInterface = _asyncTagger;
        }
Esempio n. 7
0
        internal VimComponentHost()
        {
            var editorHostFactory = new EditorHostFactory();

            editorHostFactory.Add(new AssemblyCatalog(typeof(IVim).Assembly));
            editorHostFactory.Add(new AssemblyCatalog(typeof(VimKeyProcessor).Assembly));
            editorHostFactory.Add(new AssemblyCatalog(typeof(VimComponentHost).Assembly));
            _editorHost = editorHostFactory.CreateEditorHost();
            _vim = _editorHost.CompositionContainer.GetExportedValue<IVim>();
        }
Esempio n. 8
0
        internal VimComponentHost()
        {
            var editorHostFactory = new EditorHostFactory();

            editorHostFactory.Add(new AssemblyCatalog(typeof(IVim).Assembly));
            editorHostFactory.Add(new AssemblyCatalog(typeof(VimKeyProcessor).Assembly));
            editorHostFactory.Add(new AssemblyCatalog(typeof(VimComponentHost).Assembly));
            _editorHost = editorHostFactory.CreateEditorHost();
            _vim        = _editorHost.CompositionContainer.GetExportedValue <IVim>();
        }
Esempio n. 9
0
		public DesignerHost (ServiceContainer parentServices, EditorHost host)
		{
			this.parentServices = parentServices;
			container = new DesignContainer (this);

			//register services
			parentServices.AddService (typeof (IDesignerHost), this);
			parentServices.AddService (typeof (IComponentChangeService), container);

			editorHost = host;
		}
Esempio n. 10
0
        public DesignerHost(ServiceContainer parentServices, EditorHost host)
        {
            this.parentServices = parentServices;
            container           = new DesignContainer(this);

            //register services
            parentServices.AddService(typeof(IDesignerHost), this);
            parentServices.AddService(typeof(IComponentChangeService), container);

            editorHost = host;
        }
Esempio n. 11
0
        private EditorHost GetOrCreateEditorHost()
        {
            if (EditorHostCache != null)
            {
                return(EditorHostCache);
            }

            var editorHostFactory = new EditorHostFactory();

            EditorHostCache = editorHostFactory.CreateEditorHost();
            return(EditorHostCache);
        }
Esempio n. 12
0
 public EditorHostTest()
 {
     try
     {
         _editorHost = GetOrCreateEditorHost();
     }
     catch (ReflectionTypeLoadException e)
     {
         // When this fails in AppVeyor the error message is useless.  Need to construct a more actionable
         // error message here.
         var builder = new StringBuilder();
         builder.AppendLine(e.Message);
         foreach (var item in e.LoaderExceptions)
         {
             builder.AppendLine(item.Message);
         }
         throw new Exception(builder.ToString(), e);
     }
     _synchronizationContext = new TestableSynchronizationContext();
     _synchronizationContext.Install();
 }
Esempio n. 13
0
        public MainWindow()
        {
            InitializeComponent();

#if DEBUG
            VimTrace.TraceSwitch.Level = TraceLevel.Info;
#endif

            _vimComponentHost = new VimComponentHost();
            _editorHost       = _vimComponentHost.EditorHost;
            _classificationFormatMapService = _vimComponentHost.CompositionContainer.GetExportedValue <IClassificationFormatMapService>();
            _vimAppOptions    = _vimComponentHost.CompositionContainer.GetExportedValue <IVimAppOptions>();
            _vimWindowManager = _vimComponentHost.CompositionContainer.GetExportedValue <IVimWindowManager>();
            var vimAppHost = _vimComponentHost.CompositionContainer.GetExportedValue <VimAppHost>();
            vimAppHost.MainWindow       = this;
            vimAppHost.VimWindowManager = _vimWindowManager;

            _vimWindowManager.VimWindowCreated += OnVimWindowCreated;

            // Create the initial view to display
            AddNewTab("Empty Doc");
        }
Esempio n. 14
0
        public MainWindow()
        {
            InitializeComponent();

#if DEBUG
            VimTrace.TraceSwitch.Level = TraceLevel.Info;
#endif

            _vimComponentHost = new VimComponentHost();
            _editorHost = _vimComponentHost.EditorHost;
            _classificationFormatMapService = _vimComponentHost.CompositionContainer.GetExportedValue<IClassificationFormatMapService>();
            _vimAppOptions = _vimComponentHost.CompositionContainer.GetExportedValue<IVimAppOptions>();
            _vimWindowManager = _vimComponentHost.CompositionContainer.GetExportedValue<IVimWindowManager>();
            var vimAppHost = _vimComponentHost.CompositionContainer.GetExportedValue<VimAppHost>();
            vimAppHost.MainWindow = this;
            vimAppHost.VimWindowManager = _vimWindowManager;

            _vimWindowManager.VimWindowCreated += OnVimWindowCreated;

            // Create the initial view to display 
            AddNewTab("Empty Doc");
        }
        public bool Navigate(MSBuildNavigationResult result, ITextBuffer buffer)
        {
            if (result.Kind == MSBuildReferenceKind.Target)
            {
                FindTargetDefinitions(result.Name, buffer);
                return(true);
            }

            if (result.Paths != null)
            {
                if (result.Paths.Length == 1)
                {
                    EditorHost.OpenFile(result.Paths[0], 0);
                    return(true);
                }
                if (result.Paths.Length > 1)
                {
                    ShowMultipleFiles(result.Paths);
                    return(true);
                }
            }

            if (result.DestFile != null)
            {
                EditorHost.OpenFile(result.DestFile, result.DestOffset);
                return(true);
            }

            if (result.Kind == MSBuildReferenceKind.NuGetID)
            {
                OpenNuGetUrl(result.Name, EditorHost);
                return(true);
            }

            return(false);
        }
Esempio n. 16
0
        private EditorHost GetOrCreateEditorHost()
        {
            if (EditorHostCache != null)
            {
                return EditorHostCache;
            }

            var editorHostFactory = new EditorHostFactory();
            EditorHostCache = editorHostFactory.CreateEditorHost();
            return EditorHostCache;
        }
Esempio n. 17
0
 public EditorHostTest()
 {
     _editorHost = GetOrCreateEditorHost();
     _synchronizationContext = new TestableSynchronizationContext();
     _synchronizationContext.Install();
 }
Esempio n. 18
0
 public EditorHostTest()
 {
     _editorHost             = GetOrCreateEditorHost();
     _synchronizationContext = new TestableSynchronizationContext();
     _synchronizationContext.Install();
 }
Esempio n. 19
0
 public void Create(params string[] lines)
 {
     _textBuffer = EditorHost.CreateTextBuffer(lines);
 }