diff --git a/.editorconfig b/.editorconfig index 1e507d95..e59068c7 100644 --- a/.editorconfig +++ b/.editorconfig @@ -12,5 +12,5 @@ insert_final_newline = true [*.md] trim_trailing_whitespace = false -[*.bnf] +[{*.bnf, *.flex, _SvelteLexer.java}] indent_size = 2 diff --git a/src/main/gen/dev/blachut/svelte/lang/_SvelteLexer.java b/src/main/gen/dev/blachut/svelte/lang/_SvelteLexer.java index d2003c14..2bb34837 100644 --- a/src/main/gen/dev/blachut/svelte/lang/_SvelteLexer.java +++ b/src/main/gen/dev/blachut/svelte/lang/_SvelteLexer.java @@ -5,6 +5,8 @@ import com.intellij.lexer.FlexLexer; import com.intellij.psi.tree.IElementType; +import java.util.Stack; + import static com.intellij.psi.TokenType.BAD_CHARACTER; import static com.intellij.psi.TokenType.WHITE_SPACE; import static dev.blachut.svelte.lang.psi.SvelteTypes.*; @@ -25,16 +27,18 @@ public class _SvelteLexer implements FlexLexer { /** lexical states */ public static final int YYINITIAL = 0; - public static final int VERBATIM_COMMENT = 2; - public static final int VERBATIM_HTML = 4; - public static final int HTML_TAG = 6; - public static final int TAG_STRING = 8; - public static final int SVELTE_INTERPOLATION_PRE = 10; - public static final int SVELTE_INTERPOLATION = 12; - public static final int SVELTE_TAG_PRE = 14; - public static final int SVELTE_TAG = 16; - public static final int SVELTE_ELSE_TAG = 18; - public static final int SVELTE_TAG_PAREN_AWARE = 20; + public static final int SVELTE_TAG_START = 2; + public static final int SVELTE_TAG = 4; + public static final int SVELTE_TAG_PARAMETER = 6; + public static final int SVELTE_INTERPOLATION_START = 8; + public static final int SVELTE_INTERPOLATION = 10; + public static final int VERBATIM_COMMENT = 12; + public static final int VERBATIM_HTML = 14; + public static final int HTML_TAG = 16; + public static final int ONLY_WHITESPACE = 18; + public static final int SINGLE_QUOTE = 20; + public static final int DOUBLE_QUOTE = 22; + public static final int TICKED_QUOTE = 24; /** * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l @@ -43,11 +47,11 @@ public class _SvelteLexer implements FlexLexer { * l is of the form l = 2*k, k a non negative integer */ private static final int ZZ_LEXSTATE[] = { - 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, - 8, 8, 9, 9, 10, 10 + 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, + 8, 8, 9, 9, 10, 10, 11, 11, 12, 12 }; - /** + /** * Translates characters to character classes * Chosen bits are [7, 7, 7] * Total runtime size is 1928 bytes @@ -66,29 +70,31 @@ public static int ZZ_CMAP(int ch) { /* The ZZ_CMAP_A table has 640 entries */ static final char ZZ_CMAP_A[] = zzUnpackCMap( - "\11\0\5\1\22\0\1\1\1\4\1\44\1\20\1\2\2\0\1\43\1\31\1\32\2\0\1\30\1\5\1\0\1"+ - "\22\12\2\1\21\1\0\1\3\1\0\1\42\1\0\1\33\32\2\4\0\1\2\1\0\1\24\1\36\1\7\1\35"+ - "\1\16\1\23\1\40\1\25\1\11\2\2\1\15\1\34\1\27\1\2\1\12\1\2\1\10\1\6\1\13\1"+ - "\37\1\2\1\26\1\2\1\14\1\2\1\17\1\0\1\41\7\0\1\1\32\0\1\1\337\0\1\1\177\0\13"+ - "\1\35\0\2\1\5\0\1\1\57\0\1\1\40\0"); + "\11\0\5\1\22\0\1\1\1\7\1\4\1\23\1\2\2\0\1\3\1\33\1\34\2\0\1\35\1\10\1\41\1"+ + "\25\12\2\1\24\1\0\1\6\1\0\1\50\1\0\1\42\32\2\1\36\1\51\1\37\1\0\1\2\1\5\1"+ + "\27\1\45\1\12\1\44\1\21\1\26\1\47\1\30\1\14\2\2\1\20\1\43\1\32\1\2\1\15\1"+ + "\2\1\13\1\11\1\16\1\46\1\2\1\31\1\2\1\17\1\2\1\22\1\0\1\40\7\0\1\1\32\0\1"+ + "\1\337\0\1\1\177\0\13\1\35\0\2\1\5\0\1\1\57\0\1\1\40\0"); - /** + /** * Translates DFA states to action switch labels. */ private static final int [] ZZ_ACTION = zzUnpackAction(); private static final String ZZ_ACTION_PACKED_0 = - "\13\0\1\1\1\2\1\3\1\4\2\1\1\5\1\6" + - "\1\7\1\10\1\11\1\12\1\13\1\14\1\15\1\16" + - "\1\17\1\20\6\21\1\22\3\15\1\23\2\24\1\25" + - "\1\26\3\0\1\27\1\30\1\31\2\0\3\14\1\21" + - "\1\32\4\21\4\0\1\33\1\32\4\0\2\14\5\21" + - "\1\0\1\15\1\0\1\34\4\0\2\14\1\21\1\35" + - "\1\36\1\37\1\21\1\0\1\40\4\0\1\41\1\14" + - "\1\42\1\43\1\0\1\44\2\0\1\45\1\0"; + "\15\0\1\1\1\2\1\3\1\4\6\5\1\6\1\7"+ + "\1\10\1\11\1\12\1\13\2\10\1\14\1\10\1\15"+ + "\1\16\1\17\1\20\1\21\1\22\1\23\1\24\2\25"+ + "\1\26\1\7\1\27\2\1\1\30\1\31\1\32\1\33"+ + "\1\34\1\35\1\36\1\35\3\0\1\37\1\40\1\41"+ + "\1\5\1\42\4\5\1\10\1\43\1\10\1\44\1\0"+ + "\1\45\3\26\5\0\5\5\1\10\2\26\1\0\1\46"+ + "\2\0\1\5\1\47\1\50\1\51\1\5\1\52\2\26"+ + "\4\0\1\53\1\54\1\55\1\26\3\0\1\56\1\57"+ + "\3\0"; private static int [] zzUnpackAction() { - int[] result = new int[109]; + int [] result = new int[118]; int offset = 0; offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); return result; @@ -107,29 +113,30 @@ 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\45\0\112\0\157\0\224\0\271\0\336\0\u0103"+ - "\0\u0128\0\u014d\0\u0172\0\u0197\0\u01bc\0\u01e1\0\u0206\0\u022b"+ - "\0\u0250\0\u0197\0\u0197\0\u0197\0\u0197\0\u0197\0\u0197\0\u0197" + - "\0\u0275\0\u0197\0\u0197\0\u0197\0\u029a\0\u02bf\0\u02e4\0\u0309" + - "\0\u032e\0\u0353\0\u0378\0\u039d\0\u03c2\0\u03e7\0\u040c\0\u0197" + - "\0\u0431\0\u0456\0\u0197\0\u0197\0\u047b\0\u04a0\0\u0206\0\u0197" + - "\0\u0197\0\u0197\0\u04c5\0\u04ea\0\u050f\0\u0534\0\u0559\0\u057e" + - "\0\u02bf\0\u05a3\0\u05c8\0\u05ed\0\u0612\0\u03c2\0\u0637\0\u065c" + - "\0\u0681\0\u06a6\0\u0431\0\u06cb\0\u06f0\0\u0715\0\u073a\0\u075f" + - "\0\u0784\0\u07a9\0\u07ce\0\u07f3\0\u0818\0\u083d\0\u0862\0\u06a6" + - "\0\u0887\0\u0197\0\u08ac\0\u08d1\0\u08f6\0\u091b\0\u0940\0\u0965" + - "\0\u098a\0\u02bf\0\u02bf\0\u02bf\0\u09af\0\u09d4\0\u06a6\0\u09f9" + - "\0\u0a1e\0\u0a43\0\u0a68\0\u050f\0\u0a8d\0\u02bf\0\u02bf\0\u0ab2" + - "\0\u0197\0\u0ad7\0\u0afc\0\u050f\0\u0b21"; + "\0\0\0\52\0\124\0\176\0\250\0\322\0\374\0\u0126"+ + "\0\u0150\0\u017a\0\u01a4\0\u01ce\0\u01f8\0\u0222\0\u024c\0\u0276"+ + "\0\u02a0\0\u02ca\0\u02f4\0\u031e\0\u0348\0\u0372\0\u039c\0\u0222"+ + "\0\u03c6\0\u03f0\0\u0222\0\u0222\0\u0222\0\u041a\0\u0444\0\u0222"+ + "\0\u046e\0\u0222\0\u0222\0\u0222\0\u0222\0\u0222\0\u0222\0\u0222"+ + "\0\u0222\0\u0222\0\u0498\0\u04c2\0\u0222\0\u0222\0\u04ec\0\u0516"+ + "\0\u0222\0\u0222\0\u0222\0\u0222\0\u0540\0\u0222\0\u0222\0\u056a"+ + "\0\u0594\0\u05be\0\u0276\0\u0222\0\u0222\0\u0222\0\u05e8\0\u02ca"+ + "\0\u0612\0\u063c\0\u0666\0\u0690\0\u0222\0\u03f0\0\u06ba\0\u03f0"+ + "\0\u0498\0\u0222\0\u06e4\0\u070e\0\u0738\0\u0762\0\u078c\0\u07b6"+ + "\0\u07e0\0\u080a\0\u0834\0\u085e\0\u0888\0\u08b2\0\u08dc\0\u0906"+ + "\0\u0930\0\u095a\0\u0984\0\u0222\0\u09ae\0\u09d8\0\u0a02\0\u02ca"+ + "\0\u02ca\0\u02ca\0\u0a2c\0\u03f0\0\u0a56\0\u0a80\0\u0aaa\0\u0ad4"+ + "\0\u0afe\0\u0b28\0\u02ca\0\u02ca\0\u06e4\0\u0b52\0\u0b7c\0\u0ba6"+ + "\0\u0bd0\0\u0222\0\u06e4\0\u0bfa\0\u0c24\0\u0c4e"; private static int [] zzUnpackRowMap() { - int[] result = new int[109]; + int [] result = new int[118]; int offset = 0; offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); return result; @@ -146,86 +153,78 @@ 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(); private static final String ZZ_TRANS_PACKED_0 = - "\1\14\1\15\1\14\1\16\13\14\1\17\32\14\1\20" + - "\42\14\1\21\103\14\1\22\1\23\1\24\43\14\1\25" + - "\1\26\1\27\1\15\15\27\1\30\13\27\1\31\11\27" + - "\17\32\1\33\21\32\1\34\3\32\1\14\1\35\1\36" + - "\3\14\1\36\1\37\1\36\1\40\1\36\1\41\2\36" + - "\1\42\4\14\1\36\1\43\3\36\4\14\5\36\4\14" + - "\1\32\1\44\1\45\3\32\5\45\1\46\3\45\1\33" + - "\3\32\1\45\1\47\3\45\1\50\3\32\5\45\1\34" + - "\4\32\1\15\1\51\3\32\3\51\1\52\5\51\1\33" + - "\3\32\5\51\4\32\5\51\1\34\4\32\1\44\1\45" + - "\3\32\5\45\1\46\3\45\1\33\3\32\1\45\1\47" + - "\3\45\1\50\1\53\1\54\1\32\5\45\1\34\3\32" + - "\46\0\1\15\47\0\1\55\1\0\1\56\37\0\1\57" + - "\16\0\1\60\1\61\1\62\27\0\1\63\61\0\1\64" + - "\24\0\1\65\3\0\11\65\4\0\2\65\1\66\2\65" + - "\4\0\1\65\1\67\3\65\5\0\1\35\45\0\1\36" + - "\3\0\11\36\4\0\5\36\4\0\5\36\6\0\1\36" + - "\3\0\11\36\4\0\1\36\1\70\3\36\4\0\5\36" + - "\6\0\1\36\3\0\11\36\4\0\1\71\4\36\4\0" + - "\5\36\6\0\1\36\3\0\11\36\4\0\2\36\1\72" + - "\2\36\4\0\5\36\6\0\1\36\3\0\7\36\1\73" + - "\1\36\4\0\1\36\1\74\3\36\4\0\5\36\6\0" + - "\1\36\3\0\11\36\4\0\3\36\1\75\1\36\4\0" + - "\5\36\5\0\1\44\45\0\1\76\3\0\5\76\1\77" + - "\3\76\4\0\1\76\1\100\3\76\4\0\5\76\6\0" + - "\1\76\3\0\5\76\1\77\3\76\4\0\1\76\1\100" + - "\1\101\2\76\4\0\5\76\6\0\1\76\3\0\1\102" + - "\4\76\1\77\3\76\4\0\1\76\1\100\3\76\4\0" + - "\5\76\6\0\1\51\3\0\11\51\4\0\5\51\4\0" + - "\5\51\6\0\1\51\3\0\11\51\4\0\1\103\4\51" + - "\4\0\5\51\11\0\1\104\46\0\1\105\3\0\1\106" + - "\73\0\1\22\10\0\1\107\40\0\1\65\3\0\11\65" + - "\4\0\5\65\4\0\5\65\6\0\1\65\3\0\5\65" + - "\1\110\3\65\4\0\5\65\4\0\5\65\6\0\1\65" + - "\3\0\10\65\1\111\4\0\5\65\4\0\5\65\6\0" + - "\1\36\3\0\5\36\1\112\3\36\4\0\5\36\4\0" + - "\5\36\6\0\1\36\3\0\10\36\1\113\4\0\5\36" + - "\4\0\5\36\6\0\1\36\3\0\1\114\10\36\4\0" + - "\5\36\4\0\5\36\6\0\1\36\3\0\1\36\1\115" + - "\7\36\4\0\5\36\4\0\5\36\6\0\1\36\3\0" + - "\11\36\4\0\1\36\1\116\3\36\4\0\5\36\6\0" + - "\1\76\3\0\5\76\1\77\3\76\4\0\1\76\1\100" + - "\1\117\2\76\4\0\5\76\6\0\1\76\3\0\1\120" + - "\4\76\1\77\3\76\4\0\1\76\1\100\3\76\4\0" + - "\5\76\6\0\1\76\3\0\5\76\1\77\2\76\1\121" + - "\4\0\1\76\1\100\3\76\4\0\5\76\6\0\1\120" + - "\3\0\11\120\4\0\5\120\4\0\5\120\11\0\1\122" + - "\47\0\1\123\50\0\1\124\37\0\1\125\3\0\1\126" + - "\33\0\1\65\3\0\11\65\4\0\5\65\4\0\1\127" + - "\4\65\6\0\1\65\3\0\11\65\4\0\5\65\4\0" + - "\2\65\1\130\2\65\6\0\1\36\3\0\1\36\1\131" + - "\7\36\4\0\5\36\4\0\5\36\6\0\1\36\3\0" + - "\11\36\4\0\4\36\1\132\4\0\5\36\6\0\1\36" + - "\3\0\10\36\1\133\4\0\5\36\4\0\5\36\6\0" + - "\1\36\3\0\11\36\4\0\2\36\1\134\2\36\4\0" + - "\5\36\6\0\1\36\3\0\3\36\1\135\5\36\4\0" + - "\5\36\4\0\5\36\6\0\1\76\3\0\5\76\1\77" + - "\2\76\1\136\4\0\1\76\1\100\3\76\4\0\5\76" + - "\6\0\1\76\3\0\5\76\1\77\3\76\4\0\1\76" + - "\1\100\2\76\1\137\4\0\5\76\15\0\1\140\50\0" + - "\1\141\37\0\1\142\50\0\1\143\32\0\1\65\3\0" + - "\7\65\1\144\1\65\4\0\5\65\4\0\5\65\6\0" + - "\1\65\3\0\11\65\4\0\5\65\4\0\3\65\1\145" + - "\1\65\6\0\1\36\3\0\11\36\4\0\2\36\1\146" + - "\2\36\4\0\5\36\6\0\1\36\3\0\5\36\1\147" + - "\3\36\4\0\5\36\4\0\5\36\6\0\1\76\3\0" + - "\5\76\1\77\3\76\4\0\1\76\1\100\2\76\1\120" + - "\4\0\5\76\16\0\1\150\50\0\1\151\37\0\1\152" + - "\50\0\1\153\31\0\1\65\3\0\11\65\4\0\5\65" + - "\4\0\4\65\1\154\17\0\1\151\43\0\1\155\50\0" + - "\1\63\41\0\1\63\31\0"; + "\6\16\1\17\13\16\1\20\30\16\1\21\1\22\6\16"+ + "\1\22\1\23\1\22\1\24\1\22\1\25\2\22\1\26"+ + "\4\16\1\22\1\27\3\22\10\16\5\22\2\16\1\30"+ + "\1\31\1\32\1\33\1\34\1\35\3\30\3\32\1\36"+ + "\1\32\1\37\3\32\1\40\3\30\1\32\1\41\3\32"+ + "\1\42\1\43\1\44\1\45\1\46\1\47\2\30\5\32"+ + "\3\30\1\31\1\32\1\33\1\34\1\35\3\30\11\32"+ + "\1\40\3\30\5\32\1\50\1\51\1\44\1\45\1\46"+ + "\1\47\2\30\5\32\2\30\1\52\1\53\40\52\1\54"+ + "\7\52\22\55\1\56\15\55\1\47\11\55\10\16\1\57"+ + "\47\16\1\60\46\16\1\61\1\62\43\16\1\63\1\16"+ + "\1\64\1\65\50\64\3\66\1\67\45\66\1\70\4\66"+ + "\1\67\44\66\1\70\5\66\1\67\43\66\1\70\61\0"+ + "\1\71\1\0\1\72\41\0\1\73\21\0\1\74\1\75"+ + "\1\76\25\0\1\21\52\0\1\22\6\0\11\22\4\0"+ + "\5\22\10\0\5\22\4\0\1\22\6\0\11\22\4\0"+ + "\1\22\1\77\3\22\10\0\5\22\4\0\1\22\6\0"+ + "\11\22\4\0\1\100\4\22\10\0\5\22\4\0\1\22"+ + "\6\0\11\22\4\0\2\22\1\101\2\22\10\0\5\22"+ + "\4\0\1\22\6\0\7\22\1\102\1\22\4\0\1\22"+ + "\1\103\3\22\10\0\5\22\4\0\1\22\6\0\11\22"+ + "\4\0\3\22\1\104\1\22\10\0\5\22\3\0\1\31"+ + "\52\0\1\32\6\0\11\32\4\0\5\32\6\0\1\105"+ + "\1\0\5\32\4\0\1\32\6\0\11\32\4\0\1\106"+ + "\4\32\6\0\1\105\1\0\5\32\4\0\1\32\6\0"+ + "\11\32\4\0\2\32\1\107\2\32\6\0\1\105\1\0"+ + "\5\32\4\0\1\32\6\0\1\110\10\32\4\0\5\32"+ + "\6\0\1\105\1\0\5\32\3\0\1\111\40\0\1\112"+ + "\11\0\1\113\6\0\11\113\4\0\2\113\1\114\2\113"+ + "\10\0\1\113\1\115\3\113\12\0\1\116\66\0\1\117"+ + "\25\0\1\65\50\0\52\66\10\0\1\120\53\0\1\121"+ + "\3\0\1\122\35\0\1\22\6\0\5\22\1\123\3\22"+ + "\4\0\5\22\10\0\5\22\4\0\1\22\6\0\10\22"+ + "\1\124\4\0\5\22\10\0\5\22\4\0\1\22\6\0"+ + "\1\125\10\22\4\0\5\22\10\0\5\22\4\0\1\22"+ + "\6\0\1\22\1\126\7\22\4\0\5\22\10\0\5\22"+ + "\4\0\1\22\6\0\11\22\4\0\1\22\1\127\3\22"+ + "\10\0\5\22\4\0\1\32\6\0\10\32\1\130\4\0"+ + "\5\32\6\0\1\105\1\0\5\32\4\0\1\113\6\0"+ + "\11\113\4\0\5\113\10\0\5\113\4\0\1\113\6\0"+ + "\5\113\1\131\3\113\4\0\5\113\10\0\5\113\4\0"+ + "\1\113\6\0\10\113\1\132\4\0\5\113\10\0\5\113"+ + "\52\0\1\63\12\0\1\133\50\0\1\134\54\0\1\135"+ + "\55\0\1\136\34\0\1\22\6\0\1\22\1\137\7\22"+ + "\4\0\5\22\10\0\5\22\4\0\1\22\6\0\11\22"+ + "\4\0\4\22\1\140\10\0\5\22\4\0\1\22\6\0"+ + "\10\22\1\141\4\0\5\22\10\0\5\22\4\0\1\22"+ + "\6\0\11\22\4\0\2\22\1\142\2\22\10\0\5\22"+ + "\4\0\1\22\6\0\3\22\1\143\5\22\4\0\5\22"+ + "\10\0\5\22\4\0\1\32\6\0\11\32\4\0\4\32"+ + "\1\144\6\0\1\105\1\0\5\32\4\0\1\113\6\0"+ + "\11\113\4\0\5\113\10\0\1\145\4\113\4\0\1\113"+ + "\6\0\11\113\4\0\5\113\10\0\2\113\1\146\2\113"+ + "\14\0\1\147\3\0\1\150\47\0\1\151\55\0\1\152"+ + "\33\0\1\22\6\0\11\22\4\0\2\22\1\153\2\22"+ + "\10\0\5\22\4\0\1\22\6\0\5\22\1\154\3\22"+ + "\4\0\5\22\10\0\5\22\4\0\1\113\6\0\7\113"+ + "\1\155\1\113\4\0\5\113\10\0\5\113\4\0\1\113"+ + "\6\0\11\113\4\0\5\113\10\0\3\113\1\156\1\113"+ + "\15\0\1\157\55\0\1\160\47\0\1\161\55\0\1\162"+ + "\32\0\1\113\6\0\11\113\4\0\5\113\10\0\4\113"+ + "\1\163\16\0\1\164\55\0\1\165\47\0\1\162\50\0"+ + "\1\166\55\0\1\116\46\0\1\116\33\0"; private static int [] zzUnpackTrans() { - int[] result = new int[2886]; + int [] result = new int[3192]; int offset = 0; offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); return result; @@ -263,14 +262,14 @@ 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 = - "\13\0\1\11\5\1\7\11\1\1\3\11\13\1\1\11" + - "\2\1\2\11\3\0\3\11\2\0\11\1\4\0\2\1" + - "\4\0\7\1\1\0\1\1\1\0\1\11\4\0\7\1" + - "\1\0\1\1\4\0\4\1\1\0\1\11\2\0\1\1" + - "\1\0"; + "\15\0\1\11\11\1\1\11\2\1\3\11\2\1\1\11"+ + "\1\1\11\11\2\1\2\11\2\1\4\11\1\1\2\11"+ + "\1\1\3\0\3\11\6\1\1\11\3\1\1\0\1\11"+ + "\3\1\5\0\10\1\1\0\1\11\2\0\10\1\4\0"+ + "\4\1\3\0\1\11\1\1\3\0"; private static int [] zzUnpackAttribute() { - int[] result = new int[109]; + int [] result = new int[118]; int offset = 0; offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); return result; @@ -326,9 +325,49 @@ the source of the yytext() string */ private boolean zzEOFDone; /* user code: */ - private char quote; - private int leftBraceCount; - private int leftParenCount; + private int braces = 0; + private int parens = 0; + private int brackets = 0; + private boolean rootKeywordsEnabled = false; + + private IElementType quotedToken; + + private Stack stack = new Stack<>(); + + private void pushState(int newState) { + stack.push(yystate()); + yybegin(newState); + } + + private void popState() { + yybegin(stack.pop()); + } + + private void eatWsThenBegin(int nextState) { + yybegin(nextState); + pushState(ONLY_WHITESPACE); + } + + private IElementType beginQuote(int quoteState, IElementType token) { + quotedToken = token; + pushState(quoteState); + return quotedToken; + } + + private void enableRootKeywords() { + if (notNestedCode()) rootKeywordsEnabled = true; + } + + private boolean notNestedCode() { + return (braces + parens + brackets) == 0; + } + + private void resetCounters() { + rootKeywordsEnabled = false; + braces = 0; + parens = 0; + brackets = 0; + } /** @@ -341,7 +380,7 @@ public _SvelteLexer(java.io.Reader in) { } - /** + /** * Unpacks the compressed character translation table. * * @param packed the packed character translation table @@ -492,8 +531,7 @@ public void yypushback(int number) { private void zzDoEOF() { if (!zzEOFDone) { zzEOFDone = true; - leftBraceCount = 0; - leftParenCount = 0; + resetCounters(); } } @@ -590,255 +628,244 @@ else if (zzAtEOF) { } else { switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { - case 1: + case 1: { return HTML_FRAGMENT; } // fall through - case 38: - break; - case 2: - { return WHITE_SPACE; + case 48: break; + case 2: + { yybegin(HTML_TAG); return HTML_FRAGMENT; } // fall through - case 39: - break; - case 3: - { yybegin(HTML_TAG); return HTML_FRAGMENT; + case 49: break; + case 3: + { yybegin(SVELTE_INTERPOLATION_START); return START_MUSTACHE; } // fall through - case 40: - break; - case 4: { - yybegin(SVELTE_INTERPOLATION_PRE); - return START_MUSTACHE; + case 50: break; + case 4: + { return BAD_CHARACTER; } // fall through - case 41: - break; - case 5: - { yybegin(YYINITIAL); return HTML_FRAGMENT; + case 51: break; + case 5: + { yybegin(SVELTE_TAG); return BAD_CHARACTER; } // fall through - case 42: - break; - case 6: - { yybegin(TAG_STRING); quote = '\''; return HTML_FRAGMENT; + case 52: break; + case 6: + { if (notNestedCode()) rootKeywordsEnabled = false; return CODE_FRAGMENT; } // fall through - case 43: - break; - case 7: - { yybegin(TAG_STRING); quote = '"'; return HTML_FRAGMENT; + case 53: break; + case 7: + { return CODE_FRAGMENT; } // fall through - case 44: - break; - case 8: - { if (quote == '\'') yybegin(HTML_TAG); return HTML_FRAGMENT; + case 54: break; + case 8: + { enableRootKeywords(); return CODE_FRAGMENT; } // fall through - case 45: - break; - case 9: - { if (quote == '"') yybegin(HTML_TAG); return HTML_FRAGMENT; + case 55: break; + case 9: + { enableRootKeywords(); return beginQuote(SINGLE_QUOTE, CODE_FRAGMENT); } // fall through - case 46: - break; - case 10: { - yybegin(SVELTE_INTERPOLATION); - return CODE_FRAGMENT; + case 56: break; + case 10: + { enableRootKeywords(); return beginQuote(DOUBLE_QUOTE, CODE_FRAGMENT); } // fall through - case 47: - break; - case 11: { - yybegin(SVELTE_INTERPOLATION); - leftBraceCount += 1; - return CODE_FRAGMENT; + case 57: break; + case 11: + { enableRootKeywords(); return beginQuote(TICKED_QUOTE, CODE_FRAGMENT); } // fall through - case 48: break; - case 12: { - yybegin(SVELTE_INTERPOLATION); - return BAD_CHARACTER; + case 58: break; + case 12: + { enableRootKeywords(); braces++; return CODE_FRAGMENT; } // fall through - case 49: break; - case 13: { - return CODE_FRAGMENT; + case 59: break; + case 13: + { enableRootKeywords(); parens++; return CODE_FRAGMENT; } // fall through - case 50: break; - case 14: { - leftBraceCount += 1; - return CODE_FRAGMENT; + case 60: break; + case 14: + { parens--; return CODE_FRAGMENT; } // fall through - case 51: break; - case 15: { - if (leftBraceCount == 0) { - yybegin(YYINITIAL); - return END_MUSTACHE; - } else { - leftBraceCount -= 1; - return CODE_FRAGMENT; - } + case 61: break; + case 15: + { if (notNestedCode()) { return COMMA; } else { return CODE_FRAGMENT; } } // fall through - case 52: break; - case 16: { - return BAD_CHARACTER; + case 62: break; + case 16: + { enableRootKeywords(); brackets++; return CODE_FRAGMENT; } // fall through - case 53: break; - case 17: { - yybegin(SVELTE_TAG); - return BAD_CHARACTER; + case 63: break; + case 17: + { brackets--; return CODE_FRAGMENT; } // fall through - case 54: break; - case 18: { - if (leftBraceCount == 0) { - return WHITE_SPACE; - } else { - return CODE_FRAGMENT; - } + case 64: break; + case 18: + { if (braces == 0) { eatWsThenBegin(YYINITIAL); return END_MUSTACHE; } else { braces--; return CODE_FRAGMENT; } } // fall through - case 55: break; - case 19: { - if (leftBraceCount == 0) { - return COMMA; - } else { - return CODE_FRAGMENT; - } + case 65: break; + case 19: + { parens++; if (parens == 1) { return START_PAREN; } else { return CODE_FRAGMENT; } } // fall through - case 56: break; - case 20: { - yybegin(SVELTE_TAG); - return CODE_FRAGMENT; + case 66: break; + case 20: + { parens--; if (parens == 0) { return END_PAREN; } else { return CODE_FRAGMENT; } } // fall through - case 57: break; - case 21: { - leftParenCount += 1; - if (leftParenCount == 1) { - return START_PAREN; - } else { - return CODE_FRAGMENT; - } + case 67: break; + case 21: + { yybegin(SVELTE_INTERPOLATION); yypushback(yylength()); } // fall through - case 58: break; - case 22: { - leftParenCount -= 1; - if (leftParenCount == 0) { - return END_PAREN; - } else { - return CODE_FRAGMENT; - } + case 68: break; + case 22: + { yybegin(SVELTE_INTERPOLATION); return BAD_CHARACTER; } // fall through - case 59: break; - case 23: { - yybegin(SVELTE_TAG_PRE); - return START_OPENING_MUSTACHE; + case 69: break; + case 23: + { braces++; return CODE_FRAGMENT; } // fall through - case 60: break; - case 24: { - yybegin(SVELTE_TAG_PRE); - return START_INNER_MUSTACHE; + case 70: break; + case 24: + { return beginQuote(SINGLE_QUOTE, HTML_FRAGMENT); } // fall through - case 61: break; - case 25: { - yybegin(SVELTE_TAG_PRE); - return START_CLOSING_MUSTACHE; + case 71: break; + case 25: + { return beginQuote(DOUBLE_QUOTE, HTML_FRAGMENT); } // fall through - case 62: break; - case 26: { - yybegin(SVELTE_TAG); - return IF; + case 72: break; + case 26: + { yybegin(YYINITIAL); return HTML_FRAGMENT; } // fall through - case 63: break; - case 27: { - yybegin(SVELTE_TAG_PAREN_AWARE); - return AS; + case 73: break; + case 27: + { popState(); yypushback(1); } // fall through - case 64: break; - case 28: { - yybegin(VERBATIM_COMMENT); - return HTML_FRAGMENT; + case 74: break; + case 28: + { return WHITE_SPACE; } // fall through - case 65: break; - case 29: { - yybegin(SVELTE_TAG); - return THEN; + case 75: break; + case 29: + { return quotedToken; } // fall through - case 66: break; - case 30: { - yybegin(SVELTE_ELSE_TAG); - return ELSE; + case 76: break; + case 30: + { popState(); return quotedToken; + } + // fall through + case 77: break; + case 31: + { resetCounters(); yybegin(SVELTE_TAG_START); return START_OPENING_MUSTACHE; + } + // fall through + case 78: break; + case 32: + { resetCounters(); yybegin(SVELTE_TAG_START); return START_INNER_MUSTACHE; + } + // fall through + case 79: break; + case 33: + { resetCounters(); yybegin(SVELTE_TAG_START); return START_CLOSING_MUSTACHE; + } + // fall through + case 80: break; + case 34: + { yybegin(SVELTE_TAG); return IF; + } + // fall through + case 81: break; + case 35: + { if (notNestedCode()) { return IF; } else { return CODE_FRAGMENT; } + } + // fall through + case 82: break; + case 36: + { if (notNestedCode() && rootKeywordsEnabled) { yybegin(SVELTE_TAG_PARAMETER); return AS; } else { enableRootKeywords(); return CODE_FRAGMENT; } + } + // fall through + case 83: break; + case 37: + // lookahead expression with fixed lookahead length + zzMarkedPos = Character.offsetByCodePoints + (zzBufferL/*, zzStartRead, zzEndRead - zzStartRead*/, zzMarkedPos, -1); + { return WHITE_SPACE; + } + // fall through + case 84: break; + case 38: + { yybegin(VERBATIM_COMMENT); return HTML_FRAGMENT; + } + // fall through + case 85: break; + case 39: + { yybegin(SVELTE_TAG_PARAMETER); return THEN; + } + // fall through + case 86: break; + case 40: + { eatWsThenBegin(SVELTE_TAG); return ELSE; } // fall through - case 67: - break; - case 31: { - yybegin(SVELTE_TAG); - return EACH; + case 87: break; + case 41: + { yybegin(SVELTE_TAG); return EACH; } // fall through - case 68: - break; - case 32: { - return THEN; + case 88: break; + case 42: + { if (notNestedCode() && rootKeywordsEnabled) { yybegin(SVELTE_TAG_PARAMETER); return THEN; } else { enableRootKeywords(); return CODE_FRAGMENT; } } // fall through - case 69: - break; - case 33: { - yybegin(SVELTE_INTERPOLATION); - return HTML_PREFIX; + case 89: break; + case 43: + { yybegin(SVELTE_TAG_PARAMETER); return CATCH; } // fall through - case 70: - break; - case 34: { - yybegin(SVELTE_TAG); - return CATCH; + case 90: break; + case 44: + { yybegin(SVELTE_TAG); return AWAIT; } // fall through - case 71: - break; - case 35: { - yybegin(SVELTE_TAG); - return AWAIT; + case 91: break; + case 45: + { yybegin(SVELTE_INTERPOLATION); return HTML_PREFIX; } // fall through - case 72: - break; - case 36: { - yybegin(VERBATIM_HTML); - return HTML_FRAGMENT; + case 92: break; + case 46: + { yybegin(VERBATIM_HTML); return HTML_FRAGMENT; } // fall through - case 73: - break; - case 37: { - yybegin(SVELTE_INTERPOLATION); - return DEBUG_PREFIX; + case 93: break; + case 47: + { yybegin(SVELTE_INTERPOLATION); return DEBUG_PREFIX; } // fall through - case 74: - break; + case 94: break; default: zzScanError(ZZ_NO_MATCH); } diff --git a/src/main/java/dev/blachut/svelte/lang/Svelte.flex b/src/main/java/dev/blachut/svelte/lang/Svelte.flex index 10c1d006..8e8fae36 100644 --- a/src/main/java/dev/blachut/svelte/lang/Svelte.flex +++ b/src/main/java/dev/blachut/svelte/lang/Svelte.flex @@ -10,12 +10,6 @@ import static dev.blachut.svelte.lang.psi.SvelteTypes.*; %% -%{ - private char quote; - private int leftBraceCount; - private int leftParenCount; -%} - //%debug %public %class _SvelteLexer @@ -24,106 +18,162 @@ import static dev.blachut.svelte.lang.psi.SvelteTypes.*; %type IElementType %unicode +%{ + private int braces = 0; + private int parens = 0; + private int brackets = 0; + private boolean rootKeywordsEnabled = false; + + private IElementType quotedToken; + + private Stack stack = new Stack<>(); + + private void pushState(int newState) { + stack.push(yystate()); + yybegin(newState); + } + + private void popState() { + yybegin(stack.pop()); + } + + private void eatWsThenBegin(int nextState) { + yybegin(nextState); + pushState(ONLY_WHITESPACE); + } + + private IElementType beginQuote(int quoteState, IElementType token) { + quotedToken = token; + pushState(quoteState); + return quotedToken; + } + + private void enableRootKeywords() { + if (notNestedCode()) rootKeywordsEnabled = true; + } + + private boolean notNestedCode() { + return (braces + parens + brackets) == 0; + } + + private void resetCounters() { + rootKeywordsEnabled = false; + braces = 0; + parens = 0; + brackets = 0; + } +%} + %eof{ - leftBraceCount = 0; - leftParenCount = 0; + resetCounters(); %eof} WHITE_SPACE=\s+ ID=[$_a-zA-Z0-9]+ +SINGLE_QUOTE="'" +DOUBLE_QUOTE="\"" +TICKED_QUOTE="`" +%state SVELTE_TAG_START +%state SVELTE_TAG +%state SVELTE_TAG_PARAMETER +%state SVELTE_INTERPOLATION_START +%state SVELTE_INTERPOLATION %state VERBATIM_COMMENT %state VERBATIM_HTML %state HTML_TAG -%state TAG_STRING -%state SVELTE_INTERPOLATION_PRE -%state SVELTE_INTERPOLATION -%state SVELTE_TAG_PRE -%state SVELTE_TAG -%state SVELTE_ELSE_TAG -%state SVELTE_TAG_PAREN_AWARE +%xstate ONLY_WHITESPACE +%xstate SINGLE_QUOTE +%xstate DOUBLE_QUOTE +%xstate TICKED_QUOTE %% { "" { yybegin(YYINITIAL); return HTML_FRAGMENT; } -} - - { - "" | "" { yybegin(YYINITIAL); return HTML_FRAGMENT; } -} + "-->" { yybegin(YYINITIAL); return HTML_FRAGMENT; } + "" | "" { yybegin(YYINITIAL); return HTML_FRAGMENT; } { - "'" { yybegin(TAG_STRING); quote = '\''; return HTML_FRAGMENT; } - "\"" { yybegin(TAG_STRING); quote = '"'; return HTML_FRAGMENT; } + {SINGLE_QUOTE} { return beginQuote(SINGLE_QUOTE, HTML_FRAGMENT); } + {DOUBLE_QUOTE} { return beginQuote(DOUBLE_QUOTE, HTML_FRAGMENT); } ">" { yybegin(YYINITIAL); return HTML_FRAGMENT; } } - { - "'" { if (quote == '\'') yybegin(HTML_TAG); return HTML_FRAGMENT; } - "\"" { if (quote == '"') yybegin(HTML_TAG); return HTML_FRAGMENT; } + {SINGLE_QUOTE} { popState(); return quotedToken; } + {DOUBLE_QUOTE} { popState(); return quotedToken; } + {TICKED_QUOTE} { popState(); return quotedToken; } + + { + \\[^] { return quotedToken; } + [^] { return quotedToken; } +} + + { + {WHITE_SPACE} { return WHITE_SPACE; } + [^] { popState(); yypushback(1); } } [^] { return HTML_FRAGMENT; } diff --git a/src/main/java/dev/blachut/svelte/lang/editor/SvelteEnterHandler.kt b/src/main/java/dev/blachut/svelte/lang/editor/SvelteEnterHandler.kt index 76acadf2..39ca9c85 100644 --- a/src/main/java/dev/blachut/svelte/lang/editor/SvelteEnterHandler.kt +++ b/src/main/java/dev/blachut/svelte/lang/editor/SvelteEnterHandler.kt @@ -25,11 +25,11 @@ import dev.blachut.svelte.lang.psi.SvelteOpeningTag class SvelteEnterHandler : EnterHandlerDelegateAdapter() { /** * if we are between open and close tags, we ensure the caret ends up in the "logical" place on Enter. - * i.e. "{{#foo}}{{/foo}}" becomes the following on Enter: + * i.e. "{#if x}{/if}" becomes the following on Enter: * - * {{#foo}} + * {#if x} * - * {{/foo}} + * {/if} * * (Note: may be indented depending on formatter settings.) */ @@ -48,9 +48,7 @@ class SvelteEnterHandler : EnterHandlerDelegateAdapter() { } /** - * Checks to see if `Enter` has been typed while the caret is between an open and close tag pair. - * - * @return true if between open and close tags, false otherwise + * Checks to see if `Enter` has been typed while the caret is between an open and close tag pair */ private fun isBetweenSvelteTags(editor: Editor, file: PsiFile, offset: Int): Boolean { if (offset == 0) return false diff --git a/src/main/java/dev/blachut/svelte/lang/format/SvelteFormattingModelBuilder.kt b/src/main/java/dev/blachut/svelte/lang/format/SvelteFormattingModelBuilder.kt index 63111bfe..6460bf2b 100644 --- a/src/main/java/dev/blachut/svelte/lang/format/SvelteFormattingModelBuilder.kt +++ b/src/main/java/dev/blachut/svelte/lang/format/SvelteFormattingModelBuilder.kt @@ -61,16 +61,16 @@ private class SvelteBlock(node: ASTNode, * SVELTE_BLOCKS * MARKUP_FRAGMENT * SVELTE_BLOCKS - * {#if condition} + * {/if} * ``` * * Formatting seems easy. Simply apply an indent (represented here by `----`) to the SCOPE and call it a day: * ``` - * {{#foo}} + * {#if condition} * ----SVELTE_BLOCKS * ----MARKUP_FRAGMENT * ----SVELTE_BLOCKS - * {{/foo}} + * {/if} * ``` * * However, if we're contained in markup block, it's going to provide some indents of its own @@ -78,11 +78,11 @@ private class SvelteBlock(node: ASTNode, * * ``` *
- * ::::{{#foo}} + * ::::{#if condition} * ----SVELTE_BLOCKS * ::::----MARKUP_FRAGMENT * ----SVELTE_BLOCKS - * ::::{{/foo}} + * ::::{/if} *
* ``` * So to behave correctly in both situations, we indent SCOPE from the "outside" anytime we're not wrapped @@ -179,4 +179,4 @@ private class SvelteBlock(node: ASTNode, return foreignBlockParent } -} \ No newline at end of file +} diff --git a/src/test/java/dev/blachut/svelte/lang/SvelteLexerTest.kt b/src/test/java/dev/blachut/svelte/lang/SvelteLexerTest.kt index 9c0b4f51..4649c067 100644 --- a/src/test/java/dev/blachut/svelte/lang/SvelteLexerTest.kt +++ b/src/test/java/dev/blachut/svelte/lang/SvelteLexerTest.kt @@ -21,9 +21,9 @@ class SvelteLexerTest : LexerTestCase() { fun testIncompleteExpression() = doTest() fun testWhitespace() = doTest() - // TODO Improve lexer and enable following tests -// fun testEachAsAs() = doTest(true) -// fun testAwaitThenThenThen() = doTest(true) + fun testEachAsAsAsAs() = doTest() + fun testAwaitThenThenThen() = doTest() + fun testEachAmbiguousAs() = doTest() private fun doTest() = doFileTest("svelte") } diff --git a/src/test/java/dev/blachut/svelte/lang/SvelteParsingTest.kt b/src/test/java/dev/blachut/svelte/lang/SvelteParsingTest.kt index 66204dc1..1f4f811b 100644 --- a/src/test/java/dev/blachut/svelte/lang/SvelteParsingTest.kt +++ b/src/test/java/dev/blachut/svelte/lang/SvelteParsingTest.kt @@ -5,15 +5,17 @@ import com.intellij.testFramework.ParsingTestCase class SvelteParsingTest : ParsingTestCase("dev/blachut/svelte/lang", "svelte", SvelteParserDefinition()) { override fun getTestDataPath(): String = "src/test/resources" - fun testIfElseIf() = doTest(true) - fun testEachAssets() = doTest(true) - fun testExpression() = doTest(true) - fun testIncompleteExpression() = doTest(true) - fun testWhitespace() = doTest(true) - fun testNestedBlocks() = doTest(true) + fun testIfElseIf() = doTest() + fun testEachAssets() = doTest() + fun testExpression() = doTest() + fun testIncompleteExpression() = doTest() + fun testWhitespace() = doTest() + fun testNestedBlocks() = doTest() - // TODO Improve lexer and enable following tests -// fun testEachAsAs() = doTest(true) -// fun testAwaitThenThenThen() = doTest(true) + fun testEachAsAsAsAs() = doTest() + fun testAwaitThenThenThen() = doTest() + fun testEachAmbiguousAs() = doTest() + + private fun doTest() = doTest(true) } diff --git a/src/test/java/dev/blachut/svelte/lang/format/SvelteFormatterTest.kt b/src/test/java/dev/blachut/svelte/lang/format/SvelteFormatterTest.kt index b7dd58aa..9bf81f4c 100644 --- a/src/test/java/dev/blachut/svelte/lang/format/SvelteFormatterTest.kt +++ b/src/test/java/dev/blachut/svelte/lang/format/SvelteFormatterTest.kt @@ -15,5 +15,6 @@ class SvelteFormatterTest : FormatterTestCase() { fun testScriptContents() = doTest() fun testNestedBlocks() = doTest() fun testNestedBlocksFlat() = doTest() + fun testIndentedExpressions() = doTest() // fun testOneLineBlock() = doTest() // TODO Fix formatter and enable test } diff --git a/src/test/resources/dev/blachut/svelte/lang/AwaitThenThenThen.tokens b/src/test/resources/dev/blachut/svelte/lang/AwaitThenThenThen.tokens new file mode 100644 index 00000000..4e6f8568 --- /dev/null +++ b/src/test/resources/dev/blachut/svelte/lang/AwaitThenThenThen.tokens @@ -0,0 +1,9 @@ +{# ('{#') +await ('await') +CODE_FRAGMENT (' then ') +then ('then') +CODE_FRAGMENT (' then') +} ('}') +{/ ('{/') +await ('await') +} ('}') diff --git a/src/test/resources/dev/blachut/svelte/lang/AwaitThenThenThen.txt b/src/test/resources/dev/blachut/svelte/lang/AwaitThenThenThen.txt index 64150c96..467d821d 100644 --- a/src/test/resources/dev/blachut/svelte/lang/AwaitThenThenThen.txt +++ b/src/test/resources/dev/blachut/svelte/lang/AwaitThenThenThen.txt @@ -4,18 +4,15 @@ Svelte Component Svelte: AWAIT_THEN_BLOCK_OPENING_TAG PsiElement({#)('{#') PsiElement(await)('await') - PsiWhiteSpace(' ') Svelte: EXPRESSION - PsiElement(CODE_FRAGMENT)('then') - PsiWhiteSpace(' ') + PsiElement(CODE_FRAGMENT)(' then ') PsiElement(then)('then') - PsiWhiteSpace(' ') Svelte: PARAMETER - PsiElement(CODE_FRAGMENT)('then') + PsiElement(CODE_FRAGMENT)(' then') PsiElement(})('}') Svelte: SCOPE Svelte: AWAIT_BLOCK_CLOSING_TAG PsiElement({/)('{/') PsiElement(await)('await') - PsiElement(})('}') + PsiElement(})('}') \ No newline at end of file diff --git a/src/test/resources/dev/blachut/svelte/lang/EachAmbiguousAs.svelte b/src/test/resources/dev/blachut/svelte/lang/EachAmbiguousAs.svelte new file mode 100644 index 00000000..34b5f65c --- /dev/null +++ b/src/test/resources/dev/blachut/svelte/lang/EachAmbiguousAs.svelte @@ -0,0 +1,21 @@ +{#each as + as as (as)}{/each} +{#each as+as as (as)}{/each} +{#each as.as as (as)}{/each} +{#each assets.as as as (as)}{/each} +{#each as.assets as as (as)}{/each} +{#each as. as as (as)}{/each} +{#each as + as as (as)}{/each} +{#each as({x: as}) as as, i}{/each} +{#each {} as as, i}{/each} +{#each [] as as, i}{/each} +{#each 1 + as as, i}{/each} +{#each 1 + as as, i}{/each} +{#each as + 1 as, i}{/each} +{#each as + "" as, i}{/each} +{#each "" + as as, i}{/each} +{#each as + '' as, i}{/each} +{#each '' + as as, i}{/each} +{#each as + `` as, i}{/each} +{#each `` + as as, i}{/each} +{#each as + `as` as, i}{/each} +{#each `as` + as as, i}{/each} diff --git a/src/test/resources/dev/blachut/svelte/lang/EachAmbiguousAs.tokens b/src/test/resources/dev/blachut/svelte/lang/EachAmbiguousAs.tokens new file mode 100644 index 00000000..24f64ac7 --- /dev/null +++ b/src/test/resources/dev/blachut/svelte/lang/EachAmbiguousAs.tokens @@ -0,0 +1,247 @@ +{# ('{#') +each ('each') +CODE_FRAGMENT (' as + as ') +as ('as') +CODE_FRAGMENT (' ') +( ('(') +CODE_FRAGMENT ('as') +) (')') +} ('}') +{/ ('{/') +each ('each') +} ('}') +WHITE_SPACE ('\n') +{# ('{#') +each ('each') +CODE_FRAGMENT (' as+as ') +as ('as') +CODE_FRAGMENT (' ') +( ('(') +CODE_FRAGMENT ('as') +) (')') +} ('}') +{/ ('{/') +each ('each') +} ('}') +WHITE_SPACE ('\n') +{# ('{#') +each ('each') +CODE_FRAGMENT (' as.') +as ('as') +CODE_FRAGMENT (' as ') +( ('(') +CODE_FRAGMENT ('as') +) (')') +} ('}') +{/ ('{/') +each ('each') +} ('}') +WHITE_SPACE ('\n') +{# ('{#') +each ('each') +CODE_FRAGMENT (' assets.') +as ('as') +CODE_FRAGMENT (' as as ') +( ('(') +CODE_FRAGMENT ('as') +) (')') +} ('}') +{/ ('{/') +each ('each') +} ('}') +WHITE_SPACE ('\n') +{# ('{#') +each ('each') +CODE_FRAGMENT (' as.assets ') +as ('as') +CODE_FRAGMENT (' as ') +( ('(') +CODE_FRAGMENT ('as') +) (')') +} ('}') +{/ ('{/') +each ('each') +} ('}') +WHITE_SPACE ('\n') +{# ('{#') +each ('each') +CODE_FRAGMENT (' as. ') +as ('as') +CODE_FRAGMENT (' as ') +( ('(') +CODE_FRAGMENT ('as') +) (')') +} ('}') +{/ ('{/') +each ('each') +} ('}') +WHITE_SPACE ('\n') +{# ('{#') +each ('each') +CODE_FRAGMENT (' as + as ') +as ('as') +CODE_FRAGMENT (' ') +( ('(') +CODE_FRAGMENT ('as') +) (')') +} ('}') +{/ ('{/') +each ('each') +} ('}') +WHITE_SPACE ('\n') +{# ('{#') +each ('each') +CODE_FRAGMENT (' as({x: as}) ') +as ('as') +CODE_FRAGMENT (' as') +, (',') +CODE_FRAGMENT (' i') +} ('}') +{/ ('{/') +each ('each') +} ('}') +WHITE_SPACE ('\n') +{# ('{#') +each ('each') +CODE_FRAGMENT (' {} ') +as ('as') +CODE_FRAGMENT (' as') +, (',') +CODE_FRAGMENT (' i') +} ('}') +{/ ('{/') +each ('each') +} ('}') +WHITE_SPACE ('\n') +{# ('{#') +each ('each') +CODE_FRAGMENT (' [] ') +as ('as') +CODE_FRAGMENT (' as') +, (',') +CODE_FRAGMENT (' i') +} ('}') +{/ ('{/') +each ('each') +} ('}') +WHITE_SPACE ('\n') +{# ('{#') +each ('each') +CODE_FRAGMENT (' 1 + as ') +as ('as') +, (',') +CODE_FRAGMENT (' i') +} ('}') +{/ ('{/') +each ('each') +} ('}') +WHITE_SPACE ('\n') +{# ('{#') +each ('each') +CODE_FRAGMENT (' 1 + as ') +as ('as') +, (',') +CODE_FRAGMENT (' i') +} ('}') +{/ ('{/') +each ('each') +} ('}') +WHITE_SPACE ('\n') +{# ('{#') +each ('each') +CODE_FRAGMENT (' as + 1 ') +as ('as') +, (',') +CODE_FRAGMENT (' i') +} ('}') +{/ ('{/') +each ('each') +} ('}') +WHITE_SPACE ('\n') +{# ('{#') +each ('each') +CODE_FRAGMENT (' as + "" ') +as ('as') +, (',') +CODE_FRAGMENT (' i') +} ('}') +{/ ('{/') +each ('each') +} ('}') +WHITE_SPACE ('\n') +{# ('{#') +each ('each') +CODE_FRAGMENT (' "" + as ') +as ('as') +, (',') +CODE_FRAGMENT (' i') +} ('}') +{/ ('{/') +each ('each') +} ('}') +WHITE_SPACE ('\n') +{# ('{#') +each ('each') +CODE_FRAGMENT (' as + '' ') +as ('as') +, (',') +CODE_FRAGMENT (' i') +} ('}') +{/ ('{/') +each ('each') +} ('}') +WHITE_SPACE ('\n') +{# ('{#') +each ('each') +CODE_FRAGMENT (' '' + as ') +as ('as') +, (',') +CODE_FRAGMENT (' i') +} ('}') +{/ ('{/') +each ('each') +} ('}') +WHITE_SPACE ('\n') +{# ('{#') +each ('each') +CODE_FRAGMENT (' as + `` ') +as ('as') +, (',') +CODE_FRAGMENT (' i') +} ('}') +{/ ('{/') +each ('each') +} ('}') +WHITE_SPACE ('\n') +{# ('{#') +each ('each') +CODE_FRAGMENT (' `` + as ') +as ('as') +, (',') +CODE_FRAGMENT (' i') +} ('}') +{/ ('{/') +each ('each') +} ('}') +WHITE_SPACE ('\n') +{# ('{#') +each ('each') +CODE_FRAGMENT (' as + `as` ') +as ('as') +, (',') +CODE_FRAGMENT (' i') +} ('}') +{/ ('{/') +each ('each') +} ('}') +WHITE_SPACE ('\n') +{# ('{#') +each ('each') +CODE_FRAGMENT (' `as` + as ') +as ('as') +, (',') +CODE_FRAGMENT (' i') +} ('}') +{/ ('{/') +each ('each') +} ('}') diff --git a/src/test/resources/dev/blachut/svelte/lang/EachAmbiguousAs.txt b/src/test/resources/dev/blachut/svelte/lang/EachAmbiguousAs.txt new file mode 100644 index 00000000..8a16041a --- /dev/null +++ b/src/test/resources/dev/blachut/svelte/lang/EachAmbiguousAs.txt @@ -0,0 +1,448 @@ +Svelte Component + Svelte: EACH_BLOCK + Svelte: EACH_BLOCK_OPENING + Svelte: EACH_BLOCK_OPENING_TAG + PsiElement({#)('{#') + PsiElement(each)('each') + Svelte: EXPRESSION + PsiElement(CODE_FRAGMENT)(' as + as ') + PsiElement(as)('as') + Svelte: PARAMETER + PsiElement(CODE_FRAGMENT)(' ') + PsiElement(()('(') + Svelte: EXPRESSION + PsiElement(CODE_FRAGMENT)('as') + PsiElement())(')') + PsiElement(})('}') + Svelte: SCOPE + + Svelte: EACH_BLOCK_CLOSING_TAG + PsiElement({/)('{/') + PsiElement(each)('each') + PsiElement(})('}') + PsiWhiteSpace('\n') + Svelte: EACH_BLOCK + Svelte: EACH_BLOCK_OPENING + Svelte: EACH_BLOCK_OPENING_TAG + PsiElement({#)('{#') + PsiElement(each)('each') + Svelte: EXPRESSION + PsiElement(CODE_FRAGMENT)(' as+as ') + PsiElement(as)('as') + Svelte: PARAMETER + PsiElement(CODE_FRAGMENT)(' ') + PsiElement(()('(') + Svelte: EXPRESSION + PsiElement(CODE_FRAGMENT)('as') + PsiElement())(')') + PsiElement(})('}') + Svelte: SCOPE + + Svelte: EACH_BLOCK_CLOSING_TAG + PsiElement({/)('{/') + PsiElement(each)('each') + PsiElement(})('}') + PsiWhiteSpace('\n') + Svelte: EACH_BLOCK + Svelte: EACH_BLOCK_OPENING + Svelte: EACH_BLOCK_OPENING_TAG + PsiElement({#)('{#') + PsiElement(each)('each') + Svelte: EXPRESSION + PsiElement(CODE_FRAGMENT)(' as.') + PsiElement(as)('as') + Svelte: PARAMETER + PsiElement(CODE_FRAGMENT)(' as ') + PsiElement(()('(') + Svelte: EXPRESSION + PsiElement(CODE_FRAGMENT)('as') + PsiElement())(')') + PsiElement(})('}') + Svelte: SCOPE + + Svelte: EACH_BLOCK_CLOSING_TAG + PsiElement({/)('{/') + PsiElement(each)('each') + PsiElement(})('}') + PsiWhiteSpace('\n') + Svelte: EACH_BLOCK + Svelte: EACH_BLOCK_OPENING + Svelte: EACH_BLOCK_OPENING_TAG + PsiElement({#)('{#') + PsiElement(each)('each') + Svelte: EXPRESSION + PsiElement(CODE_FRAGMENT)(' assets.') + PsiElement(as)('as') + Svelte: PARAMETER + PsiElement(CODE_FRAGMENT)(' as as ') + PsiElement(()('(') + Svelte: EXPRESSION + PsiElement(CODE_FRAGMENT)('as') + PsiElement())(')') + PsiElement(})('}') + Svelte: SCOPE + + Svelte: EACH_BLOCK_CLOSING_TAG + PsiElement({/)('{/') + PsiElement(each)('each') + PsiElement(})('}') + PsiWhiteSpace('\n') + Svelte: EACH_BLOCK + Svelte: EACH_BLOCK_OPENING + Svelte: EACH_BLOCK_OPENING_TAG + PsiElement({#)('{#') + PsiElement(each)('each') + Svelte: EXPRESSION + PsiElement(CODE_FRAGMENT)(' as.assets ') + PsiElement(as)('as') + Svelte: PARAMETER + PsiElement(CODE_FRAGMENT)(' as ') + PsiElement(()('(') + Svelte: EXPRESSION + PsiElement(CODE_FRAGMENT)('as') + PsiElement())(')') + PsiElement(})('}') + Svelte: SCOPE + + Svelte: EACH_BLOCK_CLOSING_TAG + PsiElement({/)('{/') + PsiElement(each)('each') + PsiElement(})('}') + PsiWhiteSpace('\n') + Svelte: EACH_BLOCK + Svelte: EACH_BLOCK_OPENING + Svelte: EACH_BLOCK_OPENING_TAG + PsiElement({#)('{#') + PsiElement(each)('each') + Svelte: EXPRESSION + PsiElement(CODE_FRAGMENT)(' as. ') + PsiElement(as)('as') + Svelte: PARAMETER + PsiElement(CODE_FRAGMENT)(' as ') + PsiElement(()('(') + Svelte: EXPRESSION + PsiElement(CODE_FRAGMENT)('as') + PsiElement())(')') + PsiElement(})('}') + Svelte: SCOPE + + Svelte: EACH_BLOCK_CLOSING_TAG + PsiElement({/)('{/') + PsiElement(each)('each') + PsiElement(})('}') + PsiWhiteSpace('\n') + Svelte: EACH_BLOCK + Svelte: EACH_BLOCK_OPENING + Svelte: EACH_BLOCK_OPENING_TAG + PsiElement({#)('{#') + PsiElement(each)('each') + Svelte: EXPRESSION + PsiElement(CODE_FRAGMENT)(' as + as ') + PsiElement(as)('as') + Svelte: PARAMETER + PsiElement(CODE_FRAGMENT)(' ') + PsiElement(()('(') + Svelte: EXPRESSION + PsiElement(CODE_FRAGMENT)('as') + PsiElement())(')') + PsiElement(})('}') + Svelte: SCOPE + + Svelte: EACH_BLOCK_CLOSING_TAG + PsiElement({/)('{/') + PsiElement(each)('each') + PsiElement(})('}') + PsiWhiteSpace('\n') + Svelte: EACH_BLOCK + Svelte: EACH_BLOCK_OPENING + Svelte: EACH_BLOCK_OPENING_TAG + PsiElement({#)('{#') + PsiElement(each)('each') + Svelte: EXPRESSION + PsiElement(CODE_FRAGMENT)(' as({x: as}) ') + PsiElement(as)('as') + Svelte: PARAMETER + PsiElement(CODE_FRAGMENT)(' as') + PsiElement(,)(',') + Svelte: PARAMETER + PsiElement(CODE_FRAGMENT)(' i') + PsiElement(})('}') + Svelte: SCOPE + + Svelte: EACH_BLOCK_CLOSING_TAG + PsiElement({/)('{/') + PsiElement(each)('each') + PsiElement(})('}') + PsiWhiteSpace('\n') + Svelte: EACH_BLOCK + Svelte: EACH_BLOCK_OPENING + Svelte: EACH_BLOCK_OPENING_TAG + PsiElement({#)('{#') + PsiElement(each)('each') + Svelte: EXPRESSION + PsiElement(CODE_FRAGMENT)(' {} ') + PsiElement(as)('as') + Svelte: PARAMETER + PsiElement(CODE_FRAGMENT)(' as') + PsiElement(,)(',') + Svelte: PARAMETER + PsiElement(CODE_FRAGMENT)(' i') + PsiElement(})('}') + Svelte: SCOPE + + Svelte: EACH_BLOCK_CLOSING_TAG + PsiElement({/)('{/') + PsiElement(each)('each') + PsiElement(})('}') + PsiWhiteSpace('\n') + Svelte: EACH_BLOCK + Svelte: EACH_BLOCK_OPENING + Svelte: EACH_BLOCK_OPENING_TAG + PsiElement({#)('{#') + PsiElement(each)('each') + Svelte: EXPRESSION + PsiElement(CODE_FRAGMENT)(' [] ') + PsiElement(as)('as') + Svelte: PARAMETER + PsiElement(CODE_FRAGMENT)(' as') + PsiElement(,)(',') + Svelte: PARAMETER + PsiElement(CODE_FRAGMENT)(' i') + PsiElement(})('}') + Svelte: SCOPE + + Svelte: EACH_BLOCK_CLOSING_TAG + PsiElement({/)('{/') + PsiElement(each)('each') + PsiElement(})('}') + PsiWhiteSpace('\n') + Svelte: EACH_BLOCK + Svelte: EACH_BLOCK_OPENING + Svelte: EACH_BLOCK_OPENING_TAG + PsiElement({#)('{#') + PsiElement(each)('each') + Svelte: EXPRESSION + PsiElement(CODE_FRAGMENT)(' 1 + as ') + PsiElement(as)('as') + PsiErrorElement: expected, got ',' + + PsiElement(,)(',') + Svelte: PARAMETER + PsiElement(CODE_FRAGMENT)(' i') + PsiElement(})('}') + Svelte: SCOPE + + Svelte: EACH_BLOCK_CLOSING_TAG + PsiElement({/)('{/') + PsiElement(each)('each') + PsiElement(})('}') + PsiWhiteSpace('\n') + Svelte: EACH_BLOCK + Svelte: EACH_BLOCK_OPENING + Svelte: EACH_BLOCK_OPENING_TAG + PsiElement({#)('{#') + PsiElement(each)('each') + Svelte: EXPRESSION + PsiElement(CODE_FRAGMENT)(' 1 + as ') + PsiElement(as)('as') + PsiErrorElement: expected, got ',' + + PsiElement(,)(',') + Svelte: PARAMETER + PsiElement(CODE_FRAGMENT)(' i') + PsiElement(})('}') + Svelte: SCOPE + + Svelte: EACH_BLOCK_CLOSING_TAG + PsiElement({/)('{/') + PsiElement(each)('each') + PsiElement(})('}') + PsiWhiteSpace('\n') + Svelte: EACH_BLOCK + Svelte: EACH_BLOCK_OPENING + Svelte: EACH_BLOCK_OPENING_TAG + PsiElement({#)('{#') + PsiElement(each)('each') + Svelte: EXPRESSION + PsiElement(CODE_FRAGMENT)(' as + 1 ') + PsiElement(as)('as') + PsiErrorElement: expected, got ',' + + PsiElement(,)(',') + Svelte: PARAMETER + PsiElement(CODE_FRAGMENT)(' i') + PsiElement(})('}') + Svelte: SCOPE + + Svelte: EACH_BLOCK_CLOSING_TAG + PsiElement({/)('{/') + PsiElement(each)('each') + PsiElement(})('}') + PsiWhiteSpace('\n') + Svelte: EACH_BLOCK + Svelte: EACH_BLOCK_OPENING + Svelte: EACH_BLOCK_OPENING_TAG + PsiElement({#)('{#') + PsiElement(each)('each') + Svelte: EXPRESSION + PsiElement(CODE_FRAGMENT)(' as + "" ') + PsiElement(as)('as') + PsiErrorElement: expected, got ',' + + PsiElement(,)(',') + Svelte: PARAMETER + PsiElement(CODE_FRAGMENT)(' i') + PsiElement(})('}') + Svelte: SCOPE + + Svelte: EACH_BLOCK_CLOSING_TAG + PsiElement({/)('{/') + PsiElement(each)('each') + PsiElement(})('}') + PsiWhiteSpace('\n') + Svelte: EACH_BLOCK + Svelte: EACH_BLOCK_OPENING + Svelte: EACH_BLOCK_OPENING_TAG + PsiElement({#)('{#') + PsiElement(each)('each') + Svelte: EXPRESSION + PsiElement(CODE_FRAGMENT)(' "" + as ') + PsiElement(as)('as') + PsiErrorElement: expected, got ',' + + PsiElement(,)(',') + Svelte: PARAMETER + PsiElement(CODE_FRAGMENT)(' i') + PsiElement(})('}') + Svelte: SCOPE + + Svelte: EACH_BLOCK_CLOSING_TAG + PsiElement({/)('{/') + PsiElement(each)('each') + PsiElement(})('}') + PsiWhiteSpace('\n') + Svelte: EACH_BLOCK + Svelte: EACH_BLOCK_OPENING + Svelte: EACH_BLOCK_OPENING_TAG + PsiElement({#)('{#') + PsiElement(each)('each') + Svelte: EXPRESSION + PsiElement(CODE_FRAGMENT)(' as + '' ') + PsiElement(as)('as') + PsiErrorElement: expected, got ',' + + PsiElement(,)(',') + Svelte: PARAMETER + PsiElement(CODE_FRAGMENT)(' i') + PsiElement(})('}') + Svelte: SCOPE + + Svelte: EACH_BLOCK_CLOSING_TAG + PsiElement({/)('{/') + PsiElement(each)('each') + PsiElement(})('}') + PsiWhiteSpace('\n') + Svelte: EACH_BLOCK + Svelte: EACH_BLOCK_OPENING + Svelte: EACH_BLOCK_OPENING_TAG + PsiElement({#)('{#') + PsiElement(each)('each') + Svelte: EXPRESSION + PsiElement(CODE_FRAGMENT)(' '' + as ') + PsiElement(as)('as') + PsiErrorElement: expected, got ',' + + PsiElement(,)(',') + Svelte: PARAMETER + PsiElement(CODE_FRAGMENT)(' i') + PsiElement(})('}') + Svelte: SCOPE + + Svelte: EACH_BLOCK_CLOSING_TAG + PsiElement({/)('{/') + PsiElement(each)('each') + PsiElement(})('}') + PsiWhiteSpace('\n') + Svelte: EACH_BLOCK + Svelte: EACH_BLOCK_OPENING + Svelte: EACH_BLOCK_OPENING_TAG + PsiElement({#)('{#') + PsiElement(each)('each') + Svelte: EXPRESSION + PsiElement(CODE_FRAGMENT)(' as + `` ') + PsiElement(as)('as') + PsiErrorElement: expected, got ',' + + PsiElement(,)(',') + Svelte: PARAMETER + PsiElement(CODE_FRAGMENT)(' i') + PsiElement(})('}') + Svelte: SCOPE + + Svelte: EACH_BLOCK_CLOSING_TAG + PsiElement({/)('{/') + PsiElement(each)('each') + PsiElement(})('}') + PsiWhiteSpace('\n') + Svelte: EACH_BLOCK + Svelte: EACH_BLOCK_OPENING + Svelte: EACH_BLOCK_OPENING_TAG + PsiElement({#)('{#') + PsiElement(each)('each') + Svelte: EXPRESSION + PsiElement(CODE_FRAGMENT)(' `` + as ') + PsiElement(as)('as') + PsiErrorElement: expected, got ',' + + PsiElement(,)(',') + Svelte: PARAMETER + PsiElement(CODE_FRAGMENT)(' i') + PsiElement(})('}') + Svelte: SCOPE + + Svelte: EACH_BLOCK_CLOSING_TAG + PsiElement({/)('{/') + PsiElement(each)('each') + PsiElement(})('}') + PsiWhiteSpace('\n') + Svelte: EACH_BLOCK + Svelte: EACH_BLOCK_OPENING + Svelte: EACH_BLOCK_OPENING_TAG + PsiElement({#)('{#') + PsiElement(each)('each') + Svelte: EXPRESSION + PsiElement(CODE_FRAGMENT)(' as + `as` ') + PsiElement(as)('as') + PsiErrorElement: expected, got ',' + + PsiElement(,)(',') + Svelte: PARAMETER + PsiElement(CODE_FRAGMENT)(' i') + PsiElement(})('}') + Svelte: SCOPE + + Svelte: EACH_BLOCK_CLOSING_TAG + PsiElement({/)('{/') + PsiElement(each)('each') + PsiElement(})('}') + PsiWhiteSpace('\n') + Svelte: EACH_BLOCK + Svelte: EACH_BLOCK_OPENING + Svelte: EACH_BLOCK_OPENING_TAG + PsiElement({#)('{#') + PsiElement(each)('each') + Svelte: EXPRESSION + PsiElement(CODE_FRAGMENT)(' `as` + as ') + PsiElement(as)('as') + PsiErrorElement: expected, got ',' + + PsiElement(,)(',') + Svelte: PARAMETER + PsiElement(CODE_FRAGMENT)(' i') + PsiElement(})('}') + Svelte: SCOPE + + Svelte: EACH_BLOCK_CLOSING_TAG + PsiElement({/)('{/') + PsiElement(each)('each') + PsiElement(})('}') \ No newline at end of file diff --git a/src/test/resources/dev/blachut/svelte/lang/EachAsAsAs.svelte b/src/test/resources/dev/blachut/svelte/lang/EachAsAsAs.svelte deleted file mode 100644 index 3e2a8269..00000000 --- a/src/test/resources/dev/blachut/svelte/lang/EachAsAsAs.svelte +++ /dev/null @@ -1 +0,0 @@ -{#each as as as}{/each} diff --git a/src/test/resources/dev/blachut/svelte/lang/EachAsAsAsAs.svelte b/src/test/resources/dev/blachut/svelte/lang/EachAsAsAsAs.svelte new file mode 100644 index 00000000..05d728d2 --- /dev/null +++ b/src/test/resources/dev/blachut/svelte/lang/EachAsAsAsAs.svelte @@ -0,0 +1 @@ +{#each as as as (as)}{/each} diff --git a/src/test/resources/dev/blachut/svelte/lang/EachAsAsAsAs.tokens b/src/test/resources/dev/blachut/svelte/lang/EachAsAsAsAs.tokens new file mode 100644 index 00000000..63ddf930 --- /dev/null +++ b/src/test/resources/dev/blachut/svelte/lang/EachAsAsAsAs.tokens @@ -0,0 +1,12 @@ +{# ('{#') +each ('each') +CODE_FRAGMENT (' as ') +as ('as') +CODE_FRAGMENT (' as ') +( ('(') +CODE_FRAGMENT ('as') +) (')') +} ('}') +{/ ('{/') +each ('each') +} ('}') diff --git a/src/test/resources/dev/blachut/svelte/lang/EachAsAsAs.txt b/src/test/resources/dev/blachut/svelte/lang/EachAsAsAsAs.txt similarity index 70% rename from src/test/resources/dev/blachut/svelte/lang/EachAsAsAs.txt rename to src/test/resources/dev/blachut/svelte/lang/EachAsAsAsAs.txt index a60febeb..12ca207b 100644 --- a/src/test/resources/dev/blachut/svelte/lang/EachAsAsAs.txt +++ b/src/test/resources/dev/blachut/svelte/lang/EachAsAsAsAs.txt @@ -4,18 +4,19 @@ Svelte Component Svelte: EACH_BLOCK_OPENING_TAG PsiElement({#)('{#') PsiElement(each)('each') - PsiWhiteSpace(' ') Svelte: EXPRESSION - PsiElement(CODE_FRAGMENT)('as') - PsiWhiteSpace(' ') + PsiElement(CODE_FRAGMENT)(' as ') PsiElement(as)('as') - PsiWhiteSpace(' ') Svelte: PARAMETER + PsiElement(CODE_FRAGMENT)(' as ') + PsiElement(()('(') + Svelte: EXPRESSION PsiElement(CODE_FRAGMENT)('as') + PsiElement())(')') PsiElement(})('}') Svelte: SCOPE Svelte: EACH_BLOCK_CLOSING_TAG PsiElement({/)('{/') PsiElement(each)('each') - PsiElement(})('}') + PsiElement(})('}') \ No newline at end of file diff --git a/src/test/resources/dev/blachut/svelte/lang/EachAssets.tokens b/src/test/resources/dev/blachut/svelte/lang/EachAssets.tokens index 82c9c51f..0f43a14c 100644 --- a/src/test/resources/dev/blachut/svelte/lang/EachAssets.tokens +++ b/src/test/resources/dev/blachut/svelte/lang/EachAssets.tokens @@ -1,14 +1,10 @@ {# ('{#') each ('each') -WHITE_SPACE (' ') -CODE_FRAGMENT ('assets') -WHITE_SPACE (' ') +CODE_FRAGMENT (' assets ') as ('as') -WHITE_SPACE (' ') -CODE_FRAGMENT ('asset') +CODE_FRAGMENT (' asset') , (',') -WHITE_SPACE (' ') -CODE_FRAGMENT ('i') +CODE_FRAGMENT (' i') } ('}') {/ ('{/') each ('each') diff --git a/src/test/resources/dev/blachut/svelte/lang/EachAssets.txt b/src/test/resources/dev/blachut/svelte/lang/EachAssets.txt index 9aeb2ff4..aee940ba 100644 --- a/src/test/resources/dev/blachut/svelte/lang/EachAssets.txt +++ b/src/test/resources/dev/blachut/svelte/lang/EachAssets.txt @@ -4,22 +4,18 @@ Svelte Component Svelte: EACH_BLOCK_OPENING_TAG PsiElement({#)('{#') PsiElement(each)('each') - PsiWhiteSpace(' ') Svelte: EXPRESSION - PsiElement(CODE_FRAGMENT)('assets') - PsiWhiteSpace(' ') + PsiElement(CODE_FRAGMENT)(' assets ') PsiElement(as)('as') - PsiWhiteSpace(' ') Svelte: PARAMETER - PsiElement(CODE_FRAGMENT)('asset') + PsiElement(CODE_FRAGMENT)(' asset') PsiElement(,)(',') - PsiWhiteSpace(' ') Svelte: PARAMETER - PsiElement(CODE_FRAGMENT)('i') + PsiElement(CODE_FRAGMENT)(' i') PsiElement(})('}') Svelte: SCOPE Svelte: EACH_BLOCK_CLOSING_TAG PsiElement({/)('{/') PsiElement(each)('each') - PsiElement(})('}') + PsiElement(})('}') \ No newline at end of file diff --git a/src/test/resources/dev/blachut/svelte/lang/IfElseIf.tokens b/src/test/resources/dev/blachut/svelte/lang/IfElseIf.tokens index d4cfc838..3c44c7c9 100644 --- a/src/test/resources/dev/blachut/svelte/lang/IfElseIf.tokens +++ b/src/test/resources/dev/blachut/svelte/lang/IfElseIf.tokens @@ -1,37 +1,25 @@ {# ('{#') if ('if') -WHITE_SPACE (' ') -CODE_FRAGMENT ('iffy') +CODE_FRAGMENT (' iffy') } ('}') WHITE_SPACE ('\n ') - ('

First') -WHITE_SPACE (' ') - ('branch

') -WHITE_SPACE ('\n') + ('

First branch

\n') {: ('{:') else ('else') WHITE_SPACE (' ') if ('if') -WHITE_SPACE (' ') -CODE_FRAGMENT ('life') +CODE_FRAGMENT (' life') } ('}') WHITE_SPACE ('\n ') - ('

Second') -WHITE_SPACE (' ') - ('branch

') -WHITE_SPACE ('\n') + ('

Second branch

\n') {: ('{:') else ('else') WHITE_SPACE (' ') if ('if') -WHITE_SPACE (' ') -CODE_FRAGMENT ('gif') +CODE_FRAGMENT (' gif') } ('}') WHITE_SPACE ('\n ') - ('

Third') -WHITE_SPACE (' ') - ('branch

') -WHITE_SPACE ('\n') + ('

Third branch

\n') {/ ('{/') if ('if') } ('}') diff --git a/src/test/resources/dev/blachut/svelte/lang/IfElseIf.txt b/src/test/resources/dev/blachut/svelte/lang/IfElseIf.txt index 899f2b7a..d33ffaaf 100644 --- a/src/test/resources/dev/blachut/svelte/lang/IfElseIf.txt +++ b/src/test/resources/dev/blachut/svelte/lang/IfElseIf.txt @@ -4,48 +4,36 @@ Svelte Component Svelte: IF_BLOCK_OPENING_TAG PsiElement({#)('{#') PsiElement(if)('if') - PsiWhiteSpace(' ') Svelte: EXPRESSION - PsiElement(CODE_FRAGMENT)('iffy') + PsiElement(CODE_FRAGMENT)(' iffy') PsiElement(})('}') PsiWhiteSpace('\n ') Svelte: SCOPE - PsiElement()('

First') - PsiWhiteSpace(' ') - PsiElement()('branch

') - PsiWhiteSpace('\n') + PsiElement()('

First branch

\n') Svelte: ELSE_IF_CONTINUATION Svelte: ELSE_IF_CONTINUATION_TAG PsiElement({:)('{:') PsiElement(else)('else') PsiWhiteSpace(' ') PsiElement(if)('if') - PsiWhiteSpace(' ') Svelte: EXPRESSION - PsiElement(CODE_FRAGMENT)('life') + PsiElement(CODE_FRAGMENT)(' life') PsiElement(})('}') PsiWhiteSpace('\n ') Svelte: SCOPE - PsiElement()('

Second') - PsiWhiteSpace(' ') - PsiElement()('branch

') - PsiWhiteSpace('\n') + PsiElement()('

Second branch

\n') Svelte: ELSE_IF_CONTINUATION Svelte: ELSE_IF_CONTINUATION_TAG PsiElement({:)('{:') PsiElement(else)('else') PsiWhiteSpace(' ') PsiElement(if)('if') - PsiWhiteSpace(' ') Svelte: EXPRESSION - PsiElement(CODE_FRAGMENT)('gif') + PsiElement(CODE_FRAGMENT)(' gif') PsiElement(})('}') PsiWhiteSpace('\n ') Svelte: SCOPE - PsiElement()('

Third') - PsiWhiteSpace(' ') - PsiElement()('branch

') - PsiWhiteSpace('\n') + PsiElement()('

Third branch

\n') Svelte: IF_BLOCK_CLOSING_TAG PsiElement({/)('{/') PsiElement(if)('if') diff --git a/src/test/resources/dev/blachut/svelte/lang/NestedBlocks.txt b/src/test/resources/dev/blachut/svelte/lang/NestedBlocks.txt index d67a4c81..3500b477 100644 --- a/src/test/resources/dev/blachut/svelte/lang/NestedBlocks.txt +++ b/src/test/resources/dev/blachut/svelte/lang/NestedBlocks.txt @@ -1,38 +1,26 @@ Svelte Component - PsiElement()('

') - PsiWhiteSpace('\n ') - PsiElement()('Plain') - PsiWhiteSpace(' ') - PsiElement()('html') - PsiWhiteSpace('\n') - PsiElement()('

') - PsiWhiteSpace('\n\n') + PsiElement()('

\n Plain html\n

\n\n') Svelte: IF_BLOCK Svelte: IF_BLOCK_OPENING Svelte: IF_BLOCK_OPENING_TAG PsiElement({#)('{#') PsiElement(if)('if') - PsiWhiteSpace(' ') Svelte: EXPRESSION - PsiElement(CODE_FRAGMENT)('visible') + PsiElement(CODE_FRAGMENT)(' visible') PsiElement(})('}') PsiWhiteSpace('\n ') Svelte: SCOPE - PsiElement()('') - PsiWhiteSpace('\n ') + PsiElement()('\n ') Svelte: AWAIT_BLOCK Svelte: AWAIT_THEN_BLOCK_OPENING Svelte: AWAIT_THEN_BLOCK_OPENING_TAG PsiElement({#)('{#') PsiElement(await)('await') - PsiWhiteSpace(' ') Svelte: EXPRESSION - PsiElement(CODE_FRAGMENT)('promise') - PsiWhiteSpace(' ') + PsiElement(CODE_FRAGMENT)(' promise ') PsiElement(then)('then') - PsiWhiteSpace(' ') Svelte: PARAMETER - PsiElement(CODE_FRAGMENT)('x') + PsiElement(CODE_FRAGMENT)(' x') PsiElement(})('}') PsiWhiteSpace('\n ') Svelte: SCOPE @@ -42,8 +30,7 @@ Svelte Component Svelte: EXPRESSION PsiElement(CODE_FRAGMENT)('x') PsiElement(})('}') - PsiElement()('

') - PsiWhiteSpace('\n ') + PsiElement()('

\n ') Svelte: AWAIT_BLOCK_CLOSING_TAG PsiElement({/)('{/') PsiElement(await)('await') @@ -63,28 +50,23 @@ Svelte Component PsiElement(CODE_FRAGMENT)(' name') PsiElement(})('}') PsiWhiteSpace('\n ') - PsiElement()('

Kappa

') - PsiWhiteSpace('\n') + PsiElement()('

Kappa

\n') Svelte: IF_BLOCK_CLOSING_TAG PsiElement({/)('{/') PsiElement(if)('if') PsiElement(})('}') PsiWhiteSpace('\n\n') - PsiElement()('
    ') - PsiWhiteSpace('\n ') + PsiElement()('
      \n ') Svelte: EACH_BLOCK Svelte: EACH_BLOCK_OPENING Svelte: EACH_BLOCK_OPENING_TAG PsiElement({#)('{#') PsiElement(each)('each') - PsiWhiteSpace(' ') Svelte: EXPRESSION - PsiElement(CODE_FRAGMENT)('assets') - PsiWhiteSpace(' ') + PsiElement(CODE_FRAGMENT)(' assets ') PsiElement(as)('as') - PsiWhiteSpace(' ') Svelte: PARAMETER - PsiElement(CODE_FRAGMENT)('a') + PsiElement(CODE_FRAGMENT)(' a') PsiElement(})('}') PsiWhiteSpace('\n ') Svelte: SCOPE @@ -94,8 +76,7 @@ Svelte Component Svelte: EXPRESSION PsiElement(CODE_FRAGMENT)('a') PsiElement(})('}') - PsiElement()('') - PsiWhiteSpace('\n ') + PsiElement()('\n ') Svelte: EACH_BLOCK_CLOSING_TAG PsiElement({/)('{/') PsiElement(each)('each') diff --git a/src/test/resources/dev/blachut/svelte/lang/Whitespace.tokens b/src/test/resources/dev/blachut/svelte/lang/Whitespace.tokens index 11940775..a4e520dc 100644 --- a/src/test/resources/dev/blachut/svelte/lang/Whitespace.tokens +++ b/src/test/resources/dev/blachut/svelte/lang/Whitespace.tokens @@ -1,44 +1,29 @@ {# ('{ #') if ('if') -WHITE_SPACE (' ') -CODE_FRAGMENT ('a') +CODE_FRAGMENT (' a') } ('}') WHITE_SPACE ('\n ') - ('

      First') -WHITE_SPACE (' ') - ('branch

      ') -WHITE_SPACE ('\n') + ('

      First branch

      \n') {: ('{:') BAD_CHARACTER ('elseif') -WHITE_SPACE (' ') -CODE_FRAGMENT ('b') +CODE_FRAGMENT (' b') } ('}') WHITE_SPACE ('\n ') - ('

      Second') -WHITE_SPACE (' ') - ('branch

      ') -WHITE_SPACE ('\n') + ('

      Second branch

      \n') {: ('{ :') else ('else') } ('}') WHITE_SPACE ('\n ') - ('

      Third') -WHITE_SPACE (' ') - ('branch

      ') -WHITE_SPACE ('\n') + ('

      Third branch

      \n') {/ ('{ /') if ('if') } ('}') WHITE_SPACE ('\n') {# ('{#') BAD_CHARACTER ('eachassets') -WHITE_SPACE (' ') -as ('as') -WHITE_SPACE (' ') -CODE_FRAGMENT ('asset') +CODE_FRAGMENT (' as asset') , (',') -CODE_FRAGMENT ('i') -WHITE_SPACE (' ') +CODE_FRAGMENT ('i ') } ('}') {/ ('{/') BAD_CHARACTER (' ') diff --git a/src/test/resources/dev/blachut/svelte/lang/Whitespace.txt b/src/test/resources/dev/blachut/svelte/lang/Whitespace.txt index 5a6d213c..007db081 100644 --- a/src/test/resources/dev/blachut/svelte/lang/Whitespace.txt +++ b/src/test/resources/dev/blachut/svelte/lang/Whitespace.txt @@ -4,53 +4,38 @@ Svelte Component Svelte: IF_BLOCK_OPENING_TAG PsiElement({#)('{ #') PsiElement(if)('if') - PsiWhiteSpace(' ') Svelte: EXPRESSION - PsiElement(CODE_FRAGMENT)('a') + PsiElement(CODE_FRAGMENT)(' a') PsiElement(})('}') PsiWhiteSpace('\n ') Svelte: SCOPE - PsiElement()('

      First') - PsiWhiteSpace(' ') - PsiElement()('branch

      ') + PsiElement()('

      First branch

      \n') PsiErrorElement:'{/' expected, got '{:' - PsiWhiteSpace('\n') PsiElement({:)('{:') PsiElement(DUMMY_BLOCK) PsiElement(BAD_CHARACTER)('elseif') - PsiWhiteSpace(' ') - PsiElement(CODE_FRAGMENT)('b') + PsiElement(CODE_FRAGMENT)(' b') PsiElement(})('}') PsiWhiteSpace('\n ') - PsiElement()('

      Second') - PsiWhiteSpace(' ') - PsiElement()('branch

      ') - PsiWhiteSpace('\n') + PsiElement()('

      Second branch

      \n') PsiElement({:)('{ :') PsiElement(else)('else') PsiElement(})('}') PsiWhiteSpace('\n ') - PsiElement()('

      Third') - PsiWhiteSpace(' ') - PsiElement()('branch

      ') - PsiElement(DUMMY_BLOCK) - PsiWhiteSpace('\n') + PsiElement()('

      Third branch

      \n') PsiElement({/)('{ /') PsiElement(if)('if') + PsiElement(DUMMY_BLOCK) PsiElement(})('}') PsiWhiteSpace('\n') PsiElement({#)('{#') PsiElement(BAD_CHARACTER)('eachassets') - PsiWhiteSpace(' ') - PsiElement(as)('as') - PsiWhiteSpace(' ') - PsiElement(CODE_FRAGMENT)('asset') + PsiElement(CODE_FRAGMENT)(' as asset') PsiElement(,)(',') - PsiElement(CODE_FRAGMENT)('i') - PsiWhiteSpace(' ') + PsiElement(CODE_FRAGMENT)('i ') PsiElement(})('}') - PsiElement({/)('{/') - PsiElement(BAD_CHARACTER)(' ') - PsiElement(each)('each') + PsiElement({/)('{/') + PsiElement(BAD_CHARACTER)(' ') + PsiElement(each)('each') PsiElement(})('}') \ No newline at end of file diff --git a/src/test/resources/dev/blachut/svelte/lang/format/IndentedExpressions.svelte b/src/test/resources/dev/blachut/svelte/lang/format/IndentedExpressions.svelte new file mode 100644 index 00000000..7681eafc --- /dev/null +++ b/src/test/resources/dev/blachut/svelte/lang/format/IndentedExpressions.svelte @@ -0,0 +1,9 @@ +
      +{@html 'hello'} +{ @html 'unescaped'} +{@debug x } +{ @debug x} +{@ html 'unescaped'} +{@ debug x } +{@unknown x} +
      diff --git a/src/test/resources/dev/blachut/svelte/lang/format/IndentedExpressions_after.svelte b/src/test/resources/dev/blachut/svelte/lang/format/IndentedExpressions_after.svelte new file mode 100644 index 00000000..f9d46f3b --- /dev/null +++ b/src/test/resources/dev/blachut/svelte/lang/format/IndentedExpressions_after.svelte @@ -0,0 +1,9 @@ +
      + {@html 'hello'} + { @html 'unescaped'} + {@debug x } + { @debug x} + {@ html 'unescaped'} + {@ debug x } + {@unknown x} +
      diff --git a/src/test/resources/dev/blachut/svelte/lang/format/OneLineBlock.svelte b/src/test/resources/dev/blachut/svelte/lang/format/OneLineBlock.svelte index 4b4603b4..1df55fb4 100644 --- a/src/test/resources/dev/blachut/svelte/lang/format/OneLineBlock.svelte +++ b/src/test/resources/dev/blachut/svelte/lang/format/OneLineBlock.svelte @@ -1 +1,5 @@ {#if x}
      Test
      {/if} + +
      + {1}
      {2} +
      diff --git a/src/test/resources/dev/blachut/svelte/lang/format/OneLineBlock_after.svelte b/src/test/resources/dev/blachut/svelte/lang/format/OneLineBlock_after.svelte index 4b4603b4..1df55fb4 100644 --- a/src/test/resources/dev/blachut/svelte/lang/format/OneLineBlock_after.svelte +++ b/src/test/resources/dev/blachut/svelte/lang/format/OneLineBlock_after.svelte @@ -1 +1,5 @@ {#if x}
      Test
      {/if} + +
      + {1}
      {2} +