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


C# ITrackingPoint.GetPosition方法代码示例

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


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

示例1: GetAnyCallNodeAboveTriggerPoint

    public static SyntaxNode GetAnyCallNodeAboveTriggerPoint(ITrackingPoint triggerPoint, ITextSnapshot snapshot, SyntaxTree parseTree) {
      Contract.Requires(snapshot != null);
      Contract.Requires(parseTree != null);
      Contract.Requires(triggerPoint != null);

      SyntaxNode syntaxRoot;
      if (!parseTree.TryGetRoot(out syntaxRoot))
        return null;

      var leafNode = syntaxRoot.FindToken(triggerPoint.GetPosition(snapshot), false);
      if (leafNode.IsKind(SyntaxKind.None))
        return null;

      //Is anyone in our ancestry a call node?
      var nodeInQuestion = leafNode.Parent;
      SyntaxNode ptn = null;

      while (nodeInQuestion != null) {
        //Is the node in question a node call?
        var asCall = nodeInQuestion as InvocationExpressionSyntax;
        if (asCall != null) {
          ptn = asCall;
          break;
        }

        var asCtorCall = nodeInQuestion as ObjectCreationExpressionSyntax;
        if (asCtorCall != null) {
          ptn = asCtorCall;
          break;
        }

        //Climb higher up our ancestry for the next iteration
        nodeInQuestion = nodeInQuestion.Parent;
      }

      //Did we successfully find a call node?
      return ptn;
    }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:38,代码来源:IntellisenseContractsHelper.cs

示例2: IsSpaceCompletion

 private static bool IsSpaceCompletion(ITextSnapshot snapshot, ITrackingPoint loc) {
     var pos = loc.GetPosition(snapshot);
     if (pos > 0) {
         return snapshot.GetText(pos - 1, 1) == " ";
     }
     return false;
 }
开发者ID:omnimark,项目名称:PTVS,代码行数:7,代码来源:ProjectAnalyzer.cs

示例3: GetApplicableSpan

 /// <summary>
 /// Returns the applicable span at the provided position.
 /// </summary>
 /// <returns>A tracking span, or null if there is no token at the
 /// provided position.</returns>
 internal static ITrackingSpan GetApplicableSpan(ITextSnapshot snapshot, ITrackingPoint point) {
     return GetApplicableSpan(snapshot, point.GetPosition(snapshot));
 }
开发者ID:CforED,项目名称:Node.js-Tools-for-Visual-Studio,代码行数:8,代码来源:CompletionSource.cs

示例4: DrawSingleSyncPoint

        private void DrawSingleSyncPoint(ITrackingPoint trackPoint)
        {
            var position = trackPoint.GetPosition(m_textView.TextSnapshot);
            if (position > m_textView.TextSnapshot.Length)
                return;

            var point = trackPoint.GetPoint(m_textView.TextSnapshot);
            if (position == m_textView.TextSnapshot.Length)
                point -= 1;

            var span = new SnapshotSpan(point, 1);

            var brush = Brushes.DarkGray;
            var geom = m_textView.TextViewLines.GetLineMarkerGeometry(span);
            var drawing = new GeometryDrawing(brush, null, geom);

            if (drawing.Bounds.IsEmpty)
                return;

            Rectangle rect = new Rectangle()
            {
                Fill = brush,
                Width = drawing.Bounds.Width / 6,
                Height = drawing.Bounds.Height - 4,
                Margin = new System.Windows.Thickness(0, 2, 0, 0)
            };

            Canvas.SetLeft(rect, position == m_textView.TextSnapshot.Length ? geom.Bounds.Right : geom.Bounds.Left);
            Canvas.SetTop(rect, geom.Bounds.Top);

            m_adornmentLayer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, "MultiEditLayer", rect, null);
        }
开发者ID:xps,项目名称:MultiEdit,代码行数:32,代码来源:MultiPointEditCommandFilter.cs

示例5: DrawSingleSyncPoint

        private void DrawSingleSyncPoint(ITrackingPoint trackPoint)
        {
            if (trackPoint.GetPosition(m_textView.TextSnapshot) >= m_textView.TextSnapshot.Length)
                return;

            SnapshotSpan span = new SnapshotSpan(trackPoint.GetPoint(m_textView.TextSnapshot), 1);
            var brush = Brushes.DarkGray;
            var geom = m_textView.TextViewLines.GetMarkerGeometry(span);
            GeometryDrawing drawing = new GeometryDrawing(brush, null, geom);

            if (drawing.Bounds.IsEmpty)
                return;

            Rectangle rect = new Rectangle()
            {
                Fill = brush,
                Width = 1,
                Height = drawing.Bounds.Height - 1,
                Margin = new Thickness(),
            };

            Canvas.SetLeft(rect, geom.Bounds.Left);
            Canvas.SetTop(rect, geom.Bounds.Top);
            m_adornmentLayer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, "MultiEditLayer", rect, null);
        }
开发者ID:Matt-17,项目名称:MultiEdit,代码行数:25,代码来源:MultiPointEditCommandFilter.cs

示例6: GetTargetAtTriggerPoint

    public static SyntaxNode GetTargetAtTriggerPoint(ITrackingPoint triggerPoint, ITextSnapshot snapshot, SyntaxTree parseTree)
    {
      Contract.Requires(snapshot != null);
      Contract.Requires(parseTree != null);
      Contract.Requires(triggerPoint != null);

      SyntaxNode syntaxRoot;
      if (!parseTree.TryGetRoot(out syntaxRoot))
        return null;

      var leafToken = syntaxRoot.FindToken(triggerPoint.GetPosition(snapshot), false);
      if (leafToken.IsKind(SyntaxKind.None))
        return null;

      var leafNode = leafToken.Parent;

      var asPropDecl = leafNode as PropertyDeclarationSyntax;
      if (asPropDecl != null)
      {
          return asPropDecl;
      }

      //Is our leaf node a name?
      var asName = leafNode as IdentifierNameSyntax;
      if (asName == null)
        return null;

      //Is anyone in our ancestry a call node?
      var nodeInQuestion = leafNode;
      var lastNonBinaryOperatorNode = leafNode;
      var lastNode = leafNode;
      while (nodeInQuestion != null) {

        //Is the node in question a node call?
        var asCall = nodeInQuestion as InvocationExpressionSyntax;
        if (asCall != null) {

          //Make sure we aren't on the right side of the call
          if (asCall.Expression == leafNode)
            return asCall;

          MemberAccessExpressionSyntax memberAccessExpression = asCall.Expression as MemberAccessExpressionSyntax;
          if (memberAccessExpression != null && memberAccessExpression.Name == leafNode)
            return asCall;

          GenericNameSyntax genericNameSyntax = asCall.Expression as GenericNameSyntax;
          if (genericNameSyntax != null && genericNameSyntax.Identifier == leafToken)
            return asCall;

          return null;
        }

        var asProp = nodeInQuestion as MemberAccessExpressionSyntax;
        if (asProp != null)
        {
            //Make sure we aren't on the left side of the dot
            if (asProp.Name == lastNode && asProp.Name is IdentifierNameSyntax)
            {
                return asProp;
            }
        }

        var asCtorCall = nodeInQuestion as ObjectCreationExpressionSyntax;
        if (asCtorCall != null)
        {
            return asCtorCall;
        }

        var declNode = nodeInQuestion as MemberDeclarationSyntax;
        if (declNode != null)
        {
            if (lastNode == leafNode) { return declNode; }
            return null;
        }

#warning What exactly is this doing?
#if false
        NamedAssignmentNode na = nodeInQuestion as NamedAssignmentNode;
        if (na != null)
        {
            if (na.Identifier == asName)
            {
                return na;
            }
        }
#endif

        //Is our parent a binary operator?
        var asBinaryOperator = nodeInQuestion as BinaryExpressionSyntax;
        if (asBinaryOperator != null) {

          //Make sure we are always on the rightmost of any binary operator
          if (asBinaryOperator.Right != lastNonBinaryOperatorNode)
            return null;

        } else
          lastNonBinaryOperatorNode = nodeInQuestion;

        //Climb higher up our ancestry for the next iteration
        lastNode = nodeInQuestion;
//.........这里部分代码省略.........
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:101,代码来源:IntellisenseContractsHelper.cs

示例7: RequestQuickInfo

        internal async Task RequestQuickInfo(ITextView textView, ITrackingPoint triggerPoint)
        {
            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 = triggerPoint.GetPosition(TextBuffer.CurrentSnapshot);
                var quickInfoRequest = ProtocolHandlers.CreateQuickInfoRequest(textReader, javaEditor.TypeRootIdentifier, position);
                var quickInfoResponse = await javaEditor.JavaPkgServer.Send(javaEditor, quickInfoRequest);

                if (quickInfoResponse.responseType == Protocol.Response.ResponseType.QuickInfo &&
                    quickInfoResponse.quickInfoResponse != null)
                {
                    foreach(var element in quickInfoResponse.quickInfoResponse.elements)
                    {
                        QuickInfoContent.Add(element.definition); // TODO: Better javadoc rendering + "\n\n" + element.javaDoc;
                    }
                }
            }
        }
开发者ID:XewTurquish,项目名称:vsminecraft,代码行数:21,代码来源:JavaQuickInfo.cs


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