internal void InitializeExtensionChain(DocumentContext documentContext)
        {
            if (documentContext == null)
            {
                throw new ArgumentNullException(nameof(documentContext));
            }
            DetachExtensionChain();
            var extensions    = ExtensionContext.GetExtensionNodes("/MonoDevelop/Ide/TextEditorExtensions", typeof(TextEditorExtensionNode));
            var mimetypeChain = DesktopService.GetMimeTypeInheritanceChainForFile(FileName).ToArray();
            var newExtensions = new List <TextEditorExtension> ();

            foreach (TextEditorExtensionNode extNode in extensions)
            {
                if (!extNode.Supports(FileName, mimetypeChain))
                {
                    continue;
                }
                TextEditorExtension ext;
                try {
                    var instance = extNode.CreateInstance();
                    ext = instance as TextEditorExtension;
                    if (ext != null)
                    {
                        newExtensions.Add(ext);
                    }
                } catch (Exception e) {
                    LoggingService.LogError("Error while creating text editor extension :" + extNode.Id + "(" + extNode.Type + ")", e);
                    continue;
                }
            }
            SetExtensionChain(documentContext, newExtensions);
        }
        protected override string OnGetDefaultBuildAction(string fileName)
        {
            if (DesktopService.GetMimeTypeInheritanceChainForFile(fileName).Contains("text/x-typescript"))
            {
                return(TypeScriptCompile);
            }

            return(base.OnGetDefaultBuildAction(fileName));
        }
        public override bool Evaluate(NodeElement conditionNode)
        {
            if (fileName == null)
            {
                return(false);
            }


            string [] allowedExtensions = conditionNode.GetAttribute("fileExtensions").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            if (allowedExtensions.Length > 0)
            {
                string ext = System.IO.Path.GetExtension(fileName);
                foreach (var allowedExtension in allowedExtensions)
                {
                    if (string.Equals(ext, allowedExtension, StringComparison.OrdinalIgnoreCase))
                    {
                        return(true);
                    }
                }
            }

            string[] allowedMimes = conditionNode.GetAttribute("mimeTypes").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            if (allowedMimes.Length > 0)
            {
                if (mimeTypeChain == null)
                {
                    mimeTypeChain = DesktopService.GetMimeTypeInheritanceChainForFile(fileName).ToList();
                }
                foreach (var mimeType in mimeTypeChain)
                {
                    foreach (var allowedMime in allowedMimes)
                    {
                        if (mimeType == allowedMime)
                        {
                            return(true);
                        }
                    }
                }
            }

            string[] allowedNames = conditionNode.GetAttribute("name").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            if (allowedNames.Length > 0)
            {
                string name = System.IO.Path.GetFileName(fileName);
                foreach (var allowedName in allowedNames)
                {
                    if (string.Equals(name, allowedName, StringComparison.OrdinalIgnoreCase))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Beispiel #4
0
        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> ());
            }
        }
Beispiel #5
0
        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);
            }
        }