junichi11 commented on code in PR #6569:
URL: https://github.com/apache/netbeans/pull/6569#discussion_r1366449669
##########
php/php.editor/src/org/netbeans/modules/php/editor/parser/astnodes/PHPDocTypeTag.java:
##########
@@ -49,33 +49,26 @@ public List<PHPDocTypeNode> getTypes() {
@Override
public String getDocumentation() {
- if (documentation == null && types.size() > 0) {
+ if (documentation == null && !types.isEmpty()) {
PHPDocTypeNode lastType = types.get(0);
- boolean isLastNodeArray = lastType.isArray();
for (PHPDocTypeNode node : types) {
if (lastType.getEndOffset() < node.getEndOffset()) {
lastType = node;
- isLastNodeArray = node.isArray();
}
}
- int indexAfterTypeWithoutArrayPostfix =
getValue().indexOf(lastType.getValue()) + lastType.getValue().length();
- if (isLastNodeArray) {
- String documentationWithArrayPrefix =
getValue().substring(indexAfterTypeWithoutArrayPostfix).trim();
- int firstSpace = documentationWithArrayPrefix.indexOf(" ");
//NOI18N
- int firstTab = documentationWithArrayPrefix.indexOf("\t");
//NOI18N
- int min = -1;
- if (firstSpace > 0 && (firstSpace < firstTab || firstTab ==
-1)) {
- min = firstSpace;
- } else if (firstTab > 0 && (firstTab < firstSpace ||
firstSpace == -1)) {
- min = firstTab;
- }
- if (min == -1) {
- documentation = ""; //NOI18N
- } else {
- documentation =
getValue().substring(indexAfterTypeWithoutArrayPostfix + min).trim();
- }
+ // e.g. (A&B&C)|(A&B) description
+ // arr[] description
+ // The last type is `B`. If we get the position using
String.indexOf(), we get the wrong position
+ String[] split = getValue().trim().split("[ \t]+", 2); // NOI18N
Review Comment:
Added the following to the `CodeUtils`.
```java
public static final Pattern WHITE_SPACES_PATTERN =
Pattern.compile("\\s+"); // NOI18N
public static final Pattern SPLIT_TYPES_PATTERN =
Pattern.compile("[()|&]"); // NOI18N
```
##########
php/php.editor/src/org/netbeans/modules/php/editor/model/impl/Type.java:
##########
@@ -96,6 +96,7 @@ private Type() {
public static final String PARENT = "parent"; //NOI18N
public static final String STATIC = "static"; //NOI18N NETBEANS-4443 PHP
8.0
public static final String NEVER = "never"; //NOI18N NETBEANS-5599 PHP 8.1
+ public static final String SPLIT_REGEX = "[()|&]"; // NOI18N
Review Comment:
Added the following to the `CodeUtils`.
```java
public static final Pattern WHITE_SPACES_PATTERN =
Pattern.compile("\\s+"); // NOI18N
public static final Pattern SPLIT_TYPES_PATTERN =
Pattern.compile("[()|&]"); // 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.
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