Esempio n. 1
0
 public override void EnterAssignment([NotNull] CSharpParser.AssignmentContext context)
 {
     if (commandVar == null)
     {
         return;
     }
     foreach (var command in commandVar)
     {
         string partern = command + ".CommandText";
         if (context.GetText().Contains(partern))
         {
             if (!listExpressLine.Contains(context.Start.Line))
             {
                 listExpressLine.Add(context.Start.Line);
                 if (!context.GetChild(2).GetText().StartsWith("\""))
                 {
                     ParseTreeWalker methodWalker    = new ParseTreeWalker();
                     FindCommandText commandListener = new FindCommandText(parser, context.GetChild(2).GetText());
                     methodWalker.Walk(commandListener, treeContext);
                     if (commandListener.getListLine().Count > 0)
                     {
                         foreach (var item in commandListener.getListLine())
                         {
                             if (!listExpressLine.Contains(item))
                             {
                                 listExpressLine.Add(item);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 2
0
 public override void EnterAssignment([NotNull] CSharpParser.AssignmentContext context)
 {
     //Gan' gia tri cho bien
     //child: ExpressionContext
     //Console.WriteLine(context.GetChild(2).GetText());
     //Console.WriteLine(context.GetChild(2).GetType().ToString());
     //Console.WriteLine(context.GetChild(0).GetText());
 }
Esempio n. 3
0
 public override void EnterAssignment([NotNull] CSharpParser.AssignmentContext context)
 {
     if (context.GetChild(0).GetText().Equals(commandVar))
     {
         if (!listLine.Contains(context.Start.Line))
         {
             listLine.Add(context.Start.Line);
         }
     }
     //Console.WriteLine(context.GetChild(0).GetText());
 }
        private (int ChildNodeIndex, Type tipo) treatExpressionAssignment(CSharpParser.AssignmentContext context)
        {
            Console.WriteLine("Entering assignment context.");
            Node.Kind currentKind = Node.Kind.ExpressionAssignment;
            IToken    token       = null;
            Type      currentType = null;
            Node      currentNode = null;

            (int ChildNodeIndex, Type tipo)childTreat;  //tipo e index de cada child

            if (!context.unary_expression().IsEmpty&& !context.assignment_operator().IsEmpty&& !context.expression().IsEmpty)
            {
                //expression determina o tipo
                childTreat  = treatExpression(context.expression());
                currentType = childTreat.tipo;
                //criando node
                currentNode = new Node(token, currentKind, currentType);
                ast.AddNode(currentNode);
                //adicionando ao subnode
                currentNode.AddChildIndex(childTreat.ChildNodeIndex); //expression
                childTreat = treatUnaryExpression(context.unary_expression());
                currentNode.AddChildIndex(childTreat.ChildNodeIndex); //unary
                childTreat = treatAssignmentOperator(context.assignment_operator());
                currentNode.AddChildIndex(childTreat.ChildNodeIndex); //assign op
            }
            else //unary_expression '??=' throwable_expression;
            {
                childTreat  = treatUnaryExpression(context.unary_expression());
                currentType = childTreat.tipo;
                //criando node
                token       = context.OP_COALESCING_ASSIGNMENT().Symbol;
                currentNode = new Node(token, currentKind, currentType);
                ast.AddNode(currentNode);
                //adicionando child
                currentNode.AddChildIndex(childTreat.ChildNodeIndex);//unary
                //childTreat = treatthrowable_expression(context.unary_expression());
                //currentNode.AddChildIndex(childTreat.ChildNodeIndex);
            }
            return(ast.NodeIndex(currentNode), currentType);
        }
Esempio n. 5
0
 public override void EnterAssignment([NotNull] CSharpParser.AssignmentContext context)
 {
 }