())
+ }
+}
diff --git a/src/test/java/dev/blachut/svelte/lang/editor/SvelteEditorTest.kt b/src/test/java/dev/blachut/svelte/lang/editor/SvelteEditorTest.kt
index 8f64b9e6..d2405883 100644
--- a/src/test/java/dev/blachut/svelte/lang/editor/SvelteEditorTest.kt
+++ b/src/test/java/dev/blachut/svelte/lang/editor/SvelteEditorTest.kt
@@ -55,10 +55,22 @@ class SvelteEditorTest : BasePlatformTestCase() {
}
fun testFoldingSvelteTag() {
- myFixture.testFoldingWithCollapseStatus(testDataPath + "/" + basePath + "/" + getTestName(false) + ".svelte")
+ doTestFolding()
+ }
+
+ fun testFoldingEmptySvelteTag() {
+ doTestFolding()
+ }
+
+ fun testFoldingSvelteTagInHtmlTag() {
+ doTestFolding()
}
fun testFoldingEditorFold() {
+ doTestFolding()
+ }
+
+ private fun doTestFolding() {
myFixture.testFoldingWithCollapseStatus(testDataPath + "/" + basePath + "/" + getTestName(false) + ".svelte")
}
}
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 0ed1cd55..2692acf3 100644
--- a/src/test/java/dev/blachut/svelte/lang/format/SvelteFormatterTest.kt
+++ b/src/test/java/dev/blachut/svelte/lang/format/SvelteFormatterTest.kt
@@ -12,9 +12,15 @@ class SvelteFormatterTest : FormatterTestCase() {
}
fun testNoSvelteBlocks() = doTest()
- fun testScriptContents() = doTest()
fun testNestedBlocks() = doTest()
fun testNestedBlocksFlat() = doTest()
fun testIndentedExpressions() = doTest()
fun testOneLineBlock() = doTest()
+
+ fun testScriptContents() = doTest()
+ fun testScriptContentsSingleLine() = doTest()
+ fun testScriptStyleEmpty() = doTest()
+
+ fun testMultilineExpression() = doTest()
+ fun todoMultilineProp() = doTest()
}
diff --git a/src/test/java/dev/blachut/svelte/lang/parsing/html/SvelteHtmlParserTest.kt b/src/test/java/dev/blachut/svelte/lang/parsing/html/SvelteHtmlParserTest.kt
index 6399021f..f893b9fe 100644
--- a/src/test/java/dev/blachut/svelte/lang/parsing/html/SvelteHtmlParserTest.kt
+++ b/src/test/java/dev/blachut/svelte/lang/parsing/html/SvelteHtmlParserTest.kt
@@ -74,7 +74,6 @@ class SvelteHtmlParserTest : ParsingTestCase(
fun testAttributeSpread() = doTest()
fun testAttributeUnquoted() = doTest()
- // TODO Support await...catch blocks
fun testBlockAwaitCatch() = doTest()
fun testBlockAwaitThenThenThen() = doTest()
fun testBlockEachAmbiguousAs() = doTest()
diff --git a/src/test/resources/dev/blachut/svelte/lang/editor/FoldingEmptySvelteTag.svelte b/src/test/resources/dev/blachut/svelte/lang/editor/FoldingEmptySvelteTag.svelte
new file mode 100644
index 00000000..a8a17124
--- /dev/null
+++ b/src/test/resources/dev/blachut/svelte/lang/editor/FoldingEmptySvelteTag.svelte
@@ -0,0 +1,5 @@
+{#if name}
+ >
+ {name}
+
>
+{:else}{/if}
diff --git a/src/test/resources/dev/blachut/svelte/lang/editor/FoldingSvelteTagInHtmlTag.svelte b/src/test/resources/dev/blachut/svelte/lang/editor/FoldingSvelteTagInHtmlTag.svelte
new file mode 100644
index 00000000..45cbad87
--- /dev/null
+++ b/src/test/resources/dev/blachut/svelte/lang/editor/FoldingSvelteTagInHtmlTag.svelte
@@ -0,0 +1,5 @@
+>
+ {#if test}
+ {test}
+ {/if}
+
>
diff --git a/src/test/resources/dev/blachut/svelte/lang/format/EnterInEmptyBlock.svelte b/src/test/resources/dev/blachut/svelte/lang/format/EnterInEmptyBlock.svelte
deleted file mode 100644
index 3f931b1d..00000000
--- a/src/test/resources/dev/blachut/svelte/lang/format/EnterInEmptyBlock.svelte
+++ /dev/null
@@ -1 +0,0 @@
-{#if x}{/if}
diff --git a/src/test/resources/dev/blachut/svelte/lang/format/EnterInEmptyBlock_after.svelte b/src/test/resources/dev/blachut/svelte/lang/format/EnterInEmptyBlock_after.svelte
deleted file mode 100644
index 25157421..00000000
--- a/src/test/resources/dev/blachut/svelte/lang/format/EnterInEmptyBlock_after.svelte
+++ /dev/null
@@ -1,3 +0,0 @@
-{#if x}
-
-{/if}
diff --git a/src/test/resources/dev/blachut/svelte/lang/format/MultilineExpression.svelte b/src/test/resources/dev/blachut/svelte/lang/format/MultilineExpression.svelte
new file mode 100644
index 00000000..a7ed11ef
--- /dev/null
+++ b/src/test/resources/dev/blachut/svelte/lang/format/MultilineExpression.svelte
@@ -0,0 +1,4 @@
+{@debug {
+field: true,
+ another: "hello"
+ }}
diff --git a/src/test/resources/dev/blachut/svelte/lang/format/MultilineExpression_after.svelte b/src/test/resources/dev/blachut/svelte/lang/format/MultilineExpression_after.svelte
new file mode 100644
index 00000000..cf6cb7df
--- /dev/null
+++ b/src/test/resources/dev/blachut/svelte/lang/format/MultilineExpression_after.svelte
@@ -0,0 +1,4 @@
+{@debug {
+ field: true,
+ another: "hello"
+}}
diff --git a/src/test/resources/dev/blachut/svelte/lang/format/MultilineProp.svelte b/src/test/resources/dev/blachut/svelte/lang/format/MultilineProp.svelte
new file mode 100644
index 00000000..cdc8d1c9
--- /dev/null
+++ b/src/test/resources/dev/blachut/svelte/lang/format/MultilineProp.svelte
@@ -0,0 +1,6 @@
+
diff --git a/src/test/resources/dev/blachut/svelte/lang/format/MultilineProp_after.svelte b/src/test/resources/dev/blachut/svelte/lang/format/MultilineProp_after.svelte
new file mode 100644
index 00000000..5c9640c9
--- /dev/null
+++ b/src/test/resources/dev/blachut/svelte/lang/format/MultilineProp_after.svelte
@@ -0,0 +1,6 @@
+
diff --git a/src/test/resources/dev/blachut/svelte/lang/format/ScriptContentsSingleLine.svelte b/src/test/resources/dev/blachut/svelte/lang/format/ScriptContentsSingleLine.svelte
new file mode 100644
index 00000000..1d730f4d
--- /dev/null
+++ b/src/test/resources/dev/blachut/svelte/lang/format/ScriptContentsSingleLine.svelte
@@ -0,0 +1,2 @@
+
diff --git a/src/test/resources/dev/blachut/svelte/lang/format/ScriptContentsSingleLine_after.svelte b/src/test/resources/dev/blachut/svelte/lang/format/ScriptContentsSingleLine_after.svelte
new file mode 100644
index 00000000..13b84177
--- /dev/null
+++ b/src/test/resources/dev/blachut/svelte/lang/format/ScriptContentsSingleLine_after.svelte
@@ -0,0 +1,3 @@
+
diff --git a/src/test/resources/dev/blachut/svelte/lang/format/ScriptStyleEmpty.svelte b/src/test/resources/dev/blachut/svelte/lang/format/ScriptStyleEmpty.svelte
new file mode 100644
index 00000000..d28d7a20
--- /dev/null
+++ b/src/test/resources/dev/blachut/svelte/lang/format/ScriptStyleEmpty.svelte
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/src/test/resources/dev/blachut/svelte/lang/format/ScriptStyleEmpty_after.svelte b/src/test/resources/dev/blachut/svelte/lang/format/ScriptStyleEmpty_after.svelte
new file mode 100644
index 00000000..d28d7a20
--- /dev/null
+++ b/src/test/resources/dev/blachut/svelte/lang/format/ScriptStyleEmpty_after.svelte
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/src/test/resources/dev/blachut/svelte/lang/parsing/html/lexer/BlockWhitespace.tokens b/src/test/resources/dev/blachut/svelte/lang/parsing/html/lexer/BlockWhitespace.tokens
index 3148ddbe..936986a2 100644
--- a/src/test/resources/dev/blachut/svelte/lang/parsing/html/lexer/BlockWhitespace.tokens
+++ b/src/test/resources/dev/blachut/svelte/lang/parsing/html/lexer/BlockWhitespace.tokens
@@ -1,7 +1,6 @@
START_MUSTACHE ('{')
JS:SHARP ('#')
-JS:EACH_KEYWORD ('each')
-JS:IDENTIFIER ('assets')
+JS:IDENTIFIER ('eachassets')
WHITE_SPACE (' ')
JS:AS_KEYWORD ('as')
WHITE_SPACE (' ')
@@ -39,8 +38,7 @@ XML_WHITE_SPACE ('\n')
START_MUSTACHE ('{')
TAG_WHITE_SPACE (' ')
JS:COLON (':')
-JS:ELSE_KEYWORD ('else')
-JS:IF_KEYWORD ('if')
+JS:IDENTIFIER ('elseif')
WHITE_SPACE (' ')
JS:IDENTIFIER ('b')
WHITE_SPACE (' ')
diff --git a/src/test/resources/dev/blachut/svelte/lang/parsing/html/parser/BlockAwaitCatch.txt b/src/test/resources/dev/blachut/svelte/lang/parsing/html/parser/BlockAwaitCatch.txt
index 7c6b4ae6..62552da4 100644
--- a/src/test/resources/dev/blachut/svelte/lang/parsing/html/parser/BlockAwaitCatch.txt
+++ b/src/test/resources/dev/blachut/svelte/lang/parsing/html/parser/BlockAwaitCatch.txt
@@ -13,10 +13,9 @@ SvelteHtmlFile: BlockAwaitCatch.svelte
PsiElement(JS:IDENTIFIER)('promise')
PsiWhiteSpace(' ')
PsiElement(JS:CATCH_KEYWORD)('catch')
- PsiErrorElement:unexpected token
-
PsiWhiteSpace(' ')
- PsiElement(JS:IDENTIFIER)('error')
+ SvelteJSParameter
+ PsiElement(JS:IDENTIFIER)('error')
PsiElement(JS:RBRACE)('}')
SvelteFragment
@@ -24,4 +23,4 @@ SvelteHtmlFile: BlockAwaitCatch.svelte
PsiElement(JS:LBRACE)('{')
PsiElement(JS:DIV)('/')
PsiElement(JS:AWAIT_KEYWORD)('await')
- PsiElement(JS:RBRACE)('}')
\ No newline at end of file
+ PsiElement(JS:RBRACE)('}')
diff --git a/src/test/resources/dev/blachut/svelte/lang/parsing/html/parser/BlockEachAsAsAsAs.txt b/src/test/resources/dev/blachut/svelte/lang/parsing/html/parser/BlockEachAsAsAsAs.txt
index d6196891..96c4c1bc 100644
--- a/src/test/resources/dev/blachut/svelte/lang/parsing/html/parser/BlockEachAsAsAsAs.txt
+++ b/src/test/resources/dev/blachut/svelte/lang/parsing/html/parser/BlockEachAsAsAsAs.txt
@@ -17,10 +17,11 @@ SvelteHtmlFile: BlockEachAsAsAsAs.svelte
SvelteJSParameter
PsiElement(JS:AS_KEYWORD)('as')
PsiWhiteSpace(' ')
- PsiElement(JS:LPAR)('(')
- JSReferenceExpression
- PsiElement(JS:AS_KEYWORD)('as')
- PsiElement(JS:RPAR)(')')
+ SvelteTagDependentExpression
+ PsiElement(JS:LPAR)('(')
+ JSReferenceExpression
+ PsiElement(JS:AS_KEYWORD)('as')
+ PsiElement(JS:RPAR)(')')
PsiElement(JS:RBRACE)('}')
SvelteFragment
@@ -28,4 +29,4 @@ SvelteHtmlFile: BlockEachAsAsAsAs.svelte
PsiElement(JS:LBRACE)('{')
PsiElement(JS:DIV)('/')
PsiElement(JS:EACH_KEYWORD)('each')
- PsiElement(JS:RBRACE)('}')
\ No newline at end of file
+ PsiElement(JS:RBRACE)('}')
diff --git a/src/test/resources/dev/blachut/svelte/lang/parsing/html/parser/BlockNesting.txt b/src/test/resources/dev/blachut/svelte/lang/parsing/html/parser/BlockNesting.txt
index ecd23c32..2708bc25 100644
--- a/src/test/resources/dev/blachut/svelte/lang/parsing/html/parser/BlockNesting.txt
+++ b/src/test/resources/dev/blachut/svelte/lang/parsing/html/parser/BlockNesting.txt
@@ -50,7 +50,7 @@ SvelteHtmlFile: BlockNesting.svelte
SvelteJS: CONTENT_EXPRESSION
PsiElement(JS:LBRACE)('{')
PsiElement(JS:AT)('@')
- PsiElement(JS:IDENTIFIER)('html')
+ PsiElement(JS:HTML_KEYWORD)('html')
PsiWhiteSpace(' ')
JSReferenceExpression
PsiElement(JS:IDENTIFIER)('x')
@@ -79,7 +79,7 @@ SvelteHtmlFile: BlockNesting.svelte
SvelteJS: CONTENT_EXPRESSION
PsiElement(JS:LBRACE)('{')
PsiElement(JS:AT)('@')
- PsiElement(JS:IDENTIFIER)('debug')
+ PsiElement(JS:DEBUG_KEYWORD)('debug')
PsiWhiteSpace(' ')
JSReferenceExpression
PsiElement(JS:IDENTIFIER)('name')
@@ -139,4 +139,4 @@ SvelteHtmlFile: BlockNesting.svelte
PsiWhiteSpace('\n')
XmlToken:XML_END_TAG_START('')
XmlToken:XML_NAME('ul')
- XmlToken:XML_TAG_END('>')
\ No newline at end of file
+ XmlToken:XML_TAG_END('>')
diff --git a/src/test/resources/dev/blachut/svelte/lang/parsing/html/parser/BlockWhitespace.txt b/src/test/resources/dev/blachut/svelte/lang/parsing/html/parser/BlockWhitespace.txt
index 13689902..648cc418 100644
--- a/src/test/resources/dev/blachut/svelte/lang/parsing/html/parser/BlockWhitespace.txt
+++ b/src/test/resources/dev/blachut/svelte/lang/parsing/html/parser/BlockWhitespace.txt
@@ -2,46 +2,41 @@ SvelteHtmlFile: BlockWhitespace.svelte
PsiElement(HTML_DOCUMENT)
PsiElement(XML_PROLOG)
- SvelteEachBlock
- SvelteEachPrimaryBranch
- SvelteInitialTag(EACH_START)
- PsiElement(JS:LBRACE)('{')
- PsiElement(JS:SHARP)('#')
- PsiElement(JS:EACH_KEYWORD)('eachassets')
- PsiWhiteSpace(' ')
- JSReferenceExpression
- PsiElement(JS:AS_KEYWORD)('as')
- PsiErrorElement:as expected
-
- PsiWhiteSpace(' ')
- SvelteJSParameter
- PsiElement(JS:IDENTIFIER)('asset')
- PsiElement(JS:COMMA)(',')
- SvelteJSParameter
- PsiElement(JS:IDENTIFIER)('i')
- PsiWhiteSpace(' ')
- PsiElement(JS:LPAR)('(')
- PsiWhiteSpace(' ')
- JSReferenceExpression
- JSReferenceExpression
- PsiElement(JS:IDENTIFIER)('asset')
- PsiElement(JS:DOT)('.')
- PsiElement(JS:IDENTIFIER)('id')
- PsiWhiteSpace(' ')
- PsiElement(JS:RPAR)(')')
- PsiWhiteSpace(' ')
- PsiElement(JS:RBRACE)('}')
- SvelteFragment
-
- SvelteEndTag(EACH_END)
- PsiElement(JS:LBRACE)('{')
- PsiElement(JS:DIV)('/')
- PsiErrorElement:whitespace is not allowed after /
-
- PsiWhiteSpace(' ')
- PsiElement(JS:EACH_KEYWORD)('each')
- PsiElement(CODE_FRAGMENT)(' ')
- PsiElement(JS:RBRACE)('}')
+ SvelteJS: CONTENT_EXPRESSION
+ PsiElement(JS:LBRACE)('{')
+ PsiErrorElement:expression expected
+
+ PsiElement(JS:SHARP)('#')
+ PsiErrorElement:unexpected token
+
+ PsiElement(JS:IDENTIFIER)('eachassets')
+ PsiWhiteSpace(' ')
+ PsiElement(JS:AS_KEYWORD)('as')
+ PsiWhiteSpace(' ')
+ PsiElement(JS:IDENTIFIER)('asset')
+ PsiElement(JS:COMMA)(',')
+ PsiElement(JS:IDENTIFIER)('i')
+ PsiWhiteSpace(' ')
+ PsiElement(JS:LPAR)('(')
+ PsiWhiteSpace(' ')
+ PsiElement(JS:IDENTIFIER)('asset')
+ PsiElement(JS:DOT)('.')
+ PsiElement(JS:IDENTIFIER)('id')
+ PsiWhiteSpace(' ')
+ PsiElement(JS:RPAR)(')')
+ PsiWhiteSpace(' ')
+ PsiElement(JS:RBRACE)('}')
+ PsiErrorElement:Unexpected end tag
+
+ SvelteEndTag(EACH_END)
+ PsiElement(JS:LBRACE)('{')
+ PsiElement(JS:DIV)('/')
+ PsiErrorElement:whitespace is not allowed after /
+
+ PsiWhiteSpace(' ')
+ PsiElement(JS:EACH_KEYWORD)('each')
+ PsiElement(CODE_FRAGMENT)(' ')
+ PsiElement(JS:RBRACE)('}')
PsiWhiteSpace('\n\n')
SvelteIfBlock
SvelteIfPrimaryBranch
@@ -59,19 +54,19 @@ SvelteHtmlFile: BlockWhitespace.svelte
PsiWhiteSpace('\n ')
XmlToken:XML_DATA_CHARACTERS('First')
PsiWhiteSpace('\n')
- SvelteIfElseBranch
- SvelteInitialTag(ELSE_CLAUSE)
- PsiElement(JS:LBRACE)('{')
- PsiWhiteSpace(' ')
- PsiElement(JS:COLON)(':')
- PsiElement(JS:IDENTIFIER)('elseif')
- PsiWhiteSpace(' ')
- PsiElement(JS:IDENTIFIER)('b')
- PsiErrorElement:unexpected token
-
- PsiWhiteSpace(' ')
- PsiElement(JS:RBRACE)('}')
- SvelteFragment
+ SvelteJS: CONTENT_EXPRESSION
+ PsiElement(JS:LBRACE)('{')
+ PsiErrorElement:expression expected
+
+ PsiWhiteSpace(' ')
+ PsiElement(JS:COLON)(':')
+ PsiErrorElement:unexpected token
+
+ PsiElement(JS:IDENTIFIER)('elseif')
+ PsiWhiteSpace(' ')
+ PsiElement(JS:IDENTIFIER)('b')
+ PsiWhiteSpace(' ')
+ PsiElement(JS:RBRACE)('}')
PsiWhiteSpace('\n ')
XmlToken:XML_DATA_CHARACTERS('Second')
PsiWhiteSpace('\n')
@@ -96,4 +91,4 @@ SvelteHtmlFile: BlockWhitespace.svelte
PsiElement(JS:DIV)('/')
PsiElement(JS:IF_KEYWORD)('if')
PsiElement(CODE_FRAGMENT)(' ')
- PsiElement(JS:RBRACE)('}')
\ No newline at end of file
+ PsiElement(JS:RBRACE)('}')
diff --git a/src/test/resources/dev/blachut/svelte/lang/parsing/html/parser/Expression.txt b/src/test/resources/dev/blachut/svelte/lang/parsing/html/parser/Expression.txt
index 62cd82ce..b247b97e 100644
--- a/src/test/resources/dev/blachut/svelte/lang/parsing/html/parser/Expression.txt
+++ b/src/test/resources/dev/blachut/svelte/lang/parsing/html/parser/Expression.txt
@@ -5,7 +5,7 @@ SvelteHtmlFile: Expression.svelte
SvelteJS: CONTENT_EXPRESSION
PsiElement(JS:LBRACE)('{')
PsiElement(JS:AT)('@')
- PsiElement(JS:IDENTIFIER)('html')
+ PsiElement(JS:HTML_KEYWORD)('html')
PsiWhiteSpace(' ')
JSLiteralExpression
PsiElement(JS:STRING_LITERAL)(''hello'')
@@ -15,7 +15,7 @@ SvelteHtmlFile: Expression.svelte
PsiElement(JS:LBRACE)('{')
PsiWhiteSpace(' ')
PsiElement(JS:AT)('@')
- PsiElement(JS:IDENTIFIER)('html')
+ PsiElement(JS:HTML_KEYWORD)('html')
PsiWhiteSpace(' ')
JSLiteralExpression
PsiElement(JS:STRING_LITERAL)(''hello'')
@@ -28,7 +28,7 @@ SvelteHtmlFile: Expression.svelte
PsiErrorElement:whitespace is not allowed after @
PsiWhiteSpace(' ')
- PsiElement(JS:IDENTIFIER)('html')
+ PsiElement(JS:HTML_KEYWORD)('html')
PsiWhiteSpace(' ')
JSLiteralExpression
PsiElement(JS:STRING_LITERAL)(''hello'')
@@ -37,7 +37,7 @@ SvelteHtmlFile: Expression.svelte
SvelteJS: CONTENT_EXPRESSION
PsiElement(JS:LBRACE)('{')
PsiElement(JS:AT)('@')
- PsiElement(JS:IDENTIFIER)('debug')
+ PsiElement(JS:DEBUG_KEYWORD)('debug')
PsiWhiteSpace(' ')
JSReferenceExpression
PsiElement(JS:IDENTIFIER)('x')
@@ -47,7 +47,7 @@ SvelteHtmlFile: Expression.svelte
PsiElement(JS:LBRACE)('{')
PsiWhiteSpace(' ')
PsiElement(JS:AT)('@')
- PsiElement(JS:IDENTIFIER)('debug')
+ PsiElement(JS:DEBUG_KEYWORD)('debug')
PsiWhiteSpace(' ')
JSReferenceExpression
PsiElement(JS:IDENTIFIER)('x')
@@ -60,7 +60,7 @@ SvelteHtmlFile: Expression.svelte
PsiErrorElement:whitespace is not allowed after @
PsiWhiteSpace(' ')
- PsiElement(JS:IDENTIFIER)('debug')
+ PsiElement(JS:DEBUG_KEYWORD)('debug')
PsiWhiteSpace(' ')
JSReferenceExpression
PsiElement(JS:IDENTIFIER)('x')
@@ -74,4 +74,4 @@ SvelteHtmlFile: Expression.svelte
PsiWhiteSpace(' ')
JSReferenceExpression
PsiElement(JS:IDENTIFIER)('x')
- PsiElement(JS:RBRACE)('}')
\ No newline at end of file
+ PsiElement(JS:RBRACE)('}')