tmysik commented on code in PR #6569:
URL: https://github.com/apache/netbeans/pull/6569#discussion_r1363855114
##########
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:
Again, consider compiling the pattern in advance.
--
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