/*[Category("Language")]
         * [LocDisplayName("Squirrel Studio Version")]
         * [ReadOnly(true)]
         * public string SquirrelStudioVersion
         * {
         *  get { return squirrelStudioVersion; }
         *  set { squirrelStudioVersion = value; }
         * }*/
        protected override void OnApply(DialogPage.PageApplyEventArgs e)
        {
            base.OnApply(e);
            SQLanguageService ls = (SQLanguageService)GetService(typeof(SQLanguageService));

            ls.ReloadSettings();
        }
예제 #2
0
        public void RegisterHierarchy(IVsHierarchy hierarchy)
        {
            if ((null == hierarchy) || hierarchies.ContainsKey(hierarchy))
            {
                return;
            }
            if (0 == objectManagerCookie)
            {
                IVsObjectManager2 objManager = provider.GetService(typeof(SVsObjectManager)) as IVsObjectManager2;
                if (null == objManager)
                {
                    return;
                }
                Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(
                    objManager.RegisterSimpleLibrary(library, out objectManagerCookie));
            }

            SQLanguageService ls       = (SQLanguageService)provider.GetService(typeof(SQLanguageService));
            HierarchyListener listener = new HierarchyListener(hierarchy, ls.GetSquirrelVersion());

            listener.OnAddItem    += new EventHandler <HierarchyEventArgs>(OnNewFile);
            listener.OnDeleteItem += new EventHandler <HierarchyEventArgs>(OnDeleteFile);
            listener.StartListening(true);
            hierarchies.Add(hierarchy, listener);
            RegisterForRDTEvents();

            parseThread = new Thread(new ThreadStart(ParseThread));
            parseThread.Start();
        }
예제 #3
0
 public SquirrelAuthoringScope(SQLanguageService ls, SquirrelVersion ver)
 {
     _ls              = ls;
     squirrelVersion  = ver;
     _targets         = null;
     _origcasetargets = null;
     _line            = 0;
     _compiler        = null; //created when needed
 }
예제 #4
0
        public SquirrelLibraryManager(IServiceProvider provider)
        {
            documents   = new Dictionary <uint, TextLineEventListener>();
            hierarchies = new Dictionary <IVsHierarchy, HierarchyListener>();
            library     = new Library(new Guid("0925166e-a743-49e2-9224-bbe206545104"));
            library.LibraryCapabilities = (_LIB_FLAGS2)_LIB_FLAGS.LF_PROJECT;

            this.provider   = provider;
            requests        = new Queue <LibraryTask>();
            requestPresent  = new ManualResetEvent(false);
            shutDownStarted = new ManualResetEvent(false);

            SQLanguageService ls = (SQLanguageService)provider.GetService(typeof(SQLanguageService));

            parser = new Parser(ls.GetSquirrelVersion(), ls.GetSquirrelParseLogging(), ls.GetWorkingDirectory());
        }
예제 #5
0
        public int OnBeforeDocumentWindowShow(uint docCookie, int fFirstShow, IVsWindowFrame pFrame)
        {
            // Check if this document is in the list of the documents.
            if (documents.ContainsKey(docCookie))
            {
                return(VSConstants.S_OK);
            }
            // Get the information about this document from the RDT.
            IVsRunningDocumentTable rdt = provider.GetService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable;

            if (null != rdt)
            {
                // Note that here we don't want to throw in case of error.
                uint         flags;
                uint         readLocks;
                uint         writeLocks;
                string       documentMoniker;
                IVsHierarchy hierarchy;
                uint         itemId;
                IntPtr       unkDocData;
                int          hr = rdt.GetDocumentInfo(docCookie, out flags, out readLocks, out writeLocks,
                                                      out documentMoniker, out hierarchy, out itemId, out unkDocData);
                try
                {
                    if (Microsoft.VisualStudio.ErrorHandler.Failed(hr) || (IntPtr.Zero == unkDocData))
                    {
                        return(VSConstants.S_OK);
                    }
                    // Check if the herarchy is one of the hierarchies this service is monitoring.
                    if (!hierarchies.ContainsKey(hierarchy))
                    {
                        // This hierarchy is not monitored, we can exit now.
                        return(VSConstants.S_OK);
                    }

                    // Check the extension of the file to see if a listener is required.
                    string extension = System.IO.Path.GetExtension(documentMoniker);
                    if (0 != string.Compare(extension, SQLanguageService.LanguageExtension, StringComparison.OrdinalIgnoreCase))
                    {
                        return(VSConstants.S_OK);
                    }

                    // Create the module id for this document.
                    ModuleId docId = new ModuleId(hierarchy, itemId);

                    // Try to get the text buffer.
                    IVsTextLines buffer = Marshal.GetObjectForIUnknown(unkDocData) as IVsTextLines;

                    // Create the listener.
                    SQLanguageService     ls       = (SQLanguageService)provider.GetService(typeof(SQLanguageService));
                    TextLineEventListener listener = new TextLineEventListener(buffer, documentMoniker, docId, ls.GetSquirrelVersion());
                    // Add the listener to the dictionary, so we will not create it anymore.
                    documents.Add(docCookie, listener);
                }
                finally
                {
                    if (IntPtr.Zero != unkDocData)
                    {
                        Marshal.Release(unkDocData);
                    }
                }
            }
            // Always return success.
            return(VSConstants.S_OK);
        }