Skip to content

Commit fbaeb2e

Browse files
committed
- cleanup, add more comment info for composition expression
1 parent 052f4c3 commit fbaeb2e

File tree

9 files changed

+15
-16
lines changed

9 files changed

+15
-16
lines changed

php/php.editor/src/org/netbeans/modules/php/editor/lexer/LexUtilities.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ public static int findStartTokenOfExpression(TokenSequence ts) {
624624
break;
625625
}
626626
} else if (token.id() == PHPTokenId.PHP_OPERATOR && TokenUtilities.textEquals(token.text(), "|>")) { // NOI18N
627-
//pipe operator
627+
//PHP 8.5 pipe operator
628628
start = ts.offset();
629629
break;
630630
} else if (balance == 1 && token.id() == PHPTokenId.PHP_STRING) {

php/php.editor/src/org/netbeans/modules/php/editor/parser/PHP5ErrorHandlerImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ public static String getTokenTextForm(int token) {
398398
case ASTPHP5Symbols.T_YIELD_FROM : text = "yield from"; break; //NOI18N
399399
case ASTPHP5Symbols.T_READONLY : text = "readonly"; break; //NOI18N PHP 8.1
400400
//skiping T_PIPE = "|>" PHP 8.5 as it doesn't bring much to the expected tokens error message
401+
// and it breaks multiple unit tests which displayes the expected tokens list
401402
default:
402403
//no-op
403404
}

php/php.editor/src/org/netbeans/modules/php/editor/parser/astnodes/Assignment.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ public enum Type {
3939
MOD_EQUAL("%="), //NOI18N
4040
AND_EQUAL("&="), //NOI18N
4141
OR_EQUAL("|="), //NOI18N
42-
PIPE("|>"), //NOI18N
4342
XOR_EQUAL("^="), //NOI18N
4443
SL_EQUAL("<<="), //NOI18N
4544
SR_EQUAL(">>="), //NOI18N

php/php.editor/src/org/netbeans/modules/php/editor/parser/astnodes/CompositionExpression.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,21 @@
1818
*/
1919
package org.netbeans.modules.php.editor.parser.astnodes;
2020

21-
21+
/**
22+
* Represents a function composition expression
23+
* chaining multiple callables from left to right
24+
* It's marked by the pipe operator "|>"
25+
* @see https://wiki.php.net/rfc/pipe-operator-v3
26+
* <pre>
27+
* $a |> strtoupper(...)
28+
* $a |> trim(...)
29+
* </pre>
30+
*
31+
*/
2232
public class CompositionExpression extends Expression {
2333

2434
/**
35+
* Operator type used for the composition expression
2536
* possible rfc with using "+" for composition
2637
* https://wiki.php.net/rfc/function-composition
2738
*/

php/php.editor/src/org/netbeans/modules/php/editor/verification/IncorrectFunctionCompositionHintError.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import java.util.List;
2525
import org.netbeans.api.annotations.common.NullAllowed;
2626
import org.netbeans.modules.csl.api.Hint;
27-
import org.netbeans.modules.csl.api.HintFix;
2827
import org.netbeans.modules.csl.api.OffsetRange;
2928
import org.netbeans.modules.csl.spi.support.CancelSupport;
3029
import org.netbeans.modules.php.api.PhpVersion;

php/php.editor/src/org/netbeans/modules/php/editor/verification/PHP82UnhandledError.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
import org.netbeans.modules.php.editor.parser.PHPParseResult;
3333
import org.netbeans.modules.php.editor.parser.astnodes.ASTNode;
3434
import org.netbeans.modules.php.editor.parser.astnodes.ClassDeclaration;
35-
import org.netbeans.modules.php.editor.parser.astnodes.CompositionExpression;
36-
import org.netbeans.modules.php.editor.parser.astnodes.ConditionalExpression;
3735
import org.netbeans.modules.php.editor.parser.astnodes.ConstantDeclaration;
3836
import org.netbeans.modules.php.editor.parser.astnodes.Statement;
3937
import org.netbeans.modules.php.editor.parser.astnodes.TraitDeclaration;

php/php.editor/src/org/netbeans/modules/php/editor/verification/PHP83UnhandledError.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import org.netbeans.modules.php.editor.parser.astnodes.Assignment;
3737
import org.netbeans.modules.php.editor.parser.astnodes.ClassInstanceCreation;
3838
import org.netbeans.modules.php.editor.parser.astnodes.ClassName;
39-
import org.netbeans.modules.php.editor.parser.astnodes.CompositionExpression;
4039
import org.netbeans.modules.php.editor.parser.astnodes.ConditionalExpression;
4140
import org.netbeans.modules.php.editor.parser.astnodes.ConstantDeclaration;
4241
import org.netbeans.modules.php.editor.parser.astnodes.ConstantVariable;

php/php.editor/src/org/netbeans/modules/php/editor/verification/PHP84UnhandledError.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import org.netbeans.modules.php.editor.parser.astnodes.ASTNode;
3232
import org.netbeans.modules.php.editor.parser.astnodes.BodyDeclaration.Modifier;
3333
import org.netbeans.modules.php.editor.parser.astnodes.ClassInstanceCreationVariable;
34-
import org.netbeans.modules.php.editor.parser.astnodes.CompositionExpression;
3534
import org.netbeans.modules.php.editor.parser.astnodes.FieldsDeclaration;
3635
import org.netbeans.modules.php.editor.parser.astnodes.FormalParameter;
3736
import org.netbeans.modules.php.editor.parser.astnodes.FunctionDeclaration;
@@ -146,14 +145,6 @@ public void visit(MethodDeclaration node) {
146145
super.visit(node);
147146
}
148147

149-
@Override
150-
public void visit(CompositionExpression node) {
151-
if (CancelSupport.getDefault().isCancelled()) {
152-
return;
153-
}
154-
createError(node);
155-
}
156-
157148
private void checkSetVisibility(MethodDeclaration node) {
158149
if (CodeUtils.isConstructor(node)) {
159150
FunctionDeclaration function = node.getFunction();

php/php.editor/src/org/netbeans/modules/php/editor/verification/PHP85UnhandledError.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ public void visit(CompositionExpression node) {
9292
return;
9393
}
9494

95+
//composition expression are available since PHP 8.5
9596
createError(node);
9697
}
9798

0 commit comments

Comments
 (0)