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

Java CompilationUnit类代码示例

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

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



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

示例1: compileTest

import vk.core.api.CompilationUnit; //导入依赖的package包/类
/***
 * Method: compileTest
 * <p>
 * Task: Method that takes the information from the CompileManager and
 * compiles the code, results of that compilation is taken to
 * CompileResults.
 *
 * @param code
 *            needs the testcode as a string to have something to work with.
 * @param testCode
 *            needs the code as a string in order to compile it
 *
 * @return LinkedList<String> testResults in this order: failed tests
 *         ignored tests successful tests test duration test fail messages
 */

protected LinkedList<String> compileTest(String code, String testCode) throws ClassNameParserException {
    boolean isARealTest = true;
    String codeName = ClassNameParser.getClassName(code);
    String testName = ClassNameParser.getClassName(testCode);
    CompilationUnit compilationTestUnit = new CompilationUnit(testName, testCode, isARealTest);
    CompilationUnit compilationUnit = new CompilationUnit(codeName, code, false);
    compilationUnitName = "compilationTestUnit";
    testCompilerInit(compilationUnit, compilationTestUnit);

    compileResults.setTestResults(testComp);

    compileResults.errorStringInit(testComp, compilationTestUnit, compilationUnit);
    return compileResults.getTestResults();
}
 
开发者ID:ProPra16,项目名称:programmierpraktikum-abschlussprojekt-zenamike,代码行数:31,代码来源:Compiler.java


示例2: getCompileErrors

import vk.core.api.CompilationUnit; //导入依赖的package包/类
/**
 * Gets the last compiler errors for current mode
 * 
 * @return collection of {@link CompileError}
 */
public Collection<CompileError> getCompileErrors() {
	Collection<CompileError> compileErrors = new ArrayList<CompileError>();
	switch (mode) {
	case RED:
		for (Test exerciseTest : exercise.getTests()) {
			CompilationUnit testUnit = compiler.getCompilationUnitByName(exerciseTest.getName());
			compileErrors.addAll(compilerResult.getCompilerErrorsForCompilationUnit(testUnit));
		}
		break;
	case GREEN:
	case BLUE:
		for (Class exerciseClass : exercise.getClasses()) {
			CompilationUnit classUnit = compiler.getCompilationUnitByName(exerciseClass.getName());
			compileErrors.addAll(compilerResult.getCompilerErrorsForCompilationUnit(classUnit));
		}
	}

	return compileErrors;
}
 
开发者ID:ProPra16,项目名称:programmierpraktikum-abschlussprojekt-null,代码行数:25,代码来源:CompileService.java


示例3: getAllCompileErrors

import vk.core.api.CompilationUnit; //导入依赖的package包/类
/**
 * Gets all of the last compile errors
 * 
 * @return collection of {@link CompileError}
 */
public Collection<CompileError> getAllCompileErrors() {
	Collection<CompileError> compileErrors = new ArrayList<CompileError>();
	
	for (Test exerciseTest : exercise.getTests()) {
		CompilationUnit testUnit = compiler.getCompilationUnitByName(exerciseTest.getName());
		compileErrors.addAll(compilerResult.getCompilerErrorsForCompilationUnit(testUnit));
	}

	for (Class exerciseClass : exercise.getClasses()) {
		CompilationUnit classUnit = compiler.getCompilationUnitByName(exerciseClass.getName());
		compileErrors.addAll(compilerResult.getCompilerErrorsForCompilationUnit(classUnit));
	}

	return compileErrors;
}
 
开发者ID:ProPra16,项目名称:programmierpraktikum-abschlussprojekt-null,代码行数:21,代码来源:CompileService.java


示例4: acceptanceCheck

import vk.core.api.CompilationUnit; //导入依赖的package包/类
public String acceptanceCheck() {
	acceptance = false;
	CompilationUnit classToTest = new CompilationUnit(myClass, myCode, false);
	CompilationUnit aTest = new CompilationUnit(acceptanceTestName, acceptanceTest, true);
	JavaStringCompiler myCompileObject = CompilerFactory.getCompiler(classToTest, aTest);
	myCompileObject.compileAndRunTests();
	CompilerResult cpResult = myCompileObject.getCompilerResult();
	
	String result = "";
	
	if(cpResult.hasCompileErrors()) {
		result = handleErrors(cpResult, aTest);
	}
	else if(testCode.contains("@Test")) {
		result = handleAcceptanceTests(myCompileObject);
		if(testSuccess && acceptance) acceptance = true;
		else acceptance = false;
	}
	else result = "Please add a proper Acceptance Test!";
	
	return result;
}
 
开发者ID:ProPra16,项目名称:programmierpraktikum-abschlussprojekt-stack-overflow,代码行数:23,代码来源:CompileHandler.java


示例5: test

import vk.core.api.CompilationUnit; //导入依赖的package包/类
/**
 * Gibt Testergebnisse auf die (programminterne) Konsole aus.
 * 
 * Wandelt übergebene Compilationunits mit {@link #getJSC(CompilationUnit[])} in JavaStringCompiler um,
 * bestimmt Anzahl der erfolgreichen und fehlgeschlagenen Tests und gibt dies, sowie genauere Fehlermendungen
 * auf der programminternen Konsole aus.
 */
public static void test(CompilationUnit[] comp_uns){ //gibt testergebnisse auf console aus
	JavaStringCompiler comp = getJSC(comp_uns);
	TestResult test_res = comp.getTestResult();
	int tests_ok = test_res.getNumberOfSuccessfulTests();
	int tests_fail = test_res.getNumberOfFailedTests();
	console.set_textln("Testresult:");
	Collection<TestFailure> fails = test_res.getTestFailures();
	console.set_textln("OK: "+tests_ok+" FAIL: "+tests_fail);
	for(TestFailure fail: fails){
		console.set_textln("Testname: "+fail.getTestClassName());
		console.set_textln("Methodname: "+fail.getMethodName());
		console.set_textln(fail.getMessage());
		console.set_textln("");
	}
	console.set_textln("");

}
 
开发者ID:ProPra16,项目名称:programmierpraktikum-abschlussprojekt-team-1,代码行数:25,代码来源:Testing.java


示例6: isATDDpassing

import vk.core.api.CompilationUnit; //导入依赖的package包/类
public boolean isATDDpassing(){
    if(aTDDTest == null || aTDDTestUnit == null || aktuell.getCodeUnit() == null)
        return false;

    if(!(tryCompileCode() == null))
        return false;

    InternalCompiler compile = new InternalCompiler(new CompilationUnit[] {aTDDTestUnit, aktuell.getCodeUnit()});

    try {
        compile.compileAndRunTests();

        if(compile.getTestResult().getNumberOfFailedTests() != 0)
            return false;

        return true;
    } catch(Exception e) {
        return false;
    }

}
 
开发者ID:ProPra16,项目名称:programmierpraktikum-abschlussprojekt-amigos,代码行数:22,代码来源:LogikHandler.java


示例7: setATDDTest

import vk.core.api.CompilationUnit; //导入依赖的package包/类
public String[] setATDDTest(String pTest) {
    CompilationUnit testATDD = new CompilationUnit("ATDD", pTest, true);

    InternalCompiler compileTest = new InternalCompiler(new CompilationUnit[] {testATDD, aktuell.getCodeUnit()});
    compileTest.compileAndRunTests();

    if(!compileTest.getCompilerResult().hasCompileErrors()) {
        aTDDTest = pTest;
        aTDDTestUnit = new CompilationUnit("ATDD", aTDDTest, true);

        return null;
    }

    Object[] errorObjects = compileTest.getCompilerResult().getCompilerErrorsForCompilationUnit(testATDD).toArray();
    String[] errors = new String[errorObjects.length];

    for(int i = 0; i < errors.length; i++) {
        errors[i] = ((CompileError) errorObjects[i]).toString();
    }

    return errors;
}
 
开发者ID:ProPra16,项目名称:programmierpraktikum-abschlussprojekt-amigos,代码行数:23,代码来源:LogikHandler.java


示例8: getFailingTests

import vk.core.api.CompilationUnit; //导入依赖的package包/类
public String[] getFailingTests(){
    if(aktuell.getTestUnit() == null || aktuell.getCodeUnit() == null)
        return new String[0];

    InternalCompiler compileTest = new InternalCompiler(new CompilationUnit[] {aktuell.getTestUnit(), aktuell.getCodeUnit()});
    compileTest.compileAndRunTests();

    Object[] failObjects = compileTest.getTestResult().getTestFailures().toArray();
    String[] rueckgabe = new String[failObjects.length];

    for(int i = 0; i < rueckgabe.length; i++) {
        rueckgabe[i] = ((TestFailure) failObjects[i]).getMessage();
        if(rueckgabe[i] == null) {
            rueckgabe[i] = ((TestFailure)failObjects[i]).getMethodName();
        }
    }
    
    return rueckgabe;
}
 
开发者ID:ProPra16,项目名称:programmierpraktikum-abschlussprojekt-amigos,代码行数:20,代码来源:LogikHandler.java


示例9: compileCode

import vk.core.api.CompilationUnit; //导入依赖的package包/类
/**
 * Compiles the passed code and sets info to compile errors if there are any.
 * @param code The code that is going to be compiled
 * @param className The classname of the code
    * @return True if the code is compilable. Otherwise false.
    */
public boolean compileCode(String code, String className) {
	//String className       = findClassName(code).trim();
	CompilationUnit cu     = new CompilationUnit(className, code, false);
	JavaStringCompiler jsc = CompilerFactory.getCompiler(cu);

	jsc.compileAndRunTests();
	CompilerResult cr = jsc.getCompilerResult();

	if (cr.hasCompileErrors()) {
		info = formatCompileErrors(cr, cu);
		return false;
	}

	return true;
}
 
开发者ID:ProPra16,项目名称:programmierpraktikum-abschlussprojekt-nimmdochirgendeinennamen,代码行数:22,代码来源:TDDTCompiler.java


示例10: compileAndRunTests

import vk.core.api.CompilationUnit; //导入依赖的package包/类
/**
 * Compiles and runs the passed test and sets info to any error that may have occured.
 * @param code Code of code to be compiled
 * @param codeClassName Classname of the code
 * @param test Code of tests to be compiled
 * @param testClassName Classname of the test
 * @return True if the test is compile- and runnable. Otherwise false.
 */
public boolean compileAndRunTests(String code, String codeClassName, String test, String testClassName) {
	CompilationUnit cuCode = new CompilationUnit(codeClassName, code, false);
	CompilationUnit cuTest = new CompilationUnit(testClassName, test, true);
	JavaStringCompiler jsc = CompilerFactory.getCompiler(cuCode, cuTest);
	jsc.compileAndRunTests();
	CompilerResult cr = jsc.getCompilerResult();

	if (cr.hasCompileErrors()) {
		info = formatCompileErrors(cr, cuCode);
		info += formatCompileErrors(cr, cuTest);
		return false;
	}

	TestResult tr = jsc.getTestResult();

	if (tr.getNumberOfFailedTests() != 0) {
		info = formatFailingTests(tr);
		return false;
	}

	return true;
}
 
开发者ID:ProPra16,项目名称:programmierpraktikum-abschlussprojekt-nimmdochirgendeinennamen,代码行数:31,代码来源:TDDTCompiler.java


示例11: CompilerRun

import vk.core.api.CompilationUnit; //导入依赖的package包/类
public JavaStringCompiler CompilerRun(String className, String classContent, boolean isTest) {
	CompilationUnit unit = new CompilationUnit(className, classContent, isTest);
	JavaStringCompiler compiler = CompilerFactory.getCompiler(unit);
	compiler.compileAndRunTests();
	CompilerResult compilerResult = compiler.getCompilerResult();
	Collection<CompileError> errs = compilerResult.getCompilerErrorsForCompilationUnit(unit);
	for (CompileError e : errs) {
		System.out.println(e.getMessage());
		System.out.println(e.getCodeLineContainingTheError());
	}
	System.out.println("End of errors");
	return compiler;
}
 
开发者ID:ProPra16,项目名称:programmierpraktikum-abschlussprojekt-two-finger-joe,代码行数:14,代码来源:Logic.java


示例12: testSomething

import vk.core.api.CompilationUnit; //导入依赖的package包/类
@Test
public void testSomething() {
	CompilationUnit sourceClass = new CompilationUnit("Bar" ,"public class Bar { \n"
			+ " public static int fourtyTwo() { \n"
			+ "    return 41 + 1; \n"
			+ " }\n"
			+ "}" ,false);
	CompilationUnit otherClass = new CompilationUnit("Foo","public class Foo {}",true);
	JavaStringCompiler compiler = CompilerFactory.getCompiler(sourceClass);
	compiler.compileAndRunTests();
}
 
开发者ID:ProPra16,项目名称:programmierpraktikum-abschlussprojekt-team-immortalsgg,代码行数:12,代码来源:DefaultTest.java


示例13: compileAndRunTests

import vk.core.api.CompilationUnit; //导入依赖的package包/类
/**
 * Compiles and runs tests
 */
public void compileAndRunTests() {
	List<CompilationUnit> compilationUnits = new ArrayList<CompilationUnit>();
	for (Test exerciseTest : exercise.getTests()) {
		compilationUnits.add(new CompilationUnit(exerciseTest.getName(), exerciseTest.getContent(), true));
	}

	for (Class exerciseClass : exercise.getClasses()) {
		compilationUnits.add(new CompilationUnit(exerciseClass.getName(), exerciseClass.getContent(), false));
	}
	compiler = CompilerFactory.getCompiler(compilationUnits.toArray(new CompilationUnit[0]));
	compiler.compileAndRunTests();
	compilerResult = compiler.getCompilerResult();
}
 
开发者ID:ProPra16,项目名称:programmierpraktikum-abschlussprojekt-null,代码行数:17,代码来源:CompileService.java


示例14: executeCompiler

import vk.core.api.CompilationUnit; //导入依赖的package包/类
public String[] executeCompiler() {
	//führt den Compiler aus. Unterscheidet zwischen Testklasse und Hauptklasse
	testSuccess = false;
	CompilationUnit classToTest = new CompilationUnit(myClass, myCode, false);
	CompilationUnit theTest = new CompilationUnit(testClass, testCode, true);		
	JavaStringCompiler myCompileObject = CompilerFactory.getCompiler(classToTest, theTest);
	myCompileObject.compileAndRunTests();
	CompilerResult cpResult = myCompileObject.getCompilerResult();
	
	String[] results = {"", "", "", ""};
	
	if(cpResult.hasCompileErrors()) {
		results[0] = handleErrors(cpResult, classToTest);
		results[1] = handleErrors(cpResult, theTest);
		
	}
	else if(testCode.contains("@Test")) {
			results[2] = handleTests(myCompileObject);
	}
	else results[2] = "Please add a proper Test!";
	
	String acceptanceResults = "";
	if(acceptanceTest != null) acceptanceResults = acceptanceCheck();
	
	results[3] = acceptanceResults;
	
	return results;
}
 
开发者ID:ProPra16,项目名称:programmierpraktikum-abschlussprojekt-stack-overflow,代码行数:29,代码来源:CompileHandler.java


示例15: handleErrors

import vk.core.api.CompilationUnit; //导入依赖的package包/类
private String handleErrors(CompilerResult cpResult, CompilationUnit classToCompile) {
	Collection<CompileError> errors = cpResult.getCompilerErrorsForCompilationUnit(classToCompile);
	String compilerResults = "In class " + classToCompile.getClassName() + ":\n" + errors.size() + " Errors found!\n\n";
	Iterator<CompileError> err = errors.iterator();
	while(err.hasNext()) {
		CompileError found = err.next();
		compilerResults += "In line "+ found.getLineNumber() + "\n"
				+ found.getCodeLineContainingTheError() + "\n"
				+ found.getMessage() +"\n";
	}
	return compilerResults;
}
 
开发者ID:ProPra16,项目名称:programmierpraktikum-abschlussprojekt-stack-overflow,代码行数:13,代码来源:CompileHandler.java


示例16: listToArray

import vk.core.api.CompilationUnit; //导入依赖的package包/类
/**
 * Gibt ein Array an CompilationUnits zurück
 * 
 *  
 * @param type1
 * @param type2
 * @return
 */
private CompilationUnit[] listToArray(int type1, int type2){
	List<CompilationUnit> list = getCompilationUnits(type1);
	if(type1 != type2) list.addAll(getCompilationUnits(type2));
	CompilationUnit[] array = new CompilationUnit[list.size()];
	for(int i=0;i<list.size();i++){
		array[i] = list.get(i);
	}
	return array;
}
 
开发者ID:ProPra16,项目名称:programmierpraktikum-abschlussprojekt-team-1,代码行数:18,代码来源:Project.java


示例17: getCompilationUnits

import vk.core.api.CompilationUnit; //导入依赖的package包/类
/**
 * Erstellt eine Liste aller CompilationUnits der Klassen oder Tests
 * @param type Beschreibt ob Tests oder Klassen-CompilationUnit gegeben werden sollen 
 */
private List<CompilationUnit> getCompilationUnits(int type){
	List<Code> all = (type == TEST ? tests : all_class);
	List<CompilationUnit> cus = new ArrayList<CompilationUnit>();
	for(int i = 0; i<all.size();i++){
		cus.add(all.get(i).getCompilationUnit());
	}
	return cus;
}
 
开发者ID:ProPra16,项目名称:programmierpraktikum-abschlussprojekt-team-1,代码行数:13,代码来源:Project.java


示例18: compile

import vk.core.api.CompilationUnit; //导入依赖的package包/类
/**
 * Gibt Compilierfehler (wenn vorhanden) auf die (programminterne) Konsole aus
 * 
 * Wandelt übergebene Compilationunits mit {@link #getJSC(CompilationUnit[])} in JavaStringCompiler um,
 * und gibt Compilierfehler mit {@link #print_errors_to_console(Collection)} auf der programminternen Konsole aus.

 */
public static void compile(CompilationUnit[] comp_uns){ //gibt fehlermeldungen, wenn vorhanden auf die console aus
	JavaStringCompiler comp = getJSC(comp_uns);
	CompilerResult comp_res = comp.getCompilerResult();
	if(comp_res.hasCompileErrors()){
		for(CompilationUnit cu: comp_uns){
			Collection<CompileError> errors = comp_res.getCompilerErrorsForCompilationUnit(cu);
			print_errors_to_console(errors);
		}
	} else console.set_textln("No Compilation errors");
}
 
开发者ID:ProPra16,项目名称:programmierpraktikum-abschlussprojekt-team-1,代码行数:18,代码来源:Testing.java


示例19: hasCompileErrors

import vk.core.api.CompilationUnit; //导入依赖的package包/类
/**
 * Prüft ob Compilierfehler vorliegen.
 */
public static boolean hasCompileErrors(CompilationUnit[] comp_uns){ //fuer next-button
	JavaStringCompiler comp = getJSC(comp_uns);
	CompilerResult comp_res = comp.getCompilerResult();
	compile(comp_uns);
	return comp_res.hasCompileErrors();
}
 
开发者ID:ProPra16,项目名称:programmierpraktikum-abschlussprojekt-team-1,代码行数:10,代码来源:Testing.java


示例20: tests_passed

import vk.core.api.CompilationUnit; //导入依赖的package包/类
/**
 * Prüft ob alle Tests bestanden werden.
 * 
 * Prüft ob die Compilationunits fehlerlos compilieren und prüft anschließend ob alle enthaltenen Tests erfolgreich sind.
 */
public static boolean tests_passed(CompilationUnit[] comp_uns){ //fuer next-button
	if(!hasCompileErrors(comp_uns)){
		JavaStringCompiler comp = getJSC(comp_uns);
		TestResult test_res = comp.getTestResult();
		test(comp_uns);
		return(test_res.getNumberOfFailedTests() == 0);
	} else return false;
}
 
开发者ID:ProPra16,项目名称:programmierpraktikum-abschlussprojekt-team-1,代码行数:14,代码来源:Testing.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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