From eda394999e4fd984d353fbe6ca044de781c543ef Mon Sep 17 00:00:00 2001 From: sungshik <16154899+sungshik@users.noreply.github.com> Date: Mon, 18 Nov 2024 11:41:27 +0100 Subject: [PATCH] Add method `getTagValue` that generalizes `getCategory` (#2082) --- 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(); } }