示例#1
0
        protected override ISyntaxVisitorAction Enter(
            VariableDefinitionNode node,
            IDocumentValidatorContext context)
        {
            base.Enter(node, context);

            var variableName = node.Variable.Name.Value;

            context.Unused.Add(variableName);
            context.Declared.Add(variableName);

            if (context.Schema.TryGetType(
                    node.Type.NamedType().Name.Value, out INamedType type) &&
                !type.IsInputType())
            {
                context.Errors.Add(context.VariableNotInputType(node, variableName));
            }

            if (!context.Names.Add(variableName))
            {
                context.Errors.Add(context.VariableNameNotUnique(node, variableName));
            }

            return(Skip);
        }