matthiasblaesing opened a new pull request, #9535:
URL: https://github.com/apache/netbeans/pull/9535
Trying to format an enum like this:
```php
enum Type {
case UNSET;
}
```
Results in a deformed case:
```php
enum Type {
case UNSET;
}
```
with assertions enabled, it causes an error like this:
```
SEVERE [org.openide.util.RequestProcessor]: Error in RequestProcessor
org.netbeans.modules.progress.ui.RunOffEDTImpl$1
java.lang.AssertionError: The same token (index: 14 - WHITESPACE, format
tokens: 25, offset: 33) was precessed before.
Please report this to help fix issue 188809.
<?php
enum Type {
case UNSET;
}
at
org.netbeans.modules.php.editor.indent.FormatVisitor.addFormatToken(FormatVisitor.java:2755)
at
org.netbeans.modules.php.editor.indent.FormatVisitor.visit(FormatVisitor.java:1224)
at
org.netbeans.modules.php.editor.parser.astnodes.CaseDeclaration.accept(CaseDeclaration.java:82)
```
Replacing `UNSET` with `XNSET` results in a valid result.
The problem is located in the `FormatVisitor`, which scans the `case`
expression and loops until the first string is found. That works for the normal
cases, but not for cases, where the enum name is also a keyword.
The grammar explicitly declares, that everything after the `case` is
considered an identifier (ignoring whitespace and comments). The NetBeans lexer
however yields an PHP_UNSET for the UNSET case.
Instead of relying on the token ids when scanning the `case` expression, the
position of the name of the `case` expression is extracted from the AST and
used as a terminator for the scanning sequence.
Closes: #9533
--
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