lkishalmi commented on code in PR #7097:
URL: https://github.com/apache/netbeans/pull/7097#discussion_r1518724767


##########
ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLElement.java:
##########
@@ -18,81 +18,12 @@
  */
 package org.netbeans.modules.languages.hcl.ast;
 
-import org.antlr.v4.runtime.Token;
+import java.util.List;
 
 /**
  *
  * @author Laszlo Kishalmi
  */
-public abstract class HCLElement {
-
-    public abstract void accept(Visitor v);
-    
-    public interface Visitor {
-        /**
-         * Visit the given element. Shall return {@code true} if the visit
-         * shall be finished at this level in the element tree.
-         * 
-         * @param e the element to visit.
-         * @return {@code false} if the visit shall continue on the subtree of
-         *         the given element.
-         */
-        boolean visit(HCLElement e);
-    }
-    
-    /**
-     * Convenience Visitor implementation, where the HCLElements are split to
-     * Block, Attribute, and Expression types. 
-     */
-    public abstract static class BAEVisitor implements Visitor {
-        @Override
-        public boolean visit(HCLElement e) {
-            if (e instanceof HCLBlock) {
-                return visitBlock((HCLBlock)e);
-            } else if (e instanceof HCLAttribute) {
-                return visitAttribute((HCLAttribute) e);
-            } else if (e instanceof HCLExpression) {
-                return visitExpression((HCLExpression) e);
-            }
-            return false;
-        }
-        
-        protected abstract boolean visitBlock(HCLBlock block);
-        
-        protected abstract boolean visitAttribute(HCLAttribute attr);
-        
-        protected abstract boolean visitExpression(HCLExpression expr);
-    }
-
-    public static class BAEVisitorAdapter extends BAEVisitor {
-
-        @Override
-        protected boolean visitBlock(HCLBlock block) {
-            return false;
-        }
-
-        @Override
-        protected boolean visitAttribute(HCLAttribute attr) {
-            return false;
-        }
-
-        @Override
-        protected boolean visitExpression(HCLExpression expr) {
-            return false;
-        }
-        
-    }
-
-    public static final class CreateContext {
-        public final HCLElement element;
-        public final Token start;
-        public final Token stop;
-
-        public CreateContext(HCLElement element, Token start, Token stop) {
-            this.element = element;
-            this.start = start;
-            this.stop = stop;
-        }
-        
-    }
+public sealed interface HCLElement<T extends HCLElement> permits 
HCLExpression, HCLIdentifier, HCLAddressableElement {
+    List<? extends T> elements();

Review Comment:
   TODO: record patterns...



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to