Ejemplo n.º 1
0
 void IHelpService.RemoveContextAttribute(string name, string value)
 {
     if (_ServiceProvider != null)
     {
         IVsUserContext userContext = GetUserContext();
         if (userContext != null)
         {
             NativeMethods.ThrowOnFailure(userContext.RemoveAttribute(name, value));
             NotifyContextChange(userContext);
         }
     }
 }
Ejemplo n.º 2
0
        /// <include file='doc\HelpService.uex' path='docs/doc[@for="HelpService.RemoveContextAttribute"]/*' />
        /// <devdoc>
        ///     Removes a previously added context attribute.
        /// </devdoc>
        public virtual void RemoveContextAttribute(string name, string value)
        {
            if (provider == null)
            {
                return;
            }

            // First, get our context and update the attribute.
            //
            IVsUserContext cxt = GetUserContext();

            if (cxt != null)
            {
                cxt.RemoveAttribute(name, value);
                NotifyContextChange(cxt);
            }
        }
Ejemplo n.º 3
0
        /// <devdoc>
        ///     Removes a previously added context attribute.
        /// </devdoc>
        void IHelpService.RemoveContextAttribute(string name, string value)
        {
            if (provider == null)
            {
                return;
            }

            // First, get our context and update the attribute.
            //
            IVsUserContext cxt = GetUserContext();

            if (cxt != null)
            {
                NativeMethods.ThrowOnFailure(cxt.RemoveAttribute(name, value));
                NotifyContextChange(cxt);
            }
        }
Ejemplo n.º 4
0
 void IHelpService.ClearContextAttributes()
 {
     if (_Context != null)
     {
         NativeMethods.ThrowOnFailure(_Context.RemoveAttribute(null, null));
         if (_SubContextList != null)
         {
             foreach (object obj2 in _SubContextList)
             {
                 IHelpService service = obj2 as IHelpService;
                 if (service != null)
                 {
                     service.ClearContextAttributes();
                 }
             }
         }
     }
     NotifyContextChange(_Context);
 }
Ejemplo n.º 5
0
        /// <include file='doc\HelpService.uex' path='docs/doc[@for="HelpService.ClearContextAttributes"]/*' />
        /// <devdoc>
        ///     Clears all existing context attributes from the document.
        /// </devdoc>
        public virtual void ClearContextAttributes()
        {
            if (context != null)
            {
                context.RemoveAttribute(null, null);

                if (subContextList != null)
                {
                    foreach (object helpObj in subContextList)
                    {
                        if (helpObj is IHelpService)
                        {
                            ((IHelpService)helpObj).ClearContextAttributes();
                        }
                    }
                }
            }
            NotifyContextChange(context);
        }
Ejemplo n.º 6
0
        /// <devdoc>
        ///     Clears all existing context attributes from the document.
        /// </devdoc>
        void IHelpService.ClearContextAttributes()
        {
            if (context != null)
            {
                NativeMethods.ThrowOnFailure(context.RemoveAttribute(null, null));

                if (subContextList != null)
                {
                    foreach (object helpObj in subContextList)
                    {
                        if (helpObj is IHelpService)
                        {
                            ((IHelpService)helpObj).ClearContextAttributes();
                        }
                    }
                }
            }
            NotifyContextChange(context);
        }
Ejemplo n.º 7
0
        // Help for functions and keywords.  Initiated by pressing F1.
        public override void UpdateLanguageContext(LanguageContextHint hint, IVsTextLines buffer, TextSpan[] ptsSelection, IVsUserContext context)
        {
            string searchingKeyword = null;
            // Search keyword as the function that presented where cursor stays or just before it
            Source source = (Source)this.GetSource(buffer);

            Debug.Assert(ptsSelection.Length > 0);
            int line        = ptsSelection[0].iStartLine;
            int endPosition = ptsSelection[0].iEndIndex;
            var colorState  = new DaxEditor.DaxFormatter.DummyColorState();

            TokenInfo[] lineInfos = source.GetColorizer().GetLineInfo(buffer, line, colorState);
            foreach (var tokenInfo in lineInfos)
            {
                if (!(tokenInfo.Type == TokenType.Identifier || tokenInfo.Type == TokenType.Keyword))
                {
                    continue;
                }
                var span = new TextSpan();
                span.iStartLine  = line;
                span.iEndLine    = line;
                span.iStartIndex = tokenInfo.StartIndex;
                span.iEndIndex   = tokenInfo.EndIndex + 1;

                searchingKeyword = source.GetText(span);

                if (span.iEndIndex >= endPosition)
                {
                    break;
                }
            }

            if (!string.IsNullOrEmpty(searchingKeyword))
            {
                ErrorHandler.ThrowOnFailure(context.RemoveAttribute(null, null));
                ErrorHandler.ThrowOnFailure(context.AddAttribute(VSUSERCONTEXTATTRIBUTEUSAGE.VSUC_Usage_Lookup, "keyword", "SQL11.AS.DAXREF." + searchingKeyword + ".F1"));
            }
        }
Ejemplo n.º 8
0
        internal virtual int UpdateLanguageContext(LanguageContextHint hint, IVsTextLines buffer, TextSpan[] ptsSelection, IVsUserContext context)
        {
            // From the docs: Any failure code: means the implementer is "passing" on this opportunity to provide context and the text editor will fall back to other mechanisms.
            if (ptsSelection == null || ptsSelection.Length != 1) return NativeMethods.E_FAIL;
            context.RemoveAttribute(null, null);
            TextSpan span = ptsSelection[0];
            IVsTextLines lastActiveBuffer;
            IVsTextView lastAciveView = this.LastActiveTextView;
            if (lastActiveView == null) return NativeMethods.E_FAIL;
            NativeMethods.ThrowOnFailure(lastActiveView.GetBuffer(out lastActiveBuffer));
            if (lastActiveBuffer != buffer) return NativeMethods.E_FAIL;
            ISource source = GetSource(buffer);
            if (source == null) return NativeMethods.E_FAIL;

            var req = source.BeginBackgroundRequest(span.iStartLine, span.iStartIndex, new TokenInfo(), BackgroundRequestReason.FullTypeCheck, lastActiveView, RequireFreshResults.No, new BackgroundRequestResultHandler(this.HandleUpdateLanguageContextResponse));

            if (req == null || req.Result == null) return NativeMethods.E_FAIL;

            if ((req.IsSynchronous ||
                    ((req.Result != null) && req.Result.TryWaitForBackgroundRequestCompletion(1000))))
            {
                if (req.IsAborted) return NativeMethods.E_FAIL;
                if (req.ResultScope != null)
                {
                    req.ResultScope.GetF1KeywordString(span, context);
                    return NativeMethods.S_OK;
                }
            }
            else // result is asynchronous and have not completed within 1000 ms
            {
                context.AddAttribute(VSUSERCONTEXTATTRIBUTEUSAGE.VSUC_Usage_Filter, "devlang", "fsharp");
                context.AddAttribute(VSUSERCONTEXTATTRIBUTEUSAGE.VSUC_Usage_LookupF1_CaseSensitive, "keyword", "fsharp.typechecking.incomplete");
                return NativeMethods.S_OK;
            }
            return NativeMethods.E_FAIL;

        }