Esempio n. 1
0
        internal static ITextBuffer GetBufferAt(string filePath, IServiceProvider provider)
        {
            //var package = (Microsoft.VisualStudio.OLE.Interop.IServiceProvider)node.GetService(typeof(EnvDTE.DTE));
            //var serviceProvider = ;//new Microsoft.VisualStudio.Shell.ServiceProvider(package);
            //ProjectItem pi = (ProjectItem)node.GetAutomationObject();

            IVsUIHierarchy uiHierarchy;
            uint           itemID;
            IVsWindowFrame windowFrame;

            if (VsShellUtilities.IsDocumentOpen(
                    provider,
                    filePath,
                    Guid.Empty,
                    out uiHierarchy,
                    out itemID,
                    out windowFrame))
            {
                IVsTextView  view = VsShellUtilities.GetTextView(windowFrame);
                IVsTextLines lines;
                if (view.GetBuffer(out lines) == 0)
                {
                    var buffer = lines as IVsTextBuffer;
                    if (buffer != null)
                    {
                        var componentModel = (IComponentModel)ProjectPackage.GetGlobalService(typeof(SComponentModel));
                        var editorAdapterFactoryService = componentModel.GetService <IVsEditorAdaptersFactoryService>();
                        return(editorAdapterFactoryService.GetDataBuffer(buffer));
                    }
                }
            }

            return(null);
        }
Esempio n. 2
0
        protected override void InitializeProjectProperties()
        {
            base.InitializeProjectProperties();
            SQLanguageServiceEX objectLibrary = (SQLanguageServiceEX)ProjectPackage.GetGlobalService(typeof(ISQLanguageService));

            objectLibrary.RegisterProjectNode(this);
        }
Esempio n. 3
0
        public override int InitializeForOuter(string filename, string location, string name, uint flags, ref Guid iid, out IntPtr projectPointer, out int canceled)
        {
            int result = base.InitializeForOuter(filename, location, name, flags, ref iid, out projectPointer, out canceled);
            SQLanguageServiceEX objectLibrary = (SQLanguageServiceEX)ProjectPackage.GetGlobalService(typeof(ISQLanguageService));

            objectLibrary.RegisterProjectNode(this);
            return(result);
        }
        public override int InitializeForOuter(string filename, string location, string name, uint flags, ref Guid iid, out IntPtr projectPointer, out int canceled)
        {
            int result = base.InitializeForOuter(filename, location, name, flags, ref iid, out projectPointer, out canceled);
            //RegisterUserProperty(GeneralPropertyPageTags.IntellisenseEnabled.ToString());
            SQLanguageServiceEX objectLibrary = (SQLanguageServiceEX)ProjectPackage.GetGlobalService(typeof(ISQLanguageService));

            return(result);
        }
        public override void OnUserPropertyLoad(string propertyname, string value)
        {
            SQLanguageServiceEX languageservice = (SQLanguageServiceEX)ProjectPackage.GetGlobalService(typeof(ISQLanguageService));

            if (propertyname == GeneralPropertyPageTags.IntellisenseEnabled.ToString())
            {
                languageservice.IntellisenseEnabled = value.ToLower() == "true";
            }
        }
Esempio n. 6
0
        private void SQVSProjectNode_OnProjectPropertyChanged(object sender, ProjectPropertyChangedArgs e)
        {
            if (e.NewValue != null)
            {
                SQLanguageServiceEX languageservice = (SQLanguageServiceEX)ProjectPackage.GetGlobalService(typeof(ISQLanguageService));

                /*if (e.PropertyName == GeneralPropertyPageTags.IntellisenseEnabled.ToString())
                 *  languageservice.IntellisenseEnabled = SQVSUtils.GetProjectPropertyBool(this, GeneralPropertyPageTags.IntellisenseEnabled.ToString());
                 * else if (e.PropertyName == GeneralPropertyPageTags.ClassViewEnabled.ToString())
                 *  languageservice.ClassViewEnabled = SQVSUtils.GetProjectPropertyBool(this, GeneralPropertyPageTags.ClassViewEnabled.ToString());*/
            }
        }
Esempio n. 7
0
        public override FileNode CreateFileNode(ProjectElement item)
        {
            SQProjectFileNode node = new SQProjectFileNode(this, item);

            node.OleServiceProvider.AddService(typeof(EnvDTE.Project), new OleServiceProvider.ServiceCreatorCallback(this.CreateServices), false);
            node.OleServiceProvider.AddService(typeof(ProjectItem), node.ServiceCreator, false);
            node.OleServiceProvider.AddService(typeof(VSProject), new OleServiceProvider.ServiceCreatorCallback(this.CreateServices), false);

            SQLanguageServiceEX objectLibrary = (SQLanguageServiceEX)ProjectPackage.GetGlobalService(typeof(ISQLanguageService));

            objectLibrary.RegisterFileNode(node);
            return(node);
        }
Esempio n. 8
0
        internal static IVsWindowFrame OpenDocumentInNewWindow(string filePath, IServiceProvider provider, int lineid = -1, int columnid = -1, int length = -1)
        {
            if (string.IsNullOrEmpty(filePath) || !File.Exists(filePath))
            {
                return(null);
            }

            IVsUIHierarchy hierarchy;
            uint           itemId;
            IVsWindowFrame frame = null;

            if (!VsShellUtilities.IsDocumentOpen(provider, filePath,
                                                 VSConstants.LOGVIEWID_Primary, out hierarchy, out itemId, out frame))
            {
                VsShellUtilities.OpenDocument(provider, filePath,
                                              VSConstants.LOGVIEWID_Primary, out hierarchy, out itemId, out frame);
            }
            if (frame != null && frame.Show() == VSConstants.S_OK && lineid != -1)
            {
                var vsTextView     = VsShellUtilities.GetTextView(frame);
                var componentModel = (IComponentModel)ProjectPackage.GetGlobalService(typeof(SComponentModel));
                var editorAdapterFactoryService = componentModel.GetService <IVsEditorAdaptersFactoryService>();
                var wpfTextView = editorAdapterFactoryService.GetWpfTextView(vsTextView);
                var p           = wpfTextView.TextSnapshot.GetLineFromLineNumber(lineid).Start;
                if (columnid > -1)
                {
                    p += columnid;
                }
                wpfTextView.Caret.MoveTo(p);
                SnapshotSpan span;
                if (length > 0)
                {
                    span = new SnapshotSpan(p, length);
                }
                else if (columnid != -1)
                {
                    var linespan = wpfTextView.TextSnapshot.GetLineFromLineNumber(lineid).End;
                    span = new SnapshotSpan(p, linespan);
                }
                else
                {
                    span = wpfTextView.TextSnapshot.GetLineFromLineNumber(lineid).Extent;
                }
                wpfTextView.Selection.Select(span, false);
                wpfTextView.Caret.EnsureVisible();
                //System.Windows.Forms.SendKeys.Send("{RIGHT}");
            }
            return(frame);
        }
Esempio n. 9
0
        internal static T GetService <T>() where T : class
        {
            T o = ProjectPackage.GetGlobalService(typeof(T)) as T;

            return(o);
        }
 protected override void InitializeProjectProperties()
 {
     base.InitializeProjectProperties();
     SQLanguageServiceEX objectLibrary = (SQLanguageServiceEX)ProjectPackage.GetGlobalService(typeof(ISQLanguageService));
     // RegisterUserProperty(GeneralPropertyPageTags.IntellisenseEnabled.ToString());
 }