/// <include file='doc\ViewFilter.uex' path='docs/doc[@for="ViewFilter.ExecCommand"]/*' /> /// <summary> /// Override this method to intercept the IOleCommandTarget::Exec call. /// </summary> /// <returns>Usually returns 0 if ok, or OLECMDERR_E_NOTSUPPORTED</returns> protected virtual int ExecCommand(ref Guid guidCmdGroup, uint nCmdId, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) { int rc = 0; if (this.IsExpansionUIActive) { // Pass it along to the expansion UI picker. return(this.nextTarget.Exec(ref guidCmdGroup, nCmdId, nCmdexecopt, pvaIn, pvaOut)); } ExpansionProvider ep = GetExpansionProvider(); if (ep != null && ep.InTemplateEditingMode) { if (ep.HandlePreExec(ref guidCmdGroup, nCmdId, nCmdexecopt, pvaIn, pvaOut)) { return(rc); } } if (!HandlePreExec(ref guidCmdGroup, nCmdId, nCmdexecopt, pvaIn, pvaOut)) { // Pass it along the chain. rc = this.nextTarget.Exec(ref guidCmdGroup, nCmdId, nCmdexecopt, pvaIn, pvaOut); // See if completion set just completed, so we can do auto-completion synchronously. CompletionSet cset = this.source.CompletionSet; if (cset != null && cset.IsCommitted) { OnAutoComplete(); if (this.autoCompletedNothing && this.wasCompletionActive && guidCmdGroup == VsMenus.guidStandardCommandSet2K && nCmdId == (uint)VsCommands2K.RETURN) { // This happens if the user typed ENTER while the CompletionSet was active, // but selected nothing from the list. In this case the ENTER key was gobbled up // by the CompletionSet, and we want the ENTER key inserted into the buffer instead. this.wasCompletionActive = false; this.nextTarget.Exec(ref guidCmdGroup, nCmdId, nCmdexecopt, pvaIn, pvaOut); } } if (ep != null && ep.InTemplateEditingMode) { if (ep.HandlePostExec(ref guidCmdGroup, nCmdId, nCmdexecopt, gotEnterKey, pvaIn, pvaOut)) { return(rc); } } HandlePostExec(ref guidCmdGroup, nCmdId, nCmdexecopt, pvaIn, pvaOut); } return(rc); }
/// <include file='doc\ExpansionProvider.uex' path='docs/doc[@for="DefaultFieldValue.GetSelection"]/*' /> public TextSpan GetSelection() { TextSpan result = new TextSpan(); ExpansionProvider provider = this.ExpansionProvider; if (provider != null && provider.TextView != null) { NativeMethods.ThrowOnFailure(provider.TextView.GetSelection(out result.iStartLine, out result.iStartIndex, out result.iEndLine, out result.iEndIndex)); } return(result); }
/// <include file='doc\LanguageService.uex' path='docs/doc[@for="LanguageService.CreateExpansionFunction"]/*' /> /// If the functionName is supported, return a new IVsExpansionFunction object. public virtual ExpansionFunction CreateExpansionFunction(ExpansionProvider provider, string functionName) { return null; }
public NemerleGetNameExpansionFunction(ExpansionProvider provider, int counter) : base(provider) { nameCount = counter; }
public override ExpansionFunction CreateExpansionFunction(ExpansionProvider provider, string functionName) { ExpansionFunction function = null; if (functionName == "GetName") { ++classNameCounter; function = new NemerleGetNameExpansionFunction(provider, classNameCounter); } return function; }
public ToCommandCaseExpansionFunction(ExpansionProvider provider) : base(provider) {}
/// <include file='doc\ExpansionProvider.uex' path='docs/doc[@for="ExpansionFunction.ReleaseFunction"]/*' /> public virtual int ReleaseFunction() { this.provider = null; return NativeMethods.S_OK; }
/// <include file='doc\ExpansionProvider.uex' path='docs/doc[@for="ExpansionFunction.ExpansionFunction2"]/*' /> public ExpansionFunction(ExpansionProvider provider) { this.provider = provider; }
/// <include file='doc\ExpansionProvider.uex' path='docs/doc[@for="ExpansionFunction.ReleaseFunction"]/*' /> public virtual int ReleaseFunction() { this.provider = null; return(NativeMethods.S_OK); }
/// <include file='doc\Source.uex' path='docs/doc[@for="Source.GetExpansionProvider"]/*' /> public virtual ExpansionProvider GetExpansionProvider() { if (this.expansionProvider == null && this.service != null) { this.expansionProvider = this.service.CreateExpansionProvider(this); } return this.expansionProvider; }
/// <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) { } }
/// <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; }
/// <include file='doc\ViewFilter.uex' path='docs/doc[@for="ViewFilter.QueryCommandStatus"]/*' /> /// <summary> /// Override this method to intercept the IOleCommandTarget::QueryStatus call. /// </summary> /// <param name="guidCmdGroup"></param> /// <param name="cmd"></param> /// <param name="pCmdText">null if info not required by caller</param> /// <returns>Usually returns a combination of OLECMDF flags, for example /// OLECMDF_ENABLED | OLECMDF_SUPPORTED. /// Return E_FAIL if want to delegate to the next command target. /// </returns> protected virtual int QueryCommandStatus(ref Guid guidCmdGroup, uint nCmdId) { ExpansionProvider ep = GetExpansionProvider(); if (ep != null && ep.InTemplateEditingMode) { int hr = 0; if (ep.HandleQueryStatus(ref guidCmdGroup, nCmdId, out hr)) { return(hr); } } if (guidCmdGroup == VsMenus.guidStandardCommandSet97) { VsCommands cmd = (VsCommands)nCmdId; switch (cmd) { case VsCommands.GotoDefn: case VsCommands.GotoDecl: case VsCommands.GotoRef: return((int)OLECMDF.OLECMDF_SUPPORTED | (int)OLECMDF.OLECMDF_ENABLED); } } else if (guidCmdGroup == VsMenus.guidStandardCommandSet2K) { VsCommands2K cmd = (VsCommands2K)nCmdId; switch (cmd) { case VsCommands2K.FORMATDOCUMENT: if (this.CanReformat()) { return((int)OLECMDF.OLECMDF_SUPPORTED | (int)OLECMDF.OLECMDF_ENABLED); } break; case VsCommands2K.FORMATSELECTION: if (this.CanReformat()) { return((int)OLECMDF.OLECMDF_SUPPORTED | (int)OLECMDF.OLECMDF_ENABLED); } break; case VsCommands2K.COMMENT_BLOCK: case VsCommands2K.UNCOMMENT_BLOCK: if (this.commentSupported) { return((int)OLECMDF.OLECMDF_SUPPORTED | (int)OLECMDF.OLECMDF_ENABLED); } break; case VsCommands2K.SHOWMEMBERLIST: case VsCommands2K.COMPLETEWORD: case VsCommands2K.PARAMINFO: return((int)OLECMDF.OLECMDF_SUPPORTED | (int)OLECMDF.OLECMDF_ENABLED); case VsCommands2K.QUICKINFO: if (this.service.Preferences.EnableQuickInfo) { return((int)OLECMDF.OLECMDF_SUPPORTED | (int)OLECMDF.OLECMDF_ENABLED); } break; // case VsCommands2K.HANDLEIMEMESSAGE: // return 0; // Let the core editor handle this. Stop outlining also removes user // defined hidden sections so it is handy to keep this enabled. // case VsCommands2K.OUTLN_STOP_HIDING_ALL: // int rc = (int)OLECMDF.OLECMDF_SUPPORTED; // if (this.source.OutliningEnabled) { // rc |= (int)OLECMDF.OLECMDF_ENABLED; // } // return rc; case VsCommands2K.OUTLN_START_AUTOHIDING: if (!this.source.OutliningEnabled) { return((int)OLECMDF.OLECMDF_SUPPORTED | (int)OLECMDF.OLECMDF_ENABLED); } break; case VsCommands2K.AUTOCOMPLETE: return((int)OLECMDF.OLECMDF_SUPPORTED | (int)OLECMDF.OLECMDF_ENABLED); } } else if (guidCmdGroup == typeof(LanguageServiceCommands).GUID) { switch ((LanguageServiceCommands)nCmdId) { case LanguageServiceCommands.RunTasks: return((int)OLECMDF.OLECMDF_SUPPORTED | (int)OLECMDF.OLECMDF_ENABLED); } } return((int)NativeMethods.E_FAIL); // delegate to next command target. }
public override ExpansionFunction CreateExpansionFunction( ExpansionProvider provider, string functionName) { if (functionName == "ToCommandCase") { return new ToCommandCaseExpansionFunction(provider); } return base.CreateExpansionFunction(provider, functionName); }