junichi11 commented on code in PR #6825:
URL: https://github.com/apache/netbeans/pull/6825#discussion_r1421915442


##########
php/php.editor/src/org/netbeans/modules/php/editor/verification/IncorrectEnumHintError.java:
##########
@@ -289,15 +341,41 @@ private void checkStatements(List<Statement> statements, 
EnumDeclaration node) {
                     incorrectEnumProperties.add((FieldsDeclaration) statement);
                 } else if (statement instanceof UseTraitStatement) {
                     useTraits.put(node, (UseTraitStatement) statement);
+                } else if (statement instanceof CaseDeclaration) {
+                    checkCaseDeclaration((CaseDeclaration) statement, 
isBackedEnum);
+

Review Comment:
   Fixed.



##########
php/php.editor/src/org/netbeans/modules/php/editor/verification/IncorrectEnumHintError.java:
##########
@@ -289,15 +341,41 @@ private void checkStatements(List<Statement> statements, 
EnumDeclaration node) {
                     incorrectEnumProperties.add((FieldsDeclaration) statement);
                 } else if (statement instanceof UseTraitStatement) {
                     useTraits.put(node, (UseTraitStatement) statement);
+                } else if (statement instanceof CaseDeclaration) {
+                    checkCaseDeclaration((CaseDeclaration) statement, 
isBackedEnum);
+
                 }
                 scan(statement);
             }
         }
 
+        private void checkCaseDeclaration(CaseDeclaration caseDeclaration, 
boolean isBacked) {
+            Expression initializer = caseDeclaration.getInitializer();
+            if (isBacked) {
+                if (initializer == null) {
+                    // enum Backed: int { case A;} // fatal error
+                    incorrectBackedEnumCases.add(caseDeclaration);
+                }
+            } else {
+                // enum NonBacked { case A = 1;} // fatal error
+                if (initializer != null) {
+                    incorrectNonBackedEnumCases.add(caseDeclaration);
+                }
+            }
+

Review Comment:
   Fixed.



##########
php/php.editor/src/org/netbeans/modules/php/editor/verification/IncorrectEnumHintError.java:
##########
@@ -289,15 +341,41 @@ private void checkStatements(List<Statement> statements, 
EnumDeclaration node) {
                     incorrectEnumProperties.add((FieldsDeclaration) statement);
                 } else if (statement instanceof UseTraitStatement) {
                     useTraits.put(node, (UseTraitStatement) statement);
+                } else if (statement instanceof CaseDeclaration) {
+                    checkCaseDeclaration((CaseDeclaration) statement, 
isBackedEnum);
+
                 }
                 scan(statement);
             }
         }
 
+        private void checkCaseDeclaration(CaseDeclaration caseDeclaration, 
boolean isBacked) {
+            Expression initializer = caseDeclaration.getInitializer();
+            if (isBacked) {
+                if (initializer == null) {
+                    // enum Backed: int { case A;} // fatal error
+                    incorrectBackedEnumCases.add(caseDeclaration);
+                }
+            } else {
+                // enum NonBacked { case A = 1;} // fatal error
+                if (initializer != null) {
+                    incorrectNonBackedEnumCases.add(caseDeclaration);
+                }
+            }
+
+        }

Review Comment:
   Fixed.



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