use of spoon.compiler.SpoonFolder in project spoon by INRIA.
the class StandardEnvironment method verifySourceClasspath.
private void verifySourceClasspath(String[] sourceClasspath) throws InvalidClassPathException {
for (String classPathElem : sourceClasspath) {
// preconditions
File classOrJarFolder = new File(classPathElem);
if (!classOrJarFolder.exists()) {
throw new InvalidClassPathException(classPathElem + " does not exist, it is not a valid folder");
}
if (classOrJarFolder.isDirectory()) {
// it should not contain a java file
SpoonFolder tmp = new FileSystemFolder(classOrJarFolder);
List<SpoonFile> javaFiles = tmp.getAllJavaFiles();
if (javaFiles.size() > 0) {
logger.warn("You're trying to give source code in the classpath, this should be given to " + "addInputSource " + javaFiles);
}
} else if (classOrJarFolder.getName().endsWith(".class")) {
throw new InvalidClassPathException(".class files are not accepted in source classpath.");
}
}
}
use of spoon.compiler.SpoonFolder in project spoon by INRIA.
the class ResourceTest method testVirtualFolder.
@Test
public void testVirtualFolder() throws Exception {
String dir = "src/test/resources/spoon/test/api/";
FileSystemFolder fileSystemFolder = new FileSystemFolder(new File(dir));
String dir2 = "src/test/resources/spoon/test/exceptions/";
FileSystemFolder fileSystemFolder2 = new FileSystemFolder(new File(dir2));
SpoonFolder folder = new VirtualFolder();
folder.addFolder(fileSystemFolder);
folder.addFolder(fileSystemFolder2);
assertEquals(4, folder.getAllFiles().size());
// the README is not a Java file
assertEquals(3, folder.getAllJavaFiles().size());
}
use of spoon.compiler.SpoonFolder in project spoon by INRIA.
the class FileSystemFolder method getSubFolders.
public List<SpoonFolder> getSubFolders() {
List<SpoonFolder> subFolders;
subFolders = new ArrayList<>();
for (File f : file.listFiles()) {
if (!(SpoonResourceHelper.isArchive(f) || f.isFile())) {
try {
subFolders.add(SpoonResourceHelper.createFolder(f));
} catch (FileNotFoundException e) {
Launcher.LOGGER.error(e.getMessage(), e);
}
}
}
return subFolders;
}
use of spoon.compiler.SpoonFolder in project spoon by INRIA.
the class FileSystemFolderTest method jarFileIsNotSubfolder.
@Test
public void jarFileIsNotSubfolder() {
String folderPath = "./src/test/resources/folderWithJar";
FileSystemFolder folder = new FileSystemFolder(new File(folderPath));
List<SpoonFolder> subFolders = folder.getSubFolders();
assertTrue(subFolders.isEmpty());
}
Aggregations