File tree Expand file tree Collapse file tree 4 files changed +29
-4
lines changed
main/java/org/minimallycorrect/javatransformer/internal
test/java/org/minimallycorrect/javatransformer Expand file tree Collapse file tree 4 files changed +29
-4
lines changed Original file line number Diff line number Diff line change 4545
4646@ UtilityClass
4747public class ClassPaths {
48- public static ClassPath of (ClassPath systemClassPath , Path [] paths ) {
48+ public static ClassPath of (ClassPath systemClassPath , Path ... paths ) {
4949 return new FileClassPath (systemClassPath , new ArrayList <>(Arrays .asList (paths )));
5050 }
5151
@@ -237,6 +237,15 @@ else if (Files.isRegularFile(path))
237237 }
238238 }
239239
240+ @ Override
241+ public String toString () {
242+ return "FileClassPath{" +
243+ "entries.size()=" + entries .size () +
244+ ", paths=" + paths +
245+ ", initialised=" + initialised +
246+ ", parent=" + parent +
247+ '}' ;
248+ }
240249 }
241250
242251 /*
Original file line number Diff line number Diff line change @@ -190,6 +190,7 @@ public Type resolve(@NonNull String name) {
190190 throw new TransformationException ("Couldn't resolve name: " + name +
191191 "\n Found real type: " + type +
192192 "\n Generic types: " + genericTypes +
193+ "\n Package: " + packageName +
193194 "\n Imports:" + imports .stream ().map (ResolutionContext ::toString ).collect (Collectors .toList ()) +
194195 "\n ClassPath: " + classPath );
195196
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ public JavaTransformerTest(List<Path> inputs) {
4040
4141 @ Parameterized .Parameters
4242 public static Collection <List <Path >> paths () {
43- return Arrays .asList (getClassPath (), getSourcePath ());
43+ return Arrays .asList (getClassPath (), getSourcePath (), getMixPath () );
4444 }
4545
4646 private static List <Path > getClassPath () {
@@ -51,6 +51,10 @@ private static List<Path> getSourcePath() {
5151 return new ArrayList <>(Arrays .asList (Paths .get ("src/test/java/" ), Paths .get ("src/main/java" )));
5252 }
5353
54+ private static List <Path > getMixPath () {
55+ return new ArrayList <>(Arrays .asList (Paths .get ("src/test/java/" ), JavaTransformer .pathFromClass ((JavaTransformer .class ))));
56+ }
57+
5458 private static boolean exists (Path p ) {
5559 Path base = p .getParent ();
5660 String fileName = p .getFileName ().toString ();
@@ -94,6 +98,7 @@ public void testTransform() throws Exception {
9498 c .getConstructors ().collect (Collectors .toList ());
9599 c .getMethods ().forEach (it -> {
96100 val rt = it .getReturnType ();
101+ Assert .assertNotNull (it + " should have a return type" , rt );
97102
98103 val cf = it .getCodeFragment ();
99104
Original file line number Diff line number Diff line change 22
33import java .lang .invoke .MethodHandles ;
44
5+ import org .minimallycorrect .javatransformer .api .code .CodeFragment ;
6+
57public class InnerClassReferencer {
68 public InnerClassExample .Inner test1 () {
79 throw new UnsupportedOperationException ();
@@ -12,11 +14,11 @@ public org.minimallycorrect.javatransformer.transform.InnerClassExample.Inner2 t
1214 }
1315
1416 public AnnotationInnerClassExample .TestEnum test3 () {
15- throw new UnsupportedOperationException () ;
17+ return AnnotationInnerClassExample . TestEnum . ONE ;
1618 }
1719
1820 public org .minimallycorrect .javatransformer .transform .AnnotationInnerClassExample .TestEnum test4 () {
19- throw new UnsupportedOperationException () ;
21+ return org . minimallycorrect . javatransformer . transform . AnnotationInnerClassExample . TestEnum . TWO ;
2022 }
2123
2224 public MethodHandles .Lookup test5 () {
@@ -26,4 +28,12 @@ public MethodHandles.Lookup test5() {
2628 public java .lang .invoke .MethodHandles .Lookup test6 () {
2729 throw new UnsupportedOperationException ();
2830 }
31+
32+ public CodeFragment .InsertionOptions test7 () {
33+ return org .minimallycorrect .javatransformer .api .code .CodeFragment .InsertionOptions .DEFAULT ;
34+ }
35+
36+ public org .minimallycorrect .javatransformer .api .code .CodeFragment .InsertionOptions test8 () {
37+ return CodeFragment .InsertionOptions .DEFAULT ;
38+ }
2939}
You can’t perform that action at this time.
0 commit comments