Esempio n. 1
0
        public void LintAsync(string[] files, LintCallback callback)
        {
            var context = ASContext.GetLanguageContext("haxe") as Context;

            if (context == null || !CanContinue(context))
            {
                return;
            }

            var total = files.Length;
            var list  = new List <LintingResult>();

            foreach (var file in files)
            {
                ITabbedDocument document;
                if (!File.Exists(file) || (document = DocumentManager.FindDocument(file)) != null && document.IsUntitled)
                {
                    total--;
                    continue;
                }

                var sciCreated = false;
                var sci        = document?.SciControl;
                if (sci == null)
                {
                    sci        = GetStubSci(file);
                    sciCreated = true;
                }

                var hc = context.GetHaxeComplete(sci, new ASExpr {
                    Position = 0
                }, true, HaxeCompilerService.DIAGNOSTICS);

                fileQueue.Run(finished =>
                {
                    hc.GetDiagnostics((complete, results, status) =>
                    {
                        total--;

                        if (sciCreated)
                        {
                            sci.Dispose();
                        }

                        AddDiagnosticsResults(list, status, results, hc);

                        if (total == 0)
                        {
                            callback(list);
                        }

                        finished();
                    });
                });
            }
        }
Esempio n. 2
0
        public void LintAsync(IEnumerable <string> files, LintCallback callback)
        {
            var context = ASContext.GetLanguageContext("haxe") as Context;

            if (context == null || !(PluginBase.CurrentProject is ProjectManager.Projects.Haxe.HaxeProject) || !CanContinue(context))
            {
                return;
            }

            var total = files.Count();
            var list  = new List <LintingResult>();

            String untitledFileStart = TextHelper.GetString("FlashDevelop.Info.UntitledFileStart");

            foreach (var file in files)
            {
                if (!File.Exists(file) || file.StartsWithOrdinal(untitledFileStart))
                {
                    total--;
                    continue;
                }

                var sci = GetStubSci(file);

                var hc = context.GetHaxeComplete(sci, new ASExpr {
                    Position = 0
                }, true, HaxeCompilerService.DIAGNOSTICS);

                fileQueue.Run(finished =>
                {
                    hc.GetDiagnostics((complete, results, status) =>
                    {
                        total--;

                        sci.Dispose();

                        AddDiagnosticsResults(list, status, results, hc);

                        if (total == 0)
                        {
                            callback(list);
                        }

                        finished();
                    });
                });
            }
        }