当前位置: 首页>>代码示例>>C#>>正文


C# ISignatureHelpSession.GetTriggerPoint方法代码示例

本文整理汇总了C#中ISignatureHelpSession.GetTriggerPoint方法的典型用法代码示例。如果您正苦于以下问题:C# ISignatureHelpSession.GetTriggerPoint方法的具体用法?C# ISignatureHelpSession.GetTriggerPoint怎么用?C# ISignatureHelpSession.GetTriggerPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ISignatureHelpSession的用法示例。


在下文中一共展示了ISignatureHelpSession.GetTriggerPoint方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AugmentSignatureHelpSession

        public void AugmentSignatureHelpSession(ISignatureHelpSession session, IList<ISignature> signatures)
        {
            SnapshotPoint? point = session.GetTriggerPoint(_buffer.CurrentSnapshot);
            if (!point.HasValue)
                return;

            CssEditorDocument document = CssEditorDocument.FromTextBuffer(_buffer);
            ParseItem item = document.StyleSheet.ItemBeforePosition(point.Value.Position);

            if (item == null)
                return;

            Declaration dec = item.FindType<Declaration>();
            if (dec == null || dec.PropertyName == null || dec.Colon == null)
                return;

            var span = _buffer.CurrentSnapshot.CreateTrackingSpan(dec.Colon.Start, dec.Length - dec.PropertyName.Length, SpanTrackingMode.EdgeNegative);

            ValueOrderFactory.AddSignatures method = ValueOrderFactory.GetMethod(dec);

            if (method != null)
            {
                signatures.Clear();
                method(session, signatures, dec, span);

                Dispatcher.CurrentDispatcher.BeginInvoke(
                    new Action(() => {
                        session.Properties.AddProperty("dec", dec);
                        session.Match();
                    }),
                    DispatcherPriority.Normal, null);
            }
        }
开发者ID:joeriks,项目名称:WebEssentials2013,代码行数:33,代码来源:ValueOrderSignatureHelpSource.cs

示例2: AugmentSignatureHelpSession

        public void AugmentSignatureHelpSession(ISignatureHelpSession session, IList<ISignature> signatures)
        {
            if (!session.TextView.Properties.ContainsProperty(SessionKey))
            {
                return;
            }

            // At the moment there is a bug in the javascript provider which causes it to
            // repeatedly insert the same Signature values into an ISignatureHelpSession
            // instance.  There is no way, other than reflection, for us to prevent this
            // from happening.  Instead we just ensure that our provider runs after
            // Javascript and then remove the values they add here
            signatures.Clear();

            // Map the trigger point down to our buffer.
            var subjectTriggerPoint = session.GetTriggerPoint(subjectBuffer.CurrentSnapshot);
            if (!subjectTriggerPoint.HasValue)
            {
                return;
            }

            var currentSnapshot = subjectTriggerPoint.Value.Snapshot;
            var querySpan = new SnapshotSpan(subjectTriggerPoint.Value, 0);
            var applicableToSpan = currentSnapshot.CreateTrackingSpan(
                querySpan.Start.Position,
                0,
                SpanTrackingMode.EdgeInclusive);

            string encouragement = encouragements.GetRandomEncouragement();
            if (encouragement != null)
            {
                var signature = new Signature(applicableToSpan, encouragement, "", "");
                signatures.Add(signature);
            }
        }
开发者ID:RC1140,项目名称:Encourage,代码行数:35,代码来源:EncourageSignatureHelpSource.cs

示例3: AugmentSignatureHelpSession

            public void AugmentSignatureHelpSession(ISignatureHelpSession session, IList<ISignature> signatures)
            {
                ITextSnapshot snapshot = _textBuffer.CurrentSnapshot;

                // trigger point
                SnapshotPoint? point = session.GetTriggerPoint(snapshot);
                if (point == null)
                    return;

                // get syntax tree
                SyntaxTree syntaxTree = snapshot.GetSyntaxTree();
                var root = syntaxTree.Root as RobotsTxtDocumentSyntax;

                // find line in syntax tree
                ITextSnapshotLine line = point.Value.GetContainingLine();
                RobotsTxtLineSyntax lineSyntax = root.Records.SelectMany(r => r.Lines)
                    .Where(l => !l.NameToken.IsMissing && !l.DelimiterToken.IsMissing)
                    .FirstOrDefault(l => l.Span.IntersectsWith(line.Extent));

                // found
                if (lineSyntax != null)
                {
                    if (lineSyntax.DelimiterToken.Span.Span.End <= point.Value)
                    {
                        // get semantic model
                        ISemanticModel model = syntaxTree.GetSemanticModel();

                        // add signature
                        signatures.Add(new RobotsTxtSignature(model, lineSyntax));
                    }
                }
            }
开发者ID:peterwie,项目名称:RobotsTxtLanguageService,代码行数:32,代码来源:RobotsTxtSignatureHelpSource.cs

示例4: AugmentSignatureHelpSession

        public void AugmentSignatureHelpSession(ISignatureHelpSession session, IList<ISignature> signatures)
        {
            SnapshotPoint? point = session.GetTriggerPoint(_buffer.CurrentSnapshot);
            if (!point.HasValue)
                return;

            CssEditorDocument document = CssEditorDocument.FromTextBuffer(_buffer);
            ParseItem item = document.StyleSheet.ItemBeforePosition(point.Value.Position);

            if (item == null)
                return;

            Declaration dec = item.FindType<Declaration>();
            if (dec == null || dec.PropertyName == null || dec.Colon == null)
                return;

            foreach (ISignature signature in signatures)
            {
                if (signature is ValueOrderSignature)
                {
                    signatures.RemoveAt(signatures.Count - 1);
                    break;
                }
            }
        }
开发者ID:LogoPhonix,项目名称:WebEssentials2012,代码行数:25,代码来源:RemoveCssSignatureHelpSource.cs

示例5: CollectSignatureLists

        public async System.Threading.Tasks.Task CollectSignatureLists(ISignatureHelpSession newSession)
        {
            JavaEditor javaEditor = null;
            if (TextBuffer.Properties.TryGetProperty<JavaEditor>(typeof(JavaEditor), out javaEditor) &&
                javaEditor.TypeRootIdentifier != null)
            {
                var textReader = new TextSnapshotToTextReader(TextBuffer.CurrentSnapshot) as TextReader;
                var position = newSession.GetTriggerPoint(TextBuffer).GetPosition(TextBuffer.CurrentSnapshot);
                var paramHelpRequest = ProtocolHandlers.CreateParamHelpRequest(
                    textReader,
                    javaEditor.TypeRootIdentifier,
                    position);
                var paramHelpResponse = await javaEditor.JavaPkgServer.Send(javaEditor, paramHelpRequest);

                if (paramHelpResponse.responseType == Protocol.Response.ResponseType.ParamHelp &&
                    paramHelpResponse.paramHelpResponse != null)
                {
                    if (paramHelpResponse.paramHelpResponse.status && paramHelpResponse.paramHelpResponse.signatures.Count != 0)
                    {
                        var applicableTo = TextBuffer.CurrentSnapshot.CreateTrackingSpan(new Span(paramHelpResponse.paramHelpResponse.scopeStart, paramHelpResponse.paramHelpResponse.scopeLength), SpanTrackingMode.EdgeInclusive, 0);
                        int selectedParameterIndex = paramHelpResponse.paramHelpResponse.paramCount;
                        Signatures = TransformSignatures(TextBuffer, paramHelpResponse.paramHelpResponse.signatures, applicableTo, selectedParameterIndex); 
                    }
                }
            }
        }
开发者ID:XewTurquish,项目名称:vsminecraft,代码行数:26,代码来源:JavaSignatureHelp.cs

示例6: AugmentSignatureHelpSession

        public void AugmentSignatureHelpSession(ISignatureHelpSession session, IList<ISignature> signatures)
        {
            if (!session.TextView.Properties.ContainsProperty(SessionKey))
            {
                return;
            }

            // Map the trigger point down to our buffer.
            var subjectTriggerPoint = session.GetTriggerPoint(subjectBuffer.CurrentSnapshot);
            if (!subjectTriggerPoint.HasValue)
            {
                return;
            }

            var currentSnapshot = subjectTriggerPoint.Value.Snapshot;
            var querySpan = new SnapshotSpan(subjectTriggerPoint.Value, 0);
            var applicableToSpan = currentSnapshot.CreateTrackingSpan(
                querySpan.Start.Position,
                0,
                SpanTrackingMode.EdgeInclusive);

            string encouragement = encouragements.GetRandomEncouragement();
            var signature = new Signature(applicableToSpan, encouragement, "", "");
            signatures.Add(signature);
        }
开发者ID:jeremyiverson,项目名称:Encourage,代码行数:25,代码来源:EncourageSignatureHelpSource.cs

示例7: AugmentSignatureHelpSession

        public void AugmentSignatureHelpSession(ISignatureHelpSession session, IList<ISignature> signatures)
        {
            ITextSnapshot currentSnapshot = _textBuffer.CurrentSnapshot;
            int currentPosition = session.GetTriggerPoint(_textBuffer).GetPosition(currentSnapshot);
            ITrackingSpan currentApplicableSpan = currentSnapshot.CreateTrackingSpan(new Span(currentPosition, 0), SpanTrackingMode.EdgeInclusive, TrackingFidelityMode.Forward);

            signatures.Add(CreateSignature(_textBuffer, "<content name=\"namedContentArea\" />", "Spools all output in the content element into a named text writer", currentApplicableSpan));
            signatures.Add(CreateSignature(_textBuffer, "<content var=\"variable\" />", "Spools all output into a temporary text writer", currentApplicableSpan));
            signatures.Add(CreateSignature(_textBuffer, "<content def=\"variable\" />", "Spools all output into a temporary text writer (same as 'var')", currentApplicableSpan));
            signatures.Add(CreateSignature(_textBuffer, "<default x=\"xValue\" y=\"yValue\" />", "Declares local variables if a symbol of a given name is not known to be in scope", currentApplicableSpan));
        }
开发者ID:aloker,项目名称:spark,代码行数:11,代码来源:SparkSignatureHelpSource.cs

示例8: AugmentSignatureHelpSession

        public bool AugmentSignatureHelpSession(ISignatureHelpSession session, IList<ISignature> signatures, AstRoot ast, Action<object, string> triggerSession) {
            ITextSnapshot snapshot = _textBuffer.CurrentSnapshot;
            int position = session.GetTriggerPoint(_textBuffer).GetPosition(snapshot);

            // Retrieve parameter positions from the current text buffer snapshot
            ParameterInfo parametersInfo = SignatureHelp.GetParametersInfoFromBuffer(ast, snapshot, position);
            if (parametersInfo != null) {
                position = Math.Min(parametersInfo.SignatureEnd, position);
                int start = Math.Min(position, snapshot.Length);
                int end = Math.Min(parametersInfo.SignatureEnd, snapshot.Length);

                ITrackingSpan applicableToSpan = snapshot.CreateTrackingSpan(Span.FromBounds(start, end), SpanTrackingMode.EdgeInclusive);
                IFunctionInfo functionInfo = null;

                // First try user-defined function
                functionInfo = ast.GetUserFunctionInfo(parametersInfo.FunctionName, position);
                if (functionInfo == null) {
                    var functionIndex = _shell.ExportProvider.GetExportedValue<IFunctionIndex>();
                    // Then try package functions
                    var packageName = _packageName;
                    _packageName = null;
                    // Get collection of function signatures from documentation (parsed RD file)
                    functionInfo = functionIndex.GetFunctionInfo(parametersInfo.FunctionName, packageName, triggerSession, session);
                }

                if (functionInfo != null && functionInfo.Signatures != null) {
                    foreach (ISignatureInfo signatureInfo in functionInfo.Signatures) {
                        ISignature signature = CreateSignature(session, parametersInfo.FunctionName, functionInfo, signatureInfo, applicableToSpan, ast, position);
                        signatures.Add(signature);
                    }

                    session.Properties["functionInfo"] = functionInfo;
                    return true;
                }
            }

            return false;
        }
开发者ID:Microsoft,项目名称:RTVS,代码行数:38,代码来源:SignatureHelpSource.cs

示例9: AugmentSignatureHelpSession

    public void AugmentSignatureHelpSession(ISignatureHelpSession session, IList<ISignature> signatures) {
      VSServiceProvider.Current.Logger.PublicEntry(() => {

        //Record our start time for preformance considerations
        var startTime = DateTime.Now;

        //Do we have signatures?
        if (signatures == null || signatures.Count < 1)
          return;

        //Do we have a well-formed session?
        if (session == null || session.TextView == null || session.TextView.TextBuffer == null)
          return;
        
        //Can we get our trigger point?
        var triggerPoint = session.GetTriggerPoint(_textBuffer);
        if (triggerPoint == null)
          return;

        //Can we get our snapshot?
        var workingSnapshot = _textBuffer.CurrentSnapshot;
        if (workingSnapshot == null)
          return;

        //Can we get our SourceFile?
        var sourceFile = _textViewTracker.LatestSourceFile;
        if (sourceFile == null)
          return;

        //Can we get our ParseTree?
        var parseTree = sourceFile.GetParseTree();
        if (parseTree == null)
          return;

        //Can we get our compilation?
        var comp = _textViewTracker.LatestCompilation;
        if (comp == null)
          return;

        //Is the model ready?
        if (!VSServiceProvider.IsModelReady(parseTree) || _textViewTracker.IsLatestCompilationStale || _textViewTracker.IsLatestSourceFileStale) {

          //Ask for a new model
          VSServiceProvider.Current.AskForNewVSModel();

          //Return a message saying we aren't ready yet
          VSServiceProvider.Current.Logger.WriteToLog("The VS model is out of date! Aborting contract lookup.");
          return;//"(VS isn't ready for possible contract lookup yet. Please try again in a few seconds.)";
        }

        string[] contractContents = null;

        //Proceed cautiously
        try
        {

            //Can we get a call node?
            var callNode = IntellisenseContractsHelper.GetAnyCallNodeAboveTriggerPoint(triggerPoint, workingSnapshot, parseTree);
            if (callNode == null || comp == null || sourceFile == null)
                return;

            //Can we get our semantic member?
            var semanticMember = IntellisenseContractsHelper.GetSemanticMember(callNode, comp, sourceFile);
            if (semanticMember == null)
                return;

            var declType = semanticMember.ContainingType;
            // find all members of the same name (virt/non-virt)

            var overloads = GetSignatureOverloads(declType, signatures, semanticMember);

            contractContents = GetContractsForOverloads(overloads);


            //Give up on our contracts if we get an exception
        }
        catch (IllFormedSemanticModelException)
        {
            return;
        }
        catch (InvalidOperationException e)
        {
            if (!e.Message.Contains(VSServiceProvider.InvalidOperationExceptionMessage_TheSnapshotIsOutOfDate))
                throw e;
            else
            {
                this._textViewTracker.IsLatestCompilationStale = true;
                return;
            }
        }
        catch (System.Runtime.InteropServices.COMException)
        {
          // various reasons for COMException
          // - binding failed
          // - project unavailable
          // - ...
          return;
        }

        //Enumerate the signatures and append our custom content
//.........这里部分代码省略.........
开发者ID:nbulp,项目名称:CodeContracts,代码行数:101,代码来源:SignatureHelp.cs

示例10: AugmentSignatureHelpSession

        public void AugmentSignatureHelpSession(ISignatureHelpSession session, IList<ISignature> signatures)
        {
            ITextSnapshot snapshot = this.textBuffer.CurrentSnapshot;
            int position = session.GetTriggerPoint(this.textBuffer).GetPosition(snapshot);

            ITrackingSpan applicableToSpan = this.textBuffer.CurrentSnapshot.CreateTrackingSpan(
             new Span(position, 0), SpanTrackingMode.EdgeInclusive, 0);

            SnapshotPoint? sp = session.GetTriggerPoint(snapshot);
            if (!sp.HasValue)
            {
                return;
            }

            string word = navigator.GetExtentOfWord(sp.Value - 1).Span.GetText().Trim();
            ShaderlabDataManager.Instance.HLSLCGFunctions.ForEach(f =>
                {
                    foreach (var item in f.Synopsis)
                    {
                        if (f.Name.Equals(word))
                        {
                            signatures.Add(CreateSignature(this.textBuffer, item, f.Description, applicableToSpan));
                        }
                    }
                });

            ShaderlabDataManager.Instance.UnityBuiltinFunctions.ForEach(f =>
                {
                    foreach (var item in f.Synopsis)
                    {
                        if (f.Name.Equals(word))
                        {
                            signatures.Add(CreateSignature(this.textBuffer, item, f.Description, applicableToSpan));
                        }
                    }
                });
        }
开发者ID:WilliamChao,项目名称:ShaderlabVS,代码行数:37,代码来源:ShaderlabSignatureHelp.cs


注:本文中的ISignatureHelpSession.GetTriggerPoint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。