Skip to content

Commit

Permalink
For the try blocks without resources, we create a control dependence …
Browse files Browse the repository at this point in the history
…from the PDGNode under which they are nested.

Updated plug-in version to 5.0.60
  • Loading branch information
tsantalis committed Jun 14, 2016
1 parent 09d3f52 commit c509ed0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: JDeodorant Plug-in
Bundle-SymbolicName: gr.uom.java.jdeodorant; singleton:=true
Bundle-Version: 5.0.59
Bundle-Version: 5.0.60
Bundle-Activator: gr.uom.java.jdeodorant.refactoring.Activator
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
Expand Down
25 changes: 25 additions & 0 deletions src/gr/uom/java/ast/decomposition/cfg/PDG.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.Block;
import org.eclipse.jdt.core.dom.LabeledStatement;
import org.eclipse.jdt.core.dom.Statement;
import org.eclipse.jdt.core.dom.VariableDeclaration;
Expand Down Expand Up @@ -484,11 +486,34 @@ else if(blockNode instanceof CFGSynchronizedNode) {
}
if(pdgBlockNode != null) {
nodes.add(pdgBlockNode);
PDGNode parent = findParentOfBlockNode(pdgBlockNode);
if(parent != null) {
PDGControlDependence controlDependence = new PDGControlDependence(parent, pdgBlockNode, true);
edges.add(controlDependence);
}
}
}
}
}

private PDGNode findParentOfBlockNode(PDGBlockNode blockNode) {
Statement statement = blockNode.getASTStatement();
ASTNode parent = statement.getParent();
while(parent instanceof Block) {
parent = parent.getParent();
}
if(entryNode.getMethod().getMethodDeclaration().equals(parent)) {
return entryNode;
}
for(GraphNode node : nodes) {
PDGNode pdgNode = (PDGNode)node;
if(pdgNode.getASTStatement().equals(parent)) {
return pdgNode;
}
}
return null;
}

private void processCFGNode(PDGNode previousNode, CFGNode cfgNode, boolean controlType) {
if(cfgNode instanceof CFGBranchNode) {
PDGControlPredicateNode predicateNode = new PDGControlPredicateNode(cfgNode, variableDeclarationsInMethod, fieldsAccessedInMethod);
Expand Down
4 changes: 4 additions & 0 deletions src/gr/uom/java/ast/decomposition/cfg/PDGMethodEntryNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ public PDGMethodEntryNode(AbstractMethodDeclaration method) {
}
}

public AbstractMethodDeclaration getMethod() {
return method;
}

public BasicBlock getBasicBlock() {
return null;
}
Expand Down

0 comments on commit c509ed0

Please sign in to comment.