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

Java CtNamedElement类代码示例

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

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



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

示例1: codeFragmentCoverage

import spoon.reflect.declaration.CtNamedElement; //导入依赖的package包/类
@Override
public double codeFragmentCoverage(CodeFragment stmt) {

    CtElement e = stmt.getCtCodeFragment();

    boolean foundMethod = false;
    while ( e != null && !foundMethod ) {
        e = e.getParent();
        foundMethod = e != null && (e instanceof spoon.reflect.declaration.CtMethod || e instanceof  CtConstructor);
    }

    if (foundMethod ) {
        String className = stmt.getCtCodeFragment().getParent(CtType.class).getQualifiedName();
        return methodSignatures.contains(className + "." + ((CtNamedElement)e).getSimpleName()) ? 1.0 : 0.0;
    }
    return 0.0;
    //throw new RuntimeException("Unable to find parent method");

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


示例2: runFromSpoonNodes

import spoon.reflect.declaration.CtNamedElement; //导入依赖的package包/类
public static TestListener runFromSpoonNodes(InputConfiguration configuration,
                                                String classpath,
                                                CtType<?> testClass,
                                                Collection<CtMethod<?>> testMethods) {
	return run(configuration,
			classpath,
			testClass,
			testMethods.stream()
					.map(CtNamedElement::getSimpleName)
					.collect(Collectors.toList())
	);
}
 
开发者ID:STAMP-project,项目名称:dspot,代码行数:13,代码来源:TestLauncher.java


示例3: selectToAmplify

import spoon.reflect.declaration.CtNamedElement; //导入依赖的package包/类
@Override
public List<CtMethod<?>> selectToAmplify(List<CtMethod<?>> testsToBeAmplified) {
	if (this.currentClassTestToBeAmplified == null && !testsToBeAmplified.isEmpty()) {
		this.currentClassTestToBeAmplified = testsToBeAmplified.get(0).getDeclaringType();
		this.initialCoverage = new JacocoExecutor(this.program, this.configuration, this.currentClassTestToBeAmplified).executeJacoco(this.currentClassTestToBeAmplified);
		this.selectedToBeAmplifiedCoverageResultsMap = null;
		this.selectedAmplifiedTest.clear();
	}
	final List<String> methodNames = testsToBeAmplified.stream().map(CtNamedElement::getSimpleName).collect(Collectors.toList());
	final Map<String, CoverageResults> coverageResultsMap = new JacocoExecutor(this.program, this.configuration, this.currentClassTestToBeAmplified)
			.executeJacoco(this.currentClassTestToBeAmplified, methodNames);
	final List<String> pathExecuted = new ArrayList<>();
	final List<CtMethod<?>> filteredTests = testsToBeAmplified.stream()
			.filter(ctMethod -> {
				final String pathByExecInstructions = computePathExecuted.apply(coverageResultsMap.get(ctMethod.getSimpleName()).getCoverageBuilder());
				if (pathExecuted.contains(pathByExecInstructions)) {
					return false;
				} else {
					pathExecuted.add(pathByExecInstructions);
					return true;
				}
			}).collect(Collectors.toList());

	if (this.selectedToBeAmplifiedCoverageResultsMap == null) {
		final List<String> filteredMethodNames = filteredTests.stream()
				.map(CtNamedElement::getSimpleName)
				.collect(Collectors.toList());
		this.selectedToBeAmplifiedCoverageResultsMap = coverageResultsMap.keySet()
				.stream()
				.filter(filteredMethodNames::contains)
				.collect(Collectors.toMap(Function.identity(), coverageResultsMap::get));
	}
	return filteredTests;
}
 
开发者ID:STAMP-project,项目名称:dspot,代码行数:35,代码来源:JacocoCoverageSelector.java


示例4: selectToKeep

import spoon.reflect.declaration.CtNamedElement; //导入依赖的package包/类
@Override
public List<CtMethod<?>> selectToKeep(List<CtMethod<?>> amplifiedTestToBeKept) {

    final String classpath = AutomaticBuilderFactory.getAutomaticBuilder(this.configuration)
            .buildClasspath(this.program.getProgramDir()) +
            System.getProperty("path.separator") +
            this.pathToChangedVersionOfProgram + "/" + this.program.getClassesDir() +
            System.getProperty("path.separator") +
            this.program.getProgramDir() + "/" + this.program.getTestClassesDir();

    final TestListener results = TestLauncher.run(this.configuration,
            classpath,
            this.currentClassTestToBeAmplified,
            amplifiedTestToBeKept.stream()
                    .map(CtNamedElement::getSimpleName)
                    .collect(Collectors.toList())
    );

    if (!results.getFailingTests().isEmpty()) {
        final List<String> failingTestName = results.getFailingTests()
                .stream()
                .map(Failure::getDescription)
                .map(Description::getMethodName)
                .collect(Collectors.toList());
        amplifiedTestToBeKept
                .stream()
                .filter(ctMethod -> failingTestName.contains(ctMethod.getSimpleName()))
                .forEach(this.selectedAmplifiedTest::add);
    }
    return amplifiedTestToBeKept;
}
 
开发者ID:STAMP-project,项目名称:dspot,代码行数:32,代码来源:ChangeDetectorSelector.java


示例5: process

import spoon.reflect.declaration.CtNamedElement; //导入依赖的package包/类
public void process(CtElement element) {
	if (element instanceof CtNamedElement || element instanceof CtField || element instanceof CtExecutable) {
		if (((CtModifiable) element).getModifiers().contains(ModifierKind.PUBLIC) || ((CtModifiable) element).getModifiers().contains(ModifierKind.PROTECTED)) {
			if (element.getDocComment() == null || element.getDocComment().equals("")) {
				undocumentedElements.add(element);
			}
		}
	}
}
 
开发者ID:SpoonLabs,项目名称:spoon-examples,代码行数:10,代码来源:DocProcessor.java


示例6: enter

import spoon.reflect.declaration.CtNamedElement; //导入依赖的package包/类
@Override
protected void enter(final @NotNull CtElement e) {
	super.enter(e);
	System.out.print('\n');
	printTabs();
	System.out.print(e.getClass().getSimpleName());

	if(e instanceof CtNamedElement) {
		System.out.print(": " + ((CtNamedElement) e).getSimpleName() + " " + SpoonHelper.INSTANCE.formatPosition(e.getPosition()));
	}else if(e instanceof CtReference) {
		System.out.print(": " + ((CtReference) e).getSimpleName() + " " + SpoonHelper.INSTANCE.formatPosition(e.getPosition()));
	}

	nbTab++;
}
 
开发者ID:diverse-project,项目名称:InspectorGuidget,代码行数:16,代码来源:SpoonStructurePrinter.java


示例7: selectToKeep

import spoon.reflect.declaration.CtNamedElement; //导入依赖的package包/类
@Override
public List<CtMethod<?>> selectToKeep(List<CtMethod<?>> amplifiedTestToBeKept) {
	if (amplifiedTestToBeKept.isEmpty()) {
		return amplifiedTestToBeKept;
	}
	final List<String> methodNames = amplifiedTestToBeKept.stream().map(CtNamedElement::getSimpleName).collect(Collectors.toList());
	final Map<String, CoverageResults> coverageResultsMap = new JacocoExecutor(this.program, this.configuration, this.currentClassTestToBeAmplified).executeJacoco(
			this.currentClassTestToBeAmplified, methodNames);
	final List<String> pathExecuted = new ArrayList<>();
	final List<CtMethod<?>> methodsKept = amplifiedTestToBeKept.stream()
			.filter(ctMethod ->
					this.selectedToBeAmplifiedCoverageResultsMap.get(
							getFirstParentThatHasBeenRun(ctMethod).getSimpleName()) == null ||
							coverageResultsMap.get(ctMethod.getSimpleName()).isBetterThan(
							this.selectedToBeAmplifiedCoverageResultsMap.get(
									getFirstParentThatHasBeenRun(ctMethod).getSimpleName())) &&
							!computePathExecuted.apply(coverageResultsMap.get(ctMethod.getSimpleName()).getCoverageBuilder())
							.equals(computePathExecuted.apply(this.selectedToBeAmplifiedCoverageResultsMap.get(
									getFirstParentThatHasBeenRun(ctMethod).getSimpleName()).getCoverageBuilder()))
			)
			.filter(ctMethod -> {
				final String pathByExecInstructions = computePathExecuted.apply(coverageResultsMap.get(ctMethod.getSimpleName()).getCoverageBuilder());
				if (pathExecuted.contains(pathByExecInstructions)) {
					return false;
				} else {
					pathExecuted.add(pathByExecInstructions);
					return true;
				}
			})
			.collect(Collectors.toList());

	this.selectedToBeAmplifiedCoverageResultsMap.putAll(methodsKept.stream()
			.map(CtNamedElement::getSimpleName)
			.collect(
					Collectors.toMap(Function.identity(), coverageResultsMap::get)
			)
	);

	this.selectedAmplifiedTest.addAll(new ArrayList<>(methodsKept));
	return methodsKept;
}
 
开发者ID:STAMP-project,项目名称:dspot,代码行数:42,代码来源:JacocoCoverageSelector.java


示例8: isStmtToLog

import spoon.reflect.declaration.CtNamedElement; //导入依赖的package包/类
private static boolean isStmtToLog(String filter, CtStatement statement) {
    if (!(statement.getParent() instanceof CtBlock)) {
        return false;
    }
    if (statement instanceof CtInvocation) {
        CtInvocation invocation = (CtInvocation) statement;
        //type tested by the test class
        String targetType = "";
        if (invocation.getTarget() != null &&
                invocation.getTarget().getType() != null) {
            targetType = invocation.getTarget().getType().getQualifiedName();
        }
        if (targetType.startsWith(filter)) {
            return (!isVoidReturn(invocation)
                    && !isGetter(invocation));
        } else {
            return !isVoidReturn(invocation);
        }

    }

    if (statement instanceof CtLocalVariable ||
            statement instanceof CtAssignment ||
            statement instanceof CtVariableWrite) {

        if (statement instanceof CtNamedElement) {
            if (((CtNamedElement)statement).getSimpleName()
                    .startsWith("__DSPOT_")) {
                return false;
            }
        }

        final CtTypeReference type = ((CtTypedElement) statement).getType();
        if (type.getQualifiedName().startsWith(filter)) {
            return true;
        } else {
            try {
                return type.getActualClass() == String.class;
            } catch (SpoonClassNotFoundException e) {
                return false;
            }
        }
    } else {
        return false;
    }
}
 
开发者ID:STAMP-project,项目名称:dspot,代码行数:47,代码来源:AssertGeneratorHelper.java


示例9: isToBeProcessed

import spoon.reflect.declaration.CtNamedElement; //导入依赖的package包/类
@Override
public boolean isToBeProcessed(CtNamedElement candidate) {
    return classes.contains(candidate.getSimpleName());
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:5,代码来源:JavaOutputProcessorWithFilter.java


示例10: scanCtNamedElement

import spoon.reflect.declaration.CtNamedElement; //导入依赖的package包/类
@Override
public void scanCtNamedElement(CtNamedElement e) {
	label = e.getSimpleName();
}
 
开发者ID:SpoonLabs,项目名称:gumtree-spoon-ast-diff,代码行数:5,代码来源:LabelFinder.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java DocumentRouteHeaderValue类代码示例发布时间:2022-05-22
下一篇:
Java DataTypeDoubleArray类代码示例发布时间: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