You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "junichi11 (via GitHub)" <gi...@apache.org> on 2023/03/24 01:11:22 UTC

[GitHub] [netbeans] junichi11 opened a new pull request, #5704: PHP: Fix the IntroduceSuggestion hint for Enum

junichi11 opened a new pull request, #5704:
URL: https://github.com/apache/netbeans/pull/5704

   - Add a hint to introduce enum cases
   - Fix the hint to introduce enum methods
   - Fix the deprecated method (`GsfUtilities.getDocument`)
   
   ![nb-php-enum-introduce-suggestion-hint](https://user-images.githubusercontent.com/738383/227397624-128de872-ebee-4293-bceb-66a37481c126.gif)
   


-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] tmysik merged pull request #5704: PHP: Fix the IntroduceSuggestion hint for Enum

Posted by "tmysik (via GitHub)" <gi...@apache.org>.
tmysik merged PR #5704:
URL: https://github.com/apache/netbeans/pull/5704


-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] tmysik commented on a diff in pull request #5704: PHP: Fix the IntroduceSuggestion hint for Enum

Posted by "tmysik (via GitHub)" <gi...@apache.org>.
tmysik commented on code in PR #5704:
URL: https://github.com/apache/netbeans/pull/5704#discussion_r1148306135


##########
php/php.editor/src/org/netbeans/modules/php/editor/verification/IntroduceSuggestion.java:
##########
@@ -719,6 +734,79 @@ int getOffset() throws BadLocationException {
         }
     }
 
+    private static class IntroduceEnumCaseFix extends IntroduceFix {
+
+        private final EnumScope type;
+        private final String template;
+        private final String enumCaseName;
+        private final String backingType;

Review Comment:
   `@Nullable`?
   



-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] tmysik commented on a diff in pull request #5704: PHP: Fix the IntroduceSuggestion hint for Enum

Posted by "tmysik (via GitHub)" <gi...@apache.org>.
tmysik commented on code in PR #5704:
URL: https://github.com/apache/netbeans/pull/5704#discussion_r1148306221


##########
php/php.editor/src/org/netbeans/modules/php/editor/verification/IntroduceSuggestion.java:
##########
@@ -719,6 +734,79 @@ int getOffset() throws BadLocationException {
         }
     }
 
+    private static class IntroduceEnumCaseFix extends IntroduceFix {
+
+        private final EnumScope type;
+        private final String template;
+        private final String enumCaseName;
+        private final String backingType;
+
+        public IntroduceEnumCaseFix(BaseDocument doc, StaticConstantAccess node, EnumScope type) {
+            super(doc, node);
+            this.type = type;
+            this.enumCaseName = ((StaticConstantAccess) node).getConstantName().getName();
+            this.backingType = type.getBackingType() != null ? type.getBackingType().toString() : null;
+            this.template = String.format(getTemplate(backingType), enumCaseName);
+        }
+
+        private String getTemplate(String backingType) {
+            String caseTemplate = "case %s;"; // NOI18N
+            if (backingType != null) {
+                if (Type.STRING.equals(backingType)) {
+                    caseTemplate = "case %s = '';"; // NOI18N
+                } else if (Type.INT.equals(backingType)) {
+                    caseTemplate = "case %s = " + (getLastIntIndex() + 1) + ";"; // NOI18N
+                }

Review Comment:
   No `else`? At least some log?
   



-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] junichi11 commented on pull request #5704: PHP: Fix the IntroduceSuggestion hint for Enum

Posted by "junichi11 (via GitHub)" <gi...@apache.org>.
junichi11 commented on PR #5704:
URL: https://github.com/apache/netbeans/pull/5704#issuecomment-1483484997

   @tmysik Could you please have a look at this? If there is no problem, let's merge it. Thank you!


-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] tmysik commented on pull request #5704: PHP: Fix the IntroduceSuggestion hint for Enum

Posted by "tmysik (via GitHub)" <gi...@apache.org>.
tmysik commented on PR #5704:
URL: https://github.com/apache/netbeans/pull/5704#issuecomment-1483726777

   Great work, as always. Just one nitpick, so merging :)
   


-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] junichi11 commented on pull request #5704: PHP: Fix the IntroduceSuggestion hint for Enum

Posted by "junichi11 (via GitHub)" <gi...@apache.org>.
junichi11 commented on PR #5704:
URL: https://github.com/apache/netbeans/pull/5704#issuecomment-1483736507

   Will fix it next time :) Thank you!


-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] tmysik commented on a diff in pull request #5704: PHP: Fix the IntroduceSuggestion hint for Enum

Posted by "tmysik (via GitHub)" <gi...@apache.org>.
tmysik commented on code in PR #5704:
URL: https://github.com/apache/netbeans/pull/5704#discussion_r1148306264


##########
php/php.editor/src/org/netbeans/modules/php/editor/verification/IntroduceSuggestion.java:
##########
@@ -719,6 +734,79 @@ int getOffset() throws BadLocationException {
         }
     }
 
+    private static class IntroduceEnumCaseFix extends IntroduceFix {
+
+        private final EnumScope type;
+        private final String template;
+        private final String enumCaseName;
+        private final String backingType;
+
+        public IntroduceEnumCaseFix(BaseDocument doc, StaticConstantAccess node, EnumScope type) {
+            super(doc, node);
+            this.type = type;
+            this.enumCaseName = ((StaticConstantAccess) node).getConstantName().getName();
+            this.backingType = type.getBackingType() != null ? type.getBackingType().toString() : null;
+            this.template = String.format(getTemplate(backingType), enumCaseName);
+        }
+
+        private String getTemplate(String backingType) {
+            String caseTemplate = "case %s;"; // NOI18N
+            if (backingType != null) {
+                if (Type.STRING.equals(backingType)) {
+                    caseTemplate = "case %s = '';"; // NOI18N
+                } else if (Type.INT.equals(backingType)) {
+                    caseTemplate = "case %s = " + (getLastIntIndex() + 1) + ";"; // NOI18N
+                }

Review Comment:
   I see now, we have a default value.
   



-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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