Beispiel #1
0
        private void InitializeLangPrefs()
        {
            IVsTextManager textMgr   = (IVsTextManager)Instance.GetService(typeof(SVsTextManager));
            var            langPrefs = new LANGPREFERENCES[1];

            langPrefs[0].guidLang = typeof(VSGenero4GLLanguageInfo).GUID;
            int result = textMgr.GetUserPreferences(null, null, langPrefs, null);

            _langPrefs = new Genero4GLLanguagePreferences(langPrefs[0]);

            Guid             guid = typeof(IVsTextManagerEvents2).GUID;
            IConnectionPoint connectionPoint;

            ((IConnectionPointContainer)textMgr).FindConnectionPoint(ref guid, out connectionPoint);
            uint cookie;

            connectionPoint.Advise(_langPrefs, out cookie);
        }
Beispiel #2
0
        /////////////////////////////////////////////////////////////////////////////
        // Overriden Package Implementation
        #region Package Members

        /// <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 initilaization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();
            var services = (IServiceContainer)this;

            var langService4GL = new VSGenero4GLLanguageInfo(this);

            services.AddService(langService4GL.GetType(), langService4GL, true);
            var langServicePER = new VSGeneroPERLanguageInfo(this);

            services.AddService(langServicePER.GetType(), langServicePER, true);

            services.AddService(
                typeof(ErrorTaskProvider),
                (container, serviceType) =>
            {
                var errorList     = GetService(typeof(SVsErrorList)) as IVsTaskList;
                var model         = ComponentModel;
                var errorProvider = model != null ? model.GetService <IErrorProviderFactory>() : null;
                return(new ErrorTaskProvider(this, errorList, errorProvider));
            },
                promote: true);

            services.AddService(
                typeof(CommentTaskProvider),
                (container, serviceType) =>
            {
                var taskList      = GetService(typeof(SVsTaskList)) as IVsTaskList;
                var model         = ComponentModel;
                var errorProvider = model != null ? model.GetService <IErrorProviderFactory>() : null;
                return(new CommentTaskProvider(this, taskList, errorProvider));
            },
                promote: true);

            IVsTextManager textMgr   = (IVsTextManager)Instance.GetService(typeof(SVsTextManager));
            var            langPrefs = new LANGPREFERENCES[1];

            langPrefs[0].guidLang = typeof(VSGenero4GLLanguageInfo).GUID;
            int result = textMgr.GetUserPreferences(null, null, langPrefs, null);

            _langPrefs = new Genero4GLLanguagePreferences(langPrefs[0]);

            Guid             guid = typeof(IVsTextManagerEvents2).GUID;
            IConnectionPoint connectionPoint;

            ((IConnectionPointContainer)textMgr).FindConnectionPoint(ref guid, out connectionPoint);
            uint cookie;

            connectionPoint.Advise(_langPrefs, out cookie);

            // TODO: not sure if this is needed...need to test
            DTE dte = (DTE)GetService(typeof(DTE));

            if (dte != null)
            {
                GeneroEditorFactory = new EditorFactory(this);
                this.RegisterEditorFactory(GeneroEditorFactory);
            }

            RegisterCommands(new CommonCommand[]
            {
                new ExtractSqlStatementsCommand()
            }, GuidList.guidVSGeneroCmdSet);

            var dte2 = (DTE2)Package.GetGlobalService(typeof(SDTE));
            var sp   = new ServiceProvider(dte2 as Microsoft.VisualStudio.OLE.Interop.IServiceProvider);

            try
            {
                var mefContainer = sp.GetService(typeof(Microsoft.VisualStudio.ComponentModelHost.SComponentModel))
                                   as Microsoft.VisualStudio.ComponentModelHost.IComponentModel;
                var exportSpec = mefContainer?.DefaultExportProvider.GetExport <IBuildTaskProvider>();
                if (exportSpec != null)
                {
                    _BuildTaskProvider = exportSpec.Value;
                }
                if (DefaultAnalyzer != null)
                {
                }
            }
            catch (Exception)
            { }
        }