Compare commits

..

No commits in common. "b635c13d57697726f0d87b7381f30ec62f5ffef3" and "7ffd5c2d204c76a9ecb58401c103fc2f7da595b4" have entirely different histories.

4 changed files with 23 additions and 22 deletions

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="test"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -28,7 +28,7 @@ public class GraphGenerator {
public static class Graph{
private static Pattern PATTERN = Pattern.compile("^(\\d+)\\s+->\\s+(.*)$");
private static Pattern PATTERN = Pattern.compile("^(\\d+)\\s+->\s+(.*)$");
private List<Node> nodes;

View file

@ -18,7 +18,9 @@ public class Operator{
VisitorBag vbag = visitor.visit(element);
if(!vbag.isValidated()) return new VisitorBag();
bag.merge(vbag);
set.add(vbag.computed());
for(Object computed : vbag.computeList()){
set.add(computed);
}
}
for(Object obj : set) bag.compute(obj);
return bag;
@ -51,7 +53,9 @@ public class Operator{
VisitorBag vbag = visitor.visit(element);
if(!vbag.isValidated()) return new VisitorBag();
bag.merge(vbag);
bag.compute(vbag.computed());
for(Object computed : vbag.computeList()){
bag.compute(computed);
}
return bag;
}
return bag;
@ -90,7 +94,7 @@ public class Operator{
@Override
public boolean canPropagate(){
return visitor.canPropagate();
return true;
}
};
}
@ -104,6 +108,7 @@ public class Operator{
@Override
public boolean canVisit(Class<?> type){
// System.out.println("collect can visit ? "+type);
return visitor.canVisit(type);
}

View file

@ -9,39 +9,35 @@ import java.util.Map;
//only one pass in parameter or visit ?
public class VisitorBag{
private static final Object VALIDATED_BAG = new Object();
private static final Object VALIDATE_BAG = new Object();
private List<Object> collect;
private Object computed;
public VisitorBag(){
this.collect = new ArrayList<>(0);
this.collect = new ArrayList<>();
}
public void compute(Object element){
this.computed = element;
}
public void merge(VisitorBag bag){
this.collect.addAll(bag.collect);
if((!this.collect.isEmpty()) && this.computed == null) this.computed = VALIDATED_BAG;
}
public Object computed(){
return this.computed;
}
public boolean isValidated(){
return this.computed != null;
}
VisitorBag pair(Object key){
this.collect = Arrays.asList(new Pair<>(key, this.collect));
this.collect = Arrays.asList(new Pair<>(key, collect));
return this;
}
public void merge(VisitorBag bag){
this.collect.addAll(bag.collect);
if(!this.collect.isEmpty()) this.computed = VALIDATE_BAG;
}
public boolean isValidated(){
return this.VALIDATE_BAG != null;
}
VisitorBag collect(){
if(this.computed != null) this.collect.add(this.computed);
this.collect.addAll(this.list);
return this;
}