Skip to content

Commit d4cde29

Browse files
committed
Clean up TODOs in SpEL
1 parent 5f1e25a commit d4cde29

File tree

7 files changed

+20
-26
lines changed

7 files changed

+20
-26
lines changed

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

-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ public class ConstructorReference extends SpelNodeImpl {
7676
@Nullable
7777
private final SpelNodeImpl[] dimensions;
7878

79-
// TODO is this caching safe - passing the expression around will mean this executor is also being passed around
8079
/** The cached executor that may be reused on subsequent evaluations. */
8180
@Nullable
8281
private volatile ConstructorExecutor cachedExecutor;

Diff for: spring-expression/src/main/java/org/springframework/expression/spel/ast/Projection.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ protected ValueRef getValueRef(ExpressionState state) throws EvaluationException
8282
state.exitScope();
8383
}
8484
}
85-
return new ValueRef.TypedValueHolderValueRef(new TypedValue(result), this); // TODO unable to build correct type descriptor
85+
return new ValueRef.TypedValueHolderValueRef(new TypedValue(result), this);
8686
}
8787

8888
boolean operandIsArray = ObjectUtils.isArray(operand);

Diff for: spring-expression/src/main/java/org/springframework/expression/spel/ast/Selection.java

-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ protected ValueRef getValueRef(ExpressionState state) throws EvaluationException
9090
SpelNodeImpl selectionCriteria = this.children[0];
9191

9292
if (operand instanceof Map<?, ?> mapdata) {
93-
// TODO don't lose generic info for the new map
9493
Map<Object, Object> result = new HashMap<>();
9594
Object lastKey = null;
9695

Diff for: spring-expression/src/main/java/org/springframework/expression/spel/ast/TypeReference.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public TypeReference(int startPos, int endPos, SpelNodeImpl qualifiedId, int dim
5454

5555
@Override
5656
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
57-
// TODO possible optimization here if we cache the discovered type reference, but can we do that?
57+
// TODO Possible optimization: if we cache the discovered type reference, but can we do that?
5858
String typeName = (String) this.children[0].getValueInternal(state).getValue();
5959
Assert.state(typeName != null, "No type name");
6060
if (!typeName.contains(".") && Character.isLowerCase(typeName.charAt(0))) {
@@ -99,7 +99,7 @@ public boolean isCompilable() {
9999

100100
@Override
101101
public void generateCode(MethodVisitor mv, CodeFlow cf) {
102-
// TODO Future optimization - if followed by a static method call, skip generating code here
102+
// TODO Future optimization: if followed by a static method call, skip generating code here.
103103
Assert.state(this.type != null, "No type available");
104104
if (this.type.isPrimitive()) {
105105
if (this.type == boolean.class) {

Diff for: spring-expression/src/main/java/org/springframework/expression/spel/standard/InternalSpelExpressionParser.java

-3
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,6 @@ else if (t.kind == TokenKind.SELECT_LAST) {
733733

734734
/**
735735
* Eat an identifier, possibly qualified (meaning that it is dotted).
736-
* TODO AndyC Could create complete identifiers (a.b.c) here rather than a sequence of them? (a, b, c)
737736
*/
738737
private SpelNodeImpl eatPossiblyQualifiedId() {
739738
Deque<SpelNodeImpl> qualifiedIdPieces = new ArrayDeque<>();
@@ -783,7 +782,6 @@ private boolean maybeEatMethodOrProperty(boolean nullSafeNavigation) {
783782
// method reference
784783
push(new MethodReference(nullSafeNavigation, methodOrPropertyName.stringValue(),
785784
methodOrPropertyName.startPos, methodOrPropertyName.endPos, args));
786-
// TODO what is the end position for a method reference? the name or the last arg?
787785
return true;
788786
}
789787
return false;
@@ -826,7 +824,6 @@ private boolean maybeEatConstructorReference() {
826824
else {
827825
// regular constructor invocation
828826
eatConstructorArgs(nodes);
829-
// TODO correct end position?
830827
push(new ConstructorReference(newToken.startPos, newToken.endPos, nodes.toArray(new SpelNodeImpl[0])));
831828
}
832829
return true;

Diff for: spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectionHelper.java

-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ else if (typeConverter.canConvert(suppliedArg, TypeDescriptor.valueOf(varargsPar
233233
return (match != null ? new ArgumentsMatchInfo(match) : null);
234234
}
235235

236-
// TODO could do with more refactoring around argument handling and varargs
237236
/**
238237
* Convert the supplied set of arguments into the parameter types specified
239238
* by the supplied {@link Method}.

Diff for: spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationCoverageTests.java

+17-17
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
public class SpelCompilationCoverageTests extends AbstractExpressionTests {
6565

6666
/*
67-
* Further TODOs for compilation:
67+
* TODO Potential optimizations for SpEL compilation:
6868
*
6969
* - OpMinus with a single literal operand could be treated as a negative literal. Will save a
7070
* pointless loading of 0 and then a subtract instruction in code gen.
@@ -1205,12 +1205,12 @@ void functionReferenceVarargs_SPR12359() throws Exception {
12051205
assertCanCompile(expression);
12061206
assertThat(expression.getValue(context, new SomeCompareMethod2()).toString()).isEqualTo("xyz");
12071207

1208-
// TODO fails due to conversionservice handling of String[] to Object...
1209-
// expression = parser.parseExpression("#append2(#stringArray)");
1210-
// assertEquals("xyz", expression.getValue(context).toString());
1211-
// assertTrue(((SpelNodeImpl)((SpelExpression) expression).getAST()).isCompilable());
1212-
// assertCanCompile(expression);
1213-
// assertEquals("xyz", expression.getValue(context).toString());
1208+
// TODO Determine why the String[] is passed as the first element of the Object... varargs array instead of the entire varargs array.
1209+
// expression = parser.parseExpression("#append2(#stringArray)");
1210+
// assertThat(expression.getValue(context)).hasToString("xyz");
1211+
// assertThat(((SpelNodeImpl) ((SpelExpression) expression).getAST()).isCompilable()).isTrue();
1212+
// assertCanCompile(expression);
1213+
// assertThat(expression.getValue(context)).hasToString("xyz");
12141214

12151215
expression = parser.parseExpression("#sum(1,2,3)");
12161216
assertThat(expression.getValue(context)).isEqualTo(6);
@@ -3703,16 +3703,16 @@ void methodReferenceVarargs() {
37033703
assertThat(tc.s).isEqualTo("aaabbbccc");
37043704
tc.reset();
37053705

3706-
// TODO Fails related to conversion service converting a String[] to satisfy Object...
3707-
// expression = parser.parseExpression("sixteen(stringArray)");
3708-
// assertCantCompile(expression);
3709-
// expression.getValue(tc);
3710-
// assertEquals("aaabbbccc", tc.s);
3711-
// assertCanCompile(expression);
3712-
// tc.reset();
3713-
// expression.getValue(tc);
3714-
// assertEquals("aaabbbccc", tc.s);
3715-
// tc.reset();
3706+
// TODO Determine why the String[] is passed as the first element of the Object... varargs array instead of the entire varargs array.
3707+
// expression = parser.parseExpression("sixteen(stringArray)");
3708+
// assertCantCompile(expression);
3709+
// expression.getValue(tc);
3710+
// assertThat(tc.s).isEqualTo("aaabbbccc");
3711+
// assertCanCompile(expression);
3712+
// tc.reset();
3713+
// expression.getValue(tc);
3714+
// assertThat(tc.s).isEqualTo("aaabbbccc");
3715+
// tc.reset();
37163716

37173717
// varargs int
37183718
expression = parser.parseExpression("twelve(1,2,3)");

0 commit comments

Comments
 (0)