private void InitializeContent(string content, ModuleLoadOptions newOptions) { lock (AnalysisLock) { if (!_loaded) { if (!newOptions.ShouldLoad()) { return; } content = content ?? LoadContent(newOptions); _buffer.Reset(0, content); _loaded = true; } IsOpen = (newOptions & ModuleLoadOptions.Open) == ModuleLoadOptions.Open; newOptions = newOptions | (IsOpen ? ModuleLoadOptions.Analyze : 0); var change = (_options ^ newOptions); var startAnalysis = change.ShouldAnalyze() && _analysisTcs?.Task == null; var startParse = change.ShouldParse() && _parsingTask == null; _options = newOptions; if (startAnalysis) { _analysisTcs = new TaskCompletionSource <IDocumentAnalysis>(); } if (startParse) { Parse(); } } }
protected virtual string LoadContent(ModuleLoadOptions options) { if (options.ShouldLoad() && ModuleType != ModuleType.Unresolved) { return(FileSystem.ReadAllText(FilePath)); } return(null); // Keep content as null so module can be loaded later. }