Skip to content

Commit 7a77e83

Browse files
committed
SpelNodeImpl manages start/end position in separate integer values
Fixes spring-projectsgh-22157
1 parent 5aed117 commit 7a77e83

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+280
-298
lines changed

spring-expression/src/main/java/org/springframework/expression/spel/ast/Assign.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,8 +31,8 @@
3131
*/
3232
public class Assign extends SpelNodeImpl {
3333

34-
public Assign(int pos, SpelNodeImpl... operands) {
35-
super(pos, operands);
34+
public Assign(int startPos, int endPos, SpelNodeImpl... operands) {
35+
super(startPos, endPos, operands);
3636
}
3737

3838

spring-expression/src/main/java/org/springframework/expression/spel/ast/BeanReference.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -37,8 +37,8 @@ public class BeanReference extends SpelNodeImpl {
3737
private final String beanName;
3838

3939

40-
public BeanReference(int pos, String beanName) {
41-
super(pos);
40+
public BeanReference(int startPos, int endPos, String beanName) {
41+
super(startPos, endPos);
4242
this.beanName = beanName;
4343
}
4444

spring-expression/src/main/java/org/springframework/expression/spel/ast/BooleanLiteral.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,8 +31,8 @@ public class BooleanLiteral extends Literal {
3131
private final BooleanTypedValue value;
3232

3333

34-
public BooleanLiteral(String payload, int pos, boolean value) {
35-
super(payload, pos);
34+
public BooleanLiteral(String payload, int startPos, int endPos, boolean value) {
35+
super(payload, startPos, endPos);
3636
this.value = BooleanTypedValue.forValue(value);
3737
this.exitTypeDescriptor = "Z";
3838
}

spring-expression/src/main/java/org/springframework/expression/spel/ast/CompoundExpression.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,8 +33,8 @@
3333
*/
3434
public class CompoundExpression extends SpelNodeImpl {
3535

36-
public CompoundExpression(int pos, SpelNodeImpl... expressionComponents) {
37-
super(pos, expressionComponents);
36+
public CompoundExpression(int startPos, int endPos, SpelNodeImpl... expressionComponents) {
37+
super(startPos, endPos, expressionComponents);
3838
if (expressionComponents.length < 2) {
3939
throw new IllegalStateException("Do not build compound expressions with less than two entries: " +
4040
expressionComponents.length);

spring-expression/src/main/java/org/springframework/expression/spel/ast/ConstructorReference.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -72,17 +72,17 @@ public class ConstructorReference extends SpelNodeImpl {
7272
* Create a constructor reference. The first argument is the type, the rest are the parameters to the constructor
7373
* call
7474
*/
75-
public ConstructorReference(int pos, SpelNodeImpl... arguments) {
76-
super(pos, arguments);
75+
public ConstructorReference(int startPos, int endPos, SpelNodeImpl... arguments) {
76+
super(startPos, endPos, arguments);
7777
this.isArrayConstructor = false;
7878
}
7979

8080
/**
8181
* Create a constructor reference. The first argument is the type, the rest are the parameters to the constructor
8282
* call
8383
*/
84-
public ConstructorReference(int pos, SpelNodeImpl[] dimensions, SpelNodeImpl... arguments) {
85-
super(pos, arguments);
84+
public ConstructorReference(int startPos, int endPos, SpelNodeImpl[] dimensions, SpelNodeImpl... arguments) {
85+
super(startPos, endPos, arguments);
8686
this.isArrayConstructor = true;
8787
this.dimensions = dimensions;
8888
}

spring-expression/src/main/java/org/springframework/expression/spel/ast/Elvis.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,8 +36,8 @@
3636
*/
3737
public class Elvis extends SpelNodeImpl {
3838

39-
public Elvis(int pos, SpelNodeImpl... args) {
40-
super(pos, args);
39+
public Elvis(int startPos, int endPos, SpelNodeImpl... args) {
40+
super(startPos, endPos, args);
4141
}
4242

4343

spring-expression/src/main/java/org/springframework/expression/spel/ast/FloatLiteral.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -32,8 +32,8 @@ public class FloatLiteral extends Literal {
3232
private final TypedValue value;
3333

3434

35-
public FloatLiteral(String payload, int pos, float value) {
36-
super(payload, pos);
35+
public FloatLiteral(String payload, int startPos, int endPos, float value) {
36+
super(payload, startPos, endPos);
3737
this.value = new TypedValue(value);
3838
this.exitTypeDescriptor = "F";
3939
}

spring-expression/src/main/java/org/springframework/expression/spel/ast/FunctionReference.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -57,8 +57,8 @@ public class FunctionReference extends SpelNodeImpl {
5757
private volatile Method method;
5858

5959

60-
public FunctionReference(String functionName, int pos, SpelNodeImpl... arguments) {
61-
super(pos, arguments);
60+
public FunctionReference(String functionName, int startPos, int endPos, SpelNodeImpl... arguments) {
61+
super(startPos, endPos, arguments);
6262
this.name = functionName;
6363
}
6464

spring-expression/src/main/java/org/springframework/expression/spel/ast/Identifier.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,8 +31,8 @@ public class Identifier extends SpelNodeImpl {
3131
private final TypedValue id;
3232

3333

34-
public Identifier(String payload, int pos) {
35-
super(pos);
34+
public Identifier(String payload, int startPos, int endPos) {
35+
super(startPos, endPos);
3636
this.id = new TypedValue(payload);
3737
}
3838

spring-expression/src/main/java/org/springframework/expression/spel/ast/Indexer.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -90,8 +90,8 @@ private enum IndexedType {ARRAY, LIST, MAP, STRING, OBJECT}
9090
private IndexedType indexedType;
9191

9292

93-
public Indexer(int pos, SpelNodeImpl expr) {
94-
super(pos, expr);
93+
public Indexer(int startPos, int endPos, SpelNodeImpl expr) {
94+
super(startPos, endPos, expr);
9595
}
9696

9797

spring-expression/src/main/java/org/springframework/expression/spel/ast/InlineList.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -42,8 +42,8 @@ public class InlineList extends SpelNodeImpl {
4242
private TypedValue constant; // TODO must be immutable list
4343

4444

45-
public InlineList(int pos, SpelNodeImpl... args) {
46-
super(pos, args);
45+
public InlineList(int startPos, int endPos, SpelNodeImpl... args) {
46+
super(startPos, endPos, args);
4747
checkIfConstant();
4848
}
4949

spring-expression/src/main/java/org/springframework/expression/spel/ast/InlineMap.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -40,14 +40,14 @@ public class InlineMap extends SpelNodeImpl {
4040
private TypedValue constant;
4141

4242

43-
public InlineMap(int pos, SpelNodeImpl... args) {
44-
super(pos, args);
43+
public InlineMap(int startPos, int endPos, SpelNodeImpl... args) {
44+
super(startPos, endPos, args);
4545
checkIfConstant();
4646
}
4747

4848

4949
/**
50-
* If all the components of the list are constants, or lists/maps that themselves
50+
* If all the components of the map are constants, or lists/maps that themselves
5151
* contain constants, then a constant list can be built to represent this node.
5252
* This will speed up later getValue calls and reduce the amount of garbage created.
5353
*/
@@ -70,14 +70,14 @@ else if (child instanceof InlineMap) {
7070
break;
7171
}
7272
}
73-
else if (!((c%2)==0 && (child instanceof PropertyOrFieldReference))) {
73+
else if (!(c % 2 == 0 && child instanceof PropertyOrFieldReference)) {
7474
isConstant = false;
7575
break;
7676
}
7777
}
7878
}
7979
if (isConstant) {
80-
Map<Object,Object> constantMap = new LinkedHashMap<>();
80+
Map<Object, Object> constantMap = new LinkedHashMap<>();
8181
int childCount = getChildCount();
8282
for (int c = 0; c < childCount; c++) {
8383
SpelNode keyChild = getChild(c++);
@@ -159,9 +159,9 @@ public boolean isConstant() {
159159

160160
@SuppressWarnings("unchecked")
161161
@Nullable
162-
public Map<Object,Object> getConstantValue() {
162+
public Map<Object, Object> getConstantValue() {
163163
Assert.state(this.constant != null, "No constant");
164-
return (Map<Object,Object>) this.constant.getValue();
164+
return (Map<Object, Object>) this.constant.getValue();
165165
}
166166

167167
}

spring-expression/src/main/java/org/springframework/expression/spel/ast/IntLiteral.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -32,8 +32,8 @@ public class IntLiteral extends Literal {
3232
private final TypedValue value;
3333

3434

35-
public IntLiteral(String payload, int pos, int value) {
36-
super(payload, pos);
35+
public IntLiteral(String payload, int startPos, int endPos, int value) {
36+
super(payload, startPos, endPos);
3737
this.value = new TypedValue(value);
3838
this.exitTypeDescriptor = "I";
3939
}

spring-expression/src/main/java/org/springframework/expression/spel/ast/Literal.java

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,8 +36,8 @@ public abstract class Literal extends SpelNodeImpl {
3636
private final String originalValue;
3737

3838

39-
public Literal(@Nullable String originalValue, int pos) {
40-
super(pos);
39+
public Literal(@Nullable String originalValue, int startPos, int endPos) {
40+
super(startPos, endPos);
4141
this.originalValue = originalValue;
4242
}
4343

@@ -74,39 +74,39 @@ public String toStringAST() {
7474
* @param radix the base of number
7575
* @return a subtype of Literal that can represent it
7676
*/
77-
public static Literal getIntLiteral(String numberToken, int pos, int radix) {
77+
public static Literal getIntLiteral(String numberToken, int startPos, int endPos, int radix) {
7878
try {
7979
int value = Integer.parseInt(numberToken, radix);
80-
return new IntLiteral(numberToken, pos, value);
80+
return new IntLiteral(numberToken, startPos, endPos, value);
8181
}
8282
catch (NumberFormatException ex) {
83-
throw new InternalParseException(new SpelParseException(pos>>16, ex, SpelMessage.NOT_AN_INTEGER, numberToken));
83+
throw new InternalParseException(new SpelParseException(startPos, ex, SpelMessage.NOT_AN_INTEGER, numberToken));
8484
}
8585
}
8686

87-
public static Literal getLongLiteral(String numberToken, int pos, int radix) {
87+
public static Literal getLongLiteral(String numberToken, int startPos, int endPos, int radix) {
8888
try {
8989
long value = Long.parseLong(numberToken, radix);
90-
return new LongLiteral(numberToken, pos, value);
90+
return new LongLiteral(numberToken, startPos, endPos, value);
9191
}
9292
catch (NumberFormatException ex) {
93-
throw new InternalParseException(new SpelParseException(pos>>16, ex, SpelMessage.NOT_A_LONG, numberToken));
93+
throw new InternalParseException(new SpelParseException(startPos, ex, SpelMessage.NOT_A_LONG, numberToken));
9494
}
9595
}
9696

97-
public static Literal getRealLiteral(String numberToken, int pos, boolean isFloat) {
97+
public static Literal getRealLiteral(String numberToken, int startPos, int endPos, boolean isFloat) {
9898
try {
9999
if (isFloat) {
100100
float value = Float.parseFloat(numberToken);
101-
return new FloatLiteral(numberToken, pos, value);
101+
return new FloatLiteral(numberToken, startPos, endPos, value);
102102
}
103103
else {
104104
double value = Double.parseDouble(numberToken);
105-
return new RealLiteral(numberToken, pos, value);
105+
return new RealLiteral(numberToken, startPos, endPos, value);
106106
}
107107
}
108108
catch (NumberFormatException ex) {
109-
throw new InternalParseException(new SpelParseException(pos>>16, ex, SpelMessage.NOT_A_REAL, numberToken));
109+
throw new InternalParseException(new SpelParseException(startPos, ex, SpelMessage.NOT_A_REAL, numberToken));
110110
}
111111
}
112112

spring-expression/src/main/java/org/springframework/expression/spel/ast/LongLiteral.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,8 +31,8 @@ public class LongLiteral extends Literal {
3131
private final TypedValue value;
3232

3333

34-
public LongLiteral(String payload, int pos, long value) {
35-
super(payload, pos);
34+
public LongLiteral(String payload, int startPos, int endPos, long value) {
35+
super(payload, startPos, endPos);
3636
this.value = new TypedValue(value);
3737
this.exitTypeDescriptor = "J";
3838
}

spring-expression/src/main/java/org/springframework/expression/spel/ast/MethodReference.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -64,8 +64,8 @@ public class MethodReference extends SpelNodeImpl {
6464
private volatile CachedMethodExecutor cachedExecutor;
6565

6666

67-
public MethodReference(boolean nullSafe, String methodName, int pos, SpelNodeImpl... arguments) {
68-
super(pos, arguments);
67+
public MethodReference(boolean nullSafe, String methodName, int startPos, int endPos, SpelNodeImpl... arguments) {
68+
super(startPos, endPos, arguments);
6969
this.name = methodName;
7070
this.nullSafe = nullSafe;
7171
}

0 commit comments

Comments
 (0)