aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReinier Zwitserloot <r.zwitserloot@projectlombok.org>2020-07-10 02:50:38 +0200
committerReinier Zwitserloot <r.zwitserloot@projectlombok.org>2020-07-10 02:57:45 +0200
commit1fd2401bade3db3bb3a1bd88727823776f39be0c (patch)
tree7dae9f71ce118dae54485cdf175fe51af39eb134
parent32e7cd18571200c41736e70daa4815893e9ea8c3 (diff)
downloadlombok-1fd2401bade3db3bb3a1bd88727823776f39be0c.tar.gz
lombok-1fd2401bade3db3bb3a1bd88727823776f39be0c.tar.bz2
lombok-1fd2401bade3db3bb3a1bd88727823776f39be0c.zip
[test] more flexible options for limiting your tests.
-rw-r--r--src/core/lombok/eclipse/handlers/HandleSuperBuilder.java23
-rw-r--r--test/core/src/lombok/AbstractRunTests.java18
-rw-r--r--test/core/src/lombok/DirectoryRunner.java10
3 files changed, 38 insertions, 13 deletions
diff --git a/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java b/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
index 2ba456da..b1e7c419 100644
--- a/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
+++ b/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
@@ -145,9 +145,9 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
generateBuilderMethod = true;
}
if (!checkName("buildMethodName", buildMethodName, annotationNode)) return;
-
+
boolean toBuilder = superbuilderAnnotation.toBuilder();
-
+
EclipseNode tdParent = annotationNode.up();
java.util.List<BuilderFieldData> builderFields = new ArrayList<BuilderFieldData>();
@@ -234,7 +234,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
TypeReference extendsClause = td.superclass;
TypeReference superclassBuilderClass = null;
TypeReference[] typeArguments = new TypeReference[] {
- new SingleTypeReference(classGenericName.toCharArray(), 0),
+ new SingleTypeReference(classGenericName.toCharArray(), 0),
new SingleTypeReference(builderGenericName.toCharArray(), 0)
};
if (extendsClause instanceof QualifiedTypeReference) {
@@ -333,14 +333,14 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
cleanDecl.type = TypeReference.baseTypeReference(TypeIds.T_boolean, 0);
injectFieldAndMarkGenerated(builderType, cleanDecl);
}
-
+
if (toBuilder) {
// Generate $fillValuesFrom() method in the abstract builder.
injectMethod(builderType, generateFillValuesMethod(tdParent, superclassBuilderClass != null, builderGenericName, classGenericName, builderClassName, typeParams));
// Generate $fillValuesFromInstanceIntoBuilder() method in the builder implementation class.
injectMethod(builderType, generateStaticFillValuesMethod(tdParent, builderClassName, typeParams, builderFields, ast, superbuilderAnnotation.setterPrefix()));
}
-
+
// Generate abstract self() and build() methods in the abstract builder.
injectMethod(builderType, generateAbstractSelfMethod(cfv, tdParent, superclassBuilderClass != null, builderGenericName));
injectMethod(builderType, generateAbstractBuildMethod(cfv, builderType, buildMethodName, builderFields, superclassBuilderClass != null, classGenericName, ast));
@@ -386,7 +386,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
}
sanityCheckForMethodGeneratingAnnotationsOnBuilderClass(builderImplType, annotationNode);
}
-
+
if (toBuilder) {
// Add the toBuilder() method to the annotated class.
switch (methodExists(TO_BUILDER_METHOD_NAME_STRING, tdParent, 0)) {
@@ -399,9 +399,10 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
// Should not happen.
}
}
-
+
// Create the self() and build() methods in the BuilderImpl.
injectMethod(builderImplType, generateSelfMethod(cfv, builderImplType, typeParams, p));
+
if (methodExists(buildMethodName, builderImplType, -1) == MemberExistsResult.NOT_EXISTS) {
injectMethod(builderImplType, generateBuildMethod(cfv, builderImplType, buildMethodName, returnType, builderFields, ast));
}
@@ -419,7 +420,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
}
}
}
-
+
private EclipseNode generateBuilderAbstractClass(EclipseNode tdParent, String builderClass,
TypeReference superclassBuilderClass, TypeParameter[] typeParams,
ASTNode source, String classGenericName, String builderGenericName) {
@@ -448,7 +449,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
builder.superclass = copyType(superclassBuilderClass, source);
builder.createDefaultConstructor(false, true);
-
+
builder.traverse(new SetGeneratedByVisitor(source), (ClassScope) null);
return injectType(tdParent, builder);
}
@@ -806,8 +807,8 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
out.modifiers = ClassFileConstants.AccProtected;
Annotation overrideAnn = makeMarkerAnnotation(TypeConstants.JAVA_LANG_OVERRIDE, builderImplType.get());
- Annotation rrAnn = cfv.generateReturnsReceiver() ? generateNamedAnnotation(builderImplType.get(), CheckerFrameworkVersion.NAME__RETURNS_RECEIVER): null;
- Annotation sefAnn = cfv.generatePure() ? generateNamedAnnotation(builderImplType.get(), CheckerFrameworkVersion.NAME__PURE): null;
+ Annotation rrAnn = cfv.generateReturnsReceiver() ? generateNamedAnnotation(builderImplType.get(), CheckerFrameworkVersion.NAME__RETURNS_RECEIVER) : null;
+ Annotation sefAnn = cfv.generatePure() ? generateNamedAnnotation(builderImplType.get(), CheckerFrameworkVersion.NAME__PURE) : null;
if (rrAnn != null && sefAnn != null) out.annotations = new Annotation[] {overrideAnn, rrAnn, sefAnn};
else if (rrAnn != null) out.annotations = new Annotation[] {overrideAnn, rrAnn};
else if (sefAnn != null) out.annotations = new Annotation[] {overrideAnn, sefAnn};
diff --git a/test/core/src/lombok/AbstractRunTests.java b/test/core/src/lombok/AbstractRunTests.java
index 6d2b6312..8e73e122 100644
--- a/test/core/src/lombok/AbstractRunTests.java
+++ b/test/core/src/lombok/AbstractRunTests.java
@@ -190,6 +190,8 @@ public abstract class AbstractRunTests {
for (CompilerMessage actualMessage : actualMessages) {
System.out.println(actualMessage);
}
+ System.out.println("**** Actual File ******");
+ System.out.println(lineNumber(actualFile));
System.out.println("*******************");
}
if (dumpActualFilesHere != null) {
@@ -199,6 +201,22 @@ public abstract class AbstractRunTests {
}
}
+ private CharSequence lineNumber(String content) {
+ StringBuilder out = new StringBuilder();
+ int pos = 0;
+ int ln = 1;
+ while (true) {
+ out.append(String.format("%4d ", ln));
+ int idx = content.indexOf('\n', pos);
+ if (idx == -1) {
+ return out.append(content.substring(pos));
+ }
+ out.append(content.substring(pos, idx + 1));
+ ln++;
+ pos = idx + 1;
+ }
+ }
+
@SuppressWarnings("null") /* eclipse bug workaround; it falsely thinks stuffAc will always be null. */
private static void compareMessages(String name, LombokImmutableList<CompilerMessageMatcher> expected, LinkedHashSet<CompilerMessage> actual) {
Iterator<CompilerMessageMatcher> expectedIterator = expected.iterator();
diff --git a/test/core/src/lombok/DirectoryRunner.java b/test/core/src/lombok/DirectoryRunner.java
index e4792ca9..a174355d 100644
--- a/test/core/src/lombok/DirectoryRunner.java
+++ b/test/core/src/lombok/DirectoryRunner.java
@@ -47,7 +47,7 @@ public class DirectoryRunner extends Runner {
@Override public int getVersion() {
return Javac.getJavaCompilerVersion();
}
- },
+ },
JAVAC {
@Override public int getVersion() {
return DELOMBOK.getVersion();
@@ -85,11 +85,17 @@ public class DirectoryRunner extends Runner {
if (!file.isFile() || !file.getName().endsWith(".java")) return false;
boolean positiveFilter = false;
for (String dfof : DEBUG_FOCUS_ON_FILE) {
+ if (dfof.isEmpty()) continue;
if (!dfof.endsWith(".java")) dfof = dfof + ".java";
boolean invert = dfof.startsWith("!");
if (invert) dfof = dfof.substring(1);
positiveFilter = positiveFilter || !invert;
- if (file.getName().equals(dfof)) return !invert;
+ int starIdx = dfof.indexOf('*');
+ if (starIdx == -1) {
+ if (file.getName().equals(dfof)) return !invert;
+ } else {
+ if (file.getName().startsWith(dfof.substring(0, starIdx)) && file.getName().endsWith(dfof.substring(starIdx + 1))) return !invert;
+ }
}
return !positiveFilter;
}