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 2020/12/03 22:38:40 UTC

[GitHub] [netbeans] KacerCZ opened a new pull request #2578: [NETBEANS-5091] PHP - more improvements for constants in code completion

KacerCZ opened a new pull request #2578:
URL: https://github.com/apache/netbeans/pull/2578


   
   https://issues.apache.org/jira/browse/NETBEANS-5091
   
   - Improved display of class constants (previous change affected only global constants).
   - Display more values, not only the first one.
   - Unsupported key or value is displayed as "?".
   - Conversion code was moved to parent class (`ClassConstantDeclarationInfo`) and child class (`ConstantDeclarationInfo`) uses the same method.
   - Added new tests and updated existing.
   
   Example:
   ![class_constant](https://user-images.githubusercontent.com/4249184/101096871-810c6c00-35c0-11eb-8c3f-bab833ca0383.png)


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

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 change in pull request #2578: [NETBEANS-5091] PHP - more improvements for constants in code completion

Posted by GitBox <gi...@apache.org>.
tmysik commented on a change in pull request #2578:
URL: https://github.com/apache/netbeans/pull/2578#discussion_r536968422



##########
File path: php/php.editor/src/org/netbeans/modules/php/editor/model/nodes/ClassConstantDeclarationInfo.java
##########
@@ -97,4 +96,61 @@ public PhpModifiers getAccessModifiers() {
         return PhpModifiers.fromBitMask(constantDeclaration.getModifier());
     }
 
+    @CheckForNull
+    protected static String getConstantValue(Expression expr) {
+        if (expr instanceof Scalar) {
+            return ((Scalar) expr).getStringValue();
+        }
+        if (expr instanceof UnaryOperation) {
+            UnaryOperation up = (UnaryOperation) expr;
+            if (up.getOperator() == UnaryOperation.Operator.MINUS
+                    && up.getExpression() instanceof Scalar) {
+                return "-" + ((Scalar) up.getExpression()).getStringValue(); //NOI18N
+            }
+        }
+        if (expr instanceof ArrayCreation) {
+            return getConstantValue((ArrayCreation) expr);
+        }
+        return null;
+    }
+
+    private static String getConstantValue(ArrayCreation expr) {
+        String debug = expr.toString();
+        StringBuilder sb = new StringBuilder("["); //NOI18N
+        Integer displayedElements = 0;
+        List<ArrayElement> elements = expr.getElements();
+        for (ArrayElement element : elements) {
+            if (displayedElements > 0) {
+                sb.append(", "); //NOI18N
+            }
+            sb.append(getConstantValue(element));
+            displayedElements++;
+            if (sb.length() > ARRAY_CUT_LENGTH) {
+                break;
+            }
+        }
+        if (displayedElements < elements.size()) {
+            sb.append(", ..."); //NOI18N

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

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] KacerCZ commented on pull request #2578: [NETBEANS-5091] PHP - more improvements for constants in code completion

Posted by GitBox <gi...@apache.org>.
KacerCZ commented on pull request #2578:
URL: https://github.com/apache/netbeans/pull/2578#issuecomment-738892465


   Windows build failed because of network problem.
   Linux build failed in PHP Refactoring module, but all tests passed on local machine.


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

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 merged pull request #2578: [NETBEANS-5091] PHP - more improvements for constants in code completion

Posted by GitBox <gi...@apache.org>.
junichi11 merged pull request #2578:
URL: https://github.com/apache/netbeans/pull/2578


   


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

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] KacerCZ commented on pull request #2578: [NETBEANS-5091] PHP - more improvements for constants in code completion

Posted by GitBox <gi...@apache.org>.
KacerCZ commented on pull request #2578:
URL: https://github.com/apache/netbeans/pull/2578#issuecomment-739463540


   Windows build failed because of network issue.


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

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 change in pull request #2578: [NETBEANS-5091] PHP - more improvements for constants in code completion

Posted by GitBox <gi...@apache.org>.
tmysik commented on a change in pull request #2578:
URL: https://github.com/apache/netbeans/pull/2578#discussion_r536878851



##########
File path: php/php.editor/src/org/netbeans/modules/php/editor/model/nodes/ClassConstantDeclarationInfo.java
##########
@@ -97,4 +96,61 @@ public PhpModifiers getAccessModifiers() {
         return PhpModifiers.fromBitMask(constantDeclaration.getModifier());
     }
 
+    @CheckForNull
+    protected static String getConstantValue(Expression expr) {
+        if (expr instanceof Scalar) {
+            return ((Scalar) expr).getStringValue();
+        }
+        if (expr instanceof UnaryOperation) {
+            UnaryOperation up = (UnaryOperation) expr;
+            if (up.getOperator() == UnaryOperation.Operator.MINUS
+                    && up.getExpression() instanceof Scalar) {
+                return "-" + ((Scalar) up.getExpression()).getStringValue(); //NOI18N
+            }
+        }
+        if (expr instanceof ArrayCreation) {
+            return getConstantValue((ArrayCreation) expr);
+        }
+        return null;
+    }
+
+    private static String getConstantValue(ArrayCreation expr) {
+        String debug = expr.toString();
+        StringBuilder sb = new StringBuilder("["); //NOI18N
+        Integer displayedElements = 0;
+        List<ArrayElement> elements = expr.getElements();
+        for (ArrayElement element : elements) {
+            if (displayedElements > 0) {
+                sb.append(", "); //NOI18N
+            }
+            sb.append(getConstantValue(element));
+            displayedElements++;
+            if (sb.length() > ARRAY_CUT_LENGTH) {
+                break;
+            }
+        }
+        if (displayedElements < elements.size()) {
+            sb.append(", ..."); //NOI18N

Review comment:
       Perhaps instead of `...` we could show something like `... (5 more elements)`?
   




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

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] KacerCZ commented on a change in pull request #2578: [NETBEANS-5091] PHP - more improvements for constants in code completion

Posted by GitBox <gi...@apache.org>.
KacerCZ commented on a change in pull request #2578:
URL: https://github.com/apache/netbeans/pull/2578#discussion_r536967530



##########
File path: php/php.editor/src/org/netbeans/modules/php/editor/model/nodes/ClassConstantDeclarationInfo.java
##########
@@ -97,4 +96,61 @@ public PhpModifiers getAccessModifiers() {
         return PhpModifiers.fromBitMask(constantDeclaration.getModifier());
     }
 
+    @CheckForNull
+    protected static String getConstantValue(Expression expr) {
+        if (expr instanceof Scalar) {
+            return ((Scalar) expr).getStringValue();
+        }
+        if (expr instanceof UnaryOperation) {
+            UnaryOperation up = (UnaryOperation) expr;
+            if (up.getOperator() == UnaryOperation.Operator.MINUS
+                    && up.getExpression() instanceof Scalar) {
+                return "-" + ((Scalar) up.getExpression()).getStringValue(); //NOI18N
+            }
+        }
+        if (expr instanceof ArrayCreation) {
+            return getConstantValue((ArrayCreation) expr);
+        }
+        return null;
+    }
+
+    private static String getConstantValue(ArrayCreation expr) {
+        String debug = expr.toString();
+        StringBuilder sb = new StringBuilder("["); //NOI18N
+        Integer displayedElements = 0;
+        List<ArrayElement> elements = expr.getElements();
+        for (ArrayElement element : elements) {
+            if (displayedElements > 0) {
+                sb.append(", "); //NOI18N
+            }
+            sb.append(getConstantValue(element));
+            displayedElements++;
+            if (sb.length() > ARRAY_CUT_LENGTH) {
+                break;
+            }
+        }
+        if (displayedElements < elements.size()) {
+            sb.append(", ..."); //NOI18N

Review comment:
       I made the change.




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

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 change in pull request #2578: [NETBEANS-5091] PHP - more improvements for constants in code completion

Posted by GitBox <gi...@apache.org>.
junichi11 commented on a change in pull request #2578:
URL: https://github.com/apache/netbeans/pull/2578#discussion_r535758896



##########
File path: php/php.editor/test/unit/data/testfiles/completion/lib/php56/classConst.php
##########
@@ -0,0 +1,23 @@
+<?php
+

Review comment:
       The rat does not check the license header of test files. However, we should add it to new test files if possible. Of course, we need not add it to *.completion, *.pass, and so on.




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

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] KacerCZ commented on a change in pull request #2578: [NETBEANS-5091] PHP - more improvements for constants in code completion

Posted by GitBox <gi...@apache.org>.
KacerCZ commented on a change in pull request #2578:
URL: https://github.com/apache/netbeans/pull/2578#discussion_r536967530



##########
File path: php/php.editor/src/org/netbeans/modules/php/editor/model/nodes/ClassConstantDeclarationInfo.java
##########
@@ -97,4 +96,61 @@ public PhpModifiers getAccessModifiers() {
         return PhpModifiers.fromBitMask(constantDeclaration.getModifier());
     }
 
+    @CheckForNull
+    protected static String getConstantValue(Expression expr) {
+        if (expr instanceof Scalar) {
+            return ((Scalar) expr).getStringValue();
+        }
+        if (expr instanceof UnaryOperation) {
+            UnaryOperation up = (UnaryOperation) expr;
+            if (up.getOperator() == UnaryOperation.Operator.MINUS
+                    && up.getExpression() instanceof Scalar) {
+                return "-" + ((Scalar) up.getExpression()).getStringValue(); //NOI18N
+            }
+        }
+        if (expr instanceof ArrayCreation) {
+            return getConstantValue((ArrayCreation) expr);
+        }
+        return null;
+    }
+
+    private static String getConstantValue(ArrayCreation expr) {
+        String debug = expr.toString();
+        StringBuilder sb = new StringBuilder("["); //NOI18N
+        Integer displayedElements = 0;
+        List<ArrayElement> elements = expr.getElements();
+        for (ArrayElement element : elements) {
+            if (displayedElements > 0) {
+                sb.append(", "); //NOI18N
+            }
+            sb.append(getConstantValue(element));
+            displayedElements++;
+            if (sb.length() > ARRAY_CUT_LENGTH) {
+                break;
+            }
+        }
+        if (displayedElements < elements.size()) {
+            sb.append(", ..."); //NOI18N

Review comment:
       I made the change and updated image in description.




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

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] KacerCZ commented on a change in pull request #2578: [NETBEANS-5091] PHP - more improvements for constants in code completion

Posted by GitBox <gi...@apache.org>.
KacerCZ commented on a change in pull request #2578:
URL: https://github.com/apache/netbeans/pull/2578#discussion_r536122677



##########
File path: php/php.editor/src/org/netbeans/modules/php/editor/model/nodes/ClassConstantDeclarationInfo.java
##########
@@ -22,20 +22,28 @@
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
+import org.netbeans.api.annotations.common.CheckForNull;
 import org.netbeans.modules.csl.api.OffsetRange;
 import org.netbeans.modules.php.editor.api.PhpModifiers;
 import org.netbeans.modules.php.editor.api.QualifiedName;
 import org.netbeans.modules.php.editor.model.nodes.ASTNodeInfo.Kind;
+import org.netbeans.modules.php.editor.parser.astnodes.ArrayCreation;
+import org.netbeans.modules.php.editor.parser.astnodes.ArrayElement;
 import org.netbeans.modules.php.editor.parser.astnodes.ConstantDeclaration;
 import org.netbeans.modules.php.editor.parser.astnodes.Expression;
 import org.netbeans.modules.php.editor.parser.astnodes.Identifier;
 import org.netbeans.modules.php.editor.parser.astnodes.Scalar;
 import org.netbeans.modules.php.editor.parser.astnodes.UnaryOperation;
+import org.netbeans.modules.php.editor.parser.astnodes.UnpackableArrayElement;
 
 /**
  * @author Radek Matous
  */
 public class ClassConstantDeclarationInfo extends ASTNodeInfo<Identifier> {
+    // Array display is stopped after this length of string is reached.
+    private static final Integer ARRAY_CUT_LENGTH = 50;

Review comment:
       Changed type to `int`.




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

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 #2578: [NETBEANS-5091] PHP - more improvements for constants in code completion

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


   Will rerun jobs.


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

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] KacerCZ commented on a change in pull request #2578: [NETBEANS-5091] PHP - more improvements for constants in code completion

Posted by GitBox <gi...@apache.org>.
KacerCZ commented on a change in pull request #2578:
URL: https://github.com/apache/netbeans/pull/2578#discussion_r536896264



##########
File path: php/php.editor/src/org/netbeans/modules/php/editor/model/nodes/ClassConstantDeclarationInfo.java
##########
@@ -97,4 +96,61 @@ public PhpModifiers getAccessModifiers() {
         return PhpModifiers.fromBitMask(constantDeclaration.getModifier());
     }
 
+    @CheckForNull
+    protected static String getConstantValue(Expression expr) {
+        if (expr instanceof Scalar) {
+            return ((Scalar) expr).getStringValue();
+        }
+        if (expr instanceof UnaryOperation) {
+            UnaryOperation up = (UnaryOperation) expr;
+            if (up.getOperator() == UnaryOperation.Operator.MINUS
+                    && up.getExpression() instanceof Scalar) {
+                return "-" + ((Scalar) up.getExpression()).getStringValue(); //NOI18N
+            }
+        }
+        if (expr instanceof ArrayCreation) {
+            return getConstantValue((ArrayCreation) expr);
+        }
+        return null;
+    }
+
+    private static String getConstantValue(ArrayCreation expr) {
+        String debug = expr.toString();
+        StringBuilder sb = new StringBuilder("["); //NOI18N
+        Integer displayedElements = 0;
+        List<ArrayElement> elements = expr.getElements();
+        for (ArrayElement element : elements) {
+            if (displayedElements > 0) {
+                sb.append(", "); //NOI18N
+            }
+            sb.append(getConstantValue(element));
+            displayedElements++;
+            if (sb.length() > ARRAY_CUT_LENGTH) {
+                break;
+            }
+        }
+        if (displayedElements < elements.size()) {
+            sb.append(", ..."); //NOI18N

Review comment:
       I prefer to give more space for actual elements.
   Maybe use shorter form `... (+5)` or `... (5 more)`.




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

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 change in pull request #2578: [NETBEANS-5091] PHP - more improvements for constants in code completion

Posted by GitBox <gi...@apache.org>.
tmysik commented on a change in pull request #2578:
URL: https://github.com/apache/netbeans/pull/2578#discussion_r536912011



##########
File path: php/php.editor/src/org/netbeans/modules/php/editor/model/nodes/ClassConstantDeclarationInfo.java
##########
@@ -97,4 +96,61 @@ public PhpModifiers getAccessModifiers() {
         return PhpModifiers.fromBitMask(constantDeclaration.getModifier());
     }
 
+    @CheckForNull
+    protected static String getConstantValue(Expression expr) {
+        if (expr instanceof Scalar) {
+            return ((Scalar) expr).getStringValue();
+        }
+        if (expr instanceof UnaryOperation) {
+            UnaryOperation up = (UnaryOperation) expr;
+            if (up.getOperator() == UnaryOperation.Operator.MINUS
+                    && up.getExpression() instanceof Scalar) {
+                return "-" + ((Scalar) up.getExpression()).getStringValue(); //NOI18N
+            }
+        }
+        if (expr instanceof ArrayCreation) {
+            return getConstantValue((ArrayCreation) expr);
+        }
+        return null;
+    }
+
+    private static String getConstantValue(ArrayCreation expr) {
+        String debug = expr.toString();
+        StringBuilder sb = new StringBuilder("["); //NOI18N
+        Integer displayedElements = 0;
+        List<ArrayElement> elements = expr.getElements();
+        for (ArrayElement element : elements) {
+            if (displayedElements > 0) {
+                sb.append(", "); //NOI18N
+            }
+            sb.append(getConstantValue(element));
+            displayedElements++;
+            if (sb.length() > ARRAY_CUT_LENGTH) {
+                break;
+            }
+        }
+        if (displayedElements < elements.size()) {
+            sb.append(", ..."); //NOI18N

Review comment:
       `... (5 more)` sounds good to me.
   




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

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] KacerCZ commented on a change in pull request #2578: [NETBEANS-5091] PHP - more improvements for constants in code completion

Posted by GitBox <gi...@apache.org>.
KacerCZ commented on a change in pull request #2578:
URL: https://github.com/apache/netbeans/pull/2578#discussion_r536123817



##########
File path: php/php.editor/test/unit/data/testfiles/completion/lib/php56/classConst.php
##########
@@ -0,0 +1,23 @@
+<?php
+

Review comment:
       I added license to both new test files.




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

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 #2578: [NETBEANS-5091] PHP - more improvements for constants in code completion

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


   @KacerCZ Could you please check the CI failures?
   


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

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 change in pull request #2578: [NETBEANS-5091] PHP - more improvements for constants in code completion

Posted by GitBox <gi...@apache.org>.
tmysik commented on a change in pull request #2578:
URL: https://github.com/apache/netbeans/pull/2578#discussion_r536879206



##########
File path: php/php.editor/src/org/netbeans/modules/php/editor/model/nodes/ClassConstantDeclarationInfo.java
##########
@@ -97,4 +96,61 @@ public PhpModifiers getAccessModifiers() {
         return PhpModifiers.fromBitMask(constantDeclaration.getModifier());
     }
 
+    @CheckForNull
+    protected static String getConstantValue(Expression expr) {
+        if (expr instanceof Scalar) {
+            return ((Scalar) expr).getStringValue();
+        }
+        if (expr instanceof UnaryOperation) {
+            UnaryOperation up = (UnaryOperation) expr;
+            if (up.getOperator() == UnaryOperation.Operator.MINUS
+                    && up.getExpression() instanceof Scalar) {
+                return "-" + ((Scalar) up.getExpression()).getStringValue(); //NOI18N
+            }
+        }
+        if (expr instanceof ArrayCreation) {
+            return getConstantValue((ArrayCreation) expr);
+        }
+        return null;
+    }
+
+    private static String getConstantValue(ArrayCreation expr) {
+        String debug = expr.toString();
+        StringBuilder sb = new StringBuilder("["); //NOI18N
+        Integer displayedElements = 0;
+        List<ArrayElement> elements = expr.getElements();
+        for (ArrayElement element : elements) {
+            if (displayedElements > 0) {
+                sb.append(", "); //NOI18N
+            }
+            sb.append(getConstantValue(element));
+            displayedElements++;
+            if (sb.length() > ARRAY_CUT_LENGTH) {
+                break;
+            }
+        }
+        if (displayedElements < elements.size()) {
+            sb.append(", ..."); //NOI18N

Review comment:
       @KacerCZ @junichi11 
   
   Let me know what you think about my comment. I am ready to merge. 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.

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 change in pull request #2578: [NETBEANS-5091] PHP - more improvements for constants in code completion

Posted by GitBox <gi...@apache.org>.
junichi11 commented on a change in pull request #2578:
URL: https://github.com/apache/netbeans/pull/2578#discussion_r536936631



##########
File path: php/php.editor/src/org/netbeans/modules/php/editor/model/nodes/ClassConstantDeclarationInfo.java
##########
@@ -97,4 +96,61 @@ public PhpModifiers getAccessModifiers() {
         return PhpModifiers.fromBitMask(constantDeclaration.getModifier());
     }
 
+    @CheckForNull
+    protected static String getConstantValue(Expression expr) {
+        if (expr instanceof Scalar) {
+            return ((Scalar) expr).getStringValue();
+        }
+        if (expr instanceof UnaryOperation) {
+            UnaryOperation up = (UnaryOperation) expr;
+            if (up.getOperator() == UnaryOperation.Operator.MINUS
+                    && up.getExpression() instanceof Scalar) {
+                return "-" + ((Scalar) up.getExpression()).getStringValue(); //NOI18N
+            }
+        }
+        if (expr instanceof ArrayCreation) {
+            return getConstantValue((ArrayCreation) expr);
+        }
+        return null;
+    }
+
+    private static String getConstantValue(ArrayCreation expr) {
+        String debug = expr.toString();
+        StringBuilder sb = new StringBuilder("["); //NOI18N
+        Integer displayedElements = 0;
+        List<ArrayElement> elements = expr.getElements();
+        for (ArrayElement element : elements) {
+            if (displayedElements > 0) {
+                sb.append(", "); //NOI18N
+            }
+            sb.append(getConstantValue(element));
+            displayedElements++;
+            if (sb.length() > ARRAY_CUT_LENGTH) {
+                break;
+            }
+        }
+        if (displayedElements < elements.size()) {
+            sb.append(", ..."); //NOI18N

Review comment:
       Agree with @tmysik 




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

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] KacerCZ commented on a change in pull request #2578: [NETBEANS-5091] PHP - more improvements for constants in code completion

Posted by GitBox <gi...@apache.org>.
KacerCZ commented on a change in pull request #2578:
URL: https://github.com/apache/netbeans/pull/2578#discussion_r536122310



##########
File path: php/php.editor/src/org/netbeans/modules/php/editor/model/nodes/ClassConstantDeclarationInfo.java
##########
@@ -97,4 +96,61 @@ public PhpModifiers getAccessModifiers() {
         return PhpModifiers.fromBitMask(constantDeclaration.getModifier());
     }
 
+    @CheckForNull
+    protected static String getConstantValue(Expression expr) {
+        if (expr instanceof Scalar) {
+            return ((Scalar) expr).getStringValue();
+        }
+        if (expr instanceof UnaryOperation) {
+            UnaryOperation up = (UnaryOperation) expr;
+            if (up.getOperator() == UnaryOperation.Operator.MINUS
+                    && up.getExpression() instanceof Scalar) {
+                return "-" + ((Scalar) up.getExpression()).getStringValue();

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.

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 change in pull request #2578: [NETBEANS-5091] PHP - more improvements for constants in code completion

Posted by GitBox <gi...@apache.org>.
junichi11 commented on a change in pull request #2578:
URL: https://github.com/apache/netbeans/pull/2578#discussion_r535752281



##########
File path: php/php.editor/src/org/netbeans/modules/php/editor/model/nodes/ClassConstantDeclarationInfo.java
##########
@@ -22,20 +22,28 @@
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
+import org.netbeans.api.annotations.common.CheckForNull;
 import org.netbeans.modules.csl.api.OffsetRange;
 import org.netbeans.modules.php.editor.api.PhpModifiers;
 import org.netbeans.modules.php.editor.api.QualifiedName;
 import org.netbeans.modules.php.editor.model.nodes.ASTNodeInfo.Kind;
+import org.netbeans.modules.php.editor.parser.astnodes.ArrayCreation;
+import org.netbeans.modules.php.editor.parser.astnodes.ArrayElement;
 import org.netbeans.modules.php.editor.parser.astnodes.ConstantDeclaration;
 import org.netbeans.modules.php.editor.parser.astnodes.Expression;
 import org.netbeans.modules.php.editor.parser.astnodes.Identifier;
 import org.netbeans.modules.php.editor.parser.astnodes.Scalar;
 import org.netbeans.modules.php.editor.parser.astnodes.UnaryOperation;
+import org.netbeans.modules.php.editor.parser.astnodes.UnpackableArrayElement;
 
 /**
  * @author Radek Matous
  */
 public class ClassConstantDeclarationInfo extends ASTNodeInfo<Identifier> {
+    // Array display is stopped after this length of string is reached.
+    private static final Integer ARRAY_CUT_LENGTH = 50;

Review comment:
       Why `Integer`?




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

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 #2578: [NETBEANS-5091] PHP - more improvements for constants in code completion

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


   @KacerCZ Will likely speak not only for myself - thanks a lot for your time and work!
   


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

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 change in pull request #2578: [NETBEANS-5091] PHP - more improvements for constants in code completion

Posted by GitBox <gi...@apache.org>.
junichi11 commented on a change in pull request #2578:
URL: https://github.com/apache/netbeans/pull/2578#discussion_r535751852



##########
File path: php/php.editor/src/org/netbeans/modules/php/editor/model/nodes/ClassConstantDeclarationInfo.java
##########
@@ -97,4 +96,61 @@ public PhpModifiers getAccessModifiers() {
         return PhpModifiers.fromBitMask(constantDeclaration.getModifier());
     }
 
+    @CheckForNull
+    protected static String getConstantValue(Expression expr) {
+        if (expr instanceof Scalar) {
+            return ((Scalar) expr).getStringValue();
+        }
+        if (expr instanceof UnaryOperation) {
+            UnaryOperation up = (UnaryOperation) expr;
+            if (up.getOperator() == UnaryOperation.Operator.MINUS
+                    && up.getExpression() instanceof Scalar) {
+                return "-" + ((Scalar) up.getExpression()).getStringValue();

Review comment:
       Nitpick: `NOI18N`




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

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] KacerCZ commented on pull request #2578: [NETBEANS-5091] PHP - more improvements for constants in code completion

Posted by GitBox <gi...@apache.org>.
KacerCZ commented on pull request #2578:
URL: https://github.com/apache/netbeans/pull/2578#issuecomment-739684656


   @junichi11 @tmysik Thanks for 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.

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