Skip to content

Commit

Permalink
Use common 'source' naming convention for tree unfiltered data
Browse files Browse the repository at this point in the history
  • Loading branch information
Col-E committed Nov 2, 2024
1 parent 16b3b5a commit 6ac8549
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public <I extends TreeItem<T>> void sortChildren(@Nonnull Comparator<I> comparat
/**
* @return {@code true} when this tree item is a true leaf based on the unfiltered children.
*/
protected boolean isUnfilteredLeaf() {
protected boolean isSourceLeaf() {
return sourceChildren.isEmpty();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ public synchronized boolean removeNodeByPath(@Nonnull PathNode<?> path) {

// Get that node's parent, remove the child.
if (nodeByPath != null) {
WorkspaceTreeNode parentNode = nodeByPath.getParentNode();
WorkspaceTreeNode parentNode = nodeByPath.getSourceParentNode();
if (parentNode != null) {
boolean removed = parentNode.removeSourceChild(nodeByPath);
while (parentNode.isUnfilteredLeaf() && parentNode.getParentNode() != null) {
WorkspaceTreeNode parentOfParent = parentNode.getParentNode();
while (parentNode.isSourceLeaf() && parentNode.getSourceParentNode() != null) {
WorkspaceTreeNode parentOfParent = parentNode.getSourceParentNode();
parentOfParent.removeSourceChild(parentNode);
parentNode = parentOfParent;
}
Expand Down Expand Up @@ -116,7 +116,7 @@ public synchronized WorkspaceTreeNode getFirstChild() {
public WorkspaceTreeNode getRoot() {
WorkspaceTreeNode root = this;
while (true) {
WorkspaceTreeNode parentNode = root.getParentNode();
WorkspaceTreeNode parentNode = root.getSourceParentNode();
if (parentNode == null)
break;
root = parentNode;
Expand All @@ -138,7 +138,7 @@ public boolean matches(@Nonnull PathNode<?> path) {
* @return {@link #getSourceParent()} but cast to {@link WorkspaceTreeNode}.
*/
@Nullable
public WorkspaceTreeNode getParentNode() {
public WorkspaceTreeNode getSourceParentNode() {
return (WorkspaceTreeNode) getSourceParent();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,29 +440,29 @@ void insertClassGeneratesIntermediatesToWorkspaceNode() {
assertNotNull(classNode, "Class not yielded by original assert");

// Assert all package entries exist for: software.coley.recaf.test.dummy
WorkspaceTreeNode packageDummy = classNode.getParentNode();
WorkspaceTreeNode packageDummy = classNode.getSourceParentNode();
assertNotNull(packageDummy, "Missing node for package: 'software.coley.recaf.test.dummy'");
WorkspaceTreeNode packageTest = packageDummy.getParentNode();
WorkspaceTreeNode packageTest = packageDummy.getSourceParentNode();
assertNotNull(packageTest, "Missing node for package: 'software.coley.recaf.test'");
WorkspaceTreeNode packageRecaf = packageTest.getParentNode();
WorkspaceTreeNode packageRecaf = packageTest.getSourceParentNode();
assertNotNull(packageRecaf, "Missing node for package: 'software.coley.recaf'");
WorkspaceTreeNode packageColey = packageRecaf.getParentNode();
WorkspaceTreeNode packageColey = packageRecaf.getSourceParentNode();
assertNotNull(packageColey, "Missing node for package: 'software.coley'");
WorkspaceTreeNode packageSoftware = packageColey.getParentNode();
WorkspaceTreeNode packageSoftware = packageColey.getSourceParentNode();
assertNotNull(packageSoftware, "Missing node for package: 'software'");

// Bundle parent
WorkspaceTreeNode bundleNode = packageSoftware.getParentNode();
WorkspaceTreeNode bundleNode = packageSoftware.getSourceParentNode();
assertNotNull(bundleNode, "Missing bundle node");
assertTrue(bundleNode.getValue() instanceof BundlePathNode);

// Resource parent
WorkspaceTreeNode resourceNode = bundleNode.getParentNode();
WorkspaceTreeNode resourceNode = bundleNode.getSourceParentNode();
assertNotNull(resourceNode, "Missing resource node");
assertTrue(resourceNode.getValue() instanceof ResourcePathNode);

// Workspace parent should be the same as the original item we had.
WorkspaceTreeNode workspaceNode2 = resourceNode.getParentNode();
WorkspaceTreeNode workspaceNode2 = resourceNode.getSourceParentNode();
assertSame(workspaceNode, workspaceNode2);
}

Expand Down

0 comments on commit 6ac8549

Please sign in to comment.