本文整理汇总了C#中Microsoft.VisualStudio.Shell.ErrorTask类的典型用法代码示例。如果您正苦于以下问题:C# ErrorTask类的具体用法?C# ErrorTask怎么用?C# ErrorTask使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ErrorTask类属于Microsoft.VisualStudio.Shell命名空间,在下文中一共展示了ErrorTask类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddError
public void AddError(DiagnosticBase diagnostic, TextSpan span)
{
lock (_lockObject)
{
if (_disposed)
return;
var sourceText = span.SourceText as VisualStudioSourceText;
if (sourceText == null)
return;
var line = sourceText.Snapshot.GetLineFromPosition(span.Start);
var task = new ErrorTask
{
Text = diagnostic.Message,
Line = line.LineNumber,
Column = span.Start - line.Start.Position,
Category = TaskCategory.CodeSense,
ErrorCategory = (diagnostic.Severity == DiagnosticSeverity.Error)
? TaskErrorCategory.Error
: TaskErrorCategory.Warning,
Priority = TaskPriority.Normal,
Document = span.Filename ?? _textDocument.FilePath
};
task.Navigate += OnTaskNavigate;
_errorListProvider.Tasks.Add(task);
}
}
示例2: AddError
public void AddError(Project project, string path, string errorText, TaskErrorCategory category, int iLine, int iColumn)
{
ErrorTask task;
IVsSolution solution;
IVsHierarchy hierarchy;
if (project != null)
{
try
{
solution = (IVsSolution)GetService(typeof(IVsSolution));
ErrorHandler.ThrowOnFailure(solution.GetProjectOfUniqueName(project.UniqueName, out hierarchy));
task = new ErrorTask();
task.ErrorCategory = category;
task.HierarchyItem = hierarchy;
task.Document = path;
// VS uses indexes starting at 0 while the automation model uses indexes starting at 1
task.Line = iLine - 1;
task.Column = iColumn;
task.Text = errorText;
task.Navigate += ErrorTaskNavigate;
if (ContainsLink(errorText))
{
task.Help += new EventHandler(task_Help);
}
_errorListProvider.Tasks.Add(task);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
示例3: CreateErrors
private void CreateErrors()
{
var errors = errorListProvider.GetErrors(textView.TextBuffer);
// Check if we should update the error list based on the error count to avoid refreshing the list without changes
if (errors.Count != this.previousErrors.Count)
{
// remove any previously created errors to get a clean start
ClearErrors();
foreach (ValidationError error in errors)
{
// creates the instance that will be added to the Error List
ErrorTask task = new ErrorTask();
task.Category = TaskCategory.All;
task.Priority = TaskPriority.Normal;
task.Document = textView.TextBuffer.Properties.GetProperty<ITextDocument>(typeof(ITextDocument)).FilePath;
task.ErrorCategory = TranslateErrorCategory(error.Severity);
task.Text = error.Description;
task.Line = textView.TextSnapshot.GetLineNumberFromPosition(error.Span.Start);
task.Column = error.Span.Start - textView.TextSnapshot.GetLineFromLineNumber(task.Line).Start;
task.Navigate += OnTaskNavigate;
errorList.Tasks.Add(task);
previousErrors.Add(task);
ITrackingSpan span = textView.TextSnapshot.CreateTrackingSpan(error.Span, SpanTrackingMode.EdgeNegative);
squiggleTagger.CreateTagSpan(span, new ErrorTag("syntax error", error.Description));
previousSquiggles.Add(new TrackingTagSpan<IErrorTag>(span, new ErrorTag("syntax error", error.Description)));
}
}
}
示例4: LogError
public void LogError(Exception ex)
{
ErrorTask task = new ErrorTask(ex);
task.ErrorCategory = TaskErrorCategory.Error;
task.Category = TaskCategory.Misc;
m_errorListPrivider.Tasks.Add(task);
}
示例5: AddHierarchyItem
public static void AddHierarchyItem(ErrorTask task, EnvDTE.Project project)
{
IVsHierarchy hierarchyItem = null;
IVsSolution solution = BundlerMinifierPackage.GetGlobalService(typeof(SVsSolution)) as IVsSolution;
if (solution != null && project != null)
{
int flag = -1;
try
{
flag = solution.GetProjectOfUniqueName(project.FullName, out hierarchyItem);
}
catch (COMException ex)
{
if ((uint)ex.ErrorCode != DISP_E_MEMBERNOTFOUND)
{
throw;
}
}
if (0 == flag)
{
task.HierarchyItem = hierarchyItem;
}
}
}
示例6: Show
public static void Show(Diagnostic diag)
{
var task = new ErrorTask
{
Text = string.Format(@"[N] {0,4} : {1}", diag.ID, diag.Message),
Category = TaskCategory.CodeSense,
ErrorCategory =
diag.Level == DiagnosticLevel.Warning
? TaskErrorCategory.Warning
: TaskErrorCategory.Error,
Column = diag.StartColumn,
Line = diag.StartLine - 1,
Document = diag.FilePath,
HierarchyItem = (IVsHierarchy)(AVRStudio.GetProjectItem(dte, diag.FilePath).ContainingProject != null ? AVRStudio.GetProjectItem(dte, diag.FilePath).ContainingProject.Object : null),
};
task.Navigate += (sender, args) =>
{
task.Line++;
errorListProvider.Navigate(task, Guid.Parse(EnvDTE.Constants.vsViewKindCode));
task.Line--;
};
errorListProvider.Tasks.Add(task);
}
示例7: ShowError
public virtual void ShowError(string error)
{
var errorTask = new ErrorTask
{
Category = TaskCategory.Misc,
Text = error,
CanDelete = true,
};
errorProvider.Tasks.Add(errorTask);
}
示例8: Add
public void Add(Project project, TaskErrorCategory category, string file, int line, int column, string description)
{
var task = new ErrorTask
{
ErrorCategory = category,
Document = file,
Line = Math.Max(line - 1, 0),
Column = Math.Max(column - 1, 0),
Text = description,
};
this.Add(project, task);
}
示例9: AddMessage
/// <summary>
/// Adds a message of the given document to the error list.
/// </summary>
public void AddMessage(string message, string document, ErrorCategory errorCategory)
{
var errorTask = new ErrorTask
{
ErrorCategory = (TaskErrorCategory)errorCategory,
Text = message,
Document = document,
};
this.ErrorListProvider.Tasks.Add(errorTask);
this.ErrorListProvider.Show();
this.ErrorListProvider.BringToFront();
}
示例10: Can_add_clear_error_list_tasks
public void Can_add_clear_error_list_tasks()
{
var mockServiceProvider = new Mock<IServiceProvider>();
mockServiceProvider.Setup(p => p.GetService(typeof(SVsTaskList))).Returns(new Mock<IVsTaskList>().Object);
var task = new ErrorTask();
var errorList = new DesignerErrorList(mockServiceProvider.Object);
Assert.Empty(errorList.Provider.Tasks);
errorList.AddItem(task);
Assert.Equal(new[] { task }, errorList.Provider.Tasks.Cast<ErrorTask>());
errorList.Clear();
Assert.Empty(errorList.Provider.Tasks);
}
示例11: CreateTask
/// <summary>
/// Creates task from occurence
/// </summary>
/// <param name="occurence"> occurence of defect</param>
/// <param name="fileName">file name of occurence</param>
/// <returns></returns>
Task CreateTask(Occurence occurence, string fileName)
{
var defectTask = new ErrorTask()
{
Category = TaskCategory.User,
ErrorCategory = TaskErrorCategory.Warning,
CanDelete = false,
Text = occurence.Message,
Document = fileName,
Line = int.Parse(occurence.StartLine)
};
defectTask.Navigate += navigateEventHandler;
return defectTask;
}
示例12: ShowError
/// <summary>
/// Adds an error message to the Visual Studio tasks pane
/// </summary>
private void ShowError(string path, string text)
{
_message = new ErrorTask
{
ErrorCategory = TaskErrorCategory.Error,
Category = TaskCategory.Comments,
Document = path,
Line = 0,
Column = 0,
Text = text
};
_messageList.Tasks.Add(_message);
_messageList.Show();
}
示例13: AddHierarchyItem
public void AddHierarchyItem(ErrorTask task)
{
IVsHierarchy HierarchyItem;
IVsSolution solution = EditorExtensionsPackage.GetGlobalService<IVsSolution>(typeof(SVsSolution));
if (solution != null)
{
int flag = solution.GetProjectOfUniqueName(_connection.Project.FullName, out HierarchyItem);
if (0 == flag)
{
task.HierarchyItem = HierarchyItem;
}
}
}
示例14: ProduceErrorListTask
public static Task ProduceErrorListTask(this IStylingRule rule, TaskErrorCategory category, Project project, string format)
{
var item = ResolveVsHierarchyItem(project.UniqueName);
var task = new ErrorTask
{
Document = rule.File,
Line = rule.Line - 1,
Column = rule.Column,
ErrorCategory = category,
Category = TaskCategory.Html,
Text = string.Format(format, project.Name, rule.DisplaySelectorName, rule.File, rule.Line, rule.Column),
HierarchyItem = item
};
task.Navigate += NavigateToItem;
return task;
}
示例15: AddError
public void AddError(ITextSnapshot snapshot, Diagnostic diagnostic, TextSpan span)
{
var line = snapshot.GetLineFromPosition(span.Start);
var task = new ErrorTask
{
Text = diagnostic.Message,
Line = line.LineNumber,
Column = span.Start - line.Start.Position,
Category = TaskCategory.CodeSense,
ErrorCategory = TaskErrorCategory.Error,
Priority = TaskPriority.Normal,
Document = span.Filename
};
task.Navigate += OnTaskNavigate;
_errorListProvider.Tasks.Add(task);
}