Skip to content

Commit 83ea560

Browse files
committed
Remove pre1.6 support from string generation
ECJ no longer supports pre 1.8 and JDT UI simply converts project settings to 1.8 if lower thus all this code is non reachable.
1 parent bf5a3e7 commit 83ea560

File tree

5 files changed

+86
-211
lines changed

5 files changed

+86
-211
lines changed

org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/tostringgeneration/AbstractToStringGenerator.java

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -486,10 +486,7 @@ protected void checkNeedForHelperMethods() {
486486
}
487487
if (fContext.isCustomArray() && memberType.isArray()) {
488488
ITypeBinding componentType= memberType.getComponentType();
489-
if (componentType.isPrimitive() && (!fContext.is60orHigher() && fContext.isLimitItems())) {
490-
if (!typesThatNeedArrayToStringMethod.contains(componentType))
491-
typesThatNeedArrayToStringMethod.add(componentType);
492-
} else if (!componentType.isPrimitive())
489+
if (!componentType.isPrimitive())
493490
isNonPrimitive= true;
494491
}
495492
}
@@ -716,28 +713,15 @@ protected Expression createMemberAccessExpression(Object member, boolean ignoreA
716713
MethodInvocation asListInvocation= createMethodInvocation(addImport("java.util.Arrays"), "asList", createMemberAccessExpression(member, true, true)); //$NON-NLS-1$ //$NON-NLS-2$
717714
accessExpression= createSubListInvocation(asListInvocation, lengthAccess);
718715
} else {
719-
if (fContext.is60orHigher()) {
720-
// Arrays.toString( Arrays.copyOf ( member, Math.min (maxLen, member.length) )
721-
Name arraysImport= addImport("java.util.Arrays"); //$NON-NLS-1$
722-
MethodInvocation minInvocation= createMethodInvocation(addImport("java.lang.Math"), "min", lengthAccess); //$NON-NLS-1$ //$NON-NLS-2$
723-
minInvocation.arguments().add(fAst.newSimpleName(fMaxLenVariableName));
724-
needMaxLenVariable= true;
725-
MethodInvocation copyOfInvocation= createMethodInvocation(arraysImport, "copyOf", createMemberAccessExpression(member, true, true)); //$NON-NLS-1$
726-
copyOfInvocation.arguments().add(minInvocation);
727-
Name arraysImportCopy= (Name)ASTNode.copySubtree(fAst, arraysImport);
728-
accessExpression= createMethodInvocation(arraysImportCopy, METHODNAME_TO_STRING, copyOfInvocation);
729-
} else {
730-
// arrayToString(member, member.length, maxLen)
731-
MethodInvocation arrayToStringInvocation= fAst.newMethodInvocation();
732-
if (fContext.isKeywordThis())
733-
arrayToStringInvocation.setExpression(fAst.newThisExpression());
734-
arrayToStringInvocation.setName(fAst.newSimpleName(HELPER_ARRAYTOSTRING_METHOD_NAME));
735-
arrayToStringInvocation.arguments().add(createMemberAccessExpression(member, true, true));
736-
arrayToStringInvocation.arguments().add(lengthAccess);
737-
arrayToStringInvocation.arguments().add(fAst.newSimpleName(fMaxLenVariableName));
738-
needMaxLenVariable= true;
739-
accessExpression= arrayToStringInvocation;
740-
}
716+
// Arrays.toString( Arrays.copyOf ( member, Math.min (maxLen, member.length) )
717+
Name arraysImport= addImport("java.util.Arrays"); //$NON-NLS-1$
718+
MethodInvocation minInvocation= createMethodInvocation(addImport("java.lang.Math"), "min", lengthAccess); //$NON-NLS-1$ //$NON-NLS-2$
719+
minInvocation.arguments().add(fAst.newSimpleName(fMaxLenVariableName));
720+
needMaxLenVariable= true;
721+
MethodInvocation copyOfInvocation= createMethodInvocation(arraysImport, "copyOf", createMemberAccessExpression(member, true, true)); //$NON-NLS-1$
722+
copyOfInvocation.arguments().add(minInvocation);
723+
Name arraysImportCopy= (Name)ASTNode.copySubtree(fAst, arraysImport);
724+
accessExpression= createMethodInvocation(arraysImportCopy, METHODNAME_TO_STRING, copyOfInvocation);
741725
}
742726
}
743727
}

org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/tostringgeneration/ToStringGenerationContext.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,6 @@ public ITypeBinding getTypeBinding() {
8181
return fType;
8282
}
8383

84-
public boolean is60orHigher() {
85-
return fSettings.is60orHigher;
86-
}
87-
8884
public boolean isCreateComments() {
8985
return fSettings.createComments;
9086
}

org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/tostringgeneration/ToStringGenerationSettingsCore.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,6 @@ public static class CustomBuilderSettings {
9999
/** should blocks be forced in if/for/while statements? */
100100
public boolean useBlocks;
101101

102-
/** can generated code use jdk 1.6 API? **/
103-
public boolean is60orHigher;
104-
105102
/** settings specific for custom builder code style **/
106103
public CustomBuilderSettings customBuilderSettings;
107104

0 commit comments

Comments
 (0)