Permalink
Browse files

Finished API tagging, closes #27 (had to merge manually though :s)

  • Loading branch information...
1 parent 8f63730 commit 7aa644c409abe3c7b78eba2bd144b6efd6939b23 @cderoove committed Jan 10, 2013
@@ -14,7 +14,7 @@
public InboundFactForest(ExapusModel m) {
super(m, Direction.INBOUND);
- UqName rootName = new UqName("<Packages>"); //will have others once user-provided api names are supported
+ UqName rootName = new UqName("<Untagged>");
root = new PackageTree(rootName);
addPackageTree(root);
}
@@ -2,6 +2,7 @@
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Iterator;
import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -167,5 +168,14 @@ public void acceptVisitor(IForestVisitor v) {
}
}
-
+
+ @Override
+ public void copyReference(Iterator<ForestElement> ancestors, Ref original) {
+ if(ancestors.hasNext()) {
+ super.copyReference(ancestors, original);
+ return;
+ }
+ addAPIReference(Ref.fromRef(original));
+ }
+
}
@@ -105,8 +105,16 @@ public Member getOrAddMember(ITypeBinding typeBinding) {
else
return getOrAddMemberWithoutRecursing(typeBinding);
}
-
-
+
+ public void copyReference(Iterator<ForestElement> ancestors, Ref original) {
+ ForestElement ancestor = ancestors.next();
+ if(ancestor instanceof Member) {
+ Member originalMember = (Member) ancestor;
+ Member destinationMember = getOrAddMember(originalMember.getName(), originalMember.getElement());
+ destinationMember.copyReference(ancestors, original);
+ }
+ }
+
}
@@ -178,6 +178,20 @@ public void addLayer(PackageLayer l) {
l.setParent(this);
}
+ public void copyReference(Iterator<ForestElement> ancestors, Ref original) {
+ ForestElement ancestor = ancestors.next();
+ if(ancestor instanceof PackageLayer) {
+ PackageLayer destinationLayer = getOrAddLayer(ancestor.getName(), this.getParentPackageTree());
+ destinationLayer.copyReference(ancestors, original);
+ }
+ if(ancestor instanceof Member) {
+ Member originalMember = (Member) ancestor;
+ Member destinationMember = getOrAddMember(originalMember.getName(), originalMember.getElement());
+ destinationMember.copyReference(ancestors, original);
+ }
+ assert(false);
+ }
+
}
@@ -93,11 +93,16 @@ public ICompilationUnit getCorrespondingICompilationUnit() {
return root.getAllReferences();
}
+
public void addLayer(PackageLayer l) {
root.addLayer(l);
l.setParent(this);
}
+ public PackageLayer getOrAddLayer(UqName name) {
+ return root.getOrAddLayer(name, this);
+ }
+
public PackageLayer getOrAddLayerForPackageFragment(IPackageFragment packageFragment) {
QName qname = new QName(packageFragment);
@@ -135,26 +140,26 @@ public void acceptVisitor(IForestVisitor v) {
l.acceptVisitor(v);
}
- public void insertReferenceCopy(Ref original) {
- PackageLayer originalLayer = original.getParentPackageLayer();
- PackageLayer destinationLayer = root.getOrAddLayer(originalLayer.getQName(), this);
- Member originalMember = original.getParentMember();
-
- //destinationLayer.getOrAddMember(originalMember.getQName(), originalMember.getElement());
-
- //destinationLayer.
-
-
- /*
- ForestElement parent = ref.getParent();
+ public void copyReference(Ref original) {
+ ForestElement parent = original.getParent();
LinkedList<ForestElement> parents = new LinkedList<ForestElement>();
while (parent != null && !(parent instanceof PackageTree)) {
parents.addFirst(parent);
parent = parent.getParent();
}
Iterator<ForestElement> ancestor = parents.iterator();
- insertReference(ancestor, ref);
- */
+ copyReference(ancestor, original);
+ }
+
+ public void copyReference(Iterator<ForestElement> ancestors, Ref original) {
+ ForestElement originalAncestor = ancestors.next();
+ PackageLayer originalLayer = (PackageLayer) originalAncestor;
+ if(originalLayer == null)
+ return;
+ PackageLayer destinationLayer = getOrAddLayer(originalLayer.getName());
+ destinationLayer.copyReference(ancestors, original);
}
+
+
}
@@ -73,7 +73,13 @@ protected static int getLineNumber(ASTNode n) {
protected static SourceRange getSourceRange(ASTNode n) {
return new SourceRange(n.getStartPosition(), n.getLength());
}
-
+
+ static public Ref fromRef(Ref r) {
+ if(r instanceof InboundRef)
+ return InboundRef.fromInboundRef((InboundRef) r);
+ else
+ return OutboundRef.fromOutboundRef((OutboundRef) r);
+ }
public SourceRange getSourceRange() {
return range;
@@ -1,8 +1,7 @@
package exapus.model.view;
-import exapus.model.forest.InboundRef;
+import exapus.model.forest.Direction;
import exapus.model.forest.Member;
-import exapus.model.forest.OutboundRef;
import exapus.model.forest.PackageLayer;
import exapus.model.forest.PackageTree;
import exapus.model.forest.QName;
@@ -60,30 +59,19 @@ private QName getTypePackageName() {
}
@Override
- public boolean matchProjectPackageTree(PackageTree packageTree) {
- //projects correspond to package trees, this is the only place where ROOT_SCOPE makes sense
- if(scope.equals(Scope.ROOT_SCOPE))
- return packageTree.getQName().equals(name);
- return true;
- }
-
- @Override
- public boolean matchAPIPackageTree(PackageTree packageTree) {
- //package layers are grouped in one dummy packagetree
+ public boolean matchPackageTree(PackageTree packageTree) {
+ if(scope.equals(Scope.ROOT_SCOPE)) {
+ //projects correspond to package trees, this is the only place where ROOT_SCOPE makes sense
+ if(packageTree.getParentFactForest().getDirection().equals(Direction.OUTBOUND))
+ return packageTree.getQName().equals(name);
+ //package layers are grouped in one dummy packagetree
+ return true;
+ }
return true;
}
@Override
- public boolean matchAPIPackageLayer(PackageLayer packageLayer) {
- return matchPackageLayer(packageLayer);
- }
-
- @Override
- public boolean matchProjectPackageLayer(PackageLayer packageLayer) {
- return matchPackageLayer(packageLayer);
- }
-
- private boolean matchPackageLayer(PackageLayer packageLayer) {
+ public boolean matchPackageLayer(PackageLayer packageLayer) {
//multiple scopes can be selected at the same time, cannot trust filtering to have happened above
if(scope.equals(Scope.ROOT_SCOPE))
return packageLayer.getParentPackageTree().getQName().equals(name);
@@ -106,16 +94,7 @@ private boolean matchPackageLayer(PackageLayer packageLayer) {
}
@Override
- public boolean matchAPIMember(Member member) {
- return matchMember(member);
- }
-
- @Override
- public boolean matchProjectMember(Member member) {
- return matchMember(member);
- }
-
- private boolean matchMember(Member member) {
+ public boolean matchMember(Member member) {
if(scope.equals(Scope.ROOT_SCOPE))
return member.getParentPackageTree().getQName().equals(name);
@@ -138,7 +117,8 @@ private boolean matchMember(Member member) {
}
//do the actual work here, other methods only attempt to filter out unwanted elements beforehand
- private boolean matchRef(Ref ref) {
+ @Override
+ public boolean matchRef(Ref ref) {
if(scope.equals(Scope.ROOT_SCOPE))
return ref.getParentPackageTree().getQName().equals(name);
@@ -157,18 +137,6 @@ private boolean matchRef(Ref ref) {
return false;
}
- @Override
- public boolean matchAPIRef(InboundRef ref) {
- return matchRef(ref);
- }
-
- @Override
- public boolean matchProjectRef(OutboundRef ref) {
- return matchRef(ref);
- }
-
-
-
public Scope getScope() {
return scope;
}
@@ -1,30 +1,20 @@
package exapus.model.view;
-import exapus.model.forest.InboundRef;
import exapus.model.forest.Member;
-import exapus.model.forest.OutboundRef;
import exapus.model.forest.PackageLayer;
import exapus.model.forest.PackageTree;
import exapus.model.forest.Ref;
public abstract class Selection {
- public abstract boolean matchAPIPackageTree(PackageTree packageTree);
+ public abstract boolean matchPackageTree(PackageTree packageTree);
- public abstract boolean matchAPIPackageLayer(PackageLayer packageLayer);
+ public abstract boolean matchPackageLayer(PackageLayer packageLayer);
- public abstract boolean matchAPIMember(Member member);
-
- public abstract boolean matchProjectPackageTree(PackageTree packageTree);
-
- public abstract boolean matchProjectPackageLayer(PackageLayer packageLayer);
-
- public abstract boolean matchProjectMember(Member member);
-
- public abstract boolean matchAPIRef(InboundRef inboundRef);
-
- public abstract boolean matchProjectRef(OutboundRef outboundRef);
+ public abstract boolean matchMember(Member member);
+ public abstract boolean matchRef(Ref ref);
+
public abstract String getNameString();
public abstract String getScopeString();
@@ -1,10 +1,9 @@
package exapus.model.view;
-import exapus.model.forest.InboundRef;
import exapus.model.forest.Member;
-import exapus.model.forest.OutboundRef;
import exapus.model.forest.PackageLayer;
import exapus.model.forest.PackageTree;
+import exapus.model.forest.Ref;
public class UniversalSelection extends Selection {
@@ -32,51 +31,30 @@ public String getTagString() {
return "";
}
-
- @Override
- public boolean matchAPIPackageTree(PackageTree packageTree) {
- return true;
- }
-
- @Override
- public boolean matchAPIPackageLayer(PackageLayer packageLayer) {
- return true;
- }
-
@Override
- public boolean matchAPIMember(Member member) {
- return true;
- }
-
- @Override
- public boolean matchProjectPackageTree(PackageTree packageTree) {
+ public boolean hasTag() {
return true;
}
@Override
- public boolean matchProjectPackageLayer(PackageLayer packageLayer) {
+ public boolean matchPackageTree(PackageTree packageTree) {
return true;
}
@Override
- public boolean matchProjectMember(Member member) {
+ public boolean matchPackageLayer(PackageLayer packageLayer) {
return true;
}
@Override
- public boolean matchAPIRef(InboundRef inboundRef) {
+ public boolean matchMember(Member member) {
return true;
}
@Override
- public boolean matchProjectRef(OutboundRef outboundRef) {
+ public boolean matchRef(Ref ref) {
return true;
}
- @Override
- public boolean hasTag() {
- return false;
- }
-
}
Oops, something went wrong.

0 comments on commit 7aa644c

Please sign in to comment.