private void ParseFile(FileTextContentProvider fileContent) { if (fileContent.Path.EndsWith(".py", StringComparison.OrdinalIgnoreCase)) { PythonAst ast; CollectingErrorSink errorSink; ParsePythonCode(fileContent, out ast, out errorSink); if (ast != null) { IProjectEntry analysis; IPythonProjectEntry pyAnalysis; if (fileContent != null && _projectFiles.TryGetValue(fileContent.Path, out analysis) && (pyAnalysis = analysis as IPythonProjectEntry) != null) { pyAnalysis.UpdateTree(ast, new FileCookie(fileContent.Path)); _analysisQueue.Enqueue(analysis, AnalysisPriority.Normal); } } } else if (fileContent.Path.EndsWith(".xaml", StringComparison.OrdinalIgnoreCase)) { IProjectEntry analysis; XamlProjectEntry xamlProject; if (_projectFiles.TryGetValue(fileContent.Path, out analysis) && (xamlProject = analysis as XamlProjectEntry) != null) { xamlProject.UpdateContent(fileContent.GetReader(), new FileCookie(fileContent.Path)); _analysisQueue.Enqueue(analysis, AnalysisPriority.Normal); } } }
public void Parse(TextContentProvider /*!*/ content) { var errorSink = new CollectingErrorSink(); SourceUnitTree ast = MakeParseTree(content, errorSink); ISnapshotTextContentProvider snapshotContent = content as ISnapshotTextContentProvider; if (snapshotContent != null) { // queue analysis of the parsed tree at High Pri so the active buffer is quickly re-analyzed var snapshot = snapshotContent.Snapshot; var analysis = AnalysisItem.GetAnalysis(snapshot.TextBuffer); // only update the AST when we're error free, this way we don't remove // a useful analysis with an incomplete and useless analysis. if (errorSink.Errors.Count == 0) { analysis.UpdateTree(ast, new SnapshotCookie(snapshot)); _analysisQueue.Enqueue(analysis, AnalysisPriority.High); } SimpleTagger <ErrorTag> squiggles = _squiggleProvider.GetErrorTagger(snapshot.TextBuffer); squiggles.RemoveTagSpans(x => true); // update squiggles for the live buffer foreach (ErrorResult warning in errorSink.Warnings) { var span = warning.Span; var tspan = CreateSpan(snapshot, span); squiggles.CreateTagSpan(tspan, new ErrorTag("Warning", warning.Message)); } foreach (ErrorResult error in errorSink.Errors) { var span = error.Span; var tspan = CreateSpan(snapshot, span); squiggles.CreateTagSpan(tspan, new ErrorTag("Error", error.Message)); } } else { FileTextContentProvider fileContent = content as FileTextContentProvider; AnalysisItem analysis; if (fileContent != null && _projectFiles.TryGetValue(fileContent.Path, out analysis)) { analysis.UpdateTree(ast, new FileCookie(fileContent.Path)); _analysisQueue.Enqueue(analysis, AnalysisPriority.Normal); } } }
public AnalysisItem AnalyzeFile(string path) { AnalysisItem item; if (!_projectFiles.TryGetValue(path, out item)) { var entry = new ProjectEntry(FileTextContentProvider.Make(_engine, path), path, null); _projectFiles[path] = item = new AnalysisItem(entry); } _queue.EnqueueFile(path); return(item); }
public void Parse(TextContentProvider content) { ISnapshotTextContentProvider snapshotContent = content as ISnapshotTextContentProvider; if (snapshotContent != null) { ParseSnapshot(snapshotContent); } else { FileTextContentProvider fileContent = content as FileTextContentProvider; if (fileContent != null) { ParseFile(fileContent); } } }