Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method getTagValue that generalizes getCategory #2082

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/org/rascalmpl/values/parsetrees/ProductionAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,15 @@
}

public static String getCategory(IConstructor tree) {
return getTagValue(tree, "category");

Check warning on line 161 in src/org/rascalmpl/values/parsetrees/ProductionAdapter.java

View check run for this annotation

Codecov / codecov/patch

src/org/rascalmpl/values/parsetrees/ProductionAdapter.java#L161

Added line #L161 was not covered by tests
}

public static String getTagValue(IConstructor tree, String name) {
if (!isRegular(tree)) {
for (IValue attr : getAttributes(tree)) {
if (attr.getType().isAbstractData() && ((IConstructor) attr).getConstructorType() == RascalValueFactory.Attr_Tag) {
IValue value = ((IConstructor)attr).get("tag");
if (value.getType().isNode() && ((INode) value).getName().equals("category")) {
if (value.getType().isNode() && ((INode) value).getName().equals(name)) {
return ((IString) ((INode) value).get(0)).getValue();
}
}
Expand Down
Loading