Skip to content

Commit

Permalink
Merge branch 'xjtu-enre:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
peco0x00 authored Mar 5, 2024
2 parents e512917 + c1abf5a commit 89859eb
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 5 deletions.
8 changes: 8 additions & 0 deletions src/main/java/TempOutput/JsonString.java
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,14 @@ public static JSONObject JSONWriteRelation(Map<Integer, ArrayList<Tuple<Integer,
enhanceObj.put("isAbstract", ((MethodEntity) entity).getIndices().getMethodIsAbstract());
entityObj.accumulate("enhancement", enhanceObj);
}

// method block loc
JSONObject methodBlock = new JSONObject();
methodBlock.put("startLine", entity.getLocation().getStartLine());
methodBlock.put("endLine", entity.getLocation().getEndLine());
methodBlock.put("startColumn", entity.getLocation().getStartColumn());
methodBlock.put("endColumn", entity.getLocation().getEndColumn());
entityObj.accumulate("blockLoc", methodBlock);
}
//bin path
if (entity.getBinPath()!= null){
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/entity/MethodEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public void setLambda(boolean lambda) {
//record the id of blocks in method
protected ArrayList<Block> blocks = new ArrayList<>();

Location blockLoc = new Location();

//record the initial local var name
protected ArrayList<VariableEntity> localVars = new ArrayList<>();

Expand Down Expand Up @@ -153,6 +155,14 @@ public ArrayList<VariableEntity> getLocalVars(){
// }
// }

public Location getBlockLoc(){
return this.blockLoc;
}

public void setBlockLoc(Location loc){
this.blockLoc = loc;
}

public HashMap<String, String> getName2Role(){ return this.name2Role; }

public void addName2Role (String name, String role){
Expand Down
20 changes: 17 additions & 3 deletions src/main/java/entity/dto/MethodEntityDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public class MethodEntityDTO extends InternalEntityDTO {
private String hidden;
private ICCMethodAttributeDTO iccMethodAttribute;

private LocationDTO blockLoc;

public MethodEntityDTO() {
}

Expand All @@ -26,7 +28,8 @@ public MethodEntityDTO(
LocationDTO location,
String modifiers,
ParameterDTO parameter,
String rawType) {
String rawType,
LocationDTO blockLoc) {
super(parentId, "Method");
this.File = file;
this.additionalBin = additionalBin;
Expand All @@ -35,6 +38,7 @@ public MethodEntityDTO(
this.modifiers = modifiers;
this.parameter = parameter;
this.rawType = rawType;
this.blockLoc = blockLoc;
}

public MethodEntityDTO(
Expand All @@ -49,7 +53,8 @@ public MethodEntityDTO(
String modifiers,
ParameterDTO parameter,
String rawType,
ICCMethodAttributeDTO iccMethodAttribute) {
ICCMethodAttributeDTO iccMethodAttribute,
LocationDTO blockLoc) {
super(id, name, qualifiedName, parentId, "Method");
this.File = file;
this.additionalBin = additionalBin;
Expand All @@ -59,6 +64,7 @@ public MethodEntityDTO(
this.parameter = parameter;
this.rawType = rawType;
this.iccMethodAttribute = iccMethodAttribute;
this.blockLoc = blockLoc;
}

public MethodEntityDTO(
Expand All @@ -74,7 +80,8 @@ public MethodEntityDTO(
ParameterDTO parameter,
String rawType,
String hidden,
ICCMethodAttributeDTO iccMethodAttribute) {
ICCMethodAttributeDTO iccMethodAttribute,
LocationDTO blockLoc) {
super(id, name, qualifiedName, parentId, "Method");
this.File = file;
this.additionalBin = additionalBin;
Expand All @@ -85,6 +92,7 @@ public MethodEntityDTO(
this.rawType = rawType;
this.hidden = hidden;
this.iccMethodAttribute = iccMethodAttribute;
this.blockLoc = blockLoc;
}

public String getHidden() {
Expand Down Expand Up @@ -152,6 +160,12 @@ public void setRawType(String rawType) {
this.rawType = rawType;
}

public LocationDTO getBlockLoc(){return blockLoc; }

public void setBlockLoc(LocationDTO blockLoc) {
this.blockLoc = blockLoc;
}

public static class EnhancementDTO {

private Boolean isGetter;
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/util/EnreFormatParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ private static EntityDTO parseEntityDTO(JSONObject variableObj) {
String hidden = (String) get(variableObj, "hidden");
AdditionalBinDTO additionalBinDTO = parseAdditionalBinDTO(variableObj);
LocationDTO locationDTO = parseLocationDTO(variableObj, "location");
LocationDTO blockLocDTO = parseLocationDTO(variableObj, "blockLoc");
ICCMethodAttributeDTO iccMethodAttributeDTO = parseICCMethodAttributeDTO(variableObj);
ICCVariableAttributeDTO iccVariableAttributeDTO = parseICCVariableAttributeDTO(variableObj);
ComponentDTO componentDTO = parseComponentDTO(variableObj);
Expand Down Expand Up @@ -327,7 +328,8 @@ private static EntityDTO parseEntityDTO(JSONObject variableObj) {
parameterDTO,
rawType,
hidden,
iccMethodAttributeDTO);
iccMethodAttributeDTO,
blockLocDTO);
break;
case "Module":
res = null;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/visitor/ProcessEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -492,12 +492,12 @@ public int processMethod(MethodDeclaration node,int parentTypeId, CompilationUni
String methodName = node.getName().getIdentifier();
String methodQualifiedName = singleCollect.getEntityById(parentTypeId).getQualifiedName() + "." + methodName;


MethodEntity methodEntity = new MethodEntity(methodId,methodName);
methodEntity.setQualifiedName(methodQualifiedName);
methodEntity.setParentId(parentTypeId);
methodEntity.setLocation(supplement_location(cu, node.getStartPosition(), node.getLength()));
//methodEntity.setCodeSnippet(node.toString());
methodEntity.setBlockLoc(supplement_location(cu, node.getBody().getStartPosition(), node.getBody().getLength()));

if(node.isConstructor()){
methodEntity.setConstructor(true);
Expand Down

0 comments on commit 89859eb

Please sign in to comment.