本文整理汇总了C#中ParsedDocument.CreateRefactoringContext方法的典型用法代码示例。如果您正苦于以下问题:C# ParsedDocument.CreateRefactoringContext方法的具体用法?C# ParsedDocument.CreateRefactoringContext怎么用?C# ParsedDocument.CreateRefactoringContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParsedDocument
的用法示例。
在下文中一共展示了ParsedDocument.CreateRefactoringContext方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Check
public static IEnumerable<Result> Check (Document input, ParsedDocument parsedDocument, CancellationToken cancellationToken)
{
if (!QuickTaskStrip.EnableFancyFeatures || input.Project == null || !input.IsCompileableInProject)
return Enumerable.Empty<Result> ();
#if PROFILE
var runList = new List<Tuple<long, string>> ();
#endif
var editor = input.Editor;
if (editor == null)
return Enumerable.Empty<Result> ();
var loc = editor.Caret.Location;
var result = new BlockingCollection<Result> ();
var codeIssueProvider = RefactoringService.GetInspectors (editor.Document.MimeType).ToArray ();
var context = parsedDocument.CreateRefactoringContext != null ?
parsedDocument.CreateRefactoringContext (input, cancellationToken) : null;
Parallel.ForEach (codeIssueProvider, (parentProvider) => {
try {
#if PROFILE
var clock = new Stopwatch();
clock.Start ();
#endif
foreach (var provider in EnumerateProvider (parentProvider)) {
cancellationToken.ThrowIfCancellationRequested ();
var severity = provider.GetSeverity ();
if (severity == Severity.None || !provider.GetIsEnabled ())
continue;
foreach (var r in provider.GetIssues (context, cancellationToken)) {
cancellationToken.ThrowIfCancellationRequested ();
var fixes = r.Actions == null ? new List<GenericFix> () : new List<GenericFix> (r.Actions.Where (a => a != null).Select (a => {
Action batchAction = null;
if (a.SupportsBatchRunning)
batchAction = () => a.BatchRun (input, loc);
return new GenericFix (
a.Title,
() => {
using (var script = context.CreateScript ()) {
a.Run (context, script);
}
},
batchAction) {
DocumentRegion = new DocumentRegion (r.Region.Begin, r.Region.End),
IdString = a.IdString
};
}));
result.Add (new InspectorResults (
provider,
r.Region,
r.Description,
severity,
r.IssueMarker,
fixes.ToArray ()
));
}
}
#if PROFILE
clock.Stop ();
lock (runList) {
runList.Add (Tuple.Create (clock.ElapsedMilliseconds, parentProvider.Title));
}
#endif
} catch (OperationCanceledException) {
//ignore
} catch (Exception e) {
LoggingService.LogError ("CodeAnalysis: Got exception in inspector '" + parentProvider + "'", e);
}
});
#if PROFILE
runList.Sort ();
foreach (var item in runList) {
Console.WriteLine (item.Item1 +"ms\t: " + item.Item2);
}
#endif
return result;
}