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


##########
ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLContainer.java:
##########
@@ -18,59 +18,41 @@
  */
 package org.netbeans.modules.languages.hcl.ast;
 
+import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedList;
 import java.util.List;
 
 /**
  *
  * @author Laszlo Kishalmi
  */
-public abstract class HCLContainer extends HCLAddressableElement {
-    final List<HCLElement> elements = new LinkedList<>();
+public sealed interface HCLContainer extends HCLAddressableElement permits 
HCLBlock, HCLDocument {
 
-    final List<HCLBlock> blocks = new LinkedList<>();
-    final List<HCLAttribute> attributes = new LinkedList<>();
-
-    public HCLContainer(HCLContainer parent) {
-        super(parent);
-    }
-
-    public void add(HCLBlock block) {
-        elements.add(block);
-        blocks.add(block);
-    }
-
-    public void add(HCLAttribute attr) {
-        elements.add(attr);
-        attributes.add(attr);
-    }
-
-    @Override
-    public HCLContainer getContainer() {
-        return (HCLContainer) parent;
-    }
-
-    public Collection<? extends HCLBlock> getBlocks() {
-        return Collections.unmodifiableCollection(blocks);
+    public default Collection<? extends HCLBlock> blocks() {
+        var ret = new ArrayList<HCLBlock>();

Review Comment:
   I don't quite see why `var` is used in situations like this. `List` would 
have one letter more and is also more compact than `var` if inline hints are 
enabled.
   
   Using `var` by default obfuscates code and leads to situations where you 
pretty much need inline hints to understand the code.
   
   As a rule of thumb: If the ceremony of the type declaration (as the JEP 286 
calls it) is something you really want to omit, the identifier should be used 
to describe _what_ it is. Here for example it would be `blocksList` or 
something like that. But again, I think the type here is so compact that there 
is no ceremony to be saved.
   
   variable type inference is the only added language feature I dislike, but 
not for what it does, since the original intention was fine, only for the fact 
that it is overused everywhere which directly lead to the situation that IDEs 
had to render the full type next to `var` to undo a language feature again.



-- 
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