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 override async Task DidChangeConfiguration(DidChangeConfigurationParams @params) { if (_analyzer == null) { LogMessage(MessageType.Error, "change configuration notification sent to uninitialized server"); return; } if (@params.settings != null) { if (@params.settings is LanguageServerSettings settings) { _settings = settings; } else { LogMessage(MessageType.Error, "change configuration notification sent unsupported settings"); return; } } // Make sure reload modules is executed on the analyzer thread. var task = _reloadModulesQueueItem.Task; _queue.Enqueue(_reloadModulesQueueItem, AnalysisPriority.Normal); await task; // re-analyze all of the modules when we get a new set of modules loaded... foreach (var entry in _analyzer.ModulesByFilename) { _queue.Enqueue(entry.Value.ProjectEntry, 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); } } }
private void Interpreter_ModuleNamesChanged(object sender, EventArgs e) { Analyzer.Modules.Reload(); foreach (var entry in Analyzer.ModulesByFilename) { AnalysisQueue.Enqueue(entry.Value.ProjectEntry, AnalysisPriority.Normal); } }
public async Task ReloadModulesAsync(CancellationToken token) { #if false foreach (var entry in Analyzer.ModulesByFilename) { AnalysisQueue.Enqueue(entry.Value.ProjectEntry, AnalysisPriority.Normal); } #endif }
public async Task ReloadModulesAsync(CancellationToken token) { LogMessage(MessageType._General, "Reloading modules..."); // Make sure reload modules is executed on the analyzer thread. var task = _reloadModulesQueueItem.Task; AnalysisQueue.Enqueue(_reloadModulesQueueItem, AnalysisPriority.Normal); await task; // re-analyze all of the modules when we get a new set of modules loaded... foreach (var entry in Analyzer.ModulesByFilename) { AnalysisQueue.Enqueue(entry.Value.ProjectEntry, AnalysisPriority.Normal); } }
public override async Task DidChangeConfiguration(DidChangeConfigurationParams @params) { if (_analyzer == null) { LogMessage(MessageType.Error, "change configuration notification sent to uninitialized server"); return; } await _analyzer.ReloadModulesAsync(); // re-analyze all of the modules when we get a new set of modules loaded... foreach (var entry in _analyzer.ModulesByFilename) { _queue.Enqueue(entry.Value.ProjectEntry, AnalysisPriority.Normal); } }