From f9f4dd9533b0b87b944fc3fac4103cdc96d1bb1f Mon Sep 17 00:00:00 2001 From: Sung-Shik Jongmans Date: Mon, 18 Nov 2024 09:17:40 +0100 Subject: [PATCH] Add method `getTagValue` that generalizes `getCategory` --- src/org/rascalmpl/values/parsetrees/ProductionAdapter.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/org/rascalmpl/values/parsetrees/ProductionAdapter.java b/src/org/rascalmpl/values/parsetrees/ProductionAdapter.java index 907ae429a9f..287e32002fb 100644 --- a/src/org/rascalmpl/values/parsetrees/ProductionAdapter.java +++ b/src/org/rascalmpl/values/parsetrees/ProductionAdapter.java @@ -158,11 +158,15 @@ public static boolean isKeyword(IConstructor tree) { } public static String getCategory(IConstructor tree) { + return getTagValue(tree, "category"); + } + + 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(); } }