[GitHub] [netbeans] tmysik commented on a change in pull request #1423: [NETBEANS-53] Improve constructor getter setter code generation

2019-08-14 Thread GitBox
tmysik commented on a change in pull request #1423: [NETBEANS-53] Improve 
constructor getter setter code generation
URL: https://github.com/apache/netbeans/pull/1423#discussion_r313758384
 
 

 ##
 File path: 
php/php.api.phpmodule/src/org/netbeans/modules/php/api/PhpVersion.java
 ##
 @@ -136,6 +136,39 @@ public boolean hasNamespaces() {
 return namespaces;
 }
 
+/**
+ * Check whether this version supports scalar and return type declarations.
+ *
+ * @return {@code true} if this version scalar and return type 
declarations,
+ * {@code false} otherwise
+ * @since 2.67
+ */
+public boolean hasScalarAndReturnTypes() {
+return this.compareTo(PhpVersion.PHP_70) >= 0;
 
 Review comment:
   Nice solution! I was thinking about defining this method in each 
`PhpVersion` item or using a boolean flag but your solution is much better!
   


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:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org
For additional commands, e-mail: notifications-h...@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 #1423: [NETBEANS-53] Improve constructor getter setter code generation

2019-08-13 Thread GitBox
tmysik commented on a change in pull request #1423: [NETBEANS-53] Improve 
constructor getter setter code generation
URL: https://github.com/apache/netbeans/pull/1423#discussion_r313708129
 
 

 ##
 File path: 
php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesGetter/testTypedPropertiesGetter.php.testTypedPropertiesGetter_PHP56.codegen
 ##
 @@ -0,0 +1,72 @@
+public  function getInstanceArray() {
 
 Review comment:
   We have 2 spaces (`  `) here. This is not nice...
   


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:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org
For additional commands, e-mail: notifications-h...@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 #1423: [NETBEANS-53] Improve constructor getter setter code generation

2019-08-13 Thread GitBox
tmysik commented on a change in pull request #1423: [NETBEANS-53] Improve 
constructor getter setter code generation
URL: https://github.com/apache/netbeans/pull/1423#discussion_r313708271
 
 

 ##
 File path: 
php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesGetter/testTypedPropertiesGetter.php.testTypedPropertiesGetter_PHP56.codegen
 ##
 @@ -0,0 +1,72 @@
+public  function getInstanceArray() {
 
 Review comment:
   Now I see - the formatter is called afterward, right?
   


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:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org
For additional commands, e-mail: notifications-h...@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 #1423: [NETBEANS-53] Improve constructor getter setter code generation

2019-08-13 Thread GitBox
tmysik commented on a change in pull request #1423: [NETBEANS-53] Improve 
constructor getter setter code generation
URL: https://github.com/apache/netbeans/pull/1423#discussion_r313707837
 
 

 ##
 File path: 
php/php.editor/src/org/netbeans/modules/php/editor/codegen/CGSInfo.java
 ##
 @@ -369,17 +395,40 @@ private String getFirstTypeFromBlock(final PHPDocBlock 
phpDoc) {
 }
 
 private String getFirstTypeFromTag(final PHPDocTypeTag typeTag) {
+boolean canBeNull = canBeNull(typeTag);
 String result = ""; //NOI18N
 for (PHPDocTypeNode typeNode : typeTag.getTypes()) {
 String type = typeNode.getValue();
-if (!Type.isPrimitive(type) && 
!VariousUtils.isSpecialClassName(type)) {
+if (phpVersion.compareTo(PhpVersion.PHP_70) >= 0
+&& !VariousUtils.isSpecialClassName(type)
+&& !Type.isInvalidPropertyType(type)) {
+result = typeNode.isArray() ? Type.ARRAY : type;
+if (canBeNull && phpVersion.compareTo(PhpVersion.PHP_71) 
>= 0) {
+result = CodeUtils.NULLABLE_TYPE_PREFIX + result;
+}
+break;
+} else if (!Type.isPrimitive(type) && 
!VariousUtils.isSpecialClassName(type)) {
 result = typeNode.isArray() ? Type.ARRAY : type;
 break;
 }
 }
 return result;
 }
 
+private boolean canBeNull(final PHPDocTypeTag typeTag) {
+boolean canBeNull = false;
+if (typeTag.getTypes().size() > 1) {
+for (PHPDocTypeNode typeNode : typeTag.getTypes()) {
+String type = typeNode.getValue().toLowerCase();
 
 Review comment:
   `toLowerCase()` should be always called with a parameter (locale), `EN_US` 
should work fine in this case.
   


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:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org
For additional commands, e-mail: notifications-h...@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 #1423: [NETBEANS-53] Improve constructor getter setter code generation

2019-08-13 Thread GitBox
tmysik commented on a change in pull request #1423: [NETBEANS-53] Improve 
constructor getter setter code generation
URL: https://github.com/apache/netbeans/pull/1423#discussion_r313707520
 
 

 ##
 File path: 
php/php.editor/src/org/netbeans/modules/php/editor/codegen/CGSInfo.java
 ##
 @@ -369,17 +395,40 @@ private String getFirstTypeFromBlock(final PHPDocBlock 
phpDoc) {
 }
 
 private String getFirstTypeFromTag(final PHPDocTypeTag typeTag) {
+boolean canBeNull = canBeNull(typeTag);
 String result = ""; //NOI18N
 for (PHPDocTypeNode typeNode : typeTag.getTypes()) {
 String type = typeNode.getValue();
-if (!Type.isPrimitive(type) && 
!VariousUtils.isSpecialClassName(type)) {
+if (phpVersion.compareTo(PhpVersion.PHP_70) >= 0
+&& !VariousUtils.isSpecialClassName(type)
+&& !Type.isInvalidPropertyType(type)) {
+result = typeNode.isArray() ? Type.ARRAY : type;
+if (canBeNull && phpVersion.compareTo(PhpVersion.PHP_71) 
>= 0) {
 
 Review comment:
   Consider adding e.g. hasNullableTypes() directly to PhpVersion. It would be 
much easier to use and to read.
   


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:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org
For additional commands, e-mail: notifications-h...@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 #1423: [NETBEANS-53] Improve constructor getter setter code generation

2019-08-13 Thread GitBox
tmysik commented on a change in pull request #1423: [NETBEANS-53] Improve 
constructor getter setter code generation
URL: https://github.com/apache/netbeans/pull/1423#discussion_r313707520
 
 

 ##
 File path: 
php/php.editor/src/org/netbeans/modules/php/editor/codegen/CGSInfo.java
 ##
 @@ -369,17 +395,40 @@ private String getFirstTypeFromBlock(final PHPDocBlock 
phpDoc) {
 }
 
 private String getFirstTypeFromTag(final PHPDocTypeTag typeTag) {
+boolean canBeNull = canBeNull(typeTag);
 String result = ""; //NOI18N
 for (PHPDocTypeNode typeNode : typeTag.getTypes()) {
 String type = typeNode.getValue();
-if (!Type.isPrimitive(type) && 
!VariousUtils.isSpecialClassName(type)) {
+if (phpVersion.compareTo(PhpVersion.PHP_70) >= 0
+&& !VariousUtils.isSpecialClassName(type)
+&& !Type.isInvalidPropertyType(type)) {
+result = typeNode.isArray() ? Type.ARRAY : type;
+if (canBeNull && phpVersion.compareTo(PhpVersion.PHP_71) 
>= 0) {
 
 Review comment:
   Consider adding e.g. `hasNullableTypes()` directly to `PhpVersion`. It would 
be much easier to use and to read.
   


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:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org
For additional commands, e-mail: notifications-h...@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 #1423: [NETBEANS-53] Improve constructor getter setter code generation

2019-08-13 Thread GitBox
tmysik commented on a change in pull request #1423: [NETBEANS-53] Improve 
constructor getter setter code generation
URL: https://github.com/apache/netbeans/pull/1423#discussion_r313707423
 
 

 ##
 File path: 
php/php.editor/src/org/netbeans/modules/php/editor/codegen/CGSInfo.java
 ##
 @@ -369,17 +395,40 @@ private String getFirstTypeFromBlock(final PHPDocBlock 
phpDoc) {
 }
 
 private String getFirstTypeFromTag(final PHPDocTypeTag typeTag) {
+boolean canBeNull = canBeNull(typeTag);
 String result = ""; //NOI18N
 for (PHPDocTypeNode typeNode : typeTag.getTypes()) {
 String type = typeNode.getValue();
-if (!Type.isPrimitive(type) && 
!VariousUtils.isSpecialClassName(type)) {
+if (phpVersion.compareTo(PhpVersion.PHP_70) >= 0
 
 Review comment:
   Consider adding e.g. `hasNullableTypes()` directly to `PhpVersion`. It would 
be much easier to use and to read.


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:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org
For additional commands, e-mail: notifications-h...@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 #1423: [NETBEANS-53] Improve constructor getter setter code generation

2019-08-13 Thread GitBox
tmysik commented on a change in pull request #1423: [NETBEANS-53] Improve 
constructor getter setter code generation
URL: https://github.com/apache/netbeans/pull/1423#discussion_r313707423
 
 

 ##
 File path: 
php/php.editor/src/org/netbeans/modules/php/editor/codegen/CGSInfo.java
 ##
 @@ -369,17 +395,40 @@ private String getFirstTypeFromBlock(final PHPDocBlock 
phpDoc) {
 }
 
 private String getFirstTypeFromTag(final PHPDocTypeTag typeTag) {
+boolean canBeNull = canBeNull(typeTag);
 String result = ""; //NOI18N
 for (PHPDocTypeNode typeNode : typeTag.getTypes()) {
 String type = typeNode.getValue();
-if (!Type.isPrimitive(type) && 
!VariousUtils.isSpecialClassName(type)) {
+if (phpVersion.compareTo(PhpVersion.PHP_70) >= 0
 
 Review comment:
   Consider adding e.g. `hasNullableTypes()` directly to `PhpVersion`. It would 
be much easier to use and to read.


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:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org
For additional commands, e-mail: notifications-h...@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 #1423: [NETBEANS-53] Improve constructor getter setter code generation

2019-08-13 Thread GitBox
tmysik commented on a change in pull request #1423: [NETBEANS-53] Improve 
constructor getter setter code generation
URL: https://github.com/apache/netbeans/pull/1423#discussion_r313707328
 
 

 ##
 File path: 
php/php.editor/src/org/netbeans/modules/php/editor/codegen/CGSInfo.java
 ##
 @@ -346,6 +354,24 @@ public void visit(FieldsDeclaration node) {
 }
 }
 
+private String getPropertyType(FieldsDeclaration fieldsDeclaration, 
SingleFieldDeclaration singleFieldDeclaration) {
+String type = ""; // NOI18N
+if (fieldsDeclaration.getFieldType() == null || 
phpVersion.compareTo(PhpVersion.PHP_74) < 0) {
 
 Review comment:
   Consider adding e.g. `hasTypes()` directly to `PhpVersion`. It would be much 
easier to use and to read.
   


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:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org
For additional commands, e-mail: notifications-h...@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 #1423: [NETBEANS-53] Improve constructor getter setter code generation

2019-08-13 Thread GitBox
tmysik commented on a change in pull request #1423: [NETBEANS-53] Improve 
constructor getter setter code generation
URL: https://github.com/apache/netbeans/pull/1423#discussion_r313706961
 
 

 ##
 File path: 
php/php.editor/src/org/netbeans/modules/php/editor/codegen/CGSInfo.java
 ##
 @@ -346,6 +354,24 @@ public void visit(FieldsDeclaration node) {
 }
 }
 
+private String getPropertyType(FieldsDeclaration fieldsDeclaration, 
SingleFieldDeclaration singleFieldDeclaration) {
+String type = ""; // NOI18N
+if (fieldsDeclaration.getFieldType() == null || 
phpVersion.compareTo(PhpVersion.PHP_74) < 0) {
+type = getPropertyType(singleFieldDeclaration);
+} else {
+// PHP 7.4 or newer
+QualifiedName qualifiedName = 
QualifiedName.create(fieldsDeclaration.getFieldType());
+if (qualifiedName != null) {
+type = qualifiedName.toString();
+if (fieldsDeclaration.getFieldType() instanceof 
NullableType) {
+type = CodeUtils.NULLABLE_TYPE_PREFIX + type;
+}
+}
+assert !type.isEmpty();
 
 Review comment:
   If this fails, some more information could be useful in order to fix the 
error (e.g. `qualifiedName` or `fieldsDeclaration` could be added?).
   


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:
us...@infra.apache.org


With regards,
Apache Git Services

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

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