~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeAnalysisRunner.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
using MonoDevelop.SourceEditor.QuickTasks;
40
40
using ICSharpCode.NRefactory.TypeSystem;
41
41
using MonoDevelop.CodeIssues;
 
42
using Mono.TextEditor;
42
43
 
43
44
namespace MonoDevelop.CodeIssues
44
45
{
48
49
                {
49
50
                        if (!QuickTaskStrip.EnableFancyFeatures)
50
51
                                return Enumerable.Empty<Result> ();
 
52
 
 
53
//                      var now = DateTime.Now;
 
54
 
51
55
                        var editor = input.Editor;
52
56
                        if (editor == null)
53
57
                                return Enumerable.Empty<Result> ();
54
58
                        var loc = editor.Caret.Location;
55
59
                        var result = new BlockingCollection<Result> ();
56
 
                        var codeIssueProvider = RefactoringService.GetInspectors (editor.Document.MimeType);
 
60
                
 
61
                        var codeIssueProvider = RefactoringService.GetInspectors (editor.Document.MimeType).ToArray ();
 
62
                        var context = input.ParsedDocument.CreateRefactoringContext != null ?
 
63
                                input.ParsedDocument.CreateRefactoringContext (input, cancellationToken) : null;
 
64
//                      Console.WriteLine ("start check:"+ (DateTime.Now - now).TotalMilliseconds);
57
65
                        Parallel.ForEach (codeIssueProvider, (provider) => {
58
66
                                try {
59
67
                                        var severity = provider.GetSeverity ();
60
68
                                        if (severity == Severity.None)
61
69
                                                return;
62
 
                                        foreach (var r in provider.GetIssues (input, cancellationToken)) {
63
 
                                                var fixes = new List<GenericFix> (r.Actions.Where (a => a != null).Select (a => new GenericFix (a.Title, new System.Action (() => a.Run (input, loc)))));
 
70
//                                      var now2 = DateTime.Now;
 
71
                                        foreach (var r in provider.GetIssues (context, cancellationToken)) {
 
72
                                                var fixes = new List<GenericFix> (r.Actions.Where (a => a != null).Select (a => 
 
73
                                                        new GenericFix (
 
74
                                                                a.Title,
 
75
                                                                new System.Action (() => a.Run (input, loc))) {
 
76
                                                                DocumentRegion = new DocumentRegion (r.Region.Begin, r.Region.End)
 
77
                                                }));
64
78
                                                result.Add (new InspectorResults (
65
79
                                                        provider, 
66
80
                                                        r.Region, 
70
84
                                                        fixes.ToArray ()
71
85
                                                ));
72
86
                                        }
 
87
/*                                      var ms = (DateTime.Now - now2).TotalMilliseconds;
 
88
                                        if (ms > 1000)
 
89
                                                Console.WriteLine (ms +"\t\t"+ provider.Title);*/
 
90
                                } catch (OperationCanceledException) {
 
91
                                        //ignore
73
92
                                } catch (Exception e) {
74
93
                                        LoggingService.LogError ("CodeAnalysis: Got exception in inspector '" + provider + "'", e);
75
94
                                }
76
95
                        });
 
96
//                      Console.WriteLine ("END check:"+ (DateTime.Now - now).TotalMilliseconds);
77
97
                        return result;
78
98
                }
79
99
        }