Skip to content

Commit

Permalink
Improved MappingOptimizer
Browse files Browse the repository at this point in the history
  • Loading branch information
tsantalis committed Oct 11, 2024
1 parent 9453909 commit 8b5a21e
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/main/java/gr/uom/java/xmi/UMLAttribute.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ public boolean isGetter() {
return false;
}

public boolean isSetter() {
return false;
}

public boolean isConstructor() {
return false;
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/gr/uom/java/xmi/UMLInitializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ public boolean isGetter() {
return false;
}

@Override
public boolean isSetter() {
return false;
}

@Override
public boolean isConstructor() {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ default boolean equalReturnParameter(VariableDeclarationContainer operation) {
boolean isDeclaredInAnonymousClass();
Optional<UMLAnonymousClass> getAnonymousClassContainer();
boolean isGetter();
boolean isSetter();
boolean isConstructor();
AbstractCall isDelegate();
boolean isRecursive();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,11 @@ public boolean isGetter() {
return false;
}

@Override
public boolean isSetter() {
return false;
}

@Override
public boolean isConstructor() {
return false;
Expand Down
16 changes: 14 additions & 2 deletions src/main/java/gr/uom/java/xmi/diff/MappingOptimizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,21 @@ else if(!mapper.getContainer1().equals(mapper.getParentMapper().getContainer1())
}
Set<Integer> indicesToBeRemoved = new LinkedHashSet<>();
if(callsExtractedInlinedMethod.contains(true) && callsExtractedInlinedMethod.contains(false)) {
int getterCount = 0;
int setterCount = 0;
for(int i=0; i<callsExtractedInlinedMethod.size(); i++) {
if(callsExtractedInlinedMethod.get(i) == true && !callToExtractedInlinedMethodIsArgument(mappings.get(i), mappers.get(callsExtractedInlinedMethod.indexOf(false)))) {
indicesToBeRemoved.add(i);
if(callsExtractedInlinedMethod.get(i) == false) {
if(mappers.get(i).getContainer2().isGetter())
getterCount++;
if(mappers.get(i).getContainer2().isSetter())
setterCount++;
}
}
if(getterCount == 0 && setterCount == 0) {
for(int i=0; i<callsExtractedInlinedMethod.size(); i++) {
if(callsExtractedInlinedMethod.get(i) == true && !callToExtractedInlinedMethodIsArgument(mappings.get(i), mappers.get(callsExtractedInlinedMethod.indexOf(false)))) {
indicesToBeRemoved.add(i);
}
}
}
if(matchingParentMappers(parentMappers, mappings) > 1) {
Expand Down

0 comments on commit 8b5a21e

Please sign in to comment.