use of fr.xephi.authme.ClassCollector in project AuthMeReloaded by AuthMe.
the class DebugSectionConsistencyTest method collectClasses.
@BeforeClass
public static void collectClasses() {
// TODO ljacqu 20171021: Improve ClassCollector (pass pkg by class, improve #getInstancesOfType's instantiation)
ClassCollector classCollector = new ClassCollector(TestHelper.SOURCES_FOLDER, TestHelper.PROJECT_ROOT + "command/executable/authme/debug");
debugClasses = classCollector.collectClasses();
debugSections = classCollector.getInstancesOfType(DebugSection.class, clz -> instantiate(clz));
}
use of fr.xephi.authme.ClassCollector in project AuthMeReloaded by AuthMe.
the class PermissionConsistencyTest method gatherPermissionNodes.
@BeforeClass
public static void gatherPermissionNodes() {
permissionClasses = new ClassCollector(TestHelper.SOURCES_FOLDER, TestHelper.PROJECT_ROOT + "permission").collectClasses(PermissionNode.class).stream().filter(clz -> !clz.isInterface()).collect(Collectors.toList());
permissionNodes = getPermissionsFromClasses();
pluginYmlPermissions = getPermissionsFromPluginYmlFile();
}
use of fr.xephi.authme.ClassCollector in project AuthMeReloaded by AuthMe.
the class PermissionNodesGatherer method getPermissionClasses.
/**
* Return all enum classes implementing the PermissionNode interface.
*
* @return all permission node enums
*/
public List<Class<? extends PermissionNode>> getPermissionClasses() {
if (permissionClasses == null) {
ClassCollector classCollector = new ClassCollector(ToolsConstants.MAIN_SOURCE_ROOT, "");
permissionClasses = classCollector.collectClasses(PermissionNode.class).stream().filter(Class::isEnum).collect(Collectors.toList());
}
return permissionClasses;
}
use of fr.xephi.authme.ClassCollector in project AuthMeReloaded by AuthMe.
the class DrawDependency method execute.
@Override
public void execute(Scanner scanner) {
System.out.println("Summarize classes to their generic super type where applicable?");
mapToSupertype = "y".equalsIgnoreCase(scanner.nextLine());
// Gather all connections
ClassCollector collector = new ClassCollector(TestHelper.SOURCES_FOLDER, TestHelper.PROJECT_ROOT);
for (Class<?> clazz : collector.collectClasses()) {
processClass(clazz);
}
// Prompt user for simplification of graph
System.out.println("Do you want to remove classes that are not used as dependency elsewhere?");
System.out.println("Specify the number of times to do this: [0=keep all]");
int stripVerticesCount;
try {
stripVerticesCount = Integer.valueOf(scanner.nextLine());
} catch (NumberFormatException e) {
stripVerticesCount = 0;
}
// Perform simplification as per user's wish
for (int i = 0; i < stripVerticesCount; ++i) {
stripNodesWithNoOutgoingEdges();
}
// Create dot file content
final String pattern = "\t\"%s\" -> \"%s\";";
String dotFile = "";
for (Map.Entry<Class<?>, String> entry : foundDependencies.entries()) {
dotFile += "\n" + String.format(pattern, entry.getValue(), entry.getKey().getSimpleName());
}
// Write dot file
try {
Files.write(Paths.get(DOT_FILE), ("digraph G {\n" + dotFile + "\n}").getBytes());
} catch (IOException e) {
throw new IllegalStateException(e);
}
System.out.println("Graph file written");
System.out.format("Run 'dot -Tpng %s -o graph.png' to generate image (requires GraphViz)%n", DOT_FILE);
}
use of fr.xephi.authme.ClassCollector in project AuthMeReloaded by AuthMe.
the class SettingsConsistencyTest method getSectionCommentMethods.
/**
* Gets all {@link SectionComments} methods from {@link SettingsHolder} implementations.
*/
@SuppressWarnings("unchecked")
private List<Method> getSectionCommentMethods() {
// Find all SettingsHolder classes
List<Class<? extends SettingsHolder>> settingsClasses = new ClassCollector(TestHelper.SOURCES_FOLDER, TestHelper.PROJECT_ROOT + "settings/properties/").collectClasses(SettingsHolder.class);
checkArgument(!settingsClasses.isEmpty(), "Could not find any SettingsHolder classes");
// Find all @SectionComments methods in these classes
return settingsClasses.stream().map(Class::getDeclaredMethods).flatMap(Arrays::stream).filter(method -> method.isAnnotationPresent(SectionComments.class)).collect(Collectors.toList());
}
Aggregations