void AddIssue(ProjectFile file, BaseCodeIssueProvider provider, CodeIssue r)
        {
            var topLevelProvider = (provider as CodeIssueProvider) ?? provider.Parent;

            if (topLevelProvider == null)
            {
                throw new ArgumentException("must be a CodeIssueProvider or a BaseCodeIssueProvider with Parent != null", "provider");
            }
            var issue = new IssueSummary {
                IssueDescription    = r.Description,
                Region              = r.Region,
                ProviderTitle       = topLevelProvider.Title,
                ProviderDescription = topLevelProvider.Description,
                ProviderCategory    = topLevelProvider.Category,
                Severity            = topLevelProvider.GetSeverity(),
                File              = file,
                Project           = file.Project,
                InspectorIdString = r.InspectorIdString
            };

            issue.Actions = r.Actions.Select(a => new ActionSummary {
                Batchable    = a.SupportsBatchRunning,
                SiblingKey   = a.SiblingKey,
                Title        = a.Title,
                Region       = a.DocumentRegion,
                IssueSummary = issue
            }).ToList();
            IssueSink.AddIssue(issue);
        }
Exemple #2
0
		public static IssueSummary FromCodeIssue(ProjectFile file, BaseCodeIssueProvider provider, CodeIssue codeIssue)
		{
			var topLevelProvider = (provider as CodeIssueProvider) ?? provider.Parent;
			if (topLevelProvider == null)
				throw new ArgumentException ("must be a CodeIssueProvider or a BaseCodeIssueProvider with Parent != null", "provider");
			var issueSummary = new IssueSummary {
				IssueDescription = codeIssue.Description,
				Region = codeIssue.Region,
				ProviderTitle = topLevelProvider.Title,
				ProviderDescription = topLevelProvider.Description,
				ProviderCategory = topLevelProvider.Category,
				Severity = topLevelProvider.GetSeverity (),
				IssueMarker = codeIssue.IssueMarker,
				File = file,
				Project = file.Project,
				InspectorIdString = codeIssue.InspectorIdString
			};
			issueSummary.Actions = codeIssue.Actions.Select (a => new ActionSummary {
				Batchable = a.SupportsBatchRunning,
				SiblingKey = a.SiblingKey,
				Title = a.Title,
				Region = a.DocumentRegion,
				IssueSummary = issueSummary
			}).ToList ();
			return issueSummary;
		}
Exemple #3
0
        void AddIssue(ProjectFile file, CodeIssueProvider provider, CodeIssue r)
        {
            var issue = new IssueSummary {
                IssueDescription    = r.Description,
                Region              = r.Region,
                ProviderTitle       = provider.Title,
                ProviderDescription = provider.Description,
                ProviderCategory    = provider.Category,
                Severity            = provider.GetSeverity(),
                IssueMarker         = provider.IssueMarker,
                File              = file,
                Project           = file.Project,
                InspectorIdString = r.InspectorIdString
            };

            issue.Actions = r.Actions.Select(a => new ActionSummary {
                Batchable    = a.SupportsBatchRunning,
                SiblingKey   = a.SiblingKey,
                Title        = a.Title,
                Region       = a.DocumentRegion,
                IssueSummary = issue
            }).ToList();
            IssueSink.AddIssue(issue);
        }
Exemple #4
0
        public static IssueSummary FromCodeIssue(ProjectFile file, BaseCodeIssueProvider provider, CodeIssue codeIssue)
        {
            var topLevelProvider = (provider as CodeIssueProvider) ?? provider.Parent;

            if (topLevelProvider == null)
            {
                throw new ArgumentException("must be a CodeIssueProvider or a BaseCodeIssueProvider with Parent != null", "provider");
            }
            var issueSummary = new IssueSummary {
                IssueDescription    = codeIssue.Description,
                Region              = codeIssue.Region,
                ProviderTitle       = topLevelProvider.Title,
                ProviderDescription = topLevelProvider.Description,
                ProviderCategory    = topLevelProvider.Category,
                Severity            = topLevelProvider.GetSeverity(),
                IssueMarker         = codeIssue.IssueMarker,
                File              = file,
                Project           = file.Project,
                InspectorIdString = codeIssue.InspectorIdString
            };

            issueSummary.Actions = codeIssue.Actions.Select(a => new ActionSummary {
//				Batchable = a.SupportsBatchRunning,
//				SiblingKey = a.SiblingKey,
//				Title = a.,
//				Region = a.DocumentRegion,
                IssueSummary = issueSummary
            }).ToList();
            return(issueSummary);
        }
		public override IEnumerable<CodeIssue> GetIssues (object ctx, CancellationToken cancellationToken)
		{
			var context = ctx as MDRefactoringContext;
			if (context == null || context.IsInvalid || context.RootNode == null)
				yield break;
			foreach (var action in issueProvider.GetIssues (context)) {
				if (cancellationToken.IsCancellationRequested)
					yield break;
				if (action.Actions == null) {
					LoggingService.LogError ("NRefactory actions == null in :" + Title);
					continue;
				}
				var actions = new List<MonoDevelop.CodeActions.CodeAction> ();
				foreach (var act in action.Actions) {
					if (cancellationToken.IsCancellationRequested)
						yield break;
					if (act == null) {
						LoggingService.LogError ("NRefactory issue action was null in :" + Title);
						continue;
					}
					actions.Add (new NRefactoryCodeAction (providerIdString, act.Description, act));
				}
				var issue = new CodeIssue (
					GettextCatalog.GetString (action.Description ?? ""),
					context.TextEditor.FileName,
					action.Start,
					action.End,
					actions
				);
				yield return issue;
			}
		}
		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;
			}
		}
		void AddIssue (ProjectFile file, CodeIssueProvider provider, CodeIssue r)
		{
			var issue = new IssueSummary {
				IssueDescription = r.Description,
				Region = r.Region,
				ProviderTitle = provider.Title,
				ProviderDescription = provider.Description,
				ProviderCategory = provider.Category,
				Severity = provider.GetSeverity (),
				IssueMarker = provider.IssueMarker,
				File = file,
				Project = file.Project,
				InspectorIdString = r.InspectorIdString
			};
			issue.Actions = r.Actions.Select (a => new ActionSummary {
				Batchable = a.SupportsBatchRunning,
				SiblingKey = a.SiblingKey,
				Title = a.Title,
				Region = a.DocumentRegion,
				IssueSummary = issue
			}).ToList ();
			IssueSink.AddIssue (issue);
		}
		public override IEnumerable<CodeIssue> GetIssues (Document document, CancellationToken cancellationToken)
		{
			var context = new MDRefactoringContext (document, document.Editor.Caret.Location);
			if (context.IsInvalid || context.RootNode == null)
				yield break;
			int issueNum = 0;
			foreach (var action in issueProvider.GetIssues (context)) {
				if (action.Actions == null) {
					LoggingService.LogError ("NRefactory actions == null in :" + Title);
					continue;
				}
				if (actionIdList.Count <= issueNum)
					actionIdList.Add (new List<string> ());
				var actionId = actionIdList [issueNum];
				int actionNum = 0;
				
				var actions = new List<MonoDevelop.CodeActions.CodeAction> ();
				foreach (var act in action.Actions) {
					if (act == null) {
						LoggingService.LogError ("NRefactory issue action was null in :" + Title);
						continue;
					}
					if (actionId.Count <= actionNum)
						actionId.Add (issueProvider.GetType ().FullName + "'" + issueNum + "'" + actionNum);
					actions.Add (new NRefactoryCodeAction (actionId[actionNum], act.Description, act));
					actionNum++;
				}
				var issue = new CodeIssue (
					GettextCatalog.GetString (action.Desription ?? ""),
					action.Start,
					action.End,
					actions
				);
				yield return issue;
				issueNum ++;
			}
		}