public ClassInfo(final ClassPointer superClass, final ClassPointer outerClass, final ClassInfoBuilder builder) { this.superClass = superClass; this.outerClass = outerClass; this.id = builder.id; this.access = builder.access; this.codeLines = builder.codeLines; this.annotations = FCollection.map(builder.annotations, ClassName.stringToClassName()); this.sourceFile = builder.sourceFile; this.classAnnotationValues = builder.classAnnotationValues; }
@Override public void visitMethodInsn(final int opcode, final String owner, final String name, final String desc, boolean itf) { if (FCollection.contains(this.loggingClasses, matches(owner))) { this.lines.add(this.currentLineNumber); } }
public Collection<String> extractCallDependenciesForPackages( final String clazz, final Predicate<String> targetPackages, final Predicate<DependencyAccess> doNotTraverse) throws IOException { final Set<String> allDependencies = extractCallDependencies(clazz, doNotTraverse); return FCollection.filter(allDependencies, targetPackages); }
public SmartSourceLocator(final Collection<File> roots) { final Collection<File> childDirs = FCollection.flatMap(roots, collectChildren(0)); childDirs.addAll(roots); final Function<File, SourceLocator> fileToSourceLocator = a -> new DirectorySourceLocator(a); this.children = FCollection.map(childDirs, fileToSourceLocator); }
public static Collection<String> getClassPathElementsAsPaths() { final Set<String> filesAsString = new LinkedHashSet<>(); FCollection.mapTo(getClassPathElementsAsFiles(), file -> file.getPath(), filesAsString); return filesAsString; }
private static String createInputString(final List<String> inputArguments) { final StringBuilder sb = new StringBuilder(); FCollection.fold(append(), sb, inputArguments); return sb.toString(); }
public List<T> selectFeatures(List<FeatureSetting> features, Collection<T> filters) { final List<T> factories = new ArrayList<>(filters); final Map<String, Collection<T>> featureMap = FCollection.bucket(factories, byFeatureName()); final List<T> active = FCollection.filter(factories, isOnByDefault()); for ( final FeatureSetting each : features ) { final Collection<T> providers = featureMap.get(each.feature()); if ((providers == null) || providers.isEmpty()) { throw new IllegalArgumentException("Pitest and its installed plugins do not recognise the feature " + each.feature()); } if (each.addsFeature()) { active.addAll(providers); } if (each.removesFeature()) { active.removeAll(providers); } } return active; }
private List<String> getCategories(final Class<?> a) { final Category c = a.getAnnotation(Category.class); return FCollection.flatMap(Arrays.asList(c), toCategoryNames()); }
public List<MutationAnalysisUnit> createMutationTestUnits( final Collection<ClassName> codeClasses) { final List<MutationAnalysisUnit> tus = new ArrayList<>(); final List<MutationDetails> mutations = FCollection.flatMap(codeClasses, classToMutations()); Collections.sort(mutations, comparator()); final Collection<MutationResult> analysedMutations = this.analyser .analyse(mutations); final Collection<MutationDetails> needAnalysis = analysedMutations.stream() .filter(statusNotKnown()) .map(resultToDetails()) .collect(Collectors.toList()); final List<MutationResult> analysed = FCollection.filter(analysedMutations, Prelude.not(statusNotKnown())); if (!analysed.isEmpty()) { tus.add(makePreAnalysedUnit(analysed)); } if (!needAnalysis.isEmpty()) { for (final Collection<MutationDetails> ms : this.grouper.groupMutations( codeClasses, needAnalysis)) { tus.add(makeUnanalysedUnit(ms)); } } Collections.sort(tus, new AnalysisPriorityComparator()); return tus; }
public void describeFeatures(SideEffect1<Feature> enabled, SideEffect1<Feature> disabled) { final FeatureParser parser = new FeatureParser(); final Collection<ProvidesFeature> available = new ArrayList<>(this.plugins.findInterceptors()); final List<FeatureSetting> settings = parser.parseFeatures(this.options.getFeatures()); final FeatureSelector<ProvidesFeature> selector = new FeatureSelector<>(settings, available); final HashSet<Feature> enabledFeatures = new HashSet<>(); FCollection.mapTo(selector.getActiveFeatures(), toFeature(), enabledFeatures); FCollection.forEach(enabledFeatures, enabled); final HashSet<Feature> disabledFeatures = new HashSet<>(); FCollection.mapTo(available, toFeature(), disabledFeatures); disabledFeatures.removeAll(enabledFeatures); FCollection.forEach(disabledFeatures, disabled); }
@Override public void verify(final CodeSource code) { final Collection<ClassInfo> codeClasses = FCollection.filter(code.getCode(), isNotSynthetic()); if (hasMutableCode(codeClasses)) { checkAtLeastOneClassHasLineNumbers(codeClasses); FCollection.forEach(codeClasses, throwErrorIfHasNoSourceFile()); } }
@Override public Collection<MutationDetails> intercept( Collection<MutationDetails> mutations, Mutater m) { final Map<Location,Collection<MutationDetails>> buckets = FCollection.bucket(mutations, mutationToLocation()); final List<MutationDetails> willTimeout = new ArrayList<>(); for (final Entry<Location, Collection<MutationDetails>> each : buckets.entrySet() ) { willTimeout.addAll(findTimeoutMutants(each.getKey(), each.getValue(), m)); } mutations.removeAll(willTimeout); return mutations; }
public Collection<TestInfo> getTests() { final Set<TestInfo> uniqueTests = new HashSet<>(); FCollection.flatMapTo(this.mutations, mutationToTargettedTests(), uniqueTests); return uniqueTests; }
private List<String> findModifiedClassNames() throws MojoExecutionException { final File sourceRoot = new File(this.project.getBuild() .getSourceDirectory()); final List<String> modifiedPaths = FCollection.map(findModifiedPaths(), pathByScmDir()); return FCollection.flatMap(modifiedPaths, new PathToJavaClassConverter( sourceRoot.getAbsolutePath())); }
public LoggingCallsFilter(Collection<String> loggingClasses) { FCollection.mapTo(loggingClasses, correctFormat(), this.loggingClasses); }
@Override public int getNumberOfCoveredLines(final Collection<ClassName> mutatedClass) { return FCollection.fold(numberCoveredLines(), 0, mutatedClass); }