Exemple #1
0
        public void OnConnection(object Application, ext_ConnectMode ConnectMode, object AddInInst, ref Array custom)
        {
            try
            {
                _vbe          = RootComWrapperFactory.GetVbeWrapper(Application);
                _addin        = RootComWrapperFactory.GetAddInWrapper(AddInInst);
                _addin.Object = this;

                _vbeNativeApi    = new VbeNativeApiAccessor();
                _beepInterceptor = new BeepInterceptor(_vbeNativeApi);
                VbeProvider.Initialize(_vbe, _vbeNativeApi, _beepInterceptor);
                VbeNativeServices.HookEvents(_vbe);

                SetAddInObject();

                switch (ConnectMode)
                {
                case ext_ConnectMode.ext_cm_Startup:
                    // normal execution path - don't initialize just yet, wait for OnStartupComplete to be called by the host.
                    break;

                case ext_ConnectMode.ext_cm_AfterStartup:
                    _isBeginShutdownExecuted = false;       //When we reconnect after having been unloaded, the variable might no longer have its initial value.
                    InitializeAddIn();
                    break;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemple #2
0
        public void OnConnection(object Application, ext_ConnectMode ConnectMode, object AddInInst, ref Array custom)
        {
            try
            {
                _vbe          = RootComWrapperFactory.GetVbeWrapper(Application);
                _addin        = RootComWrapperFactory.GetAddInWrapper(AddInInst);
                _addin.Object = this;

                VbeProvider.Initialize(_vbe);
                VbeNativeServices.HookEvents(_vbe);

#if DEBUG
                // FOR DEBUGGING/DEVELOPMENT PURPOSES, ALLOW ACCESS TO SOME VBETypeLibsAPI FEATURES FROM VBA
                _addin.Object = new VBEditor.ComManagement.TypeLibsAPI.VBETypeLibsAPI_Object(_vbe);
#endif

                switch (ConnectMode)
                {
                case ext_ConnectMode.ext_cm_Startup:
                    // normal execution path - don't initialize just yet, wait for OnStartupComplete to be called by the host.
                    break;

                case ext_ConnectMode.ext_cm_AfterStartup:
                    _isBeginShutdownExecuted = false;       //When we reconnect after having been unloaded, the variable might no longer have its initial value.
                    InitializeAddIn();
                    break;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemple #3
0
        // vbe is the com coclass interface from the interop assembly.
        // There is no shared interface between VBA and VB6 types, hence object.
        internal Parser(object vbe) : this()
        {
            if (_parser != null)
            {
                throw new InvalidOperationException("ParserState is already initialized.");
            }

            _vbe       = RootComWrapperFactory.GetVbeWrapper(vbe);
            _vbeEvents = VBEEvents.Initialize(_vbe);
            var declarationFinderFactory = new ConcurrentlyConstructedDeclarationFinderFactory();
            var projectRepository        = new ProjectsRepository(_vbe);

            _state = new RubberduckParserState(_vbe, projectRepository, declarationFinderFactory, _vbeEvents);
            _state.StateChanged += _state_StateChanged;
            var vbeVersion = double.Parse(_vbe.Version, CultureInfo.InvariantCulture);
            var predefinedCompilationConstants = new VBAPredefinedCompilationConstants(vbeVersion);
            var typeLibProvider = new TypeLibWrapperProvider(projectRepository);
            var compilationArgumentsProvider     = new CompilationArgumentsProvider(typeLibProvider, _dispatcher, predefinedCompilationConstants);
            var compilationsArgumentsCache       = new CompilationArgumentsCache(compilationArgumentsProvider);
            var preprocessorErrorListenerFactory = new PreprocessingParseErrorListenerFactory();
            var preprocessorParser              = new VBAPreprocessorParser(preprocessorErrorListenerFactory, preprocessorErrorListenerFactory);
            var preprocessor                    = new VBAPreprocessor(preprocessorParser, compilationsArgumentsCache);
            var mainParseErrorListenerFactory   = new MainParseErrorListenerFactory();
            var mainTokenStreamParser           = new VBATokenStreamParser(mainParseErrorListenerFactory, mainParseErrorListenerFactory);
            var tokenStreamProvider             = new SimpleVBAModuleTokenStreamProvider();
            var stringParser                    = new TokenStreamParserStringParserAdapterWithPreprocessing(tokenStreamProvider, mainTokenStreamParser, preprocessor);
            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 comLibraryProvider              = new ComLibraryProvider();
            var referencedDeclarationsCollector = new LibraryReferencedDeclarationsCollector(comLibraryProvider);
            var comSynchronizer                 = new COMReferenceSynchronizer(_state, parserStateManager, projectRepository, referencedDeclarationsCollector);
            var builtInDeclarationLoader        = new BuiltInDeclarationLoader(
                _state,
                new List <ICustomDeclarationLoader>
            {
                new DebugDeclarations(_state),
                new SpecialFormDeclarations(_state),
                new FormEventDeclarations(_state),
                new AliasDeclarations(_state),
                //new RubberduckApiDeclarations(_state)
            }
                );
            var codePaneSourceCodeHandler   = new CodePaneSourceCodeHandler(projectRepository);
            var sourceFileHandler           = _vbe.TempSourceFileHandler;
            var attributesSourceCodeHandler = new SourceFileHandlerSourceCodeHandlerAdapter(sourceFileHandler, projectRepository);
            var moduleParser = new ModuleParser(
                codePaneSourceCodeHandler,
                attributesSourceCodeHandler,
                stringParser);
            var parseRunner = new ParseRunner(
                _state,
                parserStateManager,
                moduleParser);
            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,
                compilationsArgumentsCache
                );

            _parser = new SynchronousParseCoordinator(
                _state,
                parsingStageService,
                parsingCacheService,
                projectManager,
                parserStateManager
                );
        }