From 68691f43cd7e270c776296b3f3858f51a3b1b4d2 Mon Sep 17 00:00:00 2001 From: Alireza Ardalani Date: Wed, 22 Jun 2022 22:13:48 +0430 Subject: [PATCH] update --- .../uom/java/ast/decomposition/cfg/PDG.java | 256 +++++++++--------- .../cfg/PDGObjectSliceUnion.java | 15 +- .../java/ast/decomposition/cfg/PDGSlice.java | 1 - .../ast/decomposition/cfg/PDGSliceUnion.java | 31 +-- .../cfg/PDGSliceUnionCollection.java | 3 - .../views/SingleResponsibilityViolation.java | 14 +- 6 files changed, 159 insertions(+), 161 deletions(-) diff --git a/src/gr/uom/java/ast/decomposition/cfg/PDG.java b/src/gr/uom/java/ast/decomposition/cfg/PDG.java index db1e52e..dc5fe68 100644 --- a/src/gr/uom/java/ast/decomposition/cfg/PDG.java +++ b/src/gr/uom/java/ast/decomposition/cfg/PDG.java @@ -237,15 +237,17 @@ public Map> getDefinedAttributesOfRefe return definedPropertiesMap; } + // SBSRE: Add variableOutput() method + // => + public List variableOutput(){ List outputVariableList = new ArrayList(); for(GraphNode node : nodes){ PDGNode pdgNode = (PDGNode)node; if(pdgNode instanceof PDGExitNode){ if(!pdgNode.getStatement().getUsedLocalVariables().isEmpty()){ - for (PlainVariable P : pdgNode.getStatement().getUsedLocalVariables()){ - //System.out.println("2222: " + P.toString()); - outputVariableList.add(P); + for (PlainVariable plainVariable : pdgNode.getStatement().getUsedLocalVariables()){ + outputVariableList.add(plainVariable); } } } @@ -256,28 +258,23 @@ else if(pdgNode instanceof PDGStatementNode){ ExpressionStatement expressionStatement = (ExpressionStatement)statement; Expression expression = expressionStatement.getExpression(); if(!(expression instanceof Assignment)) { - //baraye node haii ke chand method dron ham hast ma on method asli ra mikhahim baghiye .... - int I = pdgNode.getCFGNode().getStatement().getMethodInvocations().size(); - I--; - MethodInvocationObject M = pdgNode.getCFGNode().getStatement().getMethodInvocations().get(I); - // empty bodan ya error ijad mikonad ya null dar list darj mikonad ma nemikhahim hich kodam ra + int InvocationPlace = pdgNode.getCFGNode().getStatement().getMethodInvocations().size(); + InvocationPlace--; + MethodInvocationObject methodInvocationObject = pdgNode.getCFGNode().getStatement().getMethodInvocations().get(InvocationPlace); if(!pdgNode.getStatement().getUsedLocalVariables().isEmpty()){ - for (PlainVariable P : pdgNode.getStatement().getUsedLocalVariables()){ - if(M.getMethodInvocation().getExpression() != null){ - if(P.toString().equals(M.getMethodInvocation().getExpression().toString())){ - //System.out.println("11111: " + P.toString()); - if(!objectsInMethodIvocation.contains(P)){ - objectsInMethodIvocation.add(P); + for (PlainVariable plainVariable : pdgNode.getStatement().getUsedLocalVariables()){ + if(methodInvocationObject.getMethodInvocation().getExpression() != null){ + if(plainVariable.toString().equals(methodInvocationObject.getMethodInvocation().getExpression().toString())){ + if(!objectsInMethodIvocation.contains(plainVariable)){ + objectsInMethodIvocation.add(plainVariable); } } else{ - //System.out.println("22222: " + P.toString()); - outputVariableList.add(P); + outputVariableList.add(plainVariable); } } else{ - //System.out.println("22222: " + P.toString()); - outputVariableList.add(P); + outputVariableList.add(plainVariable); } } @@ -292,14 +289,18 @@ else if(pdgNode instanceof PDGStatementNode){ } return outputVariableList; } + + + // SBSRE: Add LastPDGNode() method + // => + public List LastPDGNode(){ List LastPDGNode= new ArrayList(); for(GraphNode node : nodes){ PDGNode pdgNode = (PDGNode)node; if(pdgNode instanceof PDGExitNode){ if(!pdgNode.getStatement().getUsedLocalVariables().isEmpty()){ - for (PlainVariable P : pdgNode.getStatement().getUsedLocalVariables()){ - //System.out.println("2222: " + P.toString()); + for (PlainVariable variable : pdgNode.getStatement().getUsedLocalVariables()){ LastPDGNode.add(pdgNode.getId()); } } @@ -311,24 +312,19 @@ else if(pdgNode instanceof PDGStatementNode){ ExpressionStatement expressionStatement = (ExpressionStatement)statement; Expression expression = expressionStatement.getExpression(); if(!(expression instanceof Assignment)) { - //baraye node haii ke chand method dron ham hast ma on method asli ra mikhahim baghiye .... - int I = pdgNode.getCFGNode().getStatement().getMethodInvocations().size(); - I--; - MethodInvocationObject M = pdgNode.getCFGNode().getStatement().getMethodInvocations().get(I); - // empty bodan ya error ijad mikonad ya null dar list darj mikonad ma nemikhahim hich kodam ra + int InvocationPlace = pdgNode.getCFGNode().getStatement().getMethodInvocations().size(); + InvocationPlace--; + MethodInvocationObject methodInvocationObject = pdgNode.getCFGNode().getStatement().getMethodInvocations().get(InvocationPlace); if(!pdgNode.getStatement().getUsedLocalVariables().isEmpty()){ - for (PlainVariable P : pdgNode.getStatement().getUsedLocalVariables()){ - if(M.getMethodInvocation().getExpression() != null){ - if(P.toString().equals(M.getMethodInvocation().getExpression().toString())){ - //System.out.println("11111: " + P.toString()); + for (PlainVariable plainVariable : pdgNode.getStatement().getUsedLocalVariables()){ + if(methodInvocationObject.getMethodInvocation().getExpression() != null){ + if(plainVariable.toString().equals(methodInvocationObject.getMethodInvocation().getExpression().toString())){ } else{ - //System.out.println("22222: " + P.toString()); LastPDGNode.add(pdgNode.getId()); } } else{ - //System.out.println("22222: " + P.toString()); LastPDGNode.add(pdgNode.getId()); } } @@ -338,14 +334,13 @@ else if(pdgNode instanceof PDGStatementNode){ } } } - } - } return LastPDGNode; } - - public Map alfa(){ + // SBSRE: Add outputVariableCounter() method + // => + public Map outputVariableCounter(){ Map dictionary = new HashMap(); List targetList = variableOutput(); for(PlainVariable Variable :targetList ){ @@ -355,9 +350,9 @@ public Map alfa(){ dictionary.put(Variable, 0); for(PlainVariable Variable1 :targetList ){ if(Variable.equals(Variable1)){ - Integer x= dictionary.get(Variable); - x++; - dictionary.replace(Variable, x); + Integer count= dictionary.get(Variable); + count++; + dictionary.replace(Variable, count); } } } @@ -365,42 +360,45 @@ public Map alfa(){ } return dictionary; } - + + // SBSRE: Add FirstPDGNode() method + // => public List FirstPDGNode(){ + List FirstPDGNode= new ArrayList(); List LastPDGNode = LastPDGNode(); List targetList = variableOutput(); - Map orginal = alfa(); - Map temp = alfa(); + Map orginal = outputVariableCounter(); + Map temp = outputVariableCounter(); for (PlainVariable variable : targetList){ if(orginal.get(variable) == temp.get(variable)){ FirstPDGNode.add(0); - Integer x= temp.get(variable); - x--; - temp.replace(variable, x); + Integer countOfVariable = temp.get(variable); + countOfVariable--; + temp.replace(variable,countOfVariable); } - else if(temp.get(variable)==0){ + else if(temp.get(variable) == 0){ continue; } else{ - Integer x = orginal.get(variable) - temp.get(variable); - int z = 0; - for (PlainVariable variable1 : targetList){ - if(variable.equals(variable1)){ - if(x==1){ - FirstPDGNode.add(LastPDGNode.get(z)); + Integer countOfVariable = orginal.get(variable) - temp.get(variable); + int counter = 0; + for (PlainVariable plainVariable : targetList){ + if(variable.equals(plainVariable)){ + if(countOfVariable == 1){ + FirstPDGNode.add(LastPDGNode.get(counter)); break; } else{ - x--; + countOfVariable--; } } - z++; + counter++; } - Integer m= temp.get(variable); - m--; - temp.replace(variable, m); + Integer locationOfVariable= temp.get(variable); + locationOfVariable--; + temp.replace(variable,locationOfVariable); } } @@ -410,6 +408,9 @@ else if(temp.get(variable)==0){ public Set sendGraphNode() { return nodes; } + + // SBSRE: Add getAssignmentNodesOfVariableCriterionOutputObject() method + // => public Set getAssignmentNodesOfVariableCriterionOutputObject(AbstractVariable localVariableCriterion) { Set nodeCriteria = new LinkedHashSet(); for(GraphNode node : nodes) { @@ -421,12 +422,12 @@ public Set getAssignmentNodesOfVariableCriterionOutputObject(AbstractVa ExpressionStatement expressionStatement = (ExpressionStatement)statement; Expression expression = expressionStatement.getExpression(); if(!(expression instanceof Assignment)) { - int I = pdgNode.getCFGNode().getStatement().getMethodInvocations().size(); - I--; - MethodInvocationObject M = pdgNode.getCFGNode().getStatement().getMethodInvocations().get(I); + int InvocationPlace = pdgNode.getCFGNode().getStatement().getMethodInvocations().size(); + InvocationPlace--; + MethodInvocationObject methodInvocationObject = pdgNode.getCFGNode().getStatement().getMethodInvocations().get(InvocationPlace); if(!pdgNode.getStatement().getUsedLocalVariables().isEmpty()){ - if(M.getMethodInvocation().getExpression() != null){ - if(localVariableCriterion.toString().equals(M.getMethodInvocation().getExpression().toString())){ + if(methodInvocationObject.getMethodInvocation().getExpression() != null){ + if(localVariableCriterion.toString().equals(methodInvocationObject.getMethodInvocation().getExpression().toString())){ nodeCriteria.add(pdgNode); } } @@ -441,12 +442,38 @@ public Set getAssignmentNodesOfVariableCriterionOutputObject(AbstractVa return nodeCriteria; } - + // SBSRE: Add getAssignmentNodesOfVariableCriterionOutput() method + // => public Set getAssignmentNodesOfVariableCriterionOutput(AbstractVariable localVariableCriterion , Integer First,Integer Last) { Set nodeCriteria = new LinkedHashSet(); - + boolean CompositeVariable = isCompositeVariable(localVariableCriterion); for(GraphNode node : nodes) { PDGNode pdgNode = (PDGNode)node; + if(CompositeVariable){ + if(pdgNode instanceof PDGStatementNode){ + if(!pdgNode.getCFGNode().getStatement().getMethodInvocations().isEmpty()){ + Statement statement = pdgNode.getCFGNode().getASTStatement(); + if(statement instanceof ExpressionStatement) { + ExpressionStatement expressionStatement = (ExpressionStatement)statement; + Expression expression = expressionStatement.getExpression(); + if(!(expression instanceof Assignment)) { + int InvocationPlace = pdgNode.getCFGNode().getStatement().getMethodInvocations().size(); + InvocationPlace--; + MethodInvocationObject methodInvocationObject = pdgNode.getCFGNode().getStatement().getMethodInvocations().get(InvocationPlace); + if(!pdgNode.getStatement().getUsedLocalVariables().isEmpty()){ + if(methodInvocationObject.getMethodInvocation().getExpression() != null){ + if(localVariableCriterion.toString().equals(methodInvocationObject.getMethodInvocation().getExpression().toString())){ + nodeCriteria.add(pdgNode); + } + } + } + } + } + } + } + + } + else{ if(pdgNode.definesLocalVariable(localVariableCriterion) && !pdgNode.declaresLocalVariable(localVariableCriterion) && pdgNode.getId() > First && pdgNode.getId() < Last ){ nodeCriteria.add(pdgNode); @@ -455,11 +482,10 @@ else if (pdgNode.getId()==Last && pdgNode.usesLocalVariable(localVariableCriteri if(!(pdgNode instanceof PDGExitNode)){ String MethodInvocer = ""; int Counter = 0; - System.out.println("??????"); - int I = pdgNode.getCFGNode().getStatement().getMethodInvocations().size()-1; - MethodInvocationObject M = pdgNode.getCFGNode().getStatement().getMethodInvocations().get(I); - if(M.getMethodInvocation().getExpression() != null){ - MethodInvocer = M.getMethodInvocation().getExpression().toString(); + int InvocationPlace = pdgNode.getCFGNode().getStatement().getMethodInvocations().size()-1; + MethodInvocationObject methodInvocationObject = pdgNode.getCFGNode().getStatement().getMethodInvocations().get(InvocationPlace); + if(methodInvocationObject.getMethodInvocation().getExpression() != null){ + MethodInvocer = methodInvocationObject.getMethodInvocation().getExpression().toString(); } for(VariableDeclaration declaration : getVariableDeclarationsInMethod()){ PlainVariable localVariable = new PlainVariable(declaration); @@ -470,62 +496,18 @@ else if (pdgNode.getId()==Last && pdgNode.usesLocalVariable(localVariableCriteri } } - System.out.println(Counter); - System.out.println("??///////???"); - if(Counter == 0 ){ nodeCriteria.add(pdgNode); - } - - - - - - - - - /* - for(VariableDeclaration declaration : getVariableDeclarationsInMethod()){ - PlainVariable localVariable = new PlainVariable(declaration); - int I = pdgNode.getCFGNode().getStatement().getMethodInvocations().size()-1; - MethodInvocationObject M = pdgNode.getCFGNode().getStatement().getMethodInvocations().get(I); - if(!pdgNode.getStatement().getUsedLocalVariables().isEmpty()){ - for (PlainVariable P : pdgNode.getStatement().getUsedLocalVariables()){ - if(M.getMethodInvocation().getExpression() != null){ - if(P.toString().equals(M.getMethodInvocation().getExpression().toString())){ - - } - else{ - if(pdgNode.usesLocalVariable(localVariable)){ - System.out.println("KHOOO "+localVariable.toString()); - Counter++; - } - } - } - else{ - if(pdgNode.usesLocalVariable(localVariable)){ - System.out.println("KHOOO "+localVariable.toString()); - Counter++; - } - } - } - - } - - } - - if(Counter <= 1){ - nodeCriteria.add(pdgNode); - } - */ - - - } - + } + } } + + } } return nodeCriteria; } + + public Set getAssignmentNodesOfVariableCriterion(AbstractVariable localVariableCriterion) { Set nodeCriteria = new LinkedHashSet(); for(GraphNode node : nodes) { @@ -538,10 +520,7 @@ public Set getAssignmentNodesOfVariableCriterion(AbstractVariable local } return nodeCriteria; } - - - public Set getAssignmentNodesOfVariableCriterionIncludingDeclaration(AbstractVariable localVariableCriterion) { Set nodeCriteria = new LinkedHashSet(); @@ -781,8 +760,6 @@ private boolean containsNodeWithID(int id) { } private void createControlDependenciesFromEntryNode() { - //System.out.println("case1+3"); - for(GraphNode node : cfg.nodes) { CFGNode cfgNode = (CFGNode)node; if(!isNested(cfgNode)) { @@ -1165,4 +1142,37 @@ public PDGNode getLastUse(PlainVariable variable) { } return null; } + + // SBSRE: Add isCompositeVariable() method + // => Simple and composite variables can be detected with the help of this method for output slicing + + boolean isCompositeVariable(AbstractVariable Variable){ + boolean compositeVariable = false; + for(GraphNode node : nodes) { + PDGNode pdgNode = (PDGNode)node; + if(pdgNode instanceof PDGStatementNode){ + if(!pdgNode.getCFGNode().getStatement().getMethodInvocations().isEmpty()){ + Statement statement = pdgNode.getCFGNode().getASTStatement(); + if(statement instanceof ExpressionStatement) { + ExpressionStatement expressionStatement = (ExpressionStatement)statement; + Expression expression = expressionStatement.getExpression(); + if(!(expression instanceof Assignment)) { + int InvocationPlace = pdgNode.getCFGNode().getStatement().getMethodInvocations().size(); + InvocationPlace--; + MethodInvocationObject methodInvocationObject = pdgNode.getCFGNode().getStatement().getMethodInvocations().get(InvocationPlace); + if(!pdgNode.getStatement().getUsedLocalVariables().isEmpty()){ + if(methodInvocationObject.getMethodInvocation().getExpression() != null){ + if(Variable.toString().equals(methodInvocationObject.getMethodInvocation().getExpression().toString())){ + compositeVariable = true; + break; + } + } + } + } + } + } + } + } + return compositeVariable; + } } diff --git a/src/gr/uom/java/ast/decomposition/cfg/PDGObjectSliceUnion.java b/src/gr/uom/java/ast/decomposition/cfg/PDGObjectSliceUnion.java index 1ce6f4a..b150188 100644 --- a/src/gr/uom/java/ast/decomposition/cfg/PDGObjectSliceUnion.java +++ b/src/gr/uom/java/ast/decomposition/cfg/PDGObjectSliceUnion.java @@ -551,15 +551,14 @@ private boolean sliceContainsVariableDeclarationClosedInFinallyBlock() { } return false; } - private boolean alfa(){ + private boolean sliceSameAsOrginalMethod(){ List targetList = new ArrayList(); targetList=pdg.variableOutput(); int size= targetList.size(); if(size==1){ for(VariableDeclaration declaration : pdg.getVariableDeclarationsInMethod()) { PlainVariable variable = new PlainVariable(declaration); - boolean temp=false; - + boolean temp=false; for(GraphNode node : sliceNodes) { PDGNode pdgNode = (PDGNode)node; if(pdgNode.definesLocalVariable(variable)){ @@ -570,7 +569,6 @@ else if(pdgNode.usesLocalVariable(variable)){ } } if(!temp){ - System.err.println(variable.toString()); return false; } @@ -581,13 +579,12 @@ else if(pdgNode.usesLocalVariable(variable)){ return false; } } - private boolean beta(){ + private boolean sliceSameAsOrginalMethodSecond(){ boolean result=false; Set Nodes = pdg.sendGraphNode(); for(GraphNode node : Nodes){ PDGNode pdgNode = (PDGNode)node; boolean temp=true; - //System.out.println(pdgNode.toString()); for(GraphNode node1 : sliceNodes){ PDGNode pdgNode1 = (PDGNode)node1; if(pdgNode.toString().equals(pdgNode1.toString())){ @@ -595,11 +592,9 @@ private boolean beta(){ } } if(temp){ - //System.out.println(pdgNode.toString()); for(VariableDeclaration declaration : pdg.getVariableDeclarationsInMethod()) { PlainVariable variable = new PlainVariable(declaration); - if(pdgNode.toString().contains("return")){ - + if(pdgNode instanceof PDGExitNode){ } else{ if(pdgNode.definesLocalVariable(variable)){ @@ -629,7 +624,7 @@ public boolean satisfiesRules() { return true; } public boolean satisfiesRulesSRP() { - if(objectSliceEqualsMethodBody() || objectSliceHasMinimumSize() || alfa() || beta() || + if(objectSliceEqualsMethodBody() || objectSliceHasMinimumSize() || sliceSameAsOrginalMethod() || sliceSameAsOrginalMethodSecond() || allNodeCriteriaAreDuplicated() || containsDuplicateNodeWithStateChangingMethodInvocation() || nonDuplicatedSliceNodeAntiDependsOnNonRemovableNode() || diff --git a/src/gr/uom/java/ast/decomposition/cfg/PDGSlice.java b/src/gr/uom/java/ast/decomposition/cfg/PDGSlice.java index 9cba5ec..ccd30f7 100644 --- a/src/gr/uom/java/ast/decomposition/cfg/PDGSlice.java +++ b/src/gr/uom/java/ast/decomposition/cfg/PDGSlice.java @@ -36,7 +36,6 @@ public PDGSlice(PDG pdg, BasicBlock boundaryBlock) { this.boundaryBlock = boundaryBlock; Set regionNodes = pdg.blockBasedRegion(boundaryBlock); - //CommentAlireza: for loop add all or some code of variable&if&for&..... for(PDGNode node : regionNodes) { nodes.add(node); } diff --git a/src/gr/uom/java/ast/decomposition/cfg/PDGSliceUnion.java b/src/gr/uom/java/ast/decomposition/cfg/PDGSliceUnion.java index a871548..2905f48 100644 --- a/src/gr/uom/java/ast/decomposition/cfg/PDGSliceUnion.java +++ b/src/gr/uom/java/ast/decomposition/cfg/PDGSliceUnion.java @@ -38,10 +38,6 @@ public PDGSliceUnion(PDG pdg, BasicBlock boundaryBlock, Set nodeCriteri this.Last=Last; this.subgraph = new PDGSlice(pdg, boundaryBlock); this.sliceNodes = new TreeSet(); - - //comment-alireza : localVariableCriterion this is the variable in code and all of them analys - //System.out.println(localVariableCriterion.toString()+"=>localVariableCriterion"); - for(PDGNode nodeCriterion : nodeCriteria) { sliceNodes.addAll(subgraph.computeSlice(nodeCriterion)); } @@ -553,17 +549,16 @@ private boolean sliceContainsVariableDeclarationClosedInFinallyBlock() { return false; } - private boolean alfa(){ + //SBSRE: Add sliceSameAsOrginalMethod() Method => + + private boolean sliceSameAsOrginalMethod(){ List targetList = new ArrayList(); targetList=pdg.variableOutput(); int size= targetList.size(); if(size==1){ for(VariableDeclaration declaration : pdg.getVariableDeclarationsInMethod()) { PlainVariable variable = new PlainVariable(declaration); - //System.out.println("><><><><<><><>><><><"); - //System.out.println(variable.toString()); boolean temp=false; - for(GraphNode node : sliceNodes) { PDGNode pdgNode = (PDGNode)node; if(pdgNode.definesLocalVariable(variable)){ @@ -572,30 +567,30 @@ private boolean alfa(){ else if(pdgNode.usesLocalVariable(variable)){ temp=true; } - } - + } if(!temp){ - //System.err.println(variable.toString()); return false; } } - //System.err.println("MOSHKELeeeeeeee"); return true; } else{ return false; } } + + //SBSRE: add outputRule() Method => + public boolean outputRule(){ boolean temp=false; for(GraphNode node : sliceNodes) { PDGNode pdgNode = (PDGNode)node; if(pdgNode.getId() > First && pdgNode.getId() <=Last){ - + temp = false; } else{ - temp=true; + temp = true; } } return temp; @@ -619,17 +614,17 @@ public boolean satisfiesRules() { public boolean satisfiesRulesSRP() { - if(sliceEqualsMethodBody() || alfa() || outputRule() || + if(sliceEqualsMethodBody() || sliceSameAsOrginalMethod() || outputRule() || sliceContainsOnlyOneNodeCriterionAndDeclarationOfVariableCriterion() || sliceNodes.size() <= nodeCriteria.size() || allNodeCriteriaAreDuplicated() || + nonDuplicatedSliceNodeAntiDependsOnNonRemovableNode() || containsDuplicateNodeWithStateChangingMethodInvocation() || + nonDuplicatedSliceNodeOutputDependsOnNonRemovableNode() || duplicatedSliceNodeWithClassInstantiationHasDependenceOnRemovableNode() || - !complyWithUserThresholds() || + !complyWithUserThresholds() || sliceContainsReturnStatement() || sliceContainsBranchStatementWithoutInnermostLoop()) return false; return true; } - -//nonDuplicatedSliceNodeAntiDependsOnNonRemovableNode() hazf shode baraye moshkele adam daryaf slice ha } diff --git a/src/gr/uom/java/ast/decomposition/cfg/PDGSliceUnionCollection.java b/src/gr/uom/java/ast/decomposition/cfg/PDGSliceUnionCollection.java index bce3e61..010b7ae 100644 --- a/src/gr/uom/java/ast/decomposition/cfg/PDGSliceUnionCollection.java +++ b/src/gr/uom/java/ast/decomposition/cfg/PDGSliceUnionCollection.java @@ -79,11 +79,8 @@ else if(Mode==0){ for(BasicBlock basicBlock : basicBlockIntersection) { PDGSliceUnion sliceUnion = new PDGSliceUnion(pdg, basicBlock, nodeCriteria, localVariableCriterion,First,Last); if(sliceUnion.satisfiesRulesSRP()){ - //System.out.println("Slice-Satisfies-Rules"); sliceUnionMap.put(basicBlock, sliceUnion); } - //System.out.println("!!!"); - //System.out.println(sliceUnion.satisfiesRules1()); } } diff --git a/src/gr/uom/java/jdeodorant/refactoring/views/SingleResponsibilityViolation.java b/src/gr/uom/java/jdeodorant/refactoring/views/SingleResponsibilityViolation.java index 4b0d424..5f70fbb 100644 --- a/src/gr/uom/java/jdeodorant/refactoring/views/SingleResponsibilityViolation.java +++ b/src/gr/uom/java/jdeodorant/refactoring/views/SingleResponsibilityViolation.java @@ -830,6 +830,7 @@ private void processMethod(final List extractedSliceGroups, Class Set ObjectList = new LinkedHashSet(); ObjectList = pdg.getObjectInMethodInvovation(); + /* for(PlainVariable o : ObjectList){ System.out.println("objectList "+ o); @@ -842,6 +843,7 @@ private void processMethod(final List extractedSliceGroups, Class System.out.println(Last.get(x).toString()); } + */ for(PlainVariable variable : ObjectList) { PDGSliceUnionCollection sliceUnionCollection = new PDGSliceUnionCollection(pdg, variable,0,1000,2); @@ -862,7 +864,7 @@ private void processMethod(final List extractedSliceGroups, Class sumOfDuplicationRatioInGroup += duplicationRatio; if(numberOfExtractedStatements > maximumNumberOfExtractedStatementsInGroup) maximumNumberOfExtractedStatementsInGroup = numberOfExtractedStatements; - slice.SetType("LOL"); + slice.SetType("Enhanced-Object Slicing"); sliceGroup.addCandidate(slice); } } @@ -877,9 +879,9 @@ private void processMethod(final List extractedSliceGroups, Class int andis=0; for(PlainVariable variable : targetList) { - Integer F =First.get(andis); - Integer L =Last.get(andis); - PDGSliceUnionCollection sliceUnionCollection = new PDGSliceUnionCollection(pdg, variable,F,L,0); + Integer first =First.get(andis); + Integer last =Last.get(andis); + PDGSliceUnionCollection sliceUnionCollection = new PDGSliceUnionCollection(pdg, variable,first,last,0); andis++; double sumOfExtractedStatementsInGroup = 0.0; double sumOfDuplicatedStatementsInGroup = 0.0; @@ -963,7 +965,7 @@ private void processMethod(final List extractedSliceGroups, Class sumOfDuplicationRatioInGroup += duplicationRatio; if(numberOfExtractedStatements > maximumNumberOfExtractedStatementsInGroup) maximumNumberOfExtractedStatementsInGroup = numberOfExtractedStatements; - slice.SetType("Complete Computation Slicing"); + slice.SetType("Complete-Computation Slicing"); sliceGroup.addCandidate(slice); } } @@ -995,7 +997,7 @@ private void processMethod(final List extractedSliceGroups, Class sumOfDuplicationRatioInGroup += duplicationRatio; if(numberOfExtractedStatements > maximumNumberOfExtractedStatementsInGroup) maximumNumberOfExtractedStatementsInGroup = numberOfExtractedStatements; - slice.SetType("Object State Slicing"); + slice.SetType("Object-State Slicing"); sliceGroup.addCandidate(slice); } }