当前位置: 首页>>代码示例>>Java>>正文


Java SourceFile类代码示例

本文整理汇总了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]);
}
 
开发者ID:lgrignon,项目名称:jsweet-maven-plugin,代码行数:27,代码来源:AbstractJSweetMojo.java

示例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)));
		}
	}
}
 
开发者ID:lgrignon,项目名称:jsweet-maven-plugin,代码行数:19,代码来源:AbstractJSweetMojo.java

示例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);
	}
}
 
开发者ID:cincheo,项目名称:jsweet-eclipse-plugin,代码行数:16,代码来源:JSweetBuilder.java

示例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);
	}
}
 
开发者ID:lgrignon,项目名称:jsweet-maven-plugin,代码行数:38,代码来源:AbstractJSweetMojo.java


注:本文中的org.jsweet.transpiler.SourceFile类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。