Search in sources :

Example 1 with AstComparator

use of gumtree.spoon.AstComparator in project dspot by STAMP-project.

the class SelectorOnDiff method getModifiedMethod.

@SuppressWarnings("unchecked")
private static Set<CtMethod> getModifiedMethod(String pathFile1, String pathFile2) {
    try {
        final File file1 = new File(pathFile1);
        final File file2 = new File(pathFile2);
        if (!file1.exists() || !file2.exists()) {
            return Collections.emptySet();
        }
        Diff result = (new AstComparator()).compare(file1, file2);
        return result.getRootOperations().stream().map(operation -> operation.getSrcNode().getParent(CtMethod.class)).collect(Collectors.toSet());
    } catch (Exception ignored) {
        // if something bad happen, we do not care, we go for next file
        return Collections.emptySet();
    }
}
Also used : Diff(gumtree.spoon.diff.Diff) TypeFilter(spoon.reflect.visitor.filter.TypeFilter) AmplificationHelper(fr.inria.diversify.utils.AmplificationHelper) Logger(org.slf4j.Logger) InputConfiguration(fr.inria.diversify.utils.sosiefier.InputConfiguration) Main(fr.inria.stamp.Main) AstComparator(gumtree.spoon.AstComparator) LoggerFactory(org.slf4j.LoggerFactory) Set(java.util.Set) IOException(java.io.IOException) Factory(spoon.reflect.factory.Factory) InputStreamReader(java.io.InputStreamReader) Collectors(java.util.stream.Collectors) Collections(edu.emory.mathcs.backport.java.util.Collections) File(java.io.File) CtExecutableReference(spoon.reflect.reference.CtExecutableReference) List(java.util.List) CtType(spoon.reflect.declaration.CtType) AmplificationChecker(fr.inria.diversify.utils.AmplificationChecker) BufferedReader(java.io.BufferedReader) CtMethod(spoon.reflect.declaration.CtMethod) AstComparator(gumtree.spoon.AstComparator) Diff(gumtree.spoon.diff.Diff) File(java.io.File) IOException(java.io.IOException)

Aggregations

Collections (edu.emory.mathcs.backport.java.util.Collections)1 AmplificationChecker (fr.inria.diversify.utils.AmplificationChecker)1 AmplificationHelper (fr.inria.diversify.utils.AmplificationHelper)1 InputConfiguration (fr.inria.diversify.utils.sosiefier.InputConfiguration)1 Main (fr.inria.stamp.Main)1 AstComparator (gumtree.spoon.AstComparator)1 Diff (gumtree.spoon.diff.Diff)1 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 List (java.util.List)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 CtMethod (spoon.reflect.declaration.CtMethod)1 CtType (spoon.reflect.declaration.CtType)1 Factory (spoon.reflect.factory.Factory)1 CtExecutableReference (spoon.reflect.reference.CtExecutableReference)1