diff --git a/php/php.twig/src/org/netbeans/modules/php/twig/editor/lexer/TwigVariableColoringLexer.java b/php/php.twig/src/org/netbeans/modules/php/twig/editor/lexer/TwigVariableColoringLexer.java
index 9c6171677c7f..2593bf593cab 100644
--- a/php/php.twig/src/org/netbeans/modules/php/twig/editor/lexer/TwigVariableColoringLexer.java
+++ b/php/php.twig/src/org/netbeans/modules/php/twig/editor/lexer/TwigVariableColoringLexer.java
@@ -1,4 +1,4 @@
-/* The following code was generated by JFlex 1.4.3 on 16/12/29 7:06 */
+/* The following code was generated by JFlex 1.4.3 on 8/24/25, 1:09 AM */
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -25,14 +25,14 @@
import org.netbeans.spi.lexer.LexerRestartInfo;
import org.netbeans.modules.web.common.api.ByteStack;
+@org.netbeans.api.annotations.common.SuppressWarnings({"SF_SWITCH_FALLTHROUGH", "URF_UNREAD_FIELD", "DLS_DEAD_LOCAL_STORE", "DM_DEFAULT_ENCODING"})
/**
- * This class is a scanner generated by
+ * This class is a scanner generated by
* JFlex 1.4.3
- * on 16/12/29 7:06 from the specification file
- * /home/junichi11/hg/web-main/php.twig/tools/TwigVariableColoringLexer.flex
+ * on 8/24/25, 1:09 AM from the specification file
+ * /home/bhaidu/BHA/Netbeans/Projects/netbeans/php/php.twig/tools/TwigVariableColoringLexer.flex
*/
-@org.netbeans.api.annotations.common.SuppressWarnings({"SF_SWITCH_FALLTHROUGH", "URF_UNREAD_FIELD", "DLS_DEAD_LOCAL_STORE", "DM_DEFAULT_ENCODING"})
public class TwigVariableColoringLexer {
/** This character denotes the end of file */
@@ -54,43 +54,43 @@ public class TwigVariableColoringLexer {
* at the beginning of a line
* l is of the form l = 2*k, k a non negative integer
*/
- private static final int ZZ_LEXSTATE[] = {
+ private static final int ZZ_LEXSTATE[] = {
0, 0, 1, 1, 2, 2, 3, 3, 4, 4
};
- /**
+ /**
* Translates characters to character classes
*/
- private static final String ZZ_CMAP_PACKED =
- "\11\0\1\1\1\1\2\0\1\1\22\0\1\1\1\16\1\31\1\34"+
- "\1\0\1\10\1\0\1\33\1\25\1\25\1\21\1\10\1\25\1\11"+
- "\1\23\1\22\12\27\1\25\1\0\1\17\1\4\1\17\1\25\1\0"+
- "\1\2\1\13\1\30\1\15\4\30\1\20\4\30\1\5\1\6\2\30"+
- "\1\12\1\3\1\7\3\30\1\14\2\30\1\25\1\32\1\25\1\0"+
- "\1\30\1\0\1\2\1\13\1\30\1\15\4\30\1\20\4\30\1\5"+
- "\1\6\2\30\1\12\1\3\1\7\3\30\1\14\2\30\1\24\1\25"+
- "\1\26\1\10\201\30\uff00\0";
-
- /**
+ private static final String ZZ_CMAP_PACKED =
+ "\11\0\1\1\1\35\2\0\1\35\22\0\1\1\1\16\1\32\1\25"+
+ "\1\0\1\10\1\0\1\34\1\26\1\26\1\21\1\10\1\26\1\11"+
+ "\1\23\1\22\12\30\1\26\1\0\1\17\1\4\1\17\1\26\1\0"+
+ "\1\2\1\13\1\31\1\15\4\31\1\20\4\31\1\5\1\6\2\31"+
+ "\1\12\1\3\1\7\3\31\1\14\2\31\1\26\1\33\1\26\1\0"+
+ "\1\31\1\0\1\2\1\13\1\31\1\15\4\31\1\20\4\31\1\5"+
+ "\1\6\2\31\1\12\1\3\1\7\3\31\1\14\2\31\1\24\1\26"+
+ "\1\27\1\10\201\31\uff00\0";
+
+ /**
* Translates characters to character classes
*/
private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED);
- /**
+ /**
* Translates DFA states to action switch labels.
*/
private static final int [] ZZ_ACTION = zzUnpackAction();
private static final String ZZ_ACTION_PACKED_0 =
"\5\0\1\1\1\2\2\3\1\4\2\3\1\4\1\3"+
- "\1\1\1\3\2\4\2\5\1\6\3\1\1\2\1\7"+
- "\2\1\1\10\1\1\1\11\1\12\1\4\2\3\3\0"+
- "\1\13\3\0\1\14\1\0\1\7\5\0\1\7\1\0"+
- "\1\15\1\16\3\0\1\6\1\13\1\14\1\0\1\15"+
- "\1\0\1\15";
+ "\1\1\1\3\2\4\2\5\1\1\1\6\3\1\1\2"+
+ "\1\1\1\7\2\1\1\10\1\11\1\12\1\4\2\3"+
+ "\1\0\1\13\2\0\1\14\3\0\1\15\2\0\1\7"+
+ "\1\0\1\16\4\0\1\7\1\17\3\0\1\13\1\6"+
+ "\1\14\1\15\1\0\1\16\1\0\1\16";
private static int [] zzUnpackAction() {
- int [] result = new int[64];
+ int [] result = new int[67];
int offset = 0;
offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
return result;
@@ -109,23 +109,24 @@ private static int zzUnpackAction(String packed, int offset, int [] result) {
}
- /**
+ /**
* Translates a state to a row index in the transition table
*/
private static final int [] ZZ_ROWMAP = zzUnpackRowMap();
private static final String ZZ_ROWMAP_PACKED_0 =
- "\0\0\0\35\0\72\0\127\0\164\0\221\0\256\0\313"+
- "\0\350\0\u0105\0\u0122\0\u013f\0\221\0\u015c\0\u0105\0\u0179"+
- "\0\u0196\0\u01b3\0\u01d0\0\221\0\u01ed\0\u020a\0\u0227\0\u0244"+
- "\0\u0261\0\u027e\0\u029b\0\u02b8\0\221\0\u02d5\0\221\0\u02f2"+
- "\0\350\0\u030f\0\u032c\0\u0349\0\u0366\0\u020a\0\221\0\u0383"+
- "\0\u0227\0\u03a0\0\221\0\u0244\0\221\0\u029b\0\u02b8\0\u027e"+
- "\0\u03bd\0\u03da\0\u0244\0\u03f7\0\221\0\221\0\u0414\0\u0431"+
- "\0\u044e\0\u0366\0\u020a\0\u0227\0\u046b\0\u0244\0\u0488\0\u027e";
+ "\0\0\0\36\0\74\0\132\0\170\0\226\0\264\0\322"+
+ "\0\360\0\u010e\0\u012c\0\u014a\0\226\0\u0168\0\u010e\0\u0186"+
+ "\0\u01a4\0\u01c2\0\u01e0\0\226\0\u01fe\0\u021c\0\u023a\0\u0258"+
+ "\0\u0276\0\u0294\0\u02b2\0\u02d0\0\u02ee\0\u030c\0\226\0\226"+
+ "\0\u032a\0\360\0\u0348\0\u0366\0\u0384\0\u03a2\0\u03c0\0\u023a"+
+ "\0\226\0\u03de\0\u0258\0\u03fc\0\226\0\u0276\0\u02b2\0\226"+
+ "\0\u02ee\0\226\0\u02d0\0\u041a\0\u0438\0\u0456\0\u0276\0\226"+
+ "\0\u0474\0\u0492\0\u04b0\0\226\0\u03c0\0\u023a\0\u0258\0\u04ce"+
+ "\0\u0276\0\u04ec\0\u02d0";
private static int [] zzUnpackRowMap() {
- int [] result = new int[64];
+ int [] result = new int[67];
int offset = 0;
offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
return result;
@@ -142,7 +143,7 @@ private static int zzUnpackRowMap(String packed, int offset, int [] result) {
return j;
}
- /**
+ /**
* The transition table of the DFA
*/
private static final int [] ZZ_TRANS = zzUnpackTrans();
@@ -150,39 +151,42 @@ private static int zzUnpackRowMap(String packed, int offset, int [] result) {
private static final String ZZ_TRANS_PACKED_0 =
"\1\6\1\7\1\10\1\11\1\12\1\13\1\14\1\11"+
"\2\15\1\11\1\16\2\11\1\17\1\12\1\20\1\21"+
- "\1\22\1\23\3\24\1\25\1\11\1\26\1\6\1\27"+
- "\1\6\1\30\1\31\27\30\1\32\1\33\1\30\1\34"+
- "\1\6\1\7\34\6\1\7\1\10\1\11\1\12\1\13"+
- "\1\14\1\11\2\15\1\11\1\16\2\11\1\17\1\12"+
- "\1\20\1\21\1\22\1\23\2\24\1\35\1\25\1\11"+
- "\1\26\1\6\1\27\1\36\1\37\1\40\33\37\36\0"+
- "\1\7\35\0\1\11\1\41\1\0\1\42\2\11\2\0"+
- "\4\11\2\0\1\11\6\0\2\11\6\0\2\11\1\0"+
- "\3\11\2\0\4\11\2\0\1\11\6\0\2\11\10\0"+
- "\1\15\32\0\2\11\1\0\1\11\1\43\1\11\2\0"+
- "\4\11\2\0\1\11\6\0\2\11\6\0\2\11\1\0"+
- "\3\11\2\0\1\41\3\11\2\0\1\11\6\0\2\11"+
- "\6\0\2\11\1\0\3\11\1\0\1\44\4\11\2\0"+
- "\1\11\6\0\2\11\6\0\1\11\1\41\1\0\1\41"+
- "\2\11\2\0\4\11\2\0\1\11\6\0\2\11\25\0"+
- "\1\15\35\0\1\15\35\0\1\15\34\0\1\45\3\0"+
- "\1\25\5\0\31\46\1\47\1\50\2\46\32\51\1\52"+
- "\1\53\1\51\31\54\1\55\1\56\1\54\1\57\1\54"+
- "\1\31\27\54\1\55\1\56\1\54\1\57\31\60\1\55"+
- "\1\61\1\60\1\62\31\54\1\63\2\54\1\64\24\54"+
- "\1\65\4\54\1\0\3\54\24\0\1\66\11\0\1\40"+
- "\35\0\2\11\1\0\3\11\2\0\3\11\1\41\2\0"+
- "\1\11\6\0\2\11\6\0\2\11\1\0\2\11\1\41"+
- "\2\0\4\11\2\0\1\11\6\0\2\11\6\0\1\67"+
- "\3\0\1\70\5\0\1\71\47\0\1\72\5\0\31\46"+
- "\1\73\3\46\33\51\1\74\1\51\31\60\1\32\2\60"+
- "\1\75\24\60\1\65\4\60\1\55\3\60\24\54\1\76"+
- "\4\54\1\55\1\56\1\54\1\57\5\0\1\77\41\0"+
- "\1\15\30\0\1\70\26\0\24\60\1\100\4\60\1\55"+
- "\1\61\1\60\1\62\15\0\1\15\17\0";
+ "\1\22\1\23\1\24\1\25\2\24\1\26\1\11\1\27"+
+ "\1\6\1\30\1\7\1\31\1\32\23\31\1\33\4\31"+
+ "\1\34\1\35\1\31\1\32\1\6\1\7\33\6\1\7"+
+ "\1\6\1\7\1\10\1\11\1\12\1\13\1\14\1\11"+
+ "\2\15\1\11\1\16\2\11\1\17\1\12\1\20\1\21"+
+ "\1\22\1\23\1\24\1\36\1\24\1\37\1\26\1\11"+
+ "\1\27\1\6\1\30\1\7\1\40\1\41\33\40\1\41"+
+ "\37\0\1\7\33\0\1\7\2\0\1\11\1\42\1\0"+
+ "\1\43\2\11\2\0\4\11\2\0\1\11\7\0\2\11"+
+ "\6\0\2\11\1\0\3\11\2\0\4\11\2\0\1\11"+
+ "\7\0\2\11\10\0\1\15\33\0\2\11\1\0\1\11"+
+ "\1\44\1\11\2\0\4\11\2\0\1\11\7\0\2\11"+
+ "\6\0\2\11\1\0\3\11\2\0\1\42\3\11\2\0"+
+ "\1\11\7\0\2\11\6\0\2\11\1\0\3\11\1\0"+
+ "\1\45\4\11\2\0\1\11\7\0\2\11\6\0\1\11"+
+ "\1\42\1\0\1\42\2\11\2\0\4\11\2\0\1\11"+
+ "\7\0\2\11\25\0\1\15\36\0\1\15\36\0\1\15"+
+ "\12\0\24\46\1\0\11\46\23\0\1\47\4\0\1\26"+
+ "\5\0\32\50\1\51\1\52\2\50\33\53\1\54\1\55"+
+ "\1\53\25\56\1\57\4\56\1\60\1\61\3\56\1\32"+
+ "\23\56\1\57\4\56\1\60\1\61\1\56\1\32\24\56"+
+ "\1\62\5\56\1\0\3\56\25\63\1\64\4\63\1\60"+
+ "\1\65\2\63\25\56\1\66\4\56\1\67\3\56\24\46"+
+ "\1\70\11\46\1\0\1\41\33\0\1\41\2\0\2\11"+
+ "\1\0\3\11\2\0\3\11\1\42\2\0\1\11\7\0"+
+ "\2\11\6\0\2\11\1\0\2\11\1\42\2\0\4\11"+
+ "\2\0\1\11\7\0\2\11\6\0\1\71\3\0\1\72"+
+ "\5\0\1\73\21\0\35\46\1\74\30\0\1\75\5\0"+
+ "\32\50\1\76\3\50\34\53\1\77\1\53\24\63\1\62"+
+ "\5\63\1\60\30\63\1\100\4\63\1\34\3\63\24\56"+
+ "\1\101\1\57\4\56\1\60\1\61\2\56\5\0\1\102"+
+ "\42\0\1\15\31\0\1\72\27\0\24\63\1\103\1\64"+
+ "\4\63\1\60\1\65\2\63\15\0\1\15\20\0";
private static int [] zzUnpackTrans() {
- int [] result = new int[1189];
+ int [] result = new int[1290];
int offset = 0;
offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result);
return result;
@@ -220,13 +224,13 @@ private static int zzUnpackTrans(String packed, int offset, int [] result) {
private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();
private static final String ZZ_ATTRIBUTE_PACKED_0 =
- "\5\0\1\11\6\1\1\11\6\1\1\11\10\1\1\11"+
- "\1\1\1\11\4\1\3\0\1\11\3\0\1\11\1\0"+
- "\1\11\5\0\1\1\1\0\2\11\3\0\3\1\1\0"+
- "\1\1\1\0\1\1";
+ "\5\0\1\11\6\1\1\11\6\1\1\11\12\1\2\11"+
+ "\4\1\1\0\1\1\2\0\1\11\3\0\1\11\2\0"+
+ "\1\11\1\0\1\11\4\0\1\1\1\11\3\0\1\11"+
+ "\3\1\1\0\1\1\1\0\1\1";
private static int [] zzUnpackAttribute() {
- int [] result = new int[64];
+ int [] result = new int[67];
int offset = 0;
offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
return result;
@@ -397,7 +401,7 @@ public TwigVariableColoringLexer(java.io.InputStream in) {
this(new java.io.InputStreamReader(in));
}
- /**
+ /**
* Unpacks the compressed character translation table.
*
* @param packed the packed character translation table
@@ -551,7 +555,6 @@ public void yypushback(int number) {
* @return the next token
* @exception java.io.IOException if any I/O-Error occurs
*/
- @SuppressWarnings("fallthrough")
public TwigVariableTokenId findNextToken() throws java.io.IOException {
int zzInput;
int zzAction;
@@ -609,69 +612,73 @@ public TwigVariableTokenId findNextToken() throws java.io.IOException {
}
switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
- case 6:
+ case 6:
{ return TwigVariableTokenId.T_TWIG_NUMBER;
}
- case 15: break;
- case 5:
+ case 16: break;
+ case 5:
{ return TwigVariableTokenId.T_TWIG_PUNCTUATION;
}
- case 16: break;
- case 8:
+ case 17: break;
+ case 11:
+ { return TwigVariableTokenId.T_TWIG_COMMENT;
+ }
+ case 18: break;
+ case 8:
{ popState();
return TwigVariableTokenId.T_TWIG_INTERPOLATION_END;
}
- case 17: break;
- case 11:
+ case 19: break;
+ case 12:
{ yypushback(yylength());
pushState(ST_D_STRING);
}
- case 18: break;
- case 3:
+ case 20: break;
+ case 3:
{ return TwigVariableTokenId.T_TWIG_NAME;
}
- case 19: break;
- case 13:
+ case 21: break;
+ case 14:
{ yypushback(2);
pushState(ST_INTERPOLATION);
return TwigVariableTokenId.T_TWIG_STRING;
}
- case 20: break;
- case 10:
+ case 22: break;
+ case 10:
{ popState();
return TwigVariableTokenId.T_TWIG_WHITESPACE;
}
- case 21: break;
- case 9:
+ case 23: break;
+ case 9:
{ return TwigVariableTokenId.T_TWIG_OTHER;
}
- case 22: break;
- case 2:
+ case 24: break;
+ case 2:
{ return TwigVariableTokenId.T_TWIG_WHITESPACE;
}
- case 23: break;
- case 7:
+ case 25: break;
+ case 7:
{ popState();
return TwigVariableTokenId.T_TWIG_STRING;
}
- case 24: break;
- case 14:
+ case 26: break;
+ case 15:
{ return TwigVariableTokenId.T_TWIG_INTERPOLATION_START;
}
- case 25: break;
- case 4:
+ case 27: break;
+ case 4:
{ return TwigVariableTokenId.T_TWIG_OPERATOR;
}
- case 26: break;
- case 1:
+ case 28: break;
+ case 1:
{ yypushback(yylength());
pushState(ST_HIGHLIGHTING_ERROR);
}
- case 27: break;
- case 12:
+ case 29: break;
+ case 13:
{ return TwigVariableTokenId.T_TWIG_STRING;
}
- case 28: break;
+ case 30: break;
default:
if (zzInput == YYEOF)
//zzAtEOF = true;
diff --git a/php/php.twig/src/org/netbeans/modules/php/twig/editor/lexer/TwigVariableTokenId.java b/php/php.twig/src/org/netbeans/modules/php/twig/editor/lexer/TwigVariableTokenId.java
index d88db508cab7..97c02c7af370 100644
--- a/php/php.twig/src/org/netbeans/modules/php/twig/editor/lexer/TwigVariableTokenId.java
+++ b/php/php.twig/src/org/netbeans/modules/php/twig/editor/lexer/TwigVariableTokenId.java
@@ -47,6 +47,7 @@ public enum TwigVariableTokenId implements TokenId {
T_TWIG_INTERPOLATION_START("twig_interpolation"), //NOI18N
T_TWIG_INTERPOLATION_END("twig_interpolation"), //NOI18N
T_TWIG_OTHER("twig_other"), //NOI18N
+ T_TWIG_COMMENT("twig_comment"), //NOI18N
T_TWIG_WHITESPACE("twig_whitespace"); //NOI18N
private final String primaryCategory;
diff --git a/php/php.twig/test/unit/data/goldenfiles/org/netbeans/modules/php/twig/editor/lexer/TwigLexerTest/comment-inline-expression.pass b/php/php.twig/test/unit/data/goldenfiles/org/netbeans/modules/php/twig/editor/lexer/TwigLexerTest/comment-inline-expression.pass
new file mode 100644
index 000000000000..54391454bee2
--- /dev/null
+++ b/php/php.twig/test/unit/data/goldenfiles/org/netbeans/modules/php/twig/editor/lexer/TwigLexerTest/comment-inline-expression.pass
@@ -0,0 +1,8 @@
+TOP token #0 T_TWIG_VAR_START [{{]
+token #0 T_TWIG_WHITESPACE [\n ]
+token #1 T_TWIG_STRING ["Hello World"]
+token #2 T_TWIG_PUNCTUATION [|]
+token #3 T_TWIG_NAME [upper]
+token #4 T_TWIG_WHITESPACE [ ]
+token #5 T_TWIG_COMMENT [# this is an inline comment\n]
+TOP token #2 T_TWIG_VAR_END [}}]
diff --git a/php/php.twig/test/unit/data/goldenfiles/org/netbeans/modules/php/twig/editor/lexer/TwigLexerTest/comment-inline.pass b/php/php.twig/test/unit/data/goldenfiles/org/netbeans/modules/php/twig/editor/lexer/TwigLexerTest/comment-inline.pass
new file mode 100644
index 000000000000..6f132ebe44cf
--- /dev/null
+++ b/php/php.twig/test/unit/data/goldenfiles/org/netbeans/modules/php/twig/editor/lexer/TwigLexerTest/comment-inline.pass
@@ -0,0 +1,41 @@
+TOP token #0 T_TWIG_VAR_START [{{]
+token #0 T_TWIG_WHITESPACE [\n ]
+token #1 T_TWIG_COMMENT [# this is an inline comment\n]
+token #2 T_TWIG_WHITESPACE [ ]
+token #3 T_TWIG_STRING ["Hello World"]
+token #4 T_TWIG_PUNCTUATION [|]
+token #5 T_TWIG_NAME [upper]
+token #6 T_TWIG_WHITESPACE [\n ]
+token #7 T_TWIG_COMMENT [# this is an inline comment\n]
+TOP token #2 T_TWIG_VAR_END [}}]
+TOP token #3 T_HTML [\n\n]
+TOP token #4 T_TWIG_VAR_START [{{]
+token #0 T_TWIG_WHITESPACE [\n ]
+token #1 T_TWIG_PUNCTUATION [{]
+token #2 T_TWIG_WHITESPACE [\n ]
+token #3 T_TWIG_COMMENT [# this is an inline comment\n]
+token #4 T_TWIG_WHITESPACE [ ]
+token #5 T_TWIG_NAME [fruit]
+token #6 T_TWIG_PUNCTUATION [:]
+token #7 T_TWIG_WHITESPACE [ ]
+token #8 T_TWIG_STRING ['apple']
+token #9 T_TWIG_PUNCTUATION [,]
+token #10 T_TWIG_WHITESPACE [ ]
+token #11 T_TWIG_COMMENT [# this is an inline comment\n]
+token #12 T_TWIG_WHITESPACE [ ]
+token #13 T_TWIG_NAME [color]
+token #14 T_TWIG_PUNCTUATION [:]
+token #15 T_TWIG_WHITESPACE [ ]
+token #16 T_TWIG_STRING ['red']
+token #17 T_TWIG_PUNCTUATION [,]
+token #18 T_TWIG_WHITESPACE [ ]
+token #19 T_TWIG_COMMENT [# this is an inline comment\n]
+token #20 T_TWIG_WHITESPACE [ ]
+token #21 T_TWIG_PUNCTUATION [}]
+token #22 T_TWIG_PUNCTUATION [|]
+token #23 T_TWIG_NAME [join]
+token #24 T_TWIG_PUNCTUATION [(]
+token #25 T_TWIG_STRING [', ']
+token #26 T_TWIG_PUNCTUATION [)]
+token #27 T_TWIG_WHITESPACE [\n]
+TOP token #6 T_TWIG_VAR_END [}}]
diff --git a/php/php.twig/test/unit/data/testfiles/lexer/twig/comment-inline-expression.twig b/php/php.twig/test/unit/data/testfiles/lexer/twig/comment-inline-expression.twig
new file mode 100644
index 000000000000..74406cc580ad
--- /dev/null
+++ b/php/php.twig/test/unit/data/testfiles/lexer/twig/comment-inline-expression.twig
@@ -0,0 +1,3 @@
+{{
+ "Hello World"|upper # this is an inline comment
+}}
\ No newline at end of file
diff --git a/php/php.twig/test/unit/data/testfiles/lexer/twig/comment-inline.twig b/php/php.twig/test/unit/data/testfiles/lexer/twig/comment-inline.twig
new file mode 100644
index 000000000000..42b1841da47f
--- /dev/null
+++ b/php/php.twig/test/unit/data/testfiles/lexer/twig/comment-inline.twig
@@ -0,0 +1,13 @@
+{{
+ # this is an inline comment
+ "Hello World"|upper
+ # this is an inline comment
+}}
+
+{{
+ {
+ # this is an inline comment
+ fruit: 'apple', # this is an inline comment
+ color: 'red', # this is an inline comment
+ }|join(', ')
+}}
\ No newline at end of file
diff --git a/php/php.twig/test/unit/src/org/netbeans/modules/php/twig/editor/lexer/TwigLexerTest.java b/php/php.twig/test/unit/src/org/netbeans/modules/php/twig/editor/lexer/TwigLexerTest.java
index e456013ef4eb..59ddb0cdccfc 100644
--- a/php/php.twig/test/unit/src/org/netbeans/modules/php/twig/editor/lexer/TwigLexerTest.java
+++ b/php/php.twig/test/unit/src/org/netbeans/modules/php/twig/editor/lexer/TwigLexerTest.java
@@ -680,6 +680,14 @@ public void testPrecededDoubleQuoteByBackslash_07() throws Exception {
performTest("preceded-double-quote-by-backslash_07");
}
+ public void testCommentInlineExpression() throws Exception {
+ performTest("comment-inline-expression");
+ }
+
+ public void testCommentInline() throws Exception {
+ performTest("comment-inline");
+ }
+
@Override
protected String getTestResult(String filename) throws Exception {
String content = TestUtils.getFileContent(new File(getDataDir(), "testfiles/lexer/twig/" + filename + ".twig"));
diff --git a/php/php.twig/tools/TwigVariableColoringLexer.flex b/php/php.twig/tools/TwigVariableColoringLexer.flex
index 3344d851ebe7..d428487efa64 100644
--- a/php/php.twig/tools/TwigVariableColoringLexer.flex
+++ b/php/php.twig/tools/TwigVariableColoringLexer.flex
@@ -132,6 +132,7 @@ import org.netbeans.modules.web.common.api.ByteStack;
WHITESPACE=[ \t\r\n]+
OPERATOR=("as"|"="|"not"|"+"|"-"|"or"|"b-or"|"b-xor"|"and"|"b-and"|"=="|"!="|">"|"<"|">="|"<="|"in"|"~"|"*"|"/"|"//"|"%"|"is"|".."|"**")
OPEN_CURLY="{"
+HASH="#"
PUNCTUATION=("|"|"("|")"|"["|"]"|{OPEN_CURLY}|"}"|"?"|":"|"."|",")
NUMBER=[0-9]+(\.[0-9]+)?
NAME=[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*
@@ -166,6 +167,9 @@ D_POST_INTERPOLATION={D_NO_INTERPOLATION} "\""
}
{
+ {HASH} [^{] [^\n\r]* [\r\n]? {
+ return TwigVariableTokenId.T_TWIG_COMMENT;
+ }
{OPERATOR} {
return TwigVariableTokenId.T_TWIG_OPERATOR;
}