示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="function"></param>
        /// <returns></returns>
        private ErrorInformation CreateError(IdentifierContext function)
        {
            ParserRuleContext method = (ParserRuleContext)function.Parent.Parent.Parent.Parent;

            if (method is Common_member_declarationContext)
            {
                method = (ParserRuleContext)method.Parent;
            }
            int spaceBefore = method.Start.Column;
            List <ReplaceCodeInfomation> replaceCode = new List <ReplaceCodeInfomation>()
            {
                new ReplaceCodeInfomation()
                {
                    Start       = method.Start.StartIndex - 1,
                    Length      = 1,
                    ReplaceCode = " /// <summary>\r\n"
                                  + InsertSpace(spaceBefore) + "/// " + function.GetText() + "\r\n"
                                  + InsertSpace(spaceBefore) + "/// </summary>\r\n"
                                  + InsertParameterComment(function.Symbol as MethodSymbol, spaceBefore)
                                  + InsertSpace(spaceBefore) + "/// <returns></returns>\r\n"
                                  + InsertSpace(spaceBefore)
                }
            };

            return(new ErrorInformation()
            {
                ErrorCode = "IF0002",
                ErrorMessage = "UIT: You should add comment for method " + function.GetText(),
                DisplayText = "Add comment before function",
                StartIndex = function.Start.StartIndex,
                Length = 1,
                ReplaceCode = replaceCode
            });
        }
示例#2
0
        public override void ExitAliasAssignment(AdvplParser.AliasAssignmentContext ctx)
        {
            if (ctx.expression().Length > 0)
            {
                if (ctx.expression(0).children.Count > 0)
                {
                    IParseTree it = ctx.expression(0).children[0];

                    IdentifierContext lastCxt = null;
                    for (int nx = 0; nx < it.ChildCount; nx++)
                    {
                        IParseTree tree = it.GetChild(nx);
                        if (tree is IdentifierContext)
                        {
                            lastCxt = (IdentifierContext)tree;
                        }
                    }
                    if (lastCxt != null)
                    {
                        String varName = lastCxt.GetText().ToUpper();
                        if (!currentScope.existLocalScope(varName))
                        {
                            defineVar(Symbol.Type.tALIAS, lastCxt.Start, ctx);
                        }
                    }
                }
            }
        }
        public override Expression VisitIdentifier(IdentifierContext context)
        {
            var identifierName = context.GetText();
            var identifier     = _parserContext.Scope.Lookup(identifierName);

            return(identifier);
        }
示例#4
0
 public override object VisitIdentifier([NotNull] IdentifierContext context)
 {
     if (context.InRule(typeof(Typed_member_declarationContext)))
     {
         if (context.InRule(typeof(TypeContext)))
         {
             typeContext = context;
         }
         else if (context.InRule(typeof(Member_nameContext)))
         {
             Symbol = context.Scope.Resolve(typeContext.GetText());
             return(null);
         }
     }
     return(base.VisitIdentifier(context));
 }
 public override object VisitIdentifier([NotNull] IdentifierContext context)
 {
     if (context.Scope != null)
     {
         currentScope = context.Scope;
     }
     else if (context.Symbol == null)
     {
         var symbol = currentScope.Resolve(context.GetText());
         if (symbol != null)
         {
             context.Symbol = symbol;
             context.Scope  = symbol.GetScope();
         }
     }
     return(context);
 }
        public static bool IsSameName(Unary_expressionContext unary_ExpressionContext, string methodName)
        {
            List <SimpleNameExpressionContext> simpleNameExpression = unary_ExpressionContext.GetDeepChildContext <SimpleNameExpressionContext>();
            List <Member_accessContext>        memberAccessContext  = unary_ExpressionContext.GetDeepChildContext <Member_accessContext>();

            if (simpleNameExpression.Count > 0)
            {
                string name = simpleNameExpression[0].identifier().GetText();
                if (name == methodName)
                {
                    if (memberAccessContext.Count > 0)
                    {
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
                else
                {
                    return(false);
                }
            }

            if (memberAccessContext.Count > 0)
            {
                var thisContext = unary_ExpressionContext.GetDeepChildContext <ThisReferenceExpressionContext>();
                if (thisContext.Count > 0)
                {
                    IdentifierContext identifier = memberAccessContext[0].identifier();
                    return(methodName == identifier.GetText() ? true : false);
                }
            }

            return(false);
        }
 protected string GetNodeName(IdentifierContext node)
 {
     return(node.GetText());
 }