Esempio n. 1
0
 /// <include file='doc\CodeWindowManager.uex' path='docs/doc[@for="CodeWindowManager.CodeWindowManager"]/*' />
 /// <summary>
 /// The CodeWindowManager is constructed by the base LanguageService class when VS calls
 /// the IVsLanguageInfo.GetCodeWindowManager method.  You can override CreateCodeWindowManager
 /// on your LanguageService if you want to plug in a different CodeWindowManager.
 /// </summary>
 public CodeWindowManager(LanguageService service, IVsCodeWindow codeWindow, Source source) {
     this.service = service;
     this.codeWindow = codeWindow;
     this.viewFilters = new ArrayList();
     this.source = source;
     this.properties = service.CreateDocumentProperties(this);
 }
Esempio n. 2
0
 public BooScope(LanguageService service, CompiledDocument compiledDocument, Source source, string fileName)
 {
     this.service = service;
     this.compiledDocument = compiledDocument;
     this.source = source;
     this.fileName = fileName;
 }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LuaDeclarations"/> class.
        /// </summary>
        /// <param name="languageService">The language service.</param>
        public LuaDeclarations(Microsoft.VisualStudio.Package.LanguageService languageService)
        {
            if (languageService == null)
                throw new ArgumentNullException("languageService");

            this.languageService = languageService;
        }
Esempio n. 4
0
//        private IScanner scanner;
  //      private IVsTextLines buffer;
    //    private List<TokenInfo>[] tokenList;
      //  private string savedSqlText;

        public MySqlColorizer(LanguageService service, IVsTextLines buffer, IScanner scanner)
            : base(service, buffer, scanner)
        {
            (scanner as MySqlScanner).Colorizer = this;
//            this.scanner = scanner;
  //          this.buffer = buffer;
        }
Esempio n. 5
0
        public int FDoIdle(uint grfidlef)
        {
            bool bPeriodic = (grfidlef & (uint)_OLEIDLEF.oleidlefPeriodic) != 0;

            // Use typeof(TestLanguageService) because we need to
            // reference the GUID for our language service.
            Microsoft.VisualStudio.Package.LanguageService service = GetService(typeof(XSharpLanguageService))
                                                                     as Microsoft.VisualStudio.Package.LanguageService;
            if (service != null)
            {
                service.OnIdle(bPeriodic);
            }
            if (_libraryManager != null)
            {
                _libraryManager.OnIdle();
            }

            var walker = XSharpModel.ModelWalker.GetWalker();

            if (walker != null && !walker.IsWalkerRunning && walker.HasWork)
            {
                walker.Walk();
            }
            return(0);
        }
Esempio n. 6
0
 public ViewFilter(LanguageService service, Source source, IVsTextView view){
   this.service = service;
   this.source = source;
   this.textView = view;     
   view.AddCommandFilter(this, out nextTarget);
   this.IID_IVsTextViewEvents = typeof(IVsTextViewEvents).GUID;
   this.cookie = VsShell.Connect(view, this, ref IID_IVsTextViewEvents);
 }
Esempio n. 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LuaDeclarations"/> class.
        /// </summary>
        /// <param name="languageService">The language service.</param>
        public LuaDeclarations(Microsoft.VisualStudio.Package.LanguageService languageService)
        {
            if (languageService == null)
            {
                throw new ArgumentNullException("languageService");
            }

            this.languageService = languageService;
        }
Esempio n. 8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LuaDeclarations"/> class.
        /// </summary>
        /// <param name="languageService">The language service.</param>
        /// <param name="declarations">The declarations.</param>
        public LuaDeclarations(Microsoft.VisualStudio.Package.LanguageService languageService, IEnumerable<Declaration> declarations)
        {
            if (languageService == null)
                throw new ArgumentNullException("languageService");
            if (declarations == null)
                throw new ArgumentNullException("declarations");

            this.declarations = new List<Declaration>(declarations);
            this.languageService = languageService;
        }
Esempio n. 9
0
 /// <include file='doc\ViewFilter.uex' path='docs/doc[@for="ViewFilter.ViewFilter"]/*' />
 public ViewFilter(CodeWindowManager mgr, IVsTextView view) {
     this.pvaChar = IntPtr.Zero;
     this.mgr = mgr;
     this.service = mgr.LanguageService;
     this.source = mgr.Source;
     this.commentSupported = this.service.Preferences.EnableCommenting;
     this.textView = view;
     NativeMethods.ThrowOnFailure(view.AddCommandFilter(this, out nextTarget));
     this.textViewEvents = new NativeMethods.ConnectionPointCookie(view, this, typeof(IVsTextViewEvents));
 }
Esempio n. 10
0
 public Colorizer(LanguageService languageService, IVsTextLines buffer) {
   this.languageService = languageService;  
   this.cachedLine = -1;
   string fname = null;
   uint formatIndex = 0;
   IPersistFileFormat pff = (IPersistFileFormat)buffer;
   pff.GetCurFile(out fname, out formatIndex);
   this.scanner = languageService.GetScanner(fname);
   this.buffer = buffer;
 }
Esempio n. 11
0
 /// <include file='doc\CodeWindowManager.uex' path='docs/doc[@for="CodeWindowManager.Close"]/*' />
 /// <summary>Closes all view filters, and the document properties window</summary>
 public void Close() {
     Trace.WriteLine("CodeWindowManager::Close");
     if (this.properties != null) this.properties.Close();
     CloseFilters();
     this.viewFilters = null;
     properties = null;
     service = null;
     source = null;
     this.codeWindow = null;
 }
Esempio n. 12
0
			/// <summary>
			/// Initializes a new instance of the <see cref="T:NewFactScanner"/> class.
			/// </summary>
			public FactEditorLineScanner(LanguageService service, IVsTextLines textLines)
			{
				m_LanguageService = service;
				m_TextLines = textLines;

				IMonitorSelectionService monitor = m_LanguageService.GetService(typeof(IMonitorSelectionService)) as IMonitorSelectionService;
				EventHandler<MonitorSelectionEventArgs> windowChange = new EventHandler<MonitorSelectionEventArgs>(DocumentWindowChanged);
				monitor.DocumentWindowChanged += windowChange;
				monitor.WindowChanged += windowChange;
				IORMDesignerView testView = monitor.CurrentSelectionContainer as IORMDesignerView;
				m_View = (testView != null && testView.CurrentDesigner != null) ? testView : monitor.CurrentDocumentView as IORMDesignerView;
			}
        public override bool OnSynchronizeDropdowns(
            Microsoft.VisualStudio.Package.LanguageService languageService,
            IVsTextView textView,
            int line,
            int col,
            ArrayList dropDownTypes,
            ArrayList dropDownMembers,
            ref int selectedType,
            ref int selectedMember)
        {
            if (isDirty)
            {
                isDirty = false;
                dropDownTypes.Clear();
                dropDownMembers.Clear();
                foreach (var member in barManager.GetMembersDropdown())
                {
                    dropDownMembers.Add(new DropDownMember(
                                            member.Name,
                                            member.TextSpan,
                                            member.IconId,
                                            DROPDOWNFONTATTR.FONTATTR_GRAY
                                            ));
                }

                foreach (var type in barManager.GetTypesDropdown())
                {
                    dropDownTypes.Add(
                        new DropDownMember(
                            type.Name,
                            type.TextSpan,
                            type.IconId,
                            DROPDOWNFONTATTR.FONTATTR_PLAIN));
                }
            }

            barManager.SelectCurrent(
                line,
                col,
                ref selectedType,
                ref selectedMember,
                (mIndex, attr) => {
                if (mIndex < dropDownMembers.Count)
                {
                    ((DropDownMember)dropDownMembers[mIndex]).FontAttr = attr;
                }
            });

            return(true);
        }
Esempio n. 14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LuaDeclarations"/> class.
        /// </summary>
        /// <param name="languageService">The language service.</param>
        /// <param name="declarations">The declarations.</param>
        public LuaDeclarations(Microsoft.VisualStudio.Package.LanguageService languageService, IEnumerable <Declaration> declarations)
        {
            if (languageService == null)
            {
                throw new ArgumentNullException("languageService");
            }
            if (declarations == null)
            {
                throw new ArgumentNullException("declarations");
            }

            this.declarations    = new List <Declaration>(declarations);
            this.languageService = 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;
         });
     }
 }
Esempio n. 16
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;
            }
        }
Esempio n. 17
0
 /// <include file='doc\ViewFilter.uex' path='docs/doc[@for="ViewFilter.Dispose"]/*' />
 public virtual void Dispose() {
     if (this.textView != null) {
         Marshal.ReleaseComObject(this.textView);
         this.textView = null;
     }
     this.service = null;
     if (this.nextTarget != null) {
         Marshal.ReleaseComObject(this.nextTarget);
         this.nextTarget = null;
     }
     this.textTipData = null;
     this.mgr = null;
     if (this.pvaChar != IntPtr.Zero) {
         Marshal.FreeCoTaskMem(pvaChar);
         pvaChar = IntPtr.Zero;
     }
     GC.SuppressFinalize(this);
 }
 public OsloCodeGeneratorColorizer(LanguageService svc, IVsTextLines buffer, IScanner scanner)
     : base(svc, buffer, scanner)
 {
 }
Esempio n. 19
0
    public void Close(){
      if (this.textLinesEventsCookie != 0) 
        VsShell.DisConnect(this.textLines, ref VsConstants.IID_IVsTextLinesEvents, this.textLinesEventsCookie );
      if (this.textChangeCommitEventsCookie != 0) 
        VsShell.DisConnect(this.textLines, ref VsConstants.IID_IVsFinalTextChangeCommitEvents, this.textChangeCommitEventsCookie );

#if WHIDBEY
      // release the task manager
      if (this.taskManager != null) {
        ITaskManagerFactory taskManagerFactory = (ITaskManagerFactory)service.site.GetService(typeof(ITaskManagerFactory));
        if (taskManagerFactory != null) {
          taskManagerFactory.ReleaseSharedTaskManager(this.taskManager);
        }
      }
      this.taskManager = null;
#endif

      this.statusBar = null;
      this.methodData.Close();
      this.methodData = null;
      this.completionSet.Close();
      this.completionSet = null;
      this.taskProvider.Dispose();
      this.taskProvider = null;
      this.service = null;
      this.colorizer = null;      
    }
Esempio n. 20
0
    public Source(LanguageService service, IVsTextLines textLines, Colorizer colorizer){
      this.service = service;
      this.textLines = textLines;
      this.colorizer = colorizer;
      this.taskProvider = new TaskProvider(service.site); // task list
      this.completionSet = this.GetCompletionSet();      
      this.methodData = this.GetMethodData();
      this.colorState = (IVsTextColorState)textLines;

      Guid statusBarGuid = typeof(VsShellInterop.IVsStatusbar).GUID;
      this.statusBar = (VsShellInterop.IVsStatusbar)service.site.QueryService(statusBarGuid, typeof(VsShellInterop.IVsStatusbar));
      
      this.commentInfo = new CommentInfo();
      service.GetCommentFormat(this.commentInfo);

      // track source changes
      if (service.Preferences.EnableCodeSenseFastOnLineChange){
        textChangeCommitEventsCookie = VsShell.Connect(textLines, (IVsFinalTextChangeCommitEvents)this, ref VsConstants.IID_IVsFinalTextChangeCommitEvents);
      }
      this.textLinesEventsCookie = VsShell.Connect(textLines, (IVsTextLinesEvents)this, ref VsConstants.IID_IVsTextLinesEvents);
      this.SetDirty();

#if WHIDBEY
      // create a task manager
      if (taskManager == null) {
        ITaskManagerFactory taskManagerFactory = (ITaskManagerFactory)(service.site).GetService(typeof(ITaskManagerFactory));
        if (taskManagerFactory != null) {
          taskManager = taskManagerFactory.QuerySharedTaskManager("SpecSharp", true);
        }
      }
#endif
    }
 /// <include file='doc\CodeWindowManager.uex' path='docs/doc[@for="TypeAndMemberDropdownBars.OnSynchronizeDropdowns"]/*' />
 /// <summary>
 /// This method is called to update the drop down bars to match the current contents of the text editor window. 
 /// It is called during OnIdle when the caret position changes.  You can provide new drop down members here.
 /// It is up to you to sort the ArrayLists if you want them sorted in any particular order.
 /// </summary>
 /// <param name="languageService">The language service</param>
 /// <param name="textView">The editor window</param>
 /// <param name="line">The line on which the cursor is now positioned</param>
 /// <param name="col">The column on which the cursor is now position</param>
 /// <param name="dropDownTypes">The current list of types (you can update this)</param>
 /// <param name="dropDownMembers">The current list of members (you can update this)</param>
 /// <param name="selectedType">The selected type (you can update this)</param>
 /// <param name="selectedMember">The selected member (you can update this)</param>
 /// <returns>true if something was updated</returns>
 public abstract bool OnSynchronizeDropdowns(LanguageService languageService, IVsTextView textView, int line, int col, ArrayList dropDownTypes, ArrayList dropDownMembers, ref int selectedType, ref int selectedMember);
Esempio n. 22
0
 public abstract CodeWindowManager GetCodeWindowManager(LanguageService languageService, IVsCodeWindow codeWindow, Source source);
Esempio n. 23
0
        /// <include file='doc\ViewFilter.uex' path='docs/doc[@for="ViewFilter.ViewFilter"]/*' />
        public ViewFilter(CodeWindowManager mgr, IVsTextView view)
        {
            this.pvaChar = IntPtr.Zero;
            this.mgr = mgr;
            this.service = mgr.LanguageService;
            this.source = mgr.Source;
            this.commentSupported = this.service.Preferences.EnableCommenting;
            this.textView = view;
            NativeMethods.ThrowOnFailure(view.AddCommandFilter(this, out nextTarget));

            // Register text view event handlers
            // Delegate to virtual/overridable method
            RegisterTextViewEventHandlers(view);

            if ((this.service != null) && (this.service.Site != null)) {
                IVsExpansionManager emgr = this.service.Site.GetService(typeof(SVsExpansionManager)) as IVsExpansionManager;
                if (emgr != null) {
                    int fBound;
                    emgr.GetSnippetShortCutKeybindingState(out fBound);
                    this.snippetBound = fBound == 0 ? false : true;

                    // Register expansion manager event handlers
                    // Delegate to virtual/overridable method
                    RegisterExpansionManagerEventHandlers(emgr);
                }
            }
        }
Esempio n. 24
0
 public ProjectHierarchy(LanguageService language)
 {
     this.language = language;
 }
Esempio n. 25
0
        /// <include file='doc\LanguageService.uex' path='docs/doc[@for="Source.Dispose"]/*' />
        public virtual void Dispose()
        {
            #if LANGTRACE
            Trace.WriteLine("Source::Cleanup");
            #endif
            try {
                if (this.textLinesEvents != null) {
                    this.textLinesEvents.Dispose();
                    this.textLinesEvents = null;
                }
            } catch (COMException) {
            }
            try {
                if (this.userDataEvents != null) {
                    this.userDataEvents.Dispose();
                    this.userDataEvents = null;
                }
            } catch (COMException) {
            }
            try {
                if (this.hiddenTextSession != null) {
                    // We can't throw or exit here because we need to call Dispose on the
                    // other members that need to be disposed.
                    this.hiddenTextSession.UnadviseClient();
                    this.hiddenTextSession = null;
                }
            } catch (COMException) {
            }
            try {
                if (this.methodData != null) {
                    this.methodData.Dispose();
                    this.methodData = null;
                }
            } catch (COMException) {
            }
            try {
                if (this.completionSet != null) {
                    this.completionSet.Dispose();
                    this.completionSet = null;
                }
            } catch (COMException) {
            }
            try {

                if (this.taskProvider != null) {
                    this.taskProvider.Dispose();
                    this.taskProvider = null;
                }
            } catch (COMException) {
            }
            try {
                this.service = null;
                if (this.colorizer != null) {
                    // The colorizer is owned by the core text editor, so we don't close it, the core text editor
                    // does that for us when it is ready to do so.
                    //colorizer.CloseColorizer();
                    this.colorizer = null;
                }
            } catch (COMException) {
            }
            try {
                if (this.colorState != null) {
                    this.colorState = null;
                }
            } catch (COMException) {
            }
            try {
                if (this.expansionProvider != null) {
                    this.expansionProvider.Dispose();
                    this.expansionProvider = null;
                }

            } catch (COMException) {
            }
            try {

                // Sometimes OnCloseSource is called when language service is changed, (for example
                // when you save the file with a different file extension) in which case we cannot
                // null out the site because that will cause a crash inside msenv.dll.
                //            if (this.textLines != null) {
                //                ((IObjectWithSite)this.textLines).SetSite(null);
                //            }
                if (this.textLines != null) {
                    this.textLines = null; //rely on GC rather control lifetime through ReleaseCOMObject
                    Marshal.Release(pUnkTextLines);
                }
            } catch (COMException) {
            }
        }
Esempio n. 26
0
        /// <include file='doc\Source.uex' path='docs/doc[@for="Completor.Completor"]/*' />
        public Completor(LanguageService langsvc, IVsTextView view, string description)
        {
            this.langsvc = langsvc;
            this.view = view;
            this.src = langsvc.GetSource(view);
            this.sb = new StringBuilder();
            this.caret = 0; // current position within StringBuilder.
            this.ca = CompoundActionFactory.GetCompoundAction(null, this.src, description);
            this.ca.FlushEditActions(); // make sure we see a consistent coordinate system.
            // initialize span representing what we are removing from the buffer.
            NativeMethods.ThrowOnFailure(view.GetCaretPos(out span.iStartLine, out span.iStartIndex));
            this.span.iEndLine = span.iStartLine;
            this.span.iEndIndex = span.iStartIndex;
            RefreshLine();

            macro = this.langsvc.GetIVsTextMacroHelperIfRecordingOn();
        }
Esempio n. 27
0
 /// <include file='doc\Source.uex' path='docs/doc[@for="Completor.Dispose"]/*' />
 /// <summary>This method calls Apply() if you have not already done it.</summary>
 public void Dispose()
 {
     if (this.ca != null) {
         Apply();
     }
     // DO NOT DISPOSE THE LANGUAGE SERVICE HERE -- WE DON'T OWN IT!!!
     this.langsvc = null;
     this.macro = null;
     this.view = null;
 }
Esempio n. 28
0
        public override bool OnSynchronizeDropdowns(Microsoft.VisualStudio.Package.LanguageService languageService, IVsTextView textView, int line, int col, ArrayList dropDownTypes, ArrayList dropDownMembers, ref int selectedType, ref int selectedMember)
        {
            if (isDirty)
            {
                isDirty = false;
                dropDownTypes.Clear();
                dropDownMembers.Clear();

                Source source = service.GetSource(textView);
                if (source != null)
                {
                    string           filename  = source.GetFilePath();
                    LuaFileCodeModel codeModel = service.GetFileCodeModel();
                    if (codeModel != null)
                    {
                        foreach (CodeElement elem_ in codeModel.LuaCodeElements)
                        {
                            SimpleCodeElement elem = elem_ as SimpleCodeElement;
                            if (elem != null)
                            {
                                if (elem is LuaCodeFunction)
                                {
                                    dropDownMembers.Add(new DropDownMember(
                                                            elem.FullName,
                                                            elem.GetTextSpan(),
                                                            18, // 18 for IconImageIndex.Method
                                                            DROPDOWNFONTATTR.FONTATTR_GRAY
                                                            ));
                                }
                                else
                                {
                                    dropDownTypes.Add(new DropDownMember(
                                                          elem.FullName,
                                                          elem.GetTextSpan(),
                                                          29, // 29 for IconImageIndex.Variable
                                                          DROPDOWNFONTATTR.FONTATTR_PLAIN
                                                          ));
                                }
                            }
                        }
                        // create dummy item to show as title
                        if (dropDownMembers.Count > 0)
                        {
                            dropDownMembers.Add(new DropDownMember(
                                                    String.Format("{0} function(s)", dropDownMembers.Count),
                                                    new TextSpan(),
                                                    0, // 18 for IconImageIndex.Method
                                                    DROPDOWNFONTATTR.FONTATTR_GRAY
                                                    ));
                            selectedMember = dropDownMembers.Count - 1;
                        }
                        if (dropDownTypes.Count > 0)
                        {
                            dropDownTypes.Add(new DropDownMember(
                                                  String.Format("{0} variable(s)", dropDownTypes.Count),
                                                  new TextSpan(),
                                                  0, // 29 for IconImageIndex.Variable
                                                  DROPDOWNFONTATTR.FONTATTR_GRAY
                                                  ));
                            selectedType = dropDownTypes.Count - 1;
                        }
                    }
                }
                // TODO: set current selection to selectedType and selectedMember
                // for performance reason, I did not implement it.
            }


            return(true);
        }
Esempio n. 29
0
 /// <summary>
 /// Get the XML Editor language service
 /// </summary>
 /// <returns></returns>
 LanguageService GetXmlLanguageService()
 {
     if (_xmlLanguageService == null)
     {
         IOleServiceProvider vssp = _serviceProvider.GetService(typeof(IOleServiceProvider)) as IOleServiceProvider;
         Guid xmlEditorGuid = new Guid("f6819a78-a205-47b5-be1c-675b3c7f0b8e");
         Guid iunknown = new Guid("00000000-0000-0000-C000-000000000046");
         IntPtr ptr;
         if (ErrorHandler.Succeeded(vssp.QueryService(ref xmlEditorGuid, ref iunknown, out ptr)))
         {
             try
             {
                 _xmlLanguageService = Marshal.GetObjectForIUnknown(ptr) as LanguageService;
             }
             finally
             {
                 Marshal.Release(ptr);
             }
         }
     }
     return _xmlLanguageService;
 }
Esempio n. 30
0
 public GDLColorizer(LanguageService svc, IVsTextLines buffer, IScanner scanner)
     : base(svc, buffer, scanner)
 {
     _buffer = buffer;
 }
Esempio n. 31
0
 public override bool OnSynchronizeDropdowns(VsPkg.LanguageService languageService,
                                             IVsTextView textView, int line, int col, ArrayList dropDownTypes,
                                             ArrayList dropDownMembers, ref int selectedType, ref int selectedMember)
 {
     throw new NotImplementedException("This method can't be invoked");
 }
Esempio n. 32
0
 public override Microsoft.VisualStudio.Package.CodeWindowManager GetCodeWindowManager(
     Microsoft.VisualStudio.Package.LanguageService languageService, Microsoft.VisualStudio.TextManager.Interop.IVsCodeWindow codeWindow,
     Microsoft.VisualStudio.Package.Source source)
 {
     return(new CodeWindowManager((LanguageService)languageService, codeWindow, source, glyphProvider));
 }
Esempio n. 33
0
        /// <include file='doc\Source.uex' path='docs/doc[@for="Source.Source"]/*' />
        public Source(LanguageService service, IVsTextLines textLines, Colorizer colorizer)
        {
            #if LANGTRACE
            Tracing.TraceRef(textLines, "Source.textLines");
            #endif
            this.service = service;
            this.textLines = textLines;
            pUnkTextLines = Marshal.GetIUnknownForObject(this.textLines); //so it can't get disposed on us
            this.colorizer = colorizer;
            this.dirty = true;
            this.completionSet = this.CreateCompletionSet();
            this.methodData = this.CreateMethodData();
            this.colorState = (IVsTextColorState)textLines;

            // Register text buffer (IVsTextLines) event handlers
            // Delegate to virtual/overridable method
            RegisterTextBufferEventHandlers(textLines);

            this.doOutlining = this.service.Preferences.AutoOutlining;
            if (this.doOutlining) {
                GetHiddenTextSession();
            }
            this.expansionProvider = GetExpansionProvider();

            this.lastParseTime = Int32.MaxValue;
        }
Esempio n. 34
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public XmlLanguageService(LanguageService languageService)
 {
     this.languageService = (VSXmlLanguageService) languageService;
 }
Esempio n. 35
0
 public NemerleCodeWindowManager(Microsoft.VisualStudio.Package.LanguageService service, IVsCodeWindow codeWindow, NemerleSource source)
     : base(service, codeWindow, source)
 {
     _source = source;
 }
 /// <include file='doc\CodeWindowManager.uex' path='docs/doc[@for="TypeAndMemberDropdownBars.TypeAndMemberDropdownBars"]/*' />
 protected TypeAndMemberDropdownBars(LanguageService languageService)
 {
     this.languageService = languageService;
     this.dropDownTypes = new ArrayList();
     this.dropDownMembers = new ArrayList();
 }
Esempio n. 37
0
 private void Dispose(bool disposing)
 {
     // We do not null out the scanner since we don't need to, it's a managed object, and
     // we may need it if a paint message comes in after colorizer is closed since the core
     // text editor will still call ColorizeLine in that case.  This stops the text from
     // going black when the window is closed.
     // this.scanner = null;
     this.cachedLineInfo = null;
     this.svc = null;
     this.buffer = null;
 }
Esempio n. 38
0
 public BooSource(LanguageService service, IVsTextLines textLines, Colorizer colorizer)
     : base(service, textLines, colorizer)
 {
 }
Esempio n. 39
0
 /// <include file='doc\Colorizer.uex' path='docs/doc[@for="Colorizer.Colorizer"]/*' />
 public Colorizer(LanguageService svc, IVsTextLines buffer, IScanner scanner) {
     this.cachedLine = -1;
     this.scanner = scanner;
     this.svc = svc;
     this.buffer = buffer;
 }
        public override bool OnSynchronizeDropdowns(
            Microsoft.VisualStudio.Package.LanguageService languageService,
            IVsTextView textView,
            int line,
            int col,
            ArrayList dropDownTypes,
            ArrayList dropDownMembers,
            ref int selectedType,
            ref int selectedMember)
        {
            //
            var package         = XSharp.Project.XSharpProjectPackage.Instance;
            var optionsPage     = package.GetIntellisenseOptionsPage();
            var sortItems       = optionsPage.SortNavigationBars;
            var includeFields   = optionsPage.IncludeFieldsInNavigationBars;
            var currentTypeOnly = optionsPage.ShowMembersOfCurrentTypeOnly;

            if (optionsPage.DisableEditorDropdowns)
            {
                dropDownTypes.Clear();
                dropDownMembers.Clear();
                selectedType = selectedMember = -1;
                return(true);
            }
            // when the line did not change, we do nothing for performance reasons
            // this speeds up typing  for buffers with lots of entities
            if (line == lastLine)
            {
                // same line, no changes
                return(false);
            }
            lastLine = line;

            Source src     = languageService.GetSource(textView);
            string srcFile = src.GetFilePath();
            //
            XFile file = XSolution.FindFullPath(srcFile);

            if (file == null || file.TypeList == null)
            {
                return(false);
            }
            XElement selectedElement = file.FindMemberAtRow(line);

            if (selectedElement == _lastSelected)
            {
                // Same element, no changes
                return(false);
            }
            // check if we are on the same type. When not then we need to reload the members.
            // Note that the first item in the members combo can also be a type (Classname)
            XElement parentType = null;

            if (selectedElement is XTypeMember)
            {
                parentType = selectedElement.Parent;
            }
            else if (selectedElement is XType)
            {
                parentType = selectedElement as XType;
            }
            bool newType = true;

            if (parentType != null && _lastType != null && parentType.FullName == _lastType.FullName)
            {
                newType = false;
            }
            // when we are on the same type and there are no new methods then we can
            // select the element in the members combo and we do not have to rebuild the members
            // list. We must set the selectedType and selectedMember
            if (!newType && file.ContentHashCode == _lastHashCode && lastIncludeFields == includeFields && lastCurrentTypeOnly == currentTypeOnly)
            {
                // no need to rebuild the list. Just focus to another element
                // locate item in members collection
                selectedMember = -1;
                selectedType   = -1;
                for (int i = 0; i < dropDownMembers.Count; i++)
                {
                    var member = (XDropDownMember)dropDownMembers[i];
                    if (member.Element.ComboPrototype == selectedElement.ComboPrototype)
                    {
                        selectedMember = i;
                        break;
                    }
                }
                // find the parentType in the types combo
                if (selectedMember != -1 && parentType != null) // should never be null
                {
                    for (int i = 0; i < dropDownTypes.Count; i++)
                    {
                        var member = (XDropDownMember)dropDownTypes[i];
                        var type   = member.Element as XType;
                        if (type.FullName == parentType.FullName)
                        {
                            selectedType = i;
                            break;
                        }
                    }
                }
                // normally we should always find it. But if it fails then we simply build the list below.
                if (selectedMember != -1 && selectedType != -1)
                {
                    // remember for later. No need to remember the type because it has not changed
                    _lastSelected = selectedElement;
                    return(true);
                }
            }
            dropDownTypes.Clear();
            dropDownMembers.Clear();
            int nSelType = -1;
            int nSelMbr  = -1;
            //int distanceM = int.MaxValue;
            DROPDOWNFONTATTR ft;

            //
            //
            if (file.TypeList.Count > 0)
            {
                nSelType = 0;
            }

            List <XType> xList = file.TypeList.Values.ToList <XType>();

            if (sortItems)
            {
                xList.Sort(delegate(XType elt1, XType elt2)
                {
                    return(elt1.Name.CompareTo(elt2.Name));
                });
            }
            XType typeGlobal = null;
            int   nSelect    = 0;

            XElement currentMember = null;
            XType    currentType   = null;

            if (selectedElement is XTypeMember)
            {
                currentMember = selectedElement as XTypeMember;
                currentType   = ((XTypeMember)currentMember).Parent;
            }
            else if (selectedElement is XType)
            {
                currentType   = selectedElement as XType;
                currentMember = null;
            }
            nSelect = 0;
            XDropDownMember elt;

            // C# shows all items PLAIN
            // but when the selection is not really on an item, but for example on a comment
            // between methods, or on the comments between the namespace and the first class
            // then the next method/class is selected and displayed in GRAY
            // C# also includes members (for partial classes) that are defined in other source files
            // these are colored GRAY
            foreach (XType eltType in xList)
            {
                if (eltType.Kind == Kind.Namespace)
                {
                    continue;
                }
                //
                if (XType.IsGlobalType(eltType))
                {
                    typeGlobal = eltType;
                }
                TextSpan sp = this.TextRangeToTextSpan(eltType.Range);
                ft = DROPDOWNFONTATTR.FONTATTR_PLAIN;
                string name = eltType.Name;
                if (string.IsNullOrEmpty(name))
                {
                    name = "?";
                }
                elt         = new XDropDownMember(name, sp, eltType.Glyph, ft);
                elt.Element = eltType;
                nSelect     = dropDownTypes.Add(elt);
                if (eltType?.FullName == currentType?.FullName)
                {
                    nSelType = nSelect;
                }
            }

            if (currentType == null)
            {
                currentType = typeGlobal;
            }
            bool hasPartial = false;

            if (currentType != null)    // should not happen since all files have a global type
            {
                nSelMbr = 0;
                var members = new List <XElement>();
                if (currentTypeOnly)
                {
                    if (currentType != typeGlobal && currentType.IsPartial)
                    {
                        // retrieve members from other files ?
                        var fullType = file.Project.Lookup(currentType.FullName, true);
                        hasPartial = true;
                        members.AddRange(fullType.Members);
                    }
                    else
                    {
                        members.AddRange(currentType.Members);
                    }
                }
                else
                {
                    members.AddRange(file.EntityList.Where(member => includeFields || (member.Kind != Kind.Field && member.Kind != Kind.VODefine)));
                    foreach (var ent in file.EntityList)
                    {
                        if (ent is XType)
                        {
                            var xType = ent as XType;
                            if (xType.IsPartial)
                            {
                                // load methods from other files
                                var fullType = file.Project.Lookup(xType.FullName, true);
                                hasPartial = true;
                                foreach (var member in fullType.Members)
                                {
                                    if (!members.Contains(member))
                                    {
                                        if (includeFields || (member.Kind != Kind.Field && member.Kind != Kind.VODefine))
                                        {
                                            members.Add(member);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                if (sortItems)
                {
                    members = members.OrderBy(x => x.FullName).ToList();
                }
                // Add member for class declaration. This also makes sure that there at least one
                // element in the members list, which is convenient.
                TextSpan spM = this.TextRangeToTextSpan(currentType.Range);
                ft = DROPDOWNFONTATTR.FONTATTR_PLAIN;
                if (currentTypeOnly)
                {
                    // Add a 'root' element for the type.
                    if (currentType != typeGlobal)
                    {
                        if (currentType.Kind != Kind.Delegate)
                        {
                            elt         = new XDropDownMember("(" + currentType.Name + ")", spM, currentType.Glyph, ft);
                            elt.Element = currentType;
                            dropDownMembers.Add(elt);
                        }
                    }
                    else
                    {
                        elt         = new XDropDownMember(currentType.Name, spM, currentType.Glyph, ft);
                        elt.Element = currentType;
                        dropDownMembers.Add(elt);
                    }
                }
                foreach (XElement member in members)
                {
                    bool otherFile;
                    if (includeFields || (member.Kind != Kind.Field && member.Kind != Kind.VODefine))
                    {
                        spM       = this.TextRangeToTextSpan(member.Range);
                        otherFile = false;
                        ft        = DROPDOWNFONTATTR.FONTATTR_PLAIN;
                        if (hasPartial)
                        {
                            otherFile = member.File != file;
                        }

                        string prototype = member.ComboPrototype;
                        if (!currentTypeOnly && member.Parent != null && member.Parent != typeGlobal)
                        {
                            if (member.Modifiers.HasFlag(Modifiers.Static))
                            {
                                prototype = member.Parent.Name + "." + prototype;
                            }
                            else
                            {
                                prototype = member.Parent.Name + ":" + prototype;
                            }
                        }

                        if (otherFile)
                        {
                            ft         = DROPDOWNFONTATTR.FONTATTR_GRAY;
                            prototype += " (" + System.IO.Path.GetFileName(member.File.SourcePath) + ")";
                        }
                        elt         = new XDropDownMember(prototype, spM, member.Glyph, ft);
                        nSelect     = dropDownMembers.Add(elt);
                        elt.Element = member;
                        if (member == currentMember)
                        {
                            nSelMbr = nSelect;
                        }
                    }
                }
            }
            // save the info so we can optimize the next call.
            _members            = dropDownMembers;
            _file               = file;
            _lastSelected       = selectedElement;
            _lastType           = currentType;
            _lastHashCode       = file.ContentHashCode;
            selectedType        = nSelType;
            selectedMember      = nSelMbr;
            lastIncludeFields   = includeFields;
            lastCurrentTypeOnly = currentTypeOnly;
            return(true);
        }
Esempio n. 41
0
 private void Dispose(bool disposing) {
     this.scanner = null;
     this.cachedLineInfo = null;
     this.svc = null;
     this.buffer = null;
 }