Permalink
Browse files

ForestElement's methods getAll* should now correctly take nested

Members into account (luckily, those methods weren't used yet).
  • Loading branch information...
1 parent 45f86ff commit 59aad037174ad78f1ad808041147d68284659b91 @cderoove committed Jan 24, 2013
View
8 ExapusRAP/src/exapus/model/forest/FactForest.java
@@ -53,6 +53,14 @@ public ExapusModel getModel() {
return references;
}
+
+ public Iterable<PackageLayer> getAllPackageLayers() {
+ Iterable<PackageLayer> layers = new ArrayList<PackageLayer>();
+ for(PackageTree t : getPackageTrees()) {
+ layers = Iterables.concat(layers, t.getAllPackageLayers());
+ }
+ return layers;
+ }
public Direction getDirection() {
return direction;
View
2 ExapusRAP/src/exapus/model/forest/ILayerContainer.java
@@ -2,4 +2,6 @@
public interface ILayerContainer {
public void addLayer(PackageLayer l);
+ public Iterable<PackageLayer> getPackageLayers();
+ public Iterable<PackageLayer> getAllPackageLayers();
}
View
9 ExapusRAP/src/exapus/model/forest/MemberContainer.java
@@ -11,6 +11,7 @@
import org.eclipse.jdt.core.dom.IVariableBinding;
import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
public abstract class MemberContainer extends ForestElement {
@@ -25,6 +26,14 @@ public MemberContainer(UqName id) {
return members;
}
+ public Iterable<Member> getAllMembers() {
+ Iterable<Member> members = getMembers();
+ for(Member m : getMembers()) {
+ members = Iterables.concat(members, m.getAllMembers());
+ }
+ return members;
+ }
+
public boolean hasMembers() {
return (!members.isEmpty());
View
20 ExapusRAP/src/exapus/model/forest/PackageLayer.java
@@ -43,10 +43,20 @@ public String toString() {
return "PL[" + getName().toString() + " | M(" + members.size() + ")" + ",PL(" + layers.size() + ")]";
}
- public Iterable<PackageLayer> getLayers() {
+ public Iterable<PackageLayer> getPackageLayers() {
+ return layers;
+ }
+
+ public Iterable<PackageLayer> getAllPackageLayers() {
+ Iterable<PackageLayer> layers = new ArrayList<PackageLayer>();
+ for(PackageLayer l : getPackageLayers()) {
+ layers = Iterables.concat(layers, l.getPackageLayers());
+ }
return layers;
}
+
+
public PackageLayer getOrAddLayer(Iterator<UqName> i, PackageTree project) {
PackageLayer l = getOrAddLayer(i.next(), project);
if (i.hasNext())
@@ -129,13 +139,15 @@ public ICompilationUnit getCorrespondingICompilationUnit() {
return null;
}
+ @Override
public Iterable<Member> getAllMembers() {
- Iterable<Member> members = getMembers();
- for(PackageLayer l : getLayers()) {
+ Iterable<Member> members = super.getAllMembers();
+ for(PackageLayer l : getAllPackageLayers()) {
members = Iterables.concat(members, l.getAllMembers());
}
return members;
}
+
public Iterable<Ref> getAllReferences() {
Iterable<Ref> references = new ArrayList<Ref>();
@@ -166,7 +178,7 @@ public void addInboundReference(IVariableBinding variableBinding, OutboundRef ou
public void acceptVisitor(IForestVisitor v) {
if(v.visitPackageLayer(this)) {
- for(PackageLayer l : getLayers())
+ for(PackageLayer l : getPackageLayers())
l.acceptVisitor(v);
for(Member m : getMembers())
m.acceptVisitor(v);
View
11 ExapusRAP/src/exapus/model/forest/PackageTree.java
@@ -44,9 +44,14 @@ public PackageLayer getHiddenRootLayer() {
return root;
}
- public Iterable<PackageLayer> getLayers() {
- return root.getLayers();
+ public Iterable<PackageLayer> getPackageLayers() {
+ return root.getPackageLayers();
}
+
+ public Iterable<PackageLayer> getAllPackageLayers() {
+ return root.getAllPackageLayers();
+ }
+
public void processSourcePackageFragment(IPackageFragment f) throws JavaModelException {
if (f.getKind() != IPackageFragmentRoot.K_SOURCE)
@@ -136,7 +141,7 @@ public void addInboundReference(ITypeBinding t, IVariableBinding b, OutboundRef
public void acceptVisitor(IForestVisitor v) {
if(v.visitPackageTree(this))
- for(PackageLayer l : getLayers())
+ for(PackageLayer l : getPackageLayers())
l.acceptVisitor(v);
}
View
2 ExapusRAP/src/exapus/model/forest/QName.java
@@ -106,7 +106,5 @@ public QName getButLast() {
return new QName(Joiner.on('.').join(components.subList(0, size - 1)));
}
-
-
}

0 comments on commit 59aad03

Please sign in to comment.