Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
monperrus committed May 1, 2024
1 parent da8ec79 commit 1683015
Show file tree
Hide file tree
Showing 15 changed files with 51 additions and 1,619 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import java.util.Map;

import fr.inria.coming.core.entities.interfaces.IRevisionPair;
import fr.inria.prophet4j.feature.extended.ExtendedFeatureCross;
import fr.inria.prophet4j.feature.enhanced.EnhancedFeatureCross;
import org.apache.log4j.Logger;

import com.google.gson.JsonObject;
Expand Down Expand Up @@ -98,12 +98,9 @@ public JsonObject extractFeatures(Map<String, File> filePaths) {
return null;
}
Option option = new Option();
option.featureOption = FeatureOption.EXTENDED;
//We set the first parameter of CodeDiffer as False to not allow the code generation at buggy location
//By default, coming extracts simple P4J features, so the cross sets to false
Boolean cross = ComingProperties.getPropertyBoolean("cross");
option.featureOption = FeatureOption.ENHANCED;

CodeDiffer codeDiffer = new CodeDiffer(false, option,cross);
CodeDiffer codeDiffer = new CodeDiffer(false, option);
//Get feature matrix
List<FeatureMatrix> featureMatrix = codeDiffer.runByGenerator(src, target);
//Get feature vector
Expand Down Expand Up @@ -155,7 +152,7 @@ public JsonObject genVectorsCSV(Option option, File patchedFile, List<FeatureMat
//Initial all vector as 0.
for (int idx = 0; idx < parameterVector.size(); idx++) {
FeatureCross featureCross;
featureCross = new ExtendedFeatureCross(idx);
featureCross = new EnhancedFeatureCross(idx);
header.add(featureCross.getFeatures().toString());
values.add("0");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@
public interface FeatureExtractor {
// this is for CodeDiffer.java
FeatureVector extractFeature(Repair repair, CtElement atom);
FeatureVector extractSimpleP4JFeature(Repair repair, CtElement atom);
}
Original file line number Diff line number Diff line change
Expand Up @@ -224,5 +224,4 @@ public boolean containFeature(Feature feature) {
public String toString() {
return "FeatureCross: " + features;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -552,10 +552,4 @@ private void getNearbyStmts(Repair repair, List<CtElement> stmtsF, List<CtElemen
if (!repair.isReplace)
stmtsL.add(srcElem);
}

@Override
public FeatureVector extractSimpleP4JFeature(Repair repair, CtElement atom) {
// TODO Auto-generated method stub
return null;
}
}
Original file line number Diff line number Diff line change
@@ -1,36 +1,33 @@
package fr.inria.prophet4j.feature.extended;
package fr.inria.prophet4j.feature.enhanced;

import java.lang.reflect.Type;
import java.util.*;

import fr.inria.prophet4j.utility.Structure.RepairKind;
import fr.inria.prophet4j.utility.Structure.Repair;
import fr.inria.prophet4j.utility.Structure.DiffEntry;
import fr.inria.prophet4j.feature.RepairGenerator;
import fr.inria.prophet4j.feature.extended.util.ExtendedRepairAnalyzer;
import fr.inria.prophet4j.utility.Structure.DiffEntry;
import fr.inria.prophet4j.utility.Structure.Repair;
import fr.inria.prophet4j.utility.Structure.RepairKind;
import fr.inria.prophet4j.feature.enhanced.util.EnhancedRepairAnalyzer;
import spoon.Launcher;
import spoon.reflect.code.CtIf;
import spoon.reflect.code.CtStatement;
import spoon.reflect.code.CtStatementList;
import spoon.reflect.code.*;
import spoon.reflect.declaration.CtClass;
import spoon.reflect.declaration.CtElement;
import spoon.reflect.declaration.CtMethod;
import spoon.reflect.visitor.filter.TypeFilter;
import spoon.reflect.code.*;
import spoon.reflect.factory.CoreFactory;
import spoon.reflect.path.CtRole;
import spoon.reflect.visitor.CtScanner;
import spoon.reflect.visitor.filter.TypeFilter;

import java.lang.reflect.Type;
import java.util.*;

// based on RepairGenerator.cpp
public class ExtendedRepairGenerator implements RepairGenerator {
public class EnhancedRepairGenerator implements RepairGenerator {
private Set<CtElement> area; // loc_map
private DiffEntry diffEntry;
private CoreFactory factory;
private List<Repair> repairs = new ArrayList<>();
private Map<CtStatementList, Integer> compound_counter = new HashMap<>();
private ExtendedRepairAnalyzer repairAnalyzer = new ExtendedRepairAnalyzer();
private EnhancedRepairAnalyzer repairAnalyzer = new EnhancedRepairAnalyzer();

public ExtendedRepairGenerator(DiffEntry diffEntry) {
public EnhancedRepairGenerator(DiffEntry diffEntry) {
this.area = fuzzyLocator(diffEntry.srcNode);
this.diffEntry = diffEntry;
this.factory = new Launcher().getFactory().Core();
Expand Down Expand Up @@ -189,7 +186,7 @@ private void genAddIfExit(CtStatement n) {

private void genReplaceStmt(CtStatement n) {
if (n instanceof CtExpression) {
ExtendedRepairAnalyzer.AtomReplaceVisitor V = repairAnalyzer.newAtomReplaceVisitor();
EnhancedRepairAnalyzer.AtomReplaceVisitor V = repairAnalyzer.newAtomReplaceVisitor();
V.TraverseStmt(n);
for (CtElement it : V.getResult()) {
Repair repair = new Repair();
Expand Down Expand Up @@ -241,7 +238,7 @@ private void genReplaceStmt(CtStatement n) {
private void genAddStmt(CtStatement n) {
Set<CtElement> exprs = repairAnalyzer.getGlobalCandidateExprs(n);
for (CtElement it: exprs) {
ExtendedRepairAnalyzer.AtomReplaceVisitor V = repairAnalyzer.newAtomReplaceVisitor();
EnhancedRepairAnalyzer.AtomReplaceVisitor V = repairAnalyzer.newAtomReplaceVisitor();
V.TraverseStmt(it);
// if (!repairAnalyzer.isValidStmt(it))
// continue;
Expand Down Expand Up @@ -383,7 +380,6 @@ public Repair obtainHumanRepair() {
} catch (Exception e) {
// such as public, final, static
}

return repair;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package fr.inria.prophet4j.feature.extended.util;
package fr.inria.prophet4j.feature.enhanced.util;

import spoon.reflect.code.*;
import spoon.reflect.declaration.*;
import spoon.reflect.declaration.CtClass;
import spoon.reflect.declaration.CtElement;
import spoon.reflect.declaration.CtMethod;
import spoon.reflect.visitor.filter.TypeFilter;

import java.lang.reflect.Type;
import java.util.*;

// based on LocalAnalyzer.cpp GlobalAnalyzer.cpp
public class ExtendedRepairAnalyzer {
public class EnhancedRepairAnalyzer {
public List<CtElement> getCondCandidateVars(CtElement element) {
List<CtElement> ret = new ArrayList<>();
// Global variables
Expand Down
240 changes: 0 additions & 240 deletions src/main/java/fr/inria/prophet4j/feature/extended/ExtendedFeature.java

This file was deleted.

Loading

0 comments on commit 1683015

Please sign in to comment.