Пример #1
0
        Dictionary <string, string> LoadMimeMapAsync()
        {
            var map = new Dictionary <string, string> ();

            // All recent Macs should have this file; if not we'll just die silently
            if (!File.Exists("/etc/apache2/mime.types"))
            {
                LoggingService.LogError("Apache mime database is missing");
                return(map);
            }

            mimeTimer.BeginTiming();
            try {
                using (var file = File.OpenRead("/etc/apache2/mime.types")) {
                    using (var reader = new StreamReader(file)) {
                        var    mime = new Regex("([a-zA-Z]+/[a-zA-z0-9+-_.]+)\t+([a-zA-Z]+)", RegexOptions.Compiled);
                        string line;
                        while ((line = reader.ReadLine()) != null)
                        {
                            Match m = mime.Match(line);
                            if (m.Success)
                            {
                                map ["." + m.Groups [2].Captures [0].Value] = m.Groups [1].Captures [0].Value;
                            }
                        }
                    }
                }
            } catch (Exception ex) {
                LoggingService.LogError("Could not load Apache mime database", ex);
            }
            mimeTimer.EndTiming();
            return(map);
        }
Пример #2
0
        void StartCollectTypes()
        {
            ThreadPool.QueueUserWorkItem(delegate {
                CollectTypes();

                if (isAbleToSearchMembers)
                {
                    getMembersTimer.BeginTiming();
                    try {
                        lock (members) {
                            foreach (IType type in types)
                            {
                                foreach (IMember m in type.Members)
                                {
                                    if (m is IType)
                                    {
                                        continue;
                                    }
                                    members.Add(m);
                                }
                            }
                        }
                    } finally {
                        getMembersTimer.EndTiming();
                    }
                }
            });
        }
Пример #3
0
        public MacPlatformService()
        {
            if (initedGlobal)
            {
                throw new Exception("Only one MacPlatformService instance allowed");
            }
            initedGlobal = true;

            timer.BeginTiming();

            var dir = Path.GetDirectoryName(typeof(MacPlatformService).Assembly.Location);

            if (ObjCRuntime.Dlfcn.dlopen(Path.Combine(dir, "libxammac.dylib"), 0) == IntPtr.Zero)
            {
                LoggingService.LogFatalError("Unable to load libxammac");
            }

            mimemap = new Lazy <Dictionary <string, string> > (LoadMimeMapAsync);

            //make sure the menu app name is correct even when running Mono 2.6 preview, or not running from the .app
            Carbon.SetProcessName(BrandingService.ApplicationName);

            CheckGtkVersion(2, 24, 14);

            Xwt.Toolkit.CurrentEngine.RegisterBackend <IExtendedTitleBarWindowBackend, ExtendedTitleBarWindowBackend> ();
            Xwt.Toolkit.CurrentEngine.RegisterBackend <IExtendedTitleBarDialogBackend, ExtendedTitleBarDialogBackend> ();
        }
Пример #4
0
        public MacPlatformService()
        {
            if (IntPtr.Size == 8)
            {
                throw new Exception("Mac integration is not yet 64-bit safe");
            }

            if (initedGlobal)
            {
                throw new Exception("Only one MacPlatformService instance allowed");
            }
            initedGlobal = true;

            timer.BeginTiming();

            systemVersion = Carbon.Gestalt("sysv");

            mimemap = new Lazy <Dictionary <string, string> > (LoadMimeMapAsync);

            //make sure the menu app name is correct even when running Mono 2.6 preview, or not running from the .app
            Carbon.SetProcessName(BrandingService.ApplicationName);

            CheckGtkVersion(2, 24, 14);

            Xwt.Toolkit.CurrentEngine.RegisterBackend <IExtendedTitleBarWindowBackend, ExtendedTitleBarWindowBackend> ();
            Xwt.Toolkit.CurrentEngine.RegisterBackend <IExtendedTitleBarDialogBackend, ExtendedTitleBarDialogBackend> ();
        }
Пример #5
0
        public MacPlatformService()
        {
            if (initedGlobal)
            {
                throw new Exception("Only one MacPlatformService instance allowed");
            }
            initedGlobal = true;

            timer.BeginTiming();

            systemVersion = Carbon.Gestalt("sysv");

            mimemap = new Lazy <Dictionary <string, string> > (LoadMimeMapAsync);

            //make sure the menu app name is correct even when running Mono 2.6 preview, or not running from the .app
            Carbon.SetProcessName(BrandingService.ApplicationName);

            Cocoa.InitMonoMac();

            CheckGtkVersion(2, 24, 14);

            timer.Trace("Installing App Event Handlers");
            GlobalSetup();

            timer.EndTiming();
        }
 void StartCollectTypes()
 {
     collectTypes = new Thread(new ThreadStart(delegate {
         types = GetTypes();
         if (isAbleToSearchMembers)
         {
             getMembersTimer.BeginTiming();
             try {
                 members = new List <IMember> ();
                 foreach (IType type in types)
                 {
                     foreach (IMember m in type.Members)
                     {
                         if (m is IType)
                         {
                             continue;
                         }
                         members.Add(m);
                     }
                 }
             } finally {
                 getMembersTimer.EndTiming();
             }
         }
     }));
     collectTypes.IsBackground = true;
     collectTypes.Name         = "Navigate to: Collect Types and members";
     collectTypes.Priority     = ThreadPriority.Lowest;
     collectTypes.Start();
 }
        List <IType> GetTypes()
        {
            List <IType> list = new List <IType> ();

            getTypesTimer.BeginTiming();
            try {
                foreach (Document doc in IdeApp.Workbench.Documents)
                {
                    // We only want to check it here if it's not part
                    // of the open combine.  Otherwise, it will get
                    // checked down below.
                    if (doc.Project == null && doc.IsFile)
                    {
                        ICompilationUnit info = doc.CompilationUnit;
                        if (info != null)
                        {
                            foreach (IType c in info.Types)
                            {
                                list.Add(c);
                            }
                        }
                    }
                }

                ReadOnlyCollection <Project> projects = IdeApp.Workspace.GetAllProjects();

                foreach (Project p in projects)
                {
                    ProjectDom dom = ProjectDomService.GetProjectDom(p);
                    if (dom == null)
                    {
                        continue;
                    }
                    foreach (IType c in dom.Types)
                    {
                        AddType(c, list);
                    }
                }
            } finally {
                getTypesTimer.EndTiming();
            }
            return(list);
        }
        /// <summary>
        /// Gets all the code issues inside a document.
        /// </summary>
        public override IEnumerable <CodeIssue> GetIssues(object ctx, CancellationToken cancellationToken)
        {
            var context = ctx as MDRefactoringContext;

            if (context == null || context.IsInvalid || context.RootNode == null || context.ParsedDocument.HasErrors)
            {
                return(new CodeIssue[0]);
            }
            // Holds all the actions in a particular sibling group.
            IList <ICSharpCode.NRefactory.CSharp.Refactoring.CodeIssue> issues;

            using (var timer = counter.BeginTiming()) {
                // We need to enumerate here in order to time it.
                // This shouldn't be a problem since there are current very few (if any) lazy providers.
                var _issues = parentIssue.IssueProvider.GetIssues(context, subIssue.Title);
                issues = _issues as IList <ICSharpCode.NRefactory.CSharp.Refactoring.CodeIssue> ?? _issues.ToList();
            }
            return(parentIssue.ToMonoDevelopRepresentation(cancellationToken, context, issues));
        }
Пример #9
0
        static MacPlatformService()
        {
            timer.BeginTiming();

            systemVersion = Carbon.Gestalt("sysv");

            LoadMimeMapAsync();

            CheckGtkVersion(2, 24, 0);

            //make sure the menu app name is correct even when running Mono 2.6 preview, or not running from the .app
            Carbon.SetProcessName(BrandingService.ApplicationName);

            MonoDevelop.MacInterop.Cocoa.InitMonoMac();

            timer.Trace("Installing App Event Handlers");
            GlobalSetup();

            timer.EndTiming();
        }
Пример #10
0
        Dictionary <string, string> LoadMimeMapAsync()
        {
            var map = new Dictionary <string, string> ();

            // All recent Macs should have this file; if not we'll just die silently
            if (!File.Exists("/etc/apache2/mime.types"))
            {
                LoggingService.LogError("Apache mime database is missing");
                return(map);
            }

            mimeTimer.BeginTiming();
            try {
                var loader = new MimeMapLoader(map);
                loader.LoadMimeMap("/etc/apache2/mime.types");
            } catch (Exception ex) {
                LoggingService.LogError("Could not load Apache mime database", ex);
            }
            mimeTimer.EndTiming();
            return(map);
        }
Пример #11
0
        public override IEnumerable <CodeIssue> GetIssues(object ctx, CancellationToken cancellationToken)
        {
            var context = ctx as MDRefactoringContext;

            if (context == null || context.IsInvalid || context.RootNode == null || context.ParsedDocument.HasErrors)
            {
                yield break;
            }

            // Holds all the actions in a particular sibling group.
            var actionGroups = new Dictionary <object, IList <ICSharpCode.NRefactory.CSharp.Refactoring.CodeAction> > ();
            IList <ICSharpCode.NRefactory.CSharp.Refactoring.CodeIssue> issues;

            using (var timer = counter.BeginTiming()) {
                // We need to enumerate here in order to time it.
                // This shouldn't be a problem since there are current very few (if any) lazy providers.
                var _issues = issueProvider.GetIssues(context);
                issues = _issues as IList <ICSharpCode.NRefactory.CSharp.Refactoring.CodeIssue> ?? _issues.ToList();
            }
            foreach (var action in issues)
            {
                if (cancellationToken.IsCancellationRequested)
                {
                    yield break;
                }
                if (action.Actions == null)
                {
                    LoggingService.LogError("NRefactory actions == null in :" + Title);
                    continue;
                }
                var actions = new List <NRefactoryCodeAction> ();
                foreach (var act in action.Actions)
                {
                    if (cancellationToken.IsCancellationRequested)
                    {
                        yield break;
                    }
                    if (act == null)
                    {
                        LoggingService.LogError("NRefactory issue action was null in :" + Title);
                        continue;
                    }
                    var nrefactoryCodeAction = new NRefactoryCodeAction(IdString, act.Description, act, act.SiblingKey);
                    if (act.SiblingKey != null)
                    {
                        // make sure the action has a list of its siblings
                        IList <ICSharpCode.NRefactory.CSharp.Refactoring.CodeAction> siblingGroup;
                        if (!actionGroups.TryGetValue(act.SiblingKey, out siblingGroup))
                        {
                            siblingGroup = new List <ICSharpCode.NRefactory.CSharp.Refactoring.CodeAction> ();
                            actionGroups.Add(act.SiblingKey, siblingGroup);
                        }
                        siblingGroup.Add(act);
                        nrefactoryCodeAction.SiblingActions = siblingGroup;
                    }
                    actions.Add(nrefactoryCodeAction);
                }
                var issue = new CodeIssue(
                    GettextCatalog.GetString(action.Description ?? ""),
                    context.TextEditor.FileName,
                    action.Start,
                    action.End,
                    IdString,
                    actions
                    );
                yield return(issue);
            }
        }