• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Environment类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中spoon.compiler.Environment的典型用法代码示例。如果您正苦于以下问题:Java Environment类的具体用法?Java Environment怎么用?Java Environment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Environment类属于spoon.compiler包,在下文中一共展示了Environment类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: report

import spoon.compiler.Environment; //导入依赖的package包/类
protected void report(Environment environment, CategorizedProblem problem) {
    if (problem == null) {
        throw new IllegalArgumentException("problem cannot be null");
    }

    File file = new File(new String(problem.getOriginatingFileName()));
    String filename = file.getAbsolutePath();

    String message = problem.getMessage() + " at " + filename + ":"
            + problem.getSourceLineNumber();

    if (problem.isError()) {
        if (!environment.getNoClasspath()) {
            // by default, compilation errors are notified as exception
            throw new ModelBuildingException(message);
        }
    }

}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:20,代码来源:DiversityCompiler.java


示例2: printJavaFileWithComment

import spoon.compiler.Environment; //导入依赖的package包/类
public static void printJavaFileWithComment(CtType<?> type, File directory) {
    Factory factory = type.getFactory();
    Environment env = factory.getEnvironment();
    env.setAutoImports(true);
    env.setCommentEnabled(true);
    JavaOutputProcessor processor = new JavaOutputProcessor(directory, new DefaultJavaPrettyPrinter(env));
    processor.setFactory(factory);
    processor.createJavaFile(type);
    env.setAutoImports(false);
}
 
开发者ID:STAMP-project,项目名称:dspot,代码行数:11,代码来源:DSpotUtils.java


示例3: generateClasses

import spoon.compiler.Environment; //导入依赖的package包/类
@TaskAction
public void generateClasses() throws IOException {
    // Clean the destination directory
    getProject().delete(getDestinationDir());

    // Initialize spoon
    SpoonAPI spoon = new Launcher();
    spoon.addProcessor(EVENT_CLASS_PROCESSOR);

    final Environment environment = spoon.getEnvironment();
    environment.setComplianceLevel(Integer.parseInt(JavaVersion.toVersion(getSourceCompatibility()).getMajorVersion()));
    environment.setNoClasspath(!this.validateCode);

    // Configure AST generator
    final SpoonModelBuilder compiler = spoon.createCompiler();
    compiler.setSourceClasspath(toPathArray(getClasspath().getFiles()));

    for (Object source : this.source) {
        if (!(source instanceof SourceDirectorySet)) {
            throw new UnsupportedOperationException("Source of type " + source.getClass() + " is not supported.");
        }

        ((SourceDirectorySet) source).getSrcDirs().forEach(compiler::addInputSource);
    }

    this.factory = compiler.getFactory();

    // Generate AST
    compiler.build();

    // Analyse AST
    final EventInterfaceProcessor processor = new EventInterfaceProcessor(getSource());
    compiler.process(Collections.singletonList(processor));
    final Map<CtType<?>, List<Property>> foundProperties = processor.getFoundProperties();

    this.sorter = new PropertySorter(this.sortPriorityPrefix, this.groupingPrefixes);

    dumpClasses(foundProperties);
}
 
开发者ID:SpongePowered,项目名称:event-impl-gen,代码行数:40,代码来源:EventImplGenTask.java


示例4: createEnvironment

import spoon.compiler.Environment; //导入依赖的package包/类
@Override
public @NotNull Environment createEnvironment() {
	env = new StandardEnvironment();
	env.setCommentEnabled(false);
	env.setComplianceLevel(8);
	env.setSelfChecks(false);
	env.setShouldCompile(false);
	return env;
}
 
开发者ID:diverse-project,项目名称:InspectorGuidget,代码行数:10,代码来源:InspectorGuidetAnalyser.java


示例5: getExpectedModel

import spoon.compiler.Environment; //导入依赖的package包/类
private CtModel getExpectedModel(final String path) {
	spoon.Launcher launcher = new spoon.Launcher();
	final Environment env = launcher.getEnvironment();
	env.setComplianceLevel(8);
	launcher.addInputResource(path);
	launcher.buildModel();
	return launcher.getModel();
}
 
开发者ID:diverse-project,项目名称:InspectorGuidget,代码行数:9,代码来源:TestBlobRefactoring.java


示例6: getRefactoredCode

import spoon.compiler.Environment; //导入依赖的package包/类
String getRefactoredCode() {
	Environment env = cmdAnalyser.getEnvironment();
	env.useTabulations(true);
	env.setAutoImports(true);
	DefaultJavaPrettyPrinter printer = new DefaultJavaPrettyPrinter(env);
	printer.calculate(null, new ArrayList<>(cmdAnalyser.getModel().getAllTypes()));
	return printer.getResult().replace(" \n", "\n").replaceAll("(\n)+", "\n");
}
 
开发者ID:diverse-project,项目名称:InspectorGuidget,代码行数:9,代码来源:TestBlobRefactoring.java


示例7: run

import spoon.compiler.Environment; //导入依赖的package包/类
@Override
public void run(final IMarker marker) {
	final Entry<CtExecutable<?>, UIListener> entry = DetectBlobListenerAction.getBlobCommands(marker);
	final WidgetProcessor widgetProc = new WidgetProcessor(true);
	
	System.out.println("Refactoring blob listener: " + entry);
	
	Launcher launcher = new Launcher(Collections.singletonList(widgetProc), DetectBlobListenerAction.currentAnalyser.getCmdAnalyser().getModelBuilder());
	launcher.process();
	
	System.out.println("Widgets processor ended");
	
	final CommandWidgetFinder finder = new CommandWidgetFinder(entry.getValue().getCommands(), widgetProc.getWidgetUsages());
	finder.process();
	final Collection<CommandWidgetFinder.WidgetFinderEntry> allEntries = finder.getResults().values();
	
	System.out.println("Widgets finder ended");
	
	entry.getValue().getCommands().forEach(cmd -> {
		final ListenerCommandRefactor ref = new ListenerCommandRefactor(cmd, null, false, false, false, allEntries);
		ref.execute();
		
		Environment env = widgetProc.getEnvironment();
		env.useTabulations(true);
		env.setAutoImports(true);
		DefaultJavaPrettyPrinter printer = new DefaultJavaPrettyPrinter(env);
		printer.calculate(null, cmd.getAllLocalStatmtsOrdered().stream().
				map(s -> s.getElements(new BasicFilter<CtTypeReference<?>>(CtTypeReference.class))).
				flatMap(s -> s.stream()).map(tref -> tref.getDeclaration()).collect(Collectors.toList()));
		System.out.println(printer.getResult());
	});
}
 
开发者ID:diverse-project,项目名称:InspectorGuidget,代码行数:33,代码来源:BlobMarkerResolution.java


示例8: printAllClasses

import spoon.compiler.Environment; //导入依赖的package包/类
public static void printAllClasses(Factory factory, File out, File fileFrom) {
    Environment env = factory.getEnvironment();
    Processor processor = new JavaOutputProcessorWithFilter(out, new DefaultJavaPrettyPrinter(env), allClassesName(fileFrom));
    try {
        ProcessingManager pm = new QueueProcessingManager(factory);
        pm.addProcessor(processor);
        pm.process(factory.Package().getRootPackage());
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:12,代码来源:PrintClassUtils.java


示例9: printJavaFile

import spoon.compiler.Environment; //导入依赖的package包/类
public static void printJavaFile(File directory, CtType type) throws IOException {
    try {
        Factory factory = type.getFactory();
        Environment env = factory.getEnvironment();

        JavaOutputProcessor processor = new JavaOutputProcessor(directory, new DefaultJavaPrettyPrinter(env));
        processor.setFactory(factory);

        processor.createJavaFile(type);
        Log.trace("write type {} in directory {}", type.getQualifiedName(), directory);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:15,代码来源:PrintClassUtils.java


示例10: printJavaFile

import spoon.compiler.Environment; //导入依赖的package包/类
@Override
public void printJavaFile(String directory) throws IOException {
    CtType<?> type = getPosition().getCompilationUnit().getMainType();
    Factory factory = type.getFactory();
    Environment env = factory.getEnvironment();

    JavaOutputProcessor processor = new JavaOutputProcessor(new File(directory), new DefaultJavaPrettyPrinter(env));
    processor.setFactory(factory);

    processor.createJavaFile(type);
    Log.debug("write type {} in directory {}", type.getQualifiedName(), directory);
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:13,代码来源:AddParameterCondition.java


示例11: printJavaFile

import spoon.compiler.Environment; //导入依赖的package包/类
protected void printJavaFile(String directory, List<CtType> classes) throws IOException {
    Environment env = getFactory().getEnvironment();

    classes.stream()
            .forEach(cl -> {
                Log.debug("print java file: {}", directory + "/" + cl.getQualifiedName().replace(".", "/") + ".java");
                cl.getPosition().getCompilationUnit().getDeclaredTypes().stream()
                        .forEach(cc -> {
                            JavaOutputProcessor processor = new JavaOutputProcessor(new File(directory), new DefaultJavaPrettyPrinter(env));
                            processor.setFactory(getFactory());
                            processor.createJavaFile(cc);
                        });
            });
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:15,代码来源:InstanceTransformation.java


示例12: printJavaFile

import spoon.compiler.Environment; //导入依赖的package包/类
@Override
public void printJavaFile(String srcDir) throws IOException {
    CtType<?> type = loop.getParent(CtType.class);
    Factory factory = type.getFactory();
    Environment env = factory.getEnvironment();

    JavaOutputProcessor processor = new JavaOutputProcessor(new File(srcDir), new DefaultJavaPrettyPrinter(env));
    processor.setFactory(factory);

    processor.createJavaFile(type);
    Log.debug("write type {} in directory {}", type.getQualifiedName(), srcDir);
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:13,代码来源:LoopPerforation.java


示例13: printJavaFile

import spoon.compiler.Environment; //导入依赖的package包/类
@Override
public void printJavaFile(String directory) throws IOException {
    CtType<?> type = transformation.getOriginalClass(transformation.getTransplantationPoint());
    Factory factory = type.getFactory();
    Environment env = factory.getEnvironment();

    JavaOutputProcessor processor = new JavaOutputProcessor(new File(directory), new DefaultJavaPrettyPrinter(env));
    processor.setFactory(factory);

    processor.createJavaFile(type);
    Log.debug("write type {} in directory {}", type.getQualifiedName(), directory);
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:13,代码来源:SwitchTransformation.java


示例14: printJavaFile

import spoon.compiler.Environment; //导入依赖的package包/类
/**
 * Prints the modified java file. When the transformation is done a new java file is created. This method performs a
 * pretty print of it
 *
 * @param directory Directory where the java file is going to be placed
 * @throws IOException
 */
public void printJavaFile(String directory) throws IOException {
    CtType<?> type = getOriginalClass(transplantationPoint);
    Factory factory = type.getFactory();
    Environment env = factory.getEnvironment();

    JavaOutputProcessor processor = new JavaOutputProcessor(new File(directory), new DefaultJavaPrettyPrinter(env));
    processor.setFactory(factory);

    processor.createJavaFile(type);
    Log.debug("write type {} in directory {}", type.getQualifiedName(), directory);
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:19,代码来源:SpoonTransformation.java


示例15: printJavaFile

import spoon.compiler.Environment; //导入依赖的package包/类
public void printJavaFile(String directory) throws IOException {
    CtType<?> type = getPosition().getCompilationUnit().getMainType();
    Factory factory = type.getFactory();
    Environment env = factory.getEnvironment();

    JavaOutputProcessor processor = new JavaOutputProcessor(new File(directory), new DefaultJavaPrettyPrinter(env));
    processor.setFactory(factory);

    processor.createJavaFile(type);
    Log.debug("write type {} in directory {}", type.getQualifiedName(), directory);
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:12,代码来源:SingleTransformation.java


示例16: getEnvironment

import spoon.compiler.Environment; //导入依赖的package包/类
public static Environment getEnvironment() {
	StandardEnvironment env = new StandardEnvironment();

	env.setComplianceLevel(ConfigurationProperties.getPropertyInt("javacompliancelevel"));
	env.setVerbose(false);
	env.setDebug(true);
	env.setTabulationSize(5);
	env.useTabulations(true);
	return env;
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:11,代码来源:MutationSupporter.java


示例17: spoonEnvironment

import spoon.compiler.Environment; //导入依赖的package包/类
protected Environment spoonEnvironment() {
    return spoonFactory().getEnvironment();
}
 
开发者ID:SpoonLabs,项目名称:nopol,代码行数:4,代码来源:SpoonedFile.java


示例18: init

import spoon.compiler.Environment; //导入依赖的package包/类
@Override
public void init() {
	ignoredTypes.add(getFactory().Type().createReference(Environment.class));
	ignoredTypes.add(getFactory().Type().createReference(Factory.class));
	ignoredTypes.add(getFactory().Type().createReference(FactoryAccessor.class));
}
 
开发者ID:SpoonLabs,项目名称:spoon-examples,代码行数:7,代码来源:ReferenceProcessor.java


示例19: MyPrinter

import spoon.compiler.Environment; //导入依赖的package包/类
public MyPrinter(Environment env) {
    super(env);
}
 
开发者ID:OpenHFT,项目名称:Stage-Compiler,代码行数:4,代码来源:ContextProcessor.java


示例20: getEnvironment

import spoon.compiler.Environment; //导入依赖的package包/类
@Override
public @Nullable Environment getEnvironment() {
	return env;
}
 
开发者ID:diverse-project,项目名称:InspectorGuidget,代码行数:5,代码来源:InspectorGuidetAnalyser.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ManagedBuildManager类代码示例发布时间:2022-05-23
下一篇:
Java TreeReaderFactory类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap