示例#1
0
 static CSharpTextEditorIndentation()
 {
     CompletionWindowManager.WordCompleted += delegate(object sender, CodeCompletionContextEventArgs e) {
         IExtensibleTextEditor editor = e.Widget as IExtensibleTextEditor;
         if (editor == null)
         {
             return;
         }
         ITextEditorExtension textEditorExtension = editor.Extension;
         while (textEditorExtension != null && !(textEditorExtension is CSharpTextEditorIndentation))
         {
             textEditorExtension = textEditorExtension.Next;
         }
         CSharpTextEditorIndentation extension = textEditorExtension as CSharpTextEditorIndentation;
         if (extension == null)
         {
             return;
         }
         extension.stateTracker.UpdateEngine();
         if (extension.stateTracker.Engine.NeedsReindent)
         {
             extension.DoReSmartIndent();
         }
     };
 }
示例#2
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();

            InitializeExtensionChain();
        }
示例#3
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();
        }
示例#4
0
        internal void OnDocumentAttached()
        {
            IExtensibleTextEditor editor = GetContent <IExtensibleTextEditor> ();

            if (editor != null)
            {
                InitializeEditor(editor);
                RunWhenLoaded(delegate { ListenToProjectLoad(Project); });
            }

            window.Document = this;
        }
示例#5
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> ());
            }
        }
示例#6
0
        internal void OnDocumentAttached()
        {
            IExtensibleTextEditor editor = GetContent <IExtensibleTextEditor> ();

            if (editor != null)
            {
                InitializeEditor(editor);
                RunWhenLoaded(delegate { ListenToProjectLoad(Project); });
            }

            window.Document = this;

            if (window is SdiWorkspaceWindow)
            {
                ((SdiWorkspaceWindow)window).AttachToPathedDocument(GetContent <MonoDevelop.Ide.Gui.Content.IPathedDocument> ());
            }
        }
示例#7
0
        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> ());
            }
        }
示例#8
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);
            }
        }