Exemple #1
0
        public override void ExitStringLiteral(StringLiteral stringLiteral)
        {
            if (stringLiteral.Parent is NativeMethodInvocationExpression nativeMethodInvocation &&
                nativeMethodInvocation.NativeMethodName == "String" &&
                stringLiteral == nativeMethodInvocation.Arguments.First() ||
                stringLiteral.Parent is EnumValue)
            {
                return;
            }
            var root  = stringLiteral.NearestAncestorOfType <Root>();
            var parts = new List <IExpression> {
                stringLiteral
            };

            var(constructed, matchesCase) = Construct(root, stringLiteral.Context, parts);
            if (constructed == null)
            {
                Errors.Add(new CompilationError(stringLiteral.Context, "String can not be constructed from predefined strings in Overwatch"));
            }
            else
            {
                if (!matchesCase)
                {
                    Warnings.Add(new CompilationError(stringLiteral.Context, "String case might not match the predefined strings in Overwatch"));
                }
                stringLiteral.ReplaceWith(constructed);
                Visit(constructed);
            }
        }