示例#1
0
        private static void Traverse(ITreeNode node, StringBuilder sb, int depth, CompletionTargetMarker marker)
        {
            if (node.IsWhitespaceToken())
            {
                return;
            }

            sb.Indent(depth);
            sb.ObjectId(node, marker);
            sb.AppendLine();

            foreach (var child in node.Children())
            {
                if (Visited.Contains(child))
                {
                    sb.Indent(depth);
                    sb.Append("--> ");
                    sb.ObjectId(node, marker);
                    sb.AppendLine();
                }
                else
                {
                    Visited.Add(child);
                    Traverse(child, sb, depth + 1, marker);
                }
            }
        }
示例#2
0
        public static void Dump(ITreeNode node, CompletionTargetMarker marker = null)
        {
            var sb = new StringBuilder();

            Traverse(node, sb, 0, marker);
            Console.WriteLine(sb.ToString());
            Visited.Clear();
        }
示例#3
0
 private static void PrintType(CSharpCodeCompletionContext context, CompletionTargetMarker marker)
 {
     for (var node = context.NodeInFile; node != null; node = node.Parent)
     {
         var type = node as ITypeDeclaration;
         if (type != null)
         {
             JetbrainsTreeDebugger.Dump(type, marker);
             return;
         }
     }
 }
示例#4
0
        public DeclarationVisitor(KaVELogger logger,
                                  ISet <IMethodName> entryPoints,
                                  CompletionTargetMarker marker,
                                  CancellationToken cancellationToken)
        {
            _logger            = logger;
            _entryPoints       = entryPoints;
            _marker            = marker;
            _cancellationToken = cancellationToken;

            _initVisitor  = new ExpressionVisitor(new UniqueVariableNameGenerator(), _marker);
            _cinitVisitor = new ExpressionVisitor(new UniqueVariableNameGenerator(), _marker);
        }
示例#5
0
        private static void ObjectId(this StringBuilder sb, object o, CompletionTargetMarker marker)
        {
            var isTarget = o == marker.AffectedNode;

            if (isTarget)
            {
                sb.Append("$$ ");
            }
            sb.Append(o.GetType().Name);
            sb.Append('@');
            sb.Append(o.GetHashCode());
            if (isTarget)
            {
                sb.Append(" $$");
            }
        }
 public ExpressionVisitor(UniqueVariableNameGenerator nameGen, CompletionTargetMarker marker)
 {
     _nameGen = nameGen;
     _marker  = marker;
 }
示例#7
0
 public StatementVisitor(UniqueVariableNameGenerator nameGen, CompletionTargetMarker marker)
 {
     _marker      = marker;
     _nameGen     = nameGen;
     _exprVisitor = new ExpressionVisitor(_nameGen, marker);
 }