Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: add missing Javadoc in ModelsUtils #1860

Merged
merged 1 commit into from
Feb 17, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/main/java/spoon/testing/utils/ModelUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ public static Factory createFactory() {
return new FactoryImpl(new DefaultCoreFactory(), new StandardEnvironment());
}

/** Utility method for testing: creates the model of `packageName` from src/test/java and returns the CtType corresponding to `className` */
public static <T extends CtType<?>> T build(String packageName, String className) throws Exception {
SpoonModelBuilder comp = new Launcher().createCompiler();
comp.addInputSources(SpoonResourceHelper.resources("./src/test/java/" + packageName.replace('.', '/') + "/" + className + ".java"));
comp.build();
return comp.getFactory().Package().get(packageName).getType(className);
}

/** Utility method for testing: creates the model of `packageName` and the factory from src/test/java and returns the CtType corresponding to `className` */
public static <T extends CtType<?>> T build(String packageName, String className, final Factory f) throws Exception {
Launcher launcher = new Launcher() {
@Override
Expand All @@ -57,6 +59,7 @@ public Factory createFactory() {
return comp.getFactory().Package().get(packageName).getType(className);
}

/** Utility method for testing: creates the model of the given `classesToBuild` from src/test/java and returns the factory */
public static Factory build(Class<?>... classesToBuild) throws Exception {
SpoonModelBuilder comp = new Launcher().createCompiler();
for (Class<?> classToBuild : classesToBuild) {
Expand All @@ -66,6 +69,7 @@ public static Factory build(Class<?>... classesToBuild) throws Exception {
return comp.getFactory();
}

/** Utility method for testing: creates the noclasspath model of the given `classesToBuild` from src/test/java and returns the factory */
public static Factory buildNoClasspath(Class<?>... classesToBuild) throws Exception {
final Launcher launcher = new Launcher();
launcher.getEnvironment().setNoClasspath(true);
Expand All @@ -77,6 +81,7 @@ public static Factory buildNoClasspath(Class<?>... classesToBuild) throws Except
return comp.getFactory();
}

/** Builds the Spoon mode of the `filesToBuild` given as parameter */
public static Factory build(File... filesToBuild) {
final Launcher launcher = new Launcher();
launcher.getEnvironment().setNoClasspath(true);
Expand All @@ -92,6 +97,7 @@ public static Factory build(File... filesToBuild) {
return comp.getFactory();
}

/** Builds and returns the Spoon model of `` classToBuild */
public static <T> CtType<T> buildClass(Class<T> classToBuild) throws Exception {
return build(classToBuild).Type().get(classToBuild);
}
Expand Down