• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java CtPackageReference类的典型用法和代码示例

java 2次浏览

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

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

示例1: process

点赞 3

import spoon.reflect.reference.CtPackageReference; //导入依赖的package包/类
public void process(CtPackage element) {
	CtPackageReference pack = element.getReference();
	Set<CtPackageReference> refs = new HashSet<CtPackageReference>();
	for (CtType t : element.getTypes()) {
		List<CtTypeReference<?>> listReferences = Query.getReferences(t, new ReferenceTypeFilter<CtTypeReference<?>>(CtTypeReference.class));

		for (CtTypeReference<?> tref : listReferences) {
			if (tref.getPackage() != null && !tref.getPackage().equals(pack)) {
				if (ignoredTypes.contains(tref))
					continue;
				refs.add(tref.getPackage());
			}
		}
	}
	if (refs.size() > 0) {
		packRefs.put(pack, refs);
	}
}
 

开发者ID:SpoonLabs,
项目名称:spoon-examples,
代码行数:19,
代码来源:ReferenceProcessor.java

示例2: scanDependencies

点赞 3

import spoon.reflect.reference.CtPackageReference; //导入依赖的package包/类
void scanDependencies(Stack<CtPackageReference> path) {
	CtPackageReference ref = path.peek();
	// return if already scanned
	if (scanned.contains(ref)) {
		return;
	}
	scanned.add(ref);
	Set<CtPackageReference> refs = packRefs.get(ref);
	if (refs != null) {
		for (CtPackageReference p : refs) {
			if (path.contains(p)) {
				List<CtPackageReference> circularPath = new ArrayList<CtPackageReference>(
						path.subList(path.indexOf(p), path.size()));
				circularPath.add(p);

				circularPathes.add(circularPath);
				break;
			} else {
				path.push(p);
				scanDependencies(path);
				path.pop();
			}
		}
	}
}
 

开发者ID:SpoonLabs,
项目名称:spoon-examples,
代码行数:26,
代码来源:ReferenceProcessor.java

示例3: cloneMethodTest

点赞 2

import spoon.reflect.reference.CtPackageReference; //导入依赖的package包/类
public static CtMethod cloneMethodTest(CtMethod method, String suffix) {
    CtMethod cloned_method = cloneMethod(method, suffix);
    CtAnnotation testAnnotation = cloned_method.getAnnotations().stream()
            .filter(annotation -> annotation.toString().contains("Test"))
            .findFirst().orElse(null);

    if (testAnnotation != null) {
        cloned_method.removeAnnotation(testAnnotation);
    }

    testAnnotation = method.getFactory().Core().createAnnotation();
    CtTypeReference<Object> ref = method.getFactory().Core().createTypeReference();
    ref.setSimpleName("Test");

    CtPackageReference refPackage = method.getFactory().Core().createPackageReference();
    refPackage.setSimpleName("org.junit");
    ref.setPackage(refPackage);
    testAnnotation.setAnnotationType(ref);

    Map<String, Object> elementValue = new HashMap<>();
    elementValue.put("timeout", timeOutInMs);
    testAnnotation.setElementValues(elementValue);

    cloned_method.addAnnotation(testAnnotation);

    return cloned_method;
}
 

开发者ID:STAMP-project,
项目名称:dspot,
代码行数:28,
代码来源:AmplificationHelper.java

示例4: cloneMethodTest

点赞 2

import spoon.reflect.reference.CtPackageReference; //导入依赖的package包/类
protected CtMethod cloneMethodTest(CtMethod method, String suffix, int timeOut) {
    CtMethod cloned_method = cloneMethod(method,suffix);
    CtAnnotation testAnnotation = cloned_method.getAnnotations().stream()
            .filter(annotation -> annotation.toString().contains("Test"))
            .findFirst().orElse(null);

    if(testAnnotation != null) {
        cloned_method.removeAnnotation(testAnnotation);
    }

    testAnnotation = getFactory().Core().createAnnotation();
    CtTypeReference<Object> ref = getFactory().Core().createTypeReference();
    ref.setSimpleName("Test");

    CtPackageReference refPackage = getFactory().Core().createPackageReference();
    refPackage.setSimpleName("org.junit");
    ref.setPackage(refPackage);
    testAnnotation.setAnnotationType(ref);


    Map<String, Object> elementValue = new HashMap<String, Object>();
    elementValue.put("timeout", timeOut);
    testAnnotation.setElementValues(elementValue);

    cloned_method.addAnnotation(testAnnotation);

    ampclasses.add(cloned_method.getDeclaringType());
    return cloned_method;
}
 

开发者ID:STAMP-project,
项目名称:dspot,
代码行数:30,
代码来源:TestProcessor.java

示例5: packageOf

点赞 2

import spoon.reflect.reference.CtPackageReference; //导入依赖的package包/类
public static String packageOf(CtTypeReference<?> type) {
    CtPackageReference thePackage = type.getPackage();
    if (thePackage == null) {
        thePackage = type.getDeclaringType().getPackage();
    }
    return thePackage.getSimpleName();
}
 

开发者ID:SpoonLabs,
项目名称:nopol,
代码行数:8,
代码来源:SpoonReferenceLibrary.java

示例6: isToBeProcessed

点赞 2

import spoon.reflect.reference.CtPackageReference; //导入依赖的package包/类
@Override
 public boolean isToBeProcessed(CtInvocation<?> candidate) {
     if (!candidate.getExecutable().getSimpleName().contains("assert")) {
         return false;
     }
     CtExecutableReference<?> executable = candidate.getExecutable();
     CtPackageReference executablePackage = executable.getDeclaringType()
             .getPackage();
     if (executablePackage == null
             || !executablePackage.getSimpleName().contains("junit")) {
         return false;
     }
     CtMethod<?> parentMethod = candidate.getParent(CtMethod.class);
     if (parentMethod == null) {
         return false;
     }
     createExecutionMethod(candidate);
     return super.isToBeProcessed(candidate);
     /*
* boolean found = false; for (TestCase testCase : faillingTest) { if
* (testCase.className().equals(parentClass.getQualifiedName())) { if
* (testCase.testName().equals(parentMethod.getSimpleName())) { found =
* true; break; } } }
* 
* return found;
*/
 }
 

开发者ID:SpoonLabs,
项目名称:nopol,
代码行数:28,
代码来源:AssertReplacer.java

示例7: processingDone

点赞 2

import spoon.reflect.reference.CtPackageReference; //导入依赖的package包/类
@Override
public void processingDone() {
	for (CtPackageReference p : packRefs.keySet()) {
		Stack<CtPackageReference> path = new Stack<CtPackageReference>();
		path.push(p);
		scanDependencies(path);
	}
}
 

开发者ID:SpoonLabs,
项目名称:spoon-examples,
代码行数:9,
代码来源:ReferenceProcessor.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)