You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2022/05/28 09:31:57 UTC

[GitHub] [netbeans] junichi11 opened a new pull request, #4169: PHP 8.1: Support for the special property(value) of BackedEnum #4066

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

   #4066
   
   - Fix the parser
   - Add the `value` property to backed enums as CC items
   - Add the members of `UnitEnum` and `BackedEnum` to enums as CC items
   - Add unit tests
   
   ```php
   Enums::CASE1->value;
   Enums::from("name");
   Enums::cases();
   ```


-- 
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 #4169: PHP 8.1: Support for the special property(value) of BackedEnum #4066

Posted by GitBox <gi...@apache.org>.
tmysik commented on PR #4169:
URL: https://github.com/apache/netbeans/pull/4169#issuecomment-1148426425

   @junichi11 Thanks a lot!
   


-- 
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 #4169: PHP 8.1: Support for the special property(value) of BackedEnum #4066

Posted by GitBox <gi...@apache.org>.
junichi11 commented on PR #4169:
URL: https://github.com/apache/netbeans/pull/4169#issuecomment-1148132598

   @tmysik Fixed: https://github.com/apache/netbeans/compare/bacadc55bd8cc46cd6be05ec4a1ae325cd0174c6..593d270565b080f6a38bfdf0904194af5d506c0e
   
   Thank you for your review!


-- 
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 #4169: PHP 8.1: Support for the special property(value) of BackedEnum #4066

Posted by GitBox <gi...@apache.org>.
tmysik merged PR #4169:
URL: https://github.com/apache/netbeans/pull/4169


-- 
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 #4169: PHP 8.1: Support for the special property(value) of BackedEnum #4066

Posted by GitBox <gi...@apache.org>.
junichi11 commented on PR #4169:
URL: https://github.com/apache/netbeans/pull/4169#issuecomment-1145626050

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


-- 
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 #4169: PHP 8.1: Support for the special property(value) of BackedEnum #4066

Posted by GitBox <gi...@apache.org>.
tmysik commented on code in PR #4169:
URL: https://github.com/apache/netbeans/pull/4169#discussion_r890226580


##########
php/php.editor/src/org/netbeans/modules/php/editor/completion/PHPCodeCompletion.java:
##########
@@ -1482,6 +1482,20 @@ public boolean isAccepted(PhpElement element) {
                             // XXX currently, only when mixins are used directly in the class. should support all cases?
                             accessibleTypeMembers.addAll(request.index.getAccessibleMixinTypeMembers(typeScope, enclosingType));
                         }
+                    } else if (typeScope instanceof EnumElement) {
+                        // add methods of BackedEnum/UnitEnum interface
+                        EnumElement enumElement = (EnumElement) typeScope;
+                        String enumInterfaceName = enumElement.getBackingType() != null ? "\\BackedEnum" : "\\UnitEnum"; // NOI18N
+                        final NameKind nameQuery = NameKind.exact(QualifiedName.create(enumInterfaceName));
+                        Set<InterfaceElement> enums = request.index.getInterfaces(nameQuery);
+                        for (InterfaceElement backedEnum : enums) {
+                            accessibleTypeMembers.addAll(request.index.getAccessibleTypeMembers(backedEnum, backedEnum));
+                        }
+                        if (enumElement.getBackingType() != null
+                                && !enumElement.getBackingType().toString().isEmpty()

Review Comment:
   Calling `toString()` can be sometime expensive; could we store it in a variable, please?
   



-- 
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 a diff in pull request #4169: PHP 8.1: Support for the special property(value) of BackedEnum #4066

Posted by GitBox <gi...@apache.org>.
junichi11 commented on code in PR #4169:
URL: https://github.com/apache/netbeans/pull/4169#discussion_r888646371


##########
php/php.editor/src/org/netbeans/modules/php/editor/parser/astnodes/NamespaceName.java:
##########
@@ -76,7 +76,7 @@ public static NamespaceName create(int start, int end, @NonNull String namespace
         boolean isCurrent = namespaceName.startsWith("namespace\\"); // NOI18N
         String[] names = namespaceName.split("\\\\"); // NOI18N
         int startSegment = start;
-        List<Identifier> list = new ArrayList<>();
+        List<Identifier> list = new ArrayList<>(names.length);

Review Comment:
   Fixed this: https://github.com/apache/netbeans/pull/4037#pullrequestreview-982945274



-- 
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 #4169: PHP 8.1: Support for the special property(value) of BackedEnum #4066

Posted by GitBox <gi...@apache.org>.
tmysik commented on PR #4169:
URL: https://github.com/apache/netbeans/pull/4169#issuecomment-1147534941

   @junichi11 The change seems fine to me, I am ready to merge it. Please, let me know if you want to do some changes based on my comments. 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] junichi11 commented on a diff in pull request #4169: PHP 8.1: Support for the special property(value) of BackedEnum #4066

Posted by GitBox <gi...@apache.org>.
junichi11 commented on code in PR #4169:
URL: https://github.com/apache/netbeans/pull/4169#discussion_r890625299


##########
php/php.editor/src/org/netbeans/modules/php/editor/completion/PHPCodeCompletion.java:
##########
@@ -1482,6 +1482,20 @@ public boolean isAccepted(PhpElement element) {
                             // XXX currently, only when mixins are used directly in the class. should support all cases?
                             accessibleTypeMembers.addAll(request.index.getAccessibleMixinTypeMembers(typeScope, enclosingType));
                         }
+                    } else if (typeScope instanceof EnumElement) {
+                        // add methods of BackedEnum/UnitEnum interface
+                        EnumElement enumElement = (EnumElement) typeScope;
+                        String enumInterfaceName = enumElement.getBackingType() != null ? "\\BackedEnum" : "\\UnitEnum"; // NOI18N
+                        final NameKind nameQuery = NameKind.exact(QualifiedName.create(enumInterfaceName));
+                        Set<InterfaceElement> enums = request.index.getInterfaces(nameQuery);
+                        for (InterfaceElement backedEnum : enums) {
+                            accessibleTypeMembers.addAll(request.index.getAccessibleTypeMembers(backedEnum, backedEnum));
+                        }
+                        if (enumElement.getBackingType() != null
+                                && !enumElement.getBackingType().toString().isEmpty()

Review Comment:
   Will fix 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 a diff in pull request #4169: PHP 8.1: Support for the special property(value) of BackedEnum #4066

Posted by GitBox <gi...@apache.org>.
tmysik commented on code in PR #4169:
URL: https://github.com/apache/netbeans/pull/4169#discussion_r890228922


##########
php/php.editor/src/org/netbeans/modules/php/editor/completion/PHPCodeCompletion.java:
##########
@@ -1482,6 +1482,20 @@ public boolean isAccepted(PhpElement element) {
                             // XXX currently, only when mixins are used directly in the class. should support all cases?
                             accessibleTypeMembers.addAll(request.index.getAccessibleMixinTypeMembers(typeScope, enclosingType));
                         }
+                    } else if (typeScope instanceof EnumElement) {
+                        // add methods of BackedEnum/UnitEnum interface
+                        EnumElement enumElement = (EnumElement) typeScope;
+                        String enumInterfaceName = enumElement.getBackingType() != null ? "\\BackedEnum" : "\\UnitEnum"; // NOI18N
+                        final NameKind nameQuery = NameKind.exact(QualifiedName.create(enumInterfaceName));
+                        Set<InterfaceElement> enums = request.index.getInterfaces(nameQuery);
+                        for (InterfaceElement backedEnum : enums) {
+                            accessibleTypeMembers.addAll(request.index.getAccessibleTypeMembers(backedEnum, backedEnum));
+                        }
+                        if (enumElement.getBackingType() != null
+                                && !enumElement.getBackingType().toString().isEmpty()
+                                && !staticContext) {

Review Comment:
   Nitpick: this variable could be checked earlier, to avoid calling `toString()` above at all.
   
   _Note:_ this comment is - kind-of - in a conflict with my previous one :sweat_smile: 
   



-- 
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 #4169: PHP 8.1: Support for the special property(value) of BackedEnum #4066

Posted by GitBox <gi...@apache.org>.
tmysik commented on code in PR #4169:
URL: https://github.com/apache/netbeans/pull/4169#discussion_r890230905


##########
php/php.editor/src/org/netbeans/modules/php/editor/parser/astnodes/NamespaceName.java:
##########
@@ -76,7 +76,7 @@ public static NamespaceName create(int start, int end, @NonNull String namespace
         boolean isCurrent = namespaceName.startsWith("namespace\\"); // NOI18N
         String[] names = namespaceName.split("\\\\"); // NOI18N
         int startSegment = start;
-        List<Identifier> list = new ArrayList<>();
+        List<Identifier> list = new ArrayList<>(names.length);

Review Comment:
   Great, 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