示例#1
0
        public static void Deconstruct(this Token token, out GraphQLLocation location, out string value)
        {
            Check.IsNotNull(token, nameof(token));

            location = token.Location;
            value    = token.Value;
        }
        public void GetHashCode3()
        {
            var graphQLLocation = new GraphQLLocation {
                Line = 1
            };

            Assert.Equal(0.GetHashCode() ^ 1.GetHashCode(), graphQLLocation.GetHashCode());
        }
示例#3
0
        public Argument(string name, GraphQLLocation location, Value value)
        {
            Check.IsNotNullOrWhiteSpace(name, nameof(name));

            Name     = name;
            Location = location;
            Value    = value;
        }
        public void GetHashCode2()
        {
            var graphQLLocation = new GraphQLLocation {
                Column = 1
            };

            Assert.Equal(1.GetHashCode(), graphQLLocation.GetHashCode());
        }
示例#5
0
        public Token(GraphQLLocation location, string value)
        {
            Check.IsNotNull(location, nameof(location));
            Check.IsNotNull(value, nameof(value));

            Location = location;
            Value    = value;
        }
        public void Equality1Fact()
        {
            var graphQLLocation = new GraphQLLocation {
                Column = 1, Line = 2
            };

            Assert.Equal(graphQLLocation, graphQLLocation);
        }
        public void Equality3()
        {
            var graphQLLocation1 = new GraphQLLocation();
            var graphQLLocation2 = new GraphQLLocation();

            Assert.True(graphQLLocation1 == graphQLLocation2);
            Assert.True(graphQLLocation2 == graphQLLocation1);
        }
        public void Constructor2()
        {
            var graphQLLocation = new GraphQLLocation {
                Column = 10
            };

            Assert.Equal(10U, graphQLLocation.Column);
        }
示例#9
0
        public Variable(string name, GraphQLLocation location)
        {
            Check.IsNotNullOrWhiteSpace(name, nameof(name));
            Check.IsNotNull(location, nameof(location));

            Name     = name;
            Location = location;
        }
        public void Equality5()
        {
            var graphQLLocation1 = new GraphQLLocation();
            var graphQLLocation2 = new GraphQLLocation();

            Assert.True(graphQLLocation1.Equals((object)graphQLLocation2));
            Assert.True(graphQLLocation2.Equals((object)graphQLLocation1));
        }
        public void Constructor3()
        {
            var graphQLLocation = new GraphQLLocation {
                Line = 10
            };

            Assert.Equal(10U, graphQLLocation.Line);
        }
        public void GetHashCode4()
        {
            var graphQLLocation = new GraphQLLocation {
                Column = 1,
                Line   = 2
            };

            Assert.Equal(1.GetHashCode() ^ 2.GetHashCode(), graphQLLocation.GetHashCode());
        }
        public void ConstructorFact()
        {
            var graphQLLocation = new GraphQLLocation {
                Column = 1, Line = 2
            };

            Assert.Equal(1U, graphQLLocation.Column);
            Assert.Equal(2U, graphQLLocation.Line);
        }
        public void Inequality5()
        {
            var graphQLLocation1 = new GraphQLLocation();
            var graphQLLocation2 = new GraphQLLocation {
                Column = 1, Line = 2
            };

            Assert.False(graphQLLocation1.Equals((object)graphQLLocation2));
            Assert.False(graphQLLocation2.Equals((object)graphQLLocation1));
        }
        public void Inequality3()
        {
            var graphQLLocation1 = new GraphQLLocation();
            var graphQLLocation2 = new GraphQLLocation {
                Column = 1, Line = 2
            };

            Assert.True(graphQLLocation1 != graphQLLocation2);
            Assert.True(graphQLLocation2 != graphQLLocation1);
        }
        public void GetHashCodeFact()
        {
            var graphQLLocation1 = new GraphQLLocation {
                Column = 1, Line = 2
            };
            var graphQLLocation2 = new GraphQLLocation {
                Column = 1, Line = 2
            };

            Assert.True(graphQLLocation1.GetHashCode() == graphQLLocation2.GetHashCode());
        }
        public void InEqualityOperatorFact()
        {
            var graphQLLocation1 = new GraphQLLocation {
                Column = 1, Line = 2
            };
            var graphQLLocation2 = new GraphQLLocation {
                Column = 2, Line = 1
            };

            Assert.True(graphQLLocation1 != graphQLLocation2);
        }
        public void Equality2Fact()
        {
            var graphQLLocation1 = new GraphQLLocation {
                Column = 1, Line = 2
            };
            var graphQLLocation2 = new GraphQLLocation {
                Column = 1, Line = 2
            };

            Assert.Equal(graphQLLocation1, graphQLLocation2);
        }
        public void InEqualityFact()
        {
            var graphQLLocation1 = new GraphQLLocation {
                Column = 1, Line = 2
            };
            var graphQLLocation2 = new GraphQLLocation {
                Column = 2, Line = 1
            };

            Assert.NotEqual(graphQLLocation1, graphQLLocation2);
        }
示例#20
0
        public VariableDefinition(string name, InputType type, Value defaultValue, GraphQLLocation location)
        {
            Check.IsNotNullOrWhiteSpace(name, nameof(name));
            Check.IsNotNull(type, nameof(type));
            Check.IsNotNull(location, nameof(location));

            Name         = name;
            Type         = type;
            DefaultValue = defaultValue;
            Location     = location;
        }
示例#21
0
        internal (LocatedNamedSource part, int offset, int length) ResolveNode(GraphQLLocation location)
        {
            LocatedNamedSource part = this.QueryParts.Where(x => x.StartAt <= location.Start).OrderByDescending(x => x.StartAt).First();
            int offsetStart         = location.Start - part.StartAt;
            int length = location.End - location.Start;

            if (length + offsetStart > part.Body.Length)
            {
                length = part.Body.Length - offsetStart;
            }
            return(part, offsetStart, length);
        }
示例#22
0
        private static Token Tokenize(GraphQLLocation location, string value)
        {
            if (int.TryParse(value, out var intValue))
            {
                return(new IntValueToken(location, value, intValue));
            }
            if (decimal.TryParse(value, out var decimalValue))
            {
                return(new FloatValueToken(location, value, decimalValue));
            }

            return(new NameToken(location, value));
        }
        public void Equality2()
        {
            var graphQLLocation1 = new GraphQLLocation {
                Column = 1,
                Line   = 2
            };
            var graphQLLocation2 = new GraphQLLocation {
                Column = 1,
                Line   = 2
            };

            Assert.True(graphQLLocation1.Equals(graphQLLocation2));
            Assert.True(graphQLLocation2.Equals(graphQLLocation1));
        }
        public void Inequality2()
        {
            var graphQLLocation1 = new GraphQLLocation {
                Column = 1,
                Line   = 2
            };
            var graphQLLocation2 = new GraphQLLocation {
                Column = 2,
                Line   = 1
            };

            Assert.False(graphQLLocation1.Equals(graphQLLocation2));
            Assert.False(graphQLLocation2.Equals(graphQLLocation1));
        }
        public void Equality4()
        {
            var graphQLLocation1 = new GraphQLLocation {
                Column = 1,
                Line   = 2
            };
            var graphQLLocation2 = new GraphQLLocation {
                Column = 1,
                Line   = 2
            };

            Assert.True(graphQLLocation1 == graphQLLocation2);
            Assert.True(graphQLLocation2 == graphQLLocation1);
        }
示例#26
0
        internal (string query, string filename) ResolveQuery(GraphQLLocation location)
        {
            var part = QueryParts.Where(x => x.StartAt <= location.Start).OrderByDescending(x => x.StartAt).First();

            var offsetStart = location.Start - part.StartAt;
            var length      = location.End - location.Start;

            if (length + offsetStart > part.Body.Length)
            {
                length = part.Body.Length - offsetStart;
            }

            var text = part.Body.Substring(offsetStart, length);

            return(text, part.Path);
        }
示例#27
0
        public Field(
            string name,
            string alias,
            IEnumerable <Argument> arguments,
            IEnumerable <Directive> directives,
            IEnumerable <Selection> selectionSet,
            GraphQLLocation location)
        {
            Check.IsNotNullOrWhiteSpace(name, nameof(name));
            Check.IsNotNull(location, nameof(location));

            Name         = name;
            Alias        = alias;
            Arguments    = arguments;
            Directives   = directives;
            SelectionSet = selectionSet;
            Location     = location;
        }
示例#28
0
        internal void AddError(ErrorCodes code, string message, GraphQLLocation location)
        {
            (LocatedNamedSource part, int offsetStart, int length) = ResolveNode(location);

            var allTextBeforeError = part.Body.Substring(0, offsetStart);
            var lines  = allTextBeforeError.Split('\n');
            var line   = lines.Count();
            var column = lines.Last().Length + 1;

            errors.Add(new GraphQLError()
            {
                Path    = part.Path,
                Code    = code,
                Message = message,
                Line    = line,
                Column  = column
            });
        }
示例#29
0
        internal string ResolveQuerySource(GraphQLLocation location)
        {
            (LocatedNamedSource part, _, _) = ResolveNode(location);

            return(part.Path);
        }
示例#30
0
 public LexingToken(GraphQLLocation location, string value)
     : base(location, value)
 {
 }