Exemplo n.º 1
0
        // XSharpLanguageService _langService = null;
        #region Overridden Implementation
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            // Give the codemodel a way to talk to the VS Shell
            oShellLink          = new XSharpShellLink();
            XSettings.ShellLink = oShellLink;

            this.RegisterToolWindows();

            XSharpProjectPackage.instance = this;
            this.SolutionListeners.Add(new SolutionEvents(this));
            await base.InitializeAsync(cancellationToken, progress);

            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            // The project selector helps to choose between MPF and CPS projects
            //_projectSelector = new XSharpProjectSelector();
            //await _projectSelector.InitAsync(this);

            this.settings = new XPackageSettings(this);
            VS.Events.BuildEvents.ProjectConfigurationChanged += BuildEvents_ProjectConfigurationChanged;

            this.RegisterProjectFactory(new XSharpProjectFactory(this));
            // Indicate how to open the different source files : SourceCode or Designer ??
            this.RegisterEditorFactory(new XSharpEditorFactory(this));
            this.RegisterProjectFactory(new XSharpWPFProjectFactory(this));

            // editors for the binaries
            base.RegisterEditorFactory(new VOFormEditorFactory(this));
            base.RegisterEditorFactory(new VOMenuEditorFactory(this));
            base.RegisterEditorFactory(new VODBServerEditorFactory(this));
            base.RegisterEditorFactory(new VOFieldSpecEditorFactory(this));

            //this._documentWatcher = new XSharpDocumentWatcher(this);
            _errorList = await VS.GetRequiredServiceAsync <SVsErrorList, IErrorList>();

            _taskList = await VS.GetRequiredServiceAsync <SVsTaskList, ITaskList>();

            var shell = await VS.GetRequiredServiceAsync <SVsShell, IVsShell>();

            if (shell != null)
            {
                shell.AdviseShellPropertyChanges(this, out shellCookie);
            }
            _langservice = await GetServiceAsync(typeof(XSharpLanguageService)) as XSharpLanguageService;

            await this.RegisterCommandsAsync();
            await GetEditorOptionsAsync();
        }
Exemplo n.º 2
0
        internal async void StartLanguageService()
        {
            if (_xsLangService == null)
            {
                IServiceContainer serviceContainer = this as IServiceContainer;
                await JoinableTaskFactory.SwitchToMainThreadAsync();

                if (serviceContainer.GetService(typeof(XSharpLanguageService)) == null)
                {
                    XSharpLanguageService langService = new XSharpLanguageService(this);
                    serviceContainer.AddService(typeof(XSharpLanguageService),
                                                langService,
                                                true);
                }
                _xsLangService = GetService(typeof(XSharpLanguageService)) as Microsoft.VisualStudio.Package.LanguageService;
            }
        }
 internal void StartLanguageService()
 {
     if (_xsLangService == null)
     {
         ThreadHelper.JoinableTaskFactory.Run(async delegate()
         {
             var temp = await GetServiceAsync(typeof(XSharpLanguageService));
             if (temp == null)
             {
                 XSharpLanguageService langService = new XSharpLanguageService(this);
                 var serviceContainer = (IServiceContainer)this;
                 serviceContainer.AddService(typeof(XSharpLanguageService), langService, true);
             }
             _xsLangService = await GetServiceAsync(typeof(XSharpLanguageService)) as Microsoft.VisualStudio.Package.LanguageService;
         });
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            // Suspend walking until Solution is opened.
            base.SolutionListeners.Add(new ModelScannerEvents(this));
            base.Initialize();
            XSharpProjectPackage.instance      = this;
            XSharpModel.XSolution.OutputWindow = this;
            this.RegisterProjectFactory(new XSharpProjectFactory(this));
            this.settings = new XPackageSettings(this);
            validateVulcanEditors();
            this.RegisterDebuggerEvents();
            // Indicate how to open the different source files : SourceCode or Designer ??
            this.RegisterEditorFactory(new XSharpEditorFactory(this));
            this.RegisterProjectFactory(new XSharpWPFProjectFactory(this));

            // editors for the binaries
            base.RegisterEditorFactory(new VOFormEditorFactory(this));
            base.RegisterEditorFactory(new VOMenuEditorFactory(this));
            base.RegisterEditorFactory(new VODBServerEditorFactory(this));
            base.RegisterEditorFactory(new VOFieldSpecEditorFactory(this));
            // Register the language service

            // Proffer the service.
            IServiceContainer     serviceContainer = this as IServiceContainer;
            XSharpLanguageService langService      = new XSharpLanguageService();

            langService.SetSite(this);
            serviceContainer.AddService(typeof(XSharpLanguageService),
                                        langService,
                                        true);

            // Register a timer to call our language service during
            // idle periods.
            IOleComponentManager mgr = GetService(typeof(SOleComponentManager))
                                       as IOleComponentManager;

            if (m_componentID == 0 && mgr != null)
            {
                OLECRINFO[] crinfo = new OLECRINFO[1];
                crinfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO));
                crinfo[0].grfcrf = (uint)_OLECRF.olecrfNeedIdleTime |
                                   (uint)_OLECRF.olecrfNeedPeriodicIdleTime;
                crinfo[0].grfcadvf = (uint)_OLECADVF.olecadvfModal |
                                     (uint)_OLECADVF.olecadvfRedrawOff |
                                     (uint)_OLECADVF.olecadvfWarningsOff;
                crinfo[0].uIdleTimeInterval = 1000;
                int hr = mgr.FRegisterComponent(this, crinfo, out m_componentID);
            }
            // Initialize Custom Menu Items
            XSharp.Project.XSharpMenuItems.Initialize(this);
            // register property changed event handler
            var shell = this.GetService(typeof(SVsShell)) as IVsShell;

            shell.AdviseShellPropertyChanges(this, out shellCookie);
            //
            // LibraryManager : Offers Object Browser and ClassView
            // ObjectBrowser : Add the LibraryManager service as a Service provided by that container
            IServiceContainer      container = this as IServiceContainer;
            ServiceCreatorCallback callback  = new ServiceCreatorCallback(CreateService);

            //
            container.AddService(typeof(IXSharpLibraryManager), callback, true);
            this._documentWatcher = new XSharpDocumentWatcher(this);
        }