コード例 #1
0
        internal void SetProject(Project project)
        {
            IExtensibleTextEditor editor = GetContent <IExtensibleTextEditor> ();

            if (editor != null)
            {
                editor.TextChanged -= OnDocumentChanged;
            }
            while (editorExtension != null)
            {
                try {
                    editorExtension.Dispose();
                } catch (Exception ex) {
                    LoggingService.LogError("Exception while disposing extension:" + editorExtension, ex);
                }
                editorExtension = editorExtension.Next as TextEditorExtension;
            }
            editorExtension = null;
            ISupportsProjectReload pr = GetContent <ISupportsProjectReload> ();

            if (pr != null)
            {
                Window.ViewContent.Project = project;
                pr.Update(project);
            }
            OnDocumentAttached();
        }
コード例 #2
0
        internal void SetExtensionChain(DocumentContext documentContext, IEnumerable <TextEditorExtension> extensions)
        {
            if (documentContext == null)
            {
                throw new ArgumentNullException(nameof(documentContext));
            }
            if (extensions == null)
            {
                throw new ArgumentNullException(nameof(extensions));
            }

            TextEditorExtension last = null;

            foreach (var ext in extensions)
            {
                if (ext.IsValidInContext(documentContext))
                {
                    if (last != null)
                    {
                        last.Next = ext;
                        last      = ext;
                    }
                    else
                    {
                        textEditorImpl.EditorExtension = last = ext;
                    }
                    ext.Initialize(this, documentContext);
                }
            }
            DocumentContext = documentContext;
        }
コード例 #3
0
        internal void SetProject(Project project)
        {
            if (Window.ViewContent.Project == project)
            {
                return;
            }
            while (editorExtension != null)
            {
                try {
                    editorExtension.Dispose();
                } catch (Exception ex) {
                    LoggingService.LogError("Exception while disposing extension:" + editorExtension, ex);
                }
                editorExtension = editorExtension.Next as TextEditorExtension;
            }
            editorExtension = null;
            ISupportsProjectReload pr = GetContent <ISupportsProjectReload> ();

            if (pr != null)
            {
                Window.ViewContent.Project = project;
                pr.Update(project);
            }
            if (project != null)
            {
                project.Modified += HandleProjectModified;
            }
            OnDocumentAttached();
        }
コード例 #4
0
ファイル: Document.cs プロジェクト: wellmonge/monodevelop
        public IEnumerable <T> GetContents <T> () where T : class
        {
            //check whether the ViewContent can return the type directly
            T ret = (T)Window.ActiveViewContent.GetContent(typeof(T));

            if (ret != null)
            {
                yield return(ret);
            }

            //check the primary viewcontent
            //not sure if this is the right thing to do, but things depend on this behaviour
            if (Window.ViewContent != Window.ActiveViewContent)
            {
                ret = (T)Window.ViewContent.GetContent(typeof(T));
                if (ret != null)
                {
                    yield return(ret);
                }
            }

            //no, so look through the TexteditorExtensions as well
            TextEditorExtension nextExtension = editorExtension;

            while (nextExtension != null)
            {
                if (typeof(T).IsAssignableFrom(nextExtension.GetType()))
                {
                    yield return(nextExtension as T);
                }
                nextExtension = nextExtension.Next as TextEditorExtension;
            }
        }
コード例 #5
0
        public object GetContent(Type type)
        {
            //check whether the ViewContent can return the type directly
            object ret = Window.ActiveViewContent.GetContent(type);

            if (ret != null)
            {
                return(ret);
            }

            //check the primary viewcontent
            //not sure if this is the right thing to do, but things depend on this behaviour
            if (Window.ViewContent != Window.ActiveViewContent)
            {
                ret = Window.ViewContent.GetContent(type);
                if (ret != null)
                {
                    return(ret);
                }
            }

            //no, so look through the TexteditorExtensions as well
            TextEditorExtension nextExtension = editorExtension;

            while (nextExtension != null)
            {
                if (type.IsAssignableFrom(nextExtension.GetType()))
                {
                    return(nextExtension);
                }
                nextExtension = nextExtension.Next as TextEditorExtension;
            }
            return(null);
        }
コード例 #6
0
        void OnClosed(object s, EventArgs a)
        {
            isClosed = true;
//			TypeSystemService.DomRegistered -= UpdateRegisteredDom;
            CancelParseTimeout();
            ClearTasks();
            TypeSystemService.RemoveSkippedfile(FileName);
            if (window is SdiWorkspaceWindow)
            {
                ((SdiWorkspaceWindow)window).DetachFromPathedDocument();
            }
            window.Closed -= OnClosed;
            window.ActiveViewContentChanged -= OnActiveViewContentChanged;
            if (IdeApp.Workspace != null)
            {
                IdeApp.Workspace.ItemRemovedFromSolution -= OnEntryRemoved;
            }

            // Unsubscribe project events
            if (window.ViewContent.Project != null)
            {
                window.ViewContent.Project.Modified -= HandleProjectModified;
            }

            try {
                OnClosed(a);
            } catch (Exception ex) {
                LoggingService.LogError("Exception while calling OnClosed.", ex);
            }

            while (editorExtension != null)
            {
                try {
                    editorExtension.Dispose();
                } catch (Exception ex) {
                    LoggingService.LogError("Exception while disposing extension:" + editorExtension, ex);
                }
                editorExtension = editorExtension.Next as TextEditorExtension;
            }
            editorExtension = null;

            // Parse the file when the document is closed. In this way if the document
            // is closed without saving the changes, the saved compilation unit
            // information will be restored

/*			if (currentParseFile != null) {
 *                              TypeSystemService.QueueParseJob (dom, delegate (string name, IProgressMonitor monitor) {
 *                                      TypeSystemService.Parse (curentParseProject, currentParseFile);
 *                              }, FileName);
 *                      }
 *                      if (isFileDom) {
 *                              TypeSystemService.RemoveFileDom (FileName);
 *                              dom = null;
 *                      }*/

            parsedDocument = null;
            provider       = null;
            Counters.OpenDocuments--;
        }
コード例 #7
0
 public CodeTemplateCompletionData(TextEditorExtension doc, CodeTemplate template)
 {
     this.doc            = doc;
     this.template       = template;
     this.CompletionText = template.Shortcut;
     this.Icon           = template.Icon;
     this.DisplayText    = template.Shortcut;
     this.Description    = template.Shortcut + Environment.NewLine + GettextCatalog.GetString(template.Description);
 }
コード例 #8
0
ファイル: Document.cs プロジェクト: thild/monodevelop
        void OnClosed(object s, EventArgs a)
        {
            ProjectDomService.DomRegistered -= UpdateRegisteredDom;
            if (parseTimeout != 0)
            {
                GLib.Source.Remove(parseTimeout);
                parseTimeout = 0;
            }
            ClearTasks();

            string  currentParseFile   = FileName;
            Project curentParseProject = Project;

            if (window is SdiWorkspaceWindow)
            {
                ((SdiWorkspaceWindow)window).DetachFromPathedDocument();
            }
            window.Closed -= OnClosed;
            window.ActiveViewContentChanged -= OnActiveViewContentChanged;
            if (IdeApp.Workspace != null)
            {
                IdeApp.Workspace.ItemRemovedFromSolution -= OnEntryRemoved;
            }

            try {
                OnClosed(a);
            } catch (Exception ex) {
                LoggingService.LogError("Exception while calling OnClosed.", ex);
            }

            while (editorExtension != null)
            {
                try {
                    editorExtension.Dispose();
                } catch (Exception ex) {
                    LoggingService.LogError("Exception while disposing extension:" + editorExtension, ex);
                }
                editorExtension = editorExtension.Next as TextEditorExtension;
            }

            // Parse the file when the document is closed. In this way if the document
            // is closed without saving the changes, the saved compilation unit
            // information will be restored
            if (currentParseFile != null)
            {
                ProjectDomService.QueueParseJob(dom, delegate(string name, IProgressMonitor monitor) {
                    ProjectDomService.Parse(curentParseProject, currentParseFile);
                }, FileName);
            }
            if (isFileDom)
            {
                ProjectDomService.RemoveFileDom(FileName);
                dom = null;
            }

            Counters.OpenDocuments--;
        }
コード例 #9
0
        void InitializeProjectionExtensions(DocumentContext ctx, DisabledProjectionFeatures disabledFeatures)
        {
            if (projectionsAdded)
            {
                TextEditorExtension ext = textEditorImpl.EditorExtension;
                while (ext != null && ext.Next != null)
                {
                    var pext = ext as IProjectionExtension;
                    if (pext != null)
                    {
                        pext.Projections = projections;
                    }
                    ext = ext.Next;
                }
                return;
            }

            if (projections.Count == 0)
            {
                return;
            }

            // no extensions -> no projections needed
            if (textEditorImpl.EditorExtension == null)
            {
                return;
            }

            if ((disabledFeatures & DisabledProjectionFeatures.Completion) != DisabledProjectionFeatures.Completion)
            {
                TextEditorExtension lastExtension = textEditorImpl.EditorExtension;
                while (lastExtension != null && lastExtension.Next != null)
                {
                    var completionTextEditorExtension = lastExtension.Next as CompletionTextEditorExtension;
                    if (completionTextEditorExtension != null)
                    {
                        var projectedFilterExtension = new ProjectedFilterCompletionTextEditorExtension(completionTextEditorExtension, projections)
                        {
                            Next = completionTextEditorExtension.Next
                        };
                        completionTextEditorExtension.Deinitialize();
                        lastExtension.Next = projectedFilterExtension;
                        projectedFilterExtension.Initialize(this, DocumentContext);
                    }
                    lastExtension = lastExtension.Next;
                }


                var projectedCompletionExtension = new ProjectedCompletionExtension(ctx, projections);
                projectedCompletionExtension.Next = textEditorImpl.EditorExtension;

                textEditorImpl.EditorExtension = projectedCompletionExtension;
                projectedCompletionExtension.Initialize(this, DocumentContext);
                projectionsAdded = true;
            }
        }
コード例 #10
0
 public static void AddRange(
     this CompletionDataList completionList,
     LanguageClientSession session,
     TextEditorExtension textEditorExtension,
     IEnumerable <CompletionItem> items)
 {
     if (items?.Any() == true)
     {
         completionList.AddRange(
             items.Select(item => new LanguageClientCompletionData(session, textEditorExtension, item)));
     }
 }
コード例 #11
0
        void OnClosed(object s, EventArgs a)
        {
            closed = true;
            ClearTasks();

            string  currentParseFile   = FileName;
            Project curentParseProject = Project;

            if (window is SdiWorkspaceWindow)
            {
                ((SdiWorkspaceWindow)window).DetachFromPathedDocument();
            }
            window.Closed -= OnClosed;
            window.ActiveViewContentChanged -= OnActiveViewContentChanged;
            if (IdeApp.Workspace != null)
            {
                IdeApp.Workspace.ItemRemovedFromSolution -= OnEntryRemoved;
            }

            try {
                OnClosed(a);
            } catch (Exception ex) {
                LoggingService.LogError("Exception while calling OnClosed.", ex);
            }

            while (editorExtension != null)
            {
                try {
                    editorExtension.Dispose();
                } catch (Exception ex) {
                    LoggingService.LogError("Exception while disposing extension:" + editorExtension, ex);
                }
                editorExtension = editorExtension.Next as TextEditorExtension;
            }

            // Parse the file when the document is closed. In this way if the document
            // is closed without saving the changes, the saved compilation unit
            // information will be restored
            if (currentParseFile != null)
            {
                System.Threading.ThreadPool.QueueUserWorkItem(delegate {
                    // Don't access Document properties from the thread
                    ProjectDomService.Parse(curentParseProject, currentParseFile, DesktopService.GetMimeTypeForUri(currentParseFile));
                });
            }
            if (fileDom != null)
            {
                ProjectDomService.RemoveFileDom(FileName);
                fileDom = null;
            }

            Counters.OpenDocuments--;
        }
コード例 #12
0
ファイル: Document.cs プロジェクト: wellmonge/monodevelop
 void DetachExtensionChain()
 {
     while (editorExtension != null)
     {
         try {
             editorExtension.Dispose();
         } catch (Exception ex) {
             LoggingService.LogError("Exception while disposing extension:" + editorExtension, ex);
         }
         editorExtension = editorExtension.Next as TextEditorExtension;
     }
     editorExtension = null;
 }
コード例 #13
0
        internal void OnDocumentAttached()
        {
            IExtensibleTextEditor editor = GetContent <IExtensibleTextEditor> ();

            if (editor == null)
            {
                return;
            }
            editor.TextChanged += OnDocumentChanged;
            //this.parsedDocument = MonoDevelop.Projects.Dom.Parser.ProjectDomService.Parse (Project, FileName, DesktopService.GetMimeTypeForUri (FileName), TextEditor.Text);
            OnDocumentChanged(this, null);

            // If the new document is a text editor, attach the extensions

            ExtensionNodeList extensions = AddinManager.GetExtensionNodes("/MonoDevelop/Ide/TextEditorExtensions", typeof(TextEditorExtensionNode));

            editorExtension = null;
            TextEditorExtension last = null;

            foreach (TextEditorExtensionNode extNode in extensions)
            {
                if (!extNode.Supports(FileName))
                {
                    continue;
                }
                TextEditorExtension ext = (TextEditorExtension)extNode.CreateInstance();
                if (ext.ExtendsEditor(this, editor))
                {
                    if (editorExtension == null)
                    {
                        editorExtension = ext;
                    }
                    if (last != null)
                    {
                        last.Next = ext;
                    }
                    last = ext;
                    ext.Initialize(this);
                }
            }
            if (editorExtension != null)
            {
                last.Next = editor.AttachExtension(editorExtension);
            }
            window.Document = this;

            if (window is SdiWorkspaceWindow)
            {
                ((SdiWorkspaceWindow)window).AttachToPathedDocument(GetContent <MonoDevelop.Ide.Gui.Content.IPathedDocument> ());
            }
        }
コード例 #14
0
        public async Task <CompletionDataList> GetCompletionList(
            FilePath fileName,
            CodeCompletionContext completionContext,
            TextEditorExtension textEditorExtension,
            CancellationToken token)
        {
            var completionList = await GetCompletionItems(fileName, completionContext, token);

            var completionDataList = new CompletionDataList();

            if (completionList?.Items != null)
            {
                completionDataList.AddRange(this, textEditorExtension, completionList.Items);
            }

            return(completionDataList);
        }
コード例 #15
0
ファイル: Document.cs プロジェクト: jeroldhaas/monodevelop
        void InitializeExtensionChain()
        {
            DetachExtensionChain();
            var editor = GetContent <IExtensibleTextEditor> ();

            ExtensionNodeList extensions = window.ExtensionContext.GetExtensionNodes("/MonoDevelop/Ide/TextEditorExtensions", typeof(TextEditorExtensionNode));

            editorExtension = null;
            TextEditorExtension last = null;
            var mimetypeChain        = DesktopService.GetMimeTypeInheritanceChainForFile(FileName).ToArray();

            foreach (TextEditorExtensionNode extNode in extensions)
            {
                if (!extNode.Supports(FileName, mimetypeChain))
                {
                    continue;
                }
                TextEditorExtension ext;
                try {
                    ext = (TextEditorExtension)extNode.CreateInstance();
                } catch (Exception e) {
                    LoggingService.LogError("Error while creating text editor extension :" + extNode.Id + "(" + extNode.Type + ")", e);
                    continue;
                }
                if (ext.ExtendsEditor(this, editor))
                {
                    if (last != null)
                    {
                        ext.Next  = last.Next;
                        last.Next = ext;
                        last      = ext;
                    }
                    else
                    {
                        editorExtension = last = ext;
                        last.Next       = editor.AttachExtension(editorExtension);
                    }
                    ext.Initialize(this);
                }
            }
            if (window is SdiWorkspaceWindow)
            {
                ((SdiWorkspaceWindow)window).AttachToPathedDocument(GetContent <MonoDevelop.Ide.Gui.Content.IPathedDocument> ());
            }
        }
        public LanguageClientCompletionData(
            LanguageClientSession session,
            TextEditorExtension textEditorExtension,
            CompletionItem item)
        {
            this.session   = session;
            CompletionItem = item;
            CompletionText = item.InsertText ?? item?.TextEdit?.NewText;

            if (CompletionText == null)
            {
                CompletionText = item.Label;
            }

            if (item.InsertTextFormat == InsertTextFormat.Snippet)
            {
                this.textEditorExtension = textEditorExtension;
                codeTemplate             = CodeTemplateFactory.ConvertToTemplate(CompletionText);
                CompletionText           = RemoveSnippet(CompletionText);
            }

            Icon = item.GetIcon();
        }
コード例 #17
0
ファイル: Document.cs プロジェクト: nekitozzz/monodevelop
        void InitializeExtensionChain()
        {
            DetachExtensionChain();
            var editor = GetContent <IExtensibleTextEditor> ();

            ExtensionNodeList extensions = window.ExtensionContext.GetExtensionNodes("/MonoDevelop/Ide/TextEditorExtensions", typeof(TextEditorExtensionNode));

            editorExtension = null;
            TextEditorExtension last = null;
            var mimetypeChain        = DesktopService.GetMimeTypeInheritanceChainForFile(FileName).ToArray();

            foreach (TextEditorExtensionNode extNode in extensions)
            {
                if (!extNode.Supports(FileName, mimetypeChain))
                {
                    continue;
                }
                TextEditorExtension ext = (TextEditorExtension)extNode.CreateInstance();
                if (ext.ExtendsEditor(this, editor))
                {
                    if (editorExtension == null)
                    {
                        editorExtension = ext;
                    }
                    if (last != null)
                    {
                        last.Next = ext;
                    }
                    last = ext;
                    ext.Initialize(this);
                }
            }
            if (editorExtension != null)
            {
                last.Next = editor.AttachExtension(editorExtension);
            }
        }
コード例 #18
0
ファイル: Document.cs プロジェクト: thild/monodevelop
        internal void OnDocumentAttached()
        {
            IExtensibleTextEditor editor = GetContent <IExtensibleTextEditor> ();

            if (editor == null)
            {
                return;
            }

            Editor.Document.TextReplaced += (o, a) => {
                if (Editor.Document.IsInAtomicUndo)
                {
                    wasEdited = true;
                }
                else
                {
                    StartReparseThread();
                }
            };

            Editor.Document.BeginUndo += delegate {
                wasEdited = false;
            };

            Editor.Document.EndUndo += delegate {
                if (wasEdited)
                {
                    StartReparseThread();
                }
            };
            Editor.Document.Undone += (o, a) => StartReparseThread();
            Editor.Document.Redone += (o, a) => StartReparseThread();

            // If the new document is a text editor, attach the extensions

            ExtensionNodeList extensions = window.ExtensionContext.GetExtensionNodes("/MonoDevelop/Ide/TextEditorExtensions", typeof(TextEditorExtensionNode));

            editorExtension = null;
            TextEditorExtension last = null;

            foreach (TextEditorExtensionNode extNode in extensions)
            {
                if (!extNode.Supports(FileName))
                {
                    continue;
                }
                TextEditorExtension ext = (TextEditorExtension)extNode.CreateInstance();
                if (ext.ExtendsEditor(this, editor))
                {
                    if (editorExtension == null)
                    {
                        editorExtension = ext;
                    }
                    if (last != null)
                    {
                        last.Next = ext;
                    }
                    last = ext;
                    ext.Initialize(this);
                }
            }
            if (editorExtension != null)
            {
                last.Next = editor.AttachExtension(editorExtension);
            }
            window.Document = this;
            RunWhenLoaded(() => UpdateParseDocument());
            if (window is SdiWorkspaceWindow)
            {
                ((SdiWorkspaceWindow)window).AttachToPathedDocument(GetContent <MonoDevelop.Ide.Gui.Content.IPathedDocument> ());
            }
        }
コード例 #19
0
        void InitializeEditor(IExtensibleTextEditor editor)
        {
            Editor.Document.TextReplaced += (o, a) => {
                if (parsedDocument != null)
                {
                    parsedDocument.IsInvalid = true;
                }

                if (Editor.Document.IsInAtomicUndo)
                {
                    wasEdited = true;
                }
                else
                {
                    StartReparseThread();
                }
            };

            Editor.Document.BeginUndo += delegate {
                wasEdited = false;
            };

            Editor.Document.EndUndo += delegate {
                if (wasEdited)
                {
                    StartReparseThread();
                }
            };
            Editor.Document.Undone += (o, a) => StartReparseThread();
            Editor.Document.Redone += (o, a) => StartReparseThread();

            // If the new document is a text editor, attach the extensions

            ExtensionNodeList extensions = window.ExtensionContext.GetExtensionNodes("/MonoDevelop/Ide/TextEditorExtensions", typeof(TextEditorExtensionNode));

            editorExtension = null;
            TextEditorExtension last = null;

            foreach (TextEditorExtensionNode extNode in extensions)
            {
                if (!extNode.Supports(FileName))
                {
                    continue;
                }

                TextEditorExtension ext = (TextEditorExtension)extNode.CreateInstance();
                if (ext.ExtendsEditor(this, editor))
                {
                    if (editorExtension == null)
                    {
                        editorExtension = ext;
                    }

                    if (last != null)
                    {
                        last.Next = ext;
                    }

                    last = ext;
                    ext.Initialize(this);
                }
            }

            if (editorExtension != null)
            {
                last.Next = editor.AttachExtension(editorExtension);
            }
        }