/// <summary> /// Creates a queue that starts with some already parsed module and a pending module under construction /// </summary> public static ModuleParsingQueue CreateIncrementalQueue( WorkspaceProvider workspaceProvider, WorkspaceConfiguration workspaceConfiguration, IModuleReferenceResolver moduleReferenceResolver, ModuleDefinition designatedPrelude, ParsedModule configurationModule, IEnumerable <ParsedModule> parsedModules, IEnumerable <Failure> failures) { Contract.Requires(workspaceProvider != null); Contract.Requires(moduleReferenceResolver != null); Contract.Requires(parsedModules != null); Contract.Requires(failures != null); var parsedModulesDictionary = new ConcurrentDictionary <ModuleDescriptor, ParsedModule>(parsedModules.Select(parsedModule => new KeyValuePair <ModuleDescriptor, ParsedModule>(parsedModule.Descriptor, parsedModule))); var failureBag = new ConcurrentQueue <Failure>(failures); // For IDE mode it is very crucial to preserve trivias. For instance, without it, there is no way to check that the current position is inside a comment. var queue = new ModuleParsingQueue( workspaceProvider, workspaceConfiguration, moduleReferenceResolver, designatedPrelude, configurationModule, parsedModulesDictionary, failureBag, preserveTrivias: true); return(queue); }
/// <summary> /// Creates a special version of the parsing queue required for paring/binding spec files for fingerprint computation. /// </summary> public static ModuleParsingQueue CraeteFingerprintComputationQueue( WorkspaceProvider workspaceProvider, WorkspaceConfiguration workspaceConfiguration, IModuleReferenceResolver moduleReferenceResolver) { return(new FingerprintComputationParsingQueue(workspaceProvider, workspaceConfiguration, moduleReferenceResolver)); }
private ModuleParsingQueue( WorkspaceProvider workspaceProvider, WorkspaceConfiguration workspaceConfiguration, IModuleReferenceResolver moduleReferenceResolver, ModuleDefinition designatedPrelude, ParsedModule configurationModule, ConcurrentDictionary <ModuleDescriptor, ParsedModule> alreadyParsedModules, ConcurrentQueue <Failure> failures, bool preserveTrivias = false) { Contract.Requires(workspaceProvider != null); Contract.Requires(workspaceConfiguration != null); Contract.Requires(moduleReferenceResolver != null); Contract.Requires(alreadyParsedModules != null, "alreadyParsedModules != null"); Contract.Requires(failures != null, "failures != null"); m_modulesToBeParsed = new ConcurrentDictionary <ModuleDescriptor, ModuleUnderConstruction>(); m_modulesAlreadyParsed = alreadyParsedModules; m_failures = failures; m_workspaceProvider = workspaceProvider; m_moduleReferenceResolver = moduleReferenceResolver; m_designatedPrelude = designatedPrelude; m_configurationModule = configurationModule; m_workspaceConfiguration = workspaceConfiguration; m_parsingOptions = workspaceConfiguration.ParsingOptions; if (preserveTrivias) { m_parsingOptions = (m_parsingOptions ?? ParsingOptions.DefaultParsingOptions).WithTrivia(true); } DegreeOfParallelism = workspaceConfiguration.MaxDegreeOfParallelismForParsing; // WARNING: this is extremely subtle. // We need to keep a 'registration token' from the chained operation we are doing next to avoid memory leak. // The instance of this class stores the reference to key front-end objects, like resolvers, // that keeps the entire front-end in memory. // CancellationToken.Register registers the call back, that lead to a closure allocation of the current instance. // And this means that the lifetime of this instance is coupled to the lifetime of the the workspaceConfiguration.CancellationToken which is global. // This means that if we won't dispose the resistration we'll keep the entire front-end in memory for the entire app life time. cancellationTokenChain = workspaceConfiguration.CancellationToken.Register(() => m_cancellationTokenSource.Cancel()); m_queueOptions = new ModuleParsingQueueOptions() { CancelOnFirstFailure = workspaceConfiguration.CancelOnFirstFailure, MaxDegreeOfParallelism = DegreeOfParallelism, CancellationToken = CancellationToken, }; m_parseQueue = new ActionBlock <SpecWithOwningModule>(ProcessQueuedItemForParsing, m_queueOptions); Action <ParsedSpecWithOwningModule> action = ProcessQueueItemForBinding; m_bindQueue = new ActionBlock <ParsedSpecWithOwningModule>(action, m_queueOptions); }
/// <summary> /// Creates a module parsing queue. The queue options are specified by the provided queueOptions. /// </summary> public ModuleParsingQueue( [NotNull] WorkspaceProvider workspaceProvider, WorkspaceConfiguration workspaceConfiguration, IModuleReferenceResolver moduleReferenceResolver, ModuleDefinition designatedPrelude, ParsedModule configurationModule) : this(workspaceProvider, workspaceConfiguration, moduleReferenceResolver, designatedPrelude, configurationModule, new ConcurrentDictionary <ModuleDescriptor, ParsedModule>(), new ConcurrentQueue <Failure>()) { Contract.Requires(moduleReferenceResolver != null); }
/// <summary> /// Creates a parsing queue for parsing specs in a regular BuildXL invocation. /// </summary> public static ModuleParsingQueue Create( [NotNull] WorkspaceProvider workspaceProvider, [NotNull] WorkspaceConfiguration workspaceConfiguration, [NotNull] IModuleReferenceResolver moduleReferenceResolver, [CanBeNull] ModuleDefinition designatedPrelude, [CanBeNull] ParsedModule configurationModule) { Contract.Requires(workspaceProvider != null); return(new ModuleParsingQueue( workspaceProvider, workspaceConfiguration, moduleReferenceResolver, designatedPrelude, configurationModule)); }
/// <nodoc/> public WorkspaceProvider( IWorkspaceStatistics workspaceStatistics, List <IWorkspaceModuleResolver> resolvers, IModuleReferenceResolver moduleReferenceResolver, WorkspaceConfiguration configuration, PathTable pathTable, SymbolTable symbolTable) { Contract.Requires(workspaceStatistics != null); Contract.Requires(configuration != null); Contract.Requires(moduleReferenceResolver != null); Contract.Requires(pathTable != null); Statistics = workspaceStatistics; m_moduleReferenceResolver = moduleReferenceResolver; PathTable = pathTable; Configuration = configuration; SymbolTable = symbolTable; m_resolvers = resolvers; }
/// <nodoc /> public FingerprintComputationParsingQueue(WorkspaceProvider workspaceProvider, WorkspaceConfiguration workspaceConfiguration, IModuleReferenceResolver moduleReferenceResolver) : base(workspaceProvider: workspaceProvider, workspaceConfiguration: workspaceConfiguration, moduleReferenceResolver: moduleReferenceResolver, designatedPrelude: null, configurationModule: null) { }