mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-14 06:17:44 +00:00
[test] more flexible options for limiting your tests.
This commit is contained in:
3 files changed
+38
-13
No files matched your search
@@ -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};
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user