forked from SpoonLabs/coming
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* JKali revised and fixed * jkali ground-truth testing updated * ground-truth tests added * pattern used in ground-truth testing are saved into an object * patterns and filters checked and fixed * elixir is tested * elixir revised and tested * FinalResult is logged at debug level * travis output is shortened * using null-output instead of empty-output * ignoring arja and nopol ground tests for now
- Loading branch information
1 parent
eeff21e
commit 0eeed95
Showing
47 changed files
with
757 additions
and
1,903 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>coming</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.m2e.core.maven2Builder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>org.eclipse.m2e.core.maven2Nature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
src/main/java/fr/inria/coming/repairability/models/ASTData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
package fr.inria.coming.repairability.models; | ||
|
||
import fr.inria.coming.utils.ASTInfoResolver; | ||
import spoon.reflect.code.*; | ||
import spoon.reflect.declaration.CtElement; | ||
import spoon.reflect.declaration.CtMethod; | ||
import spoon.reflect.declaration.CtVariable; | ||
|
||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
public class ASTData { | ||
private static final String NAME_SEPARATOR = "###"; | ||
|
||
private Set<String> executableInvocations; | ||
private Set<String> variablesAndLiterals; | ||
|
||
public ASTData(CtElement rootNode) { | ||
executableInvocations = new HashSet<>(); | ||
variablesAndLiterals = new HashSet<>(); | ||
|
||
List<CtElement> allElements = rootNode.getElements(null); | ||
for (CtElement element : allElements) { | ||
if (element instanceof CtAbstractInvocation) { | ||
executableInvocations.add(getExecutableQualifiedSignature(element)); | ||
} else if (element instanceof CtVariableAccess || element instanceof CtLiteral) { | ||
variablesAndLiterals.add(ASTInfoResolver.getCleanedName(element)); | ||
} else if (element instanceof CtMethod) { | ||
executableInvocations.add(getExecutableQualifiedSignature(element)); | ||
} else if (element instanceof CtVariable) { | ||
variablesAndLiterals.add(((CtVariable) element).getReference().toString()); | ||
} | ||
} | ||
} | ||
|
||
public boolean canElixirGenerateNode(CtElement mappedElement, CtElement newNode) { | ||
Set<String> validInvocationsAsArguments = new HashSet<>(); | ||
if (mappedElement != null && mappedElement instanceof CtAbstractInvocation) { | ||
List<CtExpression> arguments = ((CtAbstractInvocation) mappedElement).getArguments(); | ||
for (CtExpression argument : arguments) { | ||
if (argument instanceof CtAbstractInvocation) { | ||
validInvocationsAsArguments.add(argument.toString()); | ||
} | ||
} | ||
} | ||
if (newNode instanceof CtAbstractInvocation) { | ||
if (!executableInvocations.contains(getExecutableQualifiedSignature(newNode))) | ||
return false; | ||
List<CtExpression> arguments = ((CtAbstractInvocation) newNode).getArguments(); | ||
for (CtExpression argument : arguments) { | ||
if (argument.toString().equals("null")) | ||
continue; | ||
if (validInvocationsAsArguments.contains(argument.toString())) | ||
continue; | ||
if (!(argument instanceof CtVariableAccess || argument instanceof CtLiteral) | ||
|| !variablesAndLiterals.contains(ASTInfoResolver.getCleanedName(argument))) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} else if (newNode instanceof CtVariableAccess || newNode instanceof CtLiteral) { | ||
return variablesAndLiterals.contains(ASTInfoResolver.getCleanedName(newNode)); | ||
} | ||
return false; | ||
} | ||
|
||
private String getExecutableQualifiedSignature(CtElement element) { | ||
if (element instanceof CtAbstractInvocation) { | ||
CtAbstractInvocation invocation = (CtAbstractInvocation) element; | ||
return invocation.getExecutable().getDeclaringType() == null ? "null" : invocation.getExecutable().getDeclaringType().toString() | ||
+ NAME_SEPARATOR + invocation.getExecutable().getSignature(); | ||
} else if (element instanceof CtMethod) { | ||
CtMethod method = (CtMethod) element; | ||
return method.getDeclaringType().getQualifiedName().toString() + NAME_SEPARATOR + method.getSignature(); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public Set<String> getExecutableInvocations() { | ||
return executableInvocations; | ||
} | ||
|
||
public void setExecutableInvocations(Set<String> executableInvocations) { | ||
this.executableInvocations = executableInvocations; | ||
} | ||
|
||
public Set<String> getVariablesAndLiterals() { | ||
return variablesAndLiterals; | ||
} | ||
|
||
public void setVariablesAndLiterals(Set<String> variablesAndLiterals) { | ||
this.variablesAndLiterals = variablesAndLiterals; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.