private void AssertParserReady(ParseCoordinator parser) { parser.Parse(new System.Threading.CancellationTokenSource()); if (parser.State.Status == ParserState.ResolverError) { Assert.Fail("Parser state should be 'Ready', but returns '{0}'.", parser.State.Status); } if (parser.State.Status != ParserState.Ready) { Assert.Inconclusive("Parser state should be 'Ready', but returns '{0}'.", parser.State.Status); } }
public static ConfiguredParserResult CreateConfiguredParser(this IVBE vbe, string serializedDeclarationsPath = null) { var state = new RubberduckParserState(vbe, new ConcurrentlyConstructedDeclarationFinderFactory()); var moduleToModuleReferenceManager = new ModuleToModuleReferenceManager(); var parserStateManager = new SynchronousParserStateManager(state); var referenceRemover = new SynchronousReferenceRemover(state, moduleToModuleReferenceManager); var supertypeClearer = new SupertypeClearer(state); var comSynchronizer = new SynchronousCOMReferenceSynchronizer(state, parserStateManager, @"C:\"); var parseRunner = new SynchronousParseRunner(state, parserStateManager, () => new VBAPreprocessor(double.Parse(vbe.Version, CultureInfo.InvariantCulture)), new AttributeParser(), new ModuleExporter()); var declarationResolveRunner = new SynchronousDeclarationResolveRunner(state, parserStateManager, comSynchronizer); var referenceResolveRunner = new SynchronousReferenceResolveRunner(state, parserStateManager, moduleToModuleReferenceManager, referenceRemover); var parsingCacheService = new ParsingCacheService(state, moduleToModuleReferenceManager, referenceRemover, supertypeClearer); var parsingStageService = new ParsingStageService(comSynchronizer, new BuiltInDeclarationLoader(state, new List <ICustomDeclarationLoader> { new DebugDeclarations(state), new SpecialFormDeclarations(state), new FormEventDeclarations(state), new AliasDeclarations(state) }), parseRunner, declarationResolveRunner, referenceResolveRunner); IProjectManager projectManager = new SynchronousProjectManager(state, vbe); var parser = new ParseCoordinator(state, parsingStageService, parsingCacheService, projectManager, parserStateManager, true); return(new ConfiguredParserResult { ParseCoordinator = parser, ProjectManager = projectManager }); }
public void Initialize(Microsoft.Vbe.Interop.VBE vbe) { if (_parser != null) { throw new InvalidOperationException("ParserState is already initialized."); } _vbe = new VBE(vbe); _state = new RubberduckParserState(null); _state.StateChanged += _state_StateChanged; Func <IVBAPreprocessor> preprocessorFactory = () => new VBAPreprocessor(double.Parse(_vbe.Version, CultureInfo.InvariantCulture)); _attributeParser = new AttributeParser(new ModuleExporter(), preprocessorFactory); _parser = new ParseCoordinator(_vbe, _state, _attributeParser, preprocessorFactory, new List <ICustomDeclarationLoader> { new DebugDeclarations(_state), new SpecialFormDeclarations(_state), new FormEventDeclarations(_state), new AliasDeclarations(_state), //new RubberduckApiDeclarations(_state) }); }
public void Initialize(Microsoft.Vbe.Interop.VBE vbe) { if (_parser != null) { throw new InvalidOperationException("ParserState is already initialized."); } _vbe = new VBE(vbe); _vbeEvents = VBEEvents.Initialize(_vbe); var declarationFinderFactory = new ConcurrentlyConstructedDeclarationFinderFactory(); var projectRepository = new ProjectsRepository(_vbe); _state = new RubberduckParserState(null, projectRepository, declarationFinderFactory, _vbeEvents); _state.StateChanged += _state_StateChanged; var exporter = new ModuleExporter(); Func <IVBAPreprocessor> preprocessorFactory = () => new VBAPreprocessor(double.Parse(_vbe.Version, CultureInfo.InvariantCulture)); _attributeParser = new AttributeParser(exporter, preprocessorFactory, _state.ProjectsProvider); var projectManager = new RepositoryProjectManager(projectRepository); var moduleToModuleReferenceManager = new ModuleToModuleReferenceManager(); var parserStateManager = new ParserStateManager(_state); var referenceRemover = new ReferenceRemover(_state, moduleToModuleReferenceManager); var supertypeClearer = new SupertypeClearer(_state); var comSynchronizer = new COMReferenceSynchronizer(_state, parserStateManager); var builtInDeclarationLoader = new BuiltInDeclarationLoader( _state, new List <ICustomDeclarationLoader> { new DebugDeclarations(_state), new SpecialFormDeclarations(_state), new FormEventDeclarations(_state), new AliasDeclarations(_state), //new RubberduckApiDeclarations(_state) } ); var parseRunner = new ParseRunner( _state, parserStateManager, preprocessorFactory, _attributeParser, exporter); var declarationResolveRunner = new DeclarationResolveRunner( _state, parserStateManager, comSynchronizer); var referenceResolveRunner = new ReferenceResolveRunner( _state, parserStateManager, moduleToModuleReferenceManager, referenceRemover); var parsingStageService = new ParsingStageService( comSynchronizer, builtInDeclarationLoader, parseRunner, declarationResolveRunner, referenceResolveRunner ); var parsingCacheService = new ParsingCacheService( _state, moduleToModuleReferenceManager, referenceRemover, supertypeClearer ); _parser = new ParseCoordinator( _state, parsingStageService, parsingCacheService, projectManager, parserStateManager ); }