Skip to content

Commit

Permalink
-Updated methods
Browse files Browse the repository at this point in the history
MappingState.getMaximumCommonSubGraphs()
DivideAndConquerMatcher.getMaximumStates()
to keep all the mappings with a size equal
to max and max-1

This is a fix for the following case found in project JFreeChart-1.0.10
org.jfree.chart.plot.PiePlot3D.draw(Graphics2D,Rectangle2D,Point2D,PlotState,PlotRenderingInfo):void	lines 255-265
org.jfree.chart.plot.PiePlot.drawPie(Graphics2D,Rectangle2D,PlotRenderingInfo):void	lines 2320-2331

Before the fix statements were mapped as follows
21   double igy1 = plotArea.getY() + vGap;
13   double igy2 = plotArea.getMaxY() - vGap;

22   double igy2 = plotArea.getMaxY() - vGap;
12   double igy1 = plotArea.getY() + vGap;

-Fix in ExtractCloneRefactoring to handle properly void return types

-Fixed modifyExtractedFieldAssignmentsInSourceClass()
to handle qualifiedNames in which the rightmost part
is an extracted field.

-Fixed the naming of the getter and setter methods
created for the extracted fields, when an extracted method has the same name.
Extracted constants for "set" and "get" literals.
  • Loading branch information
tsantalis committed Sep 12, 2016
1 parent adfdc82 commit 9117380
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1615,7 +1615,7 @@ private List<MappingState> getMaximumStates(List<MappingState> currentStates) {
for(MappingState currentState : currentStates) {
if(currentState.getSize() > max) {
max = currentState.getSize();
maximumStates.clear();
clear(maximumStates, max);
maximumStates.add(currentState);
}
else if(currentState.getSize() == max) {
Expand Down Expand Up @@ -1643,4 +1643,15 @@ else if(currentState.getDistinctDifferenceCount() == minimum) {
}
return maximumStatesWithMinimumDifferences;
}

private void clear(List<MappingState> maximumStates, int max) {
List<MappingState> keepStates = new ArrayList<MappingState>();
for(MappingState state : maximumStates) {
if(state.getSize() == max-1) {
keepStates.add(state);
}
}
maximumStates.clear();
maximumStates.addAll(keepStates);
}
}
13 changes: 12 additions & 1 deletion src/gr/uom/java/ast/decomposition/cfg/mapping/MappingState.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public List<MappingState> getMaximumCommonSubGraphs() {
for(MappingState state : leaves) {
if(state.getSize() > max) {
max = state.getSize();
maximumStates.clear();
clear(maximumStates, max);
maximumStates.add(state);
}
else if(state.getSize() == max) {
Expand All @@ -196,6 +196,17 @@ else if(state.getSize() == max) {
return maximumStates;
}

private void clear(List<MappingState> maximumStates, int max) {
List<MappingState> keepStates = new ArrayList<MappingState>();
for(MappingState state : maximumStates) {
if(state.getSize() == max-1) {
keepStates.add(state);
}
}
maximumStates.clear();
maximumStates.addAll(keepStates);
}

private boolean containsSameState(List<MappingState> states, MappingState state) {
for(MappingState oldState : states) {
if(oldState.sameNodeMappings(state))
Expand Down
Loading

0 comments on commit 9117380

Please sign in to comment.