本文整理匯總了Java中org.jsweet.transpiler.SourceFile類的典型用法代碼示例。如果您正苦於以下問題:Java SourceFile類的具體用法?Java SourceFile怎麽用?Java SourceFile使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
SourceFile類屬於org.jsweet.transpiler包,在下文中一共展示了SourceFile類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: collectSourceFiles
import org.jsweet.transpiler.SourceFile; //導入依賴的package包/類
@SuppressWarnings("unchecked")
protected SourceFile[] collectSourceFiles(MavenProject project) {
logInfo("source includes: " + ArrayUtils.toString(includes));
logInfo("source excludes: " + ArrayUtils.toString(excludes));
List<String> sourcePaths = project.getCompileSourceRoots();
logInfo("sources paths: " + sourcePaths);
List<SourceFile> sources = new LinkedList<>();
for (String sourcePath : sourcePaths) {
scanForJavaFiles(sources, new File(sourcePath));
}
List<Resource> resources = project.getResources();
logInfo("sources paths from resources: " + sourcePaths);
for (Resource resource : resources) {
String directory = resource.getDirectory();
scanForJavaFiles(sources, new File(directory));
}
logInfo("sourceFiles=" + sources);
return sources.toArray(new SourceFile[0]);
}
示例2: scanForJavaFiles
import org.jsweet.transpiler.SourceFile; //導入依賴的package包/類
private void scanForJavaFiles(List<SourceFile> sources, File sourceDirectory) {
if (!sourceDirectory.exists()) {
getLog().debug(sourceDirectory.getAbsolutePath() + " is declared but doesn't exist");
return;
}
DirectoryScanner dirScanner = new DirectoryScanner();
dirScanner.setBasedir(sourceDirectory);
dirScanner.setIncludes(includes);
dirScanner.setExcludes(excludes);
dirScanner.scan();
for (String includedPath : dirScanner.getIncludedFiles()) {
if (includedPath.endsWith(".java")) {
sources.add(new SourceFile(new File(sourceDirectory, includedPath)));
}
}
}
示例3: transpileFiles
import org.jsweet.transpiler.SourceFile; //導入依賴的package包/類
private void transpileFiles(BuildingContext context, File... files) {
try {
if (context.transpiler == null || files == null || files.length == 0) {
return;
}
Log.info("compiling " + Arrays.asList(files));
SourceFile[] sfs = SourceFile.toSourceFiles(files);
for (SourceFile sf : sfs) {
context.sourceFiles.put(sf.getJavaFile(), sf);
}
context.transpiler.transpile(new JSweetTranspilationHandler(context), sfs);
} catch (Throwable t) {
Log.error("cannot compile", t);
}
}
示例4: transpile
import org.jsweet.transpiler.SourceFile; //導入依賴的package包/類
protected void transpile(MavenProject project, JSweetTranspiler transpiler) throws MojoExecutionException {
try {
ErrorCountTranspilationHandler transpilationHandler = new ErrorCountTranspilationHandler(
new ConsoleTranspilationHandler());
try {
SourceFile[] sources = collectSourceFiles(project);
transpiler.transpile(transpilationHandler, sources);
} catch (NoClassDefFoundError error) {
error.printStackTrace();
transpilationHandler.report(JSweetProblem.JAVA_COMPILER_NOT_FOUND, null,
JSweetProblem.JAVA_COMPILER_NOT_FOUND.getMessage());
}
int errorCount = transpilationHandler.getErrorCount();
if (errorCount > 0) {
throw new MojoFailureException("transpilation failed with " + errorCount + " error(s) and "
+ transpilationHandler.getWarningCount() + " warning(s)");
} else {
if (transpilationHandler.getWarningCount() > 0) {
getLog().info(
"transpilation completed with " + transpilationHandler.getWarningCount() + " warning(s)");
} else {
getLog().info("transpilation successfully completed with no errors and no warnings");
}
}
} catch (Exception e) {
getLog().error("transpilation failed", e);
throw new MojoExecutionException("transpilation failed", e);
}
}