diff options
Diffstat (limited to 'main/src/addins/CSharpBinding/MonoDevelop.CSharp.Parser/TypeSystemProvider.cs')
-rw-r--r-- | main/src/addins/CSharpBinding/MonoDevelop.CSharp.Parser/TypeSystemProvider.cs | 33 |
1 files changed, 6 insertions, 27 deletions
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Parser/TypeSystemProvider.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Parser/TypeSystemProvider.cs index 8ac0e2c89d..4f0525f43d 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Parser/TypeSystemProvider.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Parser/TypeSystemProvider.cs @@ -38,7 +38,7 @@ namespace MonoDevelop.CSharp.Parser { sealed class TypeSystemParser : MonoDevelop.Ide.TypeSystem.TypeSystemParser { - public override async System.Threading.Tasks.Task<ParsedDocument> Parse (MonoDevelop.Ide.TypeSystem.ParseOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public override System.Threading.Tasks.Task<ParsedDocument> Parse (MonoDevelop.Ide.TypeSystem.ParseOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { var fileName = options.FileName; var project = options.Project; @@ -51,40 +51,19 @@ namespace MonoDevelop.CSharp.Parser result.Flags |= ParsedDocumentFlags.NonSerializable; } - SyntaxTree unit = null; - if (project != null) { var curDoc = options.RoslynDocument; if (curDoc == null) { var curProject = TypeSystemService.GetCodeAnalysisProject (project); if (curProject != null) { var documentId = TypeSystemService.GetDocumentId (project, fileName); - if (documentId != null) - curDoc = curProject.GetDocument (documentId); - } - } - if (curDoc != null) { - try { - var model = await curDoc.GetSemanticModelAsync (cancellationToken).ConfigureAwait (false); - unit = model.SyntaxTree; - result.Ast = model; - } catch (AggregateException ae) { - ae.Flatten ().Handle (x => x is OperationCanceledException); - return result; - } catch (OperationCanceledException) { - return result; - } catch (Exception e) { - LoggingService.LogError ("Error while getting the semantic model for " + fileName, e); + result.DocumentId = documentId; } } - } - - if (unit == null) { + } else { var compilerArguments = GetCompilerArguments (project); - unit = CSharpSyntaxTree.ParseText (SourceText.From (options.Content.Text), compilerArguments, fileName); - } - - result.Unit = unit; + result.ParsedUnit = CSharpSyntaxTree.ParseText (SourceText.From (options.Content.Text), compilerArguments, fileName); + } DateTime time; try { @@ -93,7 +72,7 @@ namespace MonoDevelop.CSharp.Parser time = DateTime.UtcNow; } result.LastWriteTimeUtc = time; - return result; + return Task.FromResult<ParsedDocument> (result); } public static CSharpParseOptions GetCompilerArguments (MonoDevelop.Projects.Project project) |