Skip to content

Commit

Permalink
Improve SubsetAssertingVisitor
Browse files Browse the repository at this point in the history
  • Loading branch information
NebelNidas committed Jan 19, 2025
1 parent b012697 commit 54e15db
Showing 1 changed file with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public boolean visitPackage(String srcName, @Nullable String[] dstNames) throws
assertTrue(isEmpty(subDstNames), "Incoming package not contained in supTree: " + srcName);
}

return true;
return true; // ensure there is no element content
}

Map<String, String> supDstNamesByNsName = new HashMap<>();
Expand Down Expand Up @@ -158,7 +158,12 @@ public void visitPackageComment(String srcName, @Nullable String[] dstNames, Str

@Override
public boolean visitClass(String srcName, @Nullable String[] dstNames) throws IOException {
if (!supFeatures.supportsClasses()) return true; // sub-elements might still be supported
if (!supFeatures.supportsClasses()) {
return supFeatures.supportsFields()
|| supFeatures.supportsMethods()
|| supFeatures.supportsArgs()
|| supFeatures.supportsVars();
}

ClassMappingView supCls = supTree.getClass(srcName);
boolean supHasDstNames = supFeatures.classes().dstNames() != FeaturePresence.ABSENT;
Expand Down Expand Up @@ -196,7 +201,7 @@ public boolean visitClass(String srcName, @Nullable String[] dstNames) throws IO
}
}

return true;
return true; // ensure there is no element content
}

Map<String, String> supDstNamesByNsName = new HashMap<>();
Expand Down Expand Up @@ -273,7 +278,7 @@ public boolean visitField(String srcClsName, String srcName, @Nullable String sr
if (supHasDstDescs && subHasDstDescs) subDstDescs = supFeatures.hasNamespaces() || dstDescs == null ? dstDescs : new String[]{dstDescs[subNsIfSupNotNamespaced]};

assertTrue(isEmpty(subDstNames) && isEmpty(subDstDescs), "Incoming field not contained in supTree: " + subFldId);
return true;
return true; // ensure there is no element content
}

String supFldId = srcClsName + "#" + srcName + ":" + supFld.getSrcDesc();
Expand Down Expand Up @@ -336,7 +341,9 @@ public void visitFieldComment(String srcClsName, String srcName, @Nullable Strin
@Override
public boolean visitMethod(String srcClsName, String srcName, @Nullable String srcDesc,
@Nullable String[] dstClsNames, @Nullable String[] dstNames, @Nullable String[] dstDescs) throws IOException {
if (!supFeatures.supportsMethods()) return true;
if (!supFeatures.supportsMethods()) {
return supFeatures.supportsArgs() || supFeatures.supportsVars();
}

String subMthId = srcClsName + "#" + srcName + srcDesc;
ClassMappingView supCls = Objects.requireNonNull(supTree.getClass(srcClsName), "Incoming method's parent class not contained in supTree: " + subMthId);
Expand All @@ -357,7 +364,7 @@ public boolean visitMethod(String srcClsName, String srcName, @Nullable String s
if (supHasDstDescs && subHasDstDescs) subDstDescs = supFeatures.hasNamespaces() || dstDescs == null ? dstDescs : new String[]{dstDescs[subNsIfSupNotNamespaced]};

assertTrue(isEmpty(subDstNames) && isEmpty(subDstDescs), "Incoming method not contained in supTree: " + subMthId);
return true;
return true; // ensure there is no element content
}

String supMthId = srcClsName + "#" + srcName + supMth.getSrcDesc();
Expand Down Expand Up @@ -442,7 +449,7 @@ public boolean visitMethodArg(String srcClsName, String srcMethodName, @Nullable
assertTrue(isEmpty(subDstNames), "Incoming arg not contained in supTree: " + subArgId);
}

return true;
return true; // ensure there is no element content
}

Map<String, String> supDstNamesByNsName = new HashMap<>();
Expand Down Expand Up @@ -526,7 +533,7 @@ public boolean visitMethodVar(String srcClsName, String srcMethodName, @Nullable
assertTrue(isEmpty(subDstNames), "Incoming var not contained in supTree: " + subVarId);
}

return true;
return true; // ensure there is no element content
}

Map<String, String> supDstNamesByNsName = new HashMap<>();
Expand Down

0 comments on commit 54e15db

Please sign in to comment.