Ejemplo n.º 1
0
        public void CheckLockStatement(ParserRuleContext context, out ErrorInformation error)
        {
            error = null;
            var priExpressionContext = context.GetDeepChildContext <Primary_expressionContext>()[0];

            if (priExpressionContext.GetText() == "this")
            {
                error = ThrowError(priExpressionContext);
            }
            else
            {
                var typeofContext = priExpressionContext.GetDeepChildContext <TypeofExpressionContext>();
                if (typeofContext.Count > 0)
                {
                    error = ThrowError(priExpressionContext);
                }
            }
        }
        public void VisitCatchContext(ParserRuleContext context, out ErrorInformation error)
        {
            error = null;
            var blockContext = context.GetDeepChildContext <BlockContext>()[0];
            int a            = blockContext.Start.StartIndex;
            int b            = blockContext.Stop.StopIndex;

            if (blockContext.Start
                .InputStream.GetText(new Antlr4.Runtime.Misc.Interval(a, b))
                .Replace("\r", "")
                .Replace("\n", "")
                .Replace(" ", "")
                == "{}")
            {
                var identifier = blockContext.GetText();
                error = new ErrorInformation
                {
                    StartIndex   = blockContext.Start.StartIndex,
                    ErrorCode    = "WA0003",
                    Length       = blockContext.Stop.StopIndex - blockContext.Start.StartIndex + 1,
                    ErrorMessage = "UIT: Catch Statement should not be empty"
                };
            }
        }