ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / extensions / html-language-features / server / src / test / embedded.test.ts 167 строк · изменён 14 нояб., 04:52
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
import { suite, test } from 'node:test' ;
import assert from 'node:assert/strict' ;
import * as embeddedSupport from '../modes/embeddedSupport.js' ;
import { getLanguageService } from 'vscode-html-languageservice' ;
import { TextDocument } from '../modes/languageModes.js' ;
suite ( 'HTML Embedded Support' , ( ) => {
const htmlLanguageService = getLanguageService ( ) ;
function assertLanguageId ( value: expectedLanguageId
offset value
value value offset value offset
document TextDocument value
position document offset
docRegions embeddedSupport htmlLanguageService document
languageId docRegions position
assert languageId expectedLanguageId
value languageId expectedContent
document TextDocument value
docRegions embeddedSupport htmlLanguageService document
content docRegions languageId
assert content expectedContent
value languageId expectedContents
document TextDocument value
docRegions embeddedSupport htmlLanguageService document
contents docRegions languageId content content
assert contents expectedContents
string
,
:
string
|
undefined
)
:
void
{
const
=
.
indexOf
(
'|'
)
;
=
.
substr
(
0
,
)
+
.
substr
(
+
1
)
;
const
=
.
create
(
'test://test/test.html'
,
'html'
,
0
,
)
;
const
=
.
positionAt
(
)
;
const
=
.
getDocumentRegions
(
,
)
;
const
=
.
getLanguageAtPosition
(
)
;
.
strictEqual
(
,
)
;
}
function
assertEmbeddedLanguageContent
(
:
string
,
:
string
,
:
string
)
:
void
{
const
=
.
create
(
'test://test/test.html'
,
'html'
,
0
,
)
;
const
=
.
getDocumentRegions
(
,
)
;
const
=
.
getEmbeddedDocument
(
)
;
.
strictEqual
(
.
getText
(
)
,
)
;
}
function
assertEmbeddedLanguageContents
(
:
string
,
:
string
,
:
string
[
]
)
:
void
{
const
=
.
create
(
'test://test/test.html'
,
'html'
,
0
,
)
;
const
=
.
getDocumentRegions
(
,
)
;
const
=
.
getEmbeddedDocuments
(
)
.
map
(
=>
.
getText
(
)
)
;
.
deepStrictEqual
(
,
)
;
}
test
(
'Styles'
,
function
(
)
:
any
{
assertLanguageId
(
'|<html><style>foo { }</style></html>'
,
'html'
)
;
assertLanguageId
(
'<html|><style>foo { }</style></html>'
,
'html'
)
;
assertLanguageId
(
'<html><st|yle>foo { }</style></html>'
,
'html'
)
;
assertLanguageId
(
'<html><style>|foo { }</style></html>'
,
'css'
)
;
assertLanguageId
(
'<html><style>foo| { }</style></html>'
,
'css'
)
;
assertLanguageId
(
'<html><style>foo { }|</style></html>'
,
'css'
)
;
assertLanguageId
(
'<html><style>foo { }</sty|le></html>'
,
'html'
)
;
}
)
;
test
(
'Styles - Incomplete HTML'
,
function
(
)
:
any
{
assertLanguageId
(
'|<html><style>foo { }'
,
'html'
)
;
assertLanguageId
(
'<html><style>fo|o { }'
,
'css'
)
;
assertLanguageId
(
'<html><style>foo { }|'
,
'css'
)
;
}
)
;
test
(
'Style in attribute'
,
function
(
)
:
any
{
assertLanguageId
(
'<div id="xy" |style="color: red"/>'
,
'html'
)
;
assertLanguageId
(
'<div id="xy" styl|e="color: red"/>'
,
'html'
)
;
assertLanguageId
(
'<div id="xy" style=|"color: red"/>'
,
'html'
)
;
assertLanguageId
(
'<div id="xy" style="|color: red"/>'
,
'css'
)
;
assertLanguageId
(
'<div id="xy" style="color|: red"/>'
,
'css'
)
;
assertLanguageId
(
'<div id="xy" style="color: red|"/>'
,
'css'
)
;
assertLanguageId
(
'<div id="xy" style="color: red"|/>'
,
'html'
)
;
assertLanguageId
(
'<div id="xy" style=\'color: r|ed\'/>'
,
'css'
)
;
assertLanguageId
(
'<div id="xy" style|=color:red/>'
,
'html'
)
;
assertLanguageId
(
'<div id="xy" style=|color:red/>'
,
'css'
)
;
assertLanguageId
(
'<div id="xy" style=color:r|ed/>'
,
'css'
)
;
assertLanguageId
(
'<div id="xy" style=color:red|/>'
,
'css'
)
;
assertLanguageId
(
'<div id="xy" style=color:red/|>'
,
'html'
)
;
}
)
;
test
(
'Style content'
,
function
(
)
:
any
{
assertEmbeddedLanguageContent
(
'<html><style>foo { }</style></html>'
,
'css'
,
' foo { } '
)
;
assertEmbeddedLanguageContent
(
'<html><script>var i = 0;</script></html>'
,
'css'
,
' '
)
;
assertEmbeddedLanguageContent
(
'<html><style>foo { }</style>Hello<style>foo { }</style></html>'
,
'css'
,
' foo { } foo { } '
)
;
assertEmbeddedLanguageContent
(
'<html>\n <style>\n foo { } \n </style>\n</html>\n'
,
'css'
,
'\n \n foo { } \n \n\n'
)
;
assertEmbeddedLanguageContent
(
'<div style="color: red"></div>'
,
'css'
,
' __{color: red} '
)
;
assertEmbeddedLanguageContent
(
'<div style=color:red></div>'
,
'css'
,
' __{color:red} '
)
;
}
)
;
test
(
'Scripts'
,
function
(
)
:
any
{
assertLanguageId
(
'|<html><script>var i = 0;</script></html>'
,
'html'
)
;
assertLanguageId
(
'<html|><script>var i = 0;</script></html>'
,
'html'
)
;
assertLanguageId
(
'<html><scr|ipt>var i = 0;</script></html>'
,
'html'
)
;
assertLanguageId
(
'<html><script>|var i = 0;</script></html>'
,
'javascript'
)
;
assertLanguageId
(
'<html><script>var| i = 0;</script></html>'
,
'javascript'
)
;
assertLanguageId
(
'<html><script>var i = 0;|</script></html>'
,
'javascript'
)
;
assertLanguageId
(
'<html><script>var i = 0;</scr|ipt></html>'
,
'html'
)
;
assertLanguageId
(
'<script type="text/javascript">var| i = 0;</script>'
,
'javascript'
)
;
assertLanguageId
(
'<script type="text/ecmascript">var| i = 0;</script>'
,
'javascript'
)
;
assertLanguageId
(
'<script type="application/javascript">var| i = 0;</script>'
,
'javascript'
)
;
assertLanguageId
(
'<script type="application/ecmascript">var| i = 0;</script>'
,
'javascript'
)
;
assertLanguageId
(
'<script type="application/typescript">var| i = 0;</script>'
,
undefined
)
;
assertLanguageId
(
'<script type=\'text/javascript\'>var| i = 0;</script>'
,
'javascript'
)
;
}
)
;
test
(
'Scripts in attribute'
,
function
(
)
:
any
{
assertLanguageId
(
'<div |onKeyUp="foo()" onkeydown=\'bar()\'/>'
,
'html'
)
;
assertLanguageId
(
'<div onKeyUp=|"foo()" onkeydown=\'bar()\'/>'
,
'html'
)
;
assertLanguageId
(
'<div onKeyUp="|foo()" onkeydown=\'bar()\'/>'
,
'javascript'
)
;
assertLanguageId
(
'<div onKeyUp="foo(|)" onkeydown=\'bar()\'/>'
,
'javascript'
)
;
assertLanguageId
(
'<div onKeyUp="foo()|" onkeydown=\'bar()\'/>'
,
'javascript'
)
;
assertLanguageId
(
'<div onKeyUp="foo()"| onkeydown=\'bar()\'/>'
,
'html'
)
;
assertLanguageId
(
'<div onKeyUp="foo()" onkeydown=|\'bar()\'/>'
,
'html'
)
;
assertLanguageId
(
'<div onKeyUp="foo()" onkeydown=\'|bar()\'/>'
,
'javascript'
)
;
assertLanguageId
(
'<div onKeyUp="foo()" onkeydown=\'bar()|\'/>'
,
'javascript'
)
;
assertLanguageId
(
'<div onKeyUp="foo()" onkeydown=\'bar()\'|/>'
,
'html'
)
;
assertLanguageId
(
'<DIV ONKEYUP|=foo()</DIV>'
,
'html'
)
;
assertLanguageId
(
'<DIV ONKEYUP=|foo()</DIV>'
,
'javascript'
)
;
assertLanguageId
(
'<DIV ONKEYUP=f|oo()</DIV>'
,
'javascript'
)
;
assertLanguageId
(
'<DIV ONKEYUP=foo(|)</DIV>'
,
'javascript'
)
;
assertLanguageId
(
'<DIV ONKEYUP=foo()|</DIV>'
,
'javascript'
)
;
assertLanguageId
(
'<DIV ONKEYUP=foo()<|/DIV>'
,
'html'
)
;
assertLanguageId
(
'<label data-content="|Checkbox"/>'
,
'html'
)
;
assertLanguageId
(
'<label on="|Checkbox"/>'
,
'html'
)
;
}
)
;
test
(
'Script content'
,
function
(
)
:
any
{
assertEmbeddedLanguageContent
(
'<html><script>var i = 0;</script></html>'
,
'javascript'
,
' var i = 0; '
)
;
assertEmbeddedLanguageContent
(
'<script type="text/javascript">var i = 0;</script>'
,
'javascript'
,
' var i = 0; '
)
;
assertEmbeddedLanguageContent
(
'<script><!--this comment should not give error--></script>'
,
'javascript'
,
' /* this comment should not give error */ '
)
;
assertEmbeddedLanguageContent
(
'<script><!--this comment should not give error--> console.log("logging");</script>'
,
'javascript'
,
' /* this comment should not give error */ console.log("logging"); '
)
;
assertEmbeddedLanguageContent
(
'<script>var data=100; <!--this comment should not give error--> </script>'
,
'javascript'
,
' var data=100; /* this comment should not give error */ '
)
;
assertEmbeddedLanguageContent
(
'<script>/* --> */</script>'
,
'javascript'
,
' /* --> */ '
)
;
assertEmbeddedLanguageContent
(
'<script>/* --> ----------------------------- */</script>'
,
'javascript'
,
' /* --> ----------------------------- */ '
)
;
assertEmbeddedLanguageContent
(
'<script><!--commnet1-->\n<!--conment2--></script>'
,
'javascript'
,
' /* commnet1 */\n/* conment2 */ '
)
;
assertEmbeddedLanguageContent
(
'<script><!--a--> foo(); <!--b--></script>'
,
'javascript'
,
' /* a */ foo(); /* b */ '
)
;
assertEmbeddedLanguageContent
(
'<div onKeyUp="foo()" onkeydown="bar()"/>'
,
'javascript'
,
' foo(); bar(); '
)
;
assertEmbeddedLanguageContent
(
'<div onKeyUp="return"/>'
,
'javascript'
,
' return; '
)
;
assertEmbeddedLanguageContent
(
'<div onKeyUp=return\n/><script>foo();</script>'
,
'javascript'
,
' return;\n foo(); '
)
;
}
)
;
test
(
'Scripts with type module'
,
function
(
)
:
any
{
assertLanguageId
(
'<script type="module">var| i = 0;</script>'
,
'javascript'
)
;
assertLanguageId
(
'<script type=module>var| i = 0;</script>'
,
'javascript'
)
;
assertLanguageId
(
'<script type="Module">var| i = 0;</script>'
,
'javascript'
)
;
assertLanguageId
(
'<script type=MODULE>var| i = 0;</script>'
,
'javascript'
)
;
}
)
;
test
(
'Script content - module validation documents'
,
function
(
)
:
any
{
assertEmbeddedLanguageContent
(
'<script>let a = 1;</script><script type="module">let a = 2;</script>'
,
'javascript'
,
' let a = 1; let a = 2; '
)
;
assertEmbeddedLanguageContents
(
'<script>let a = 1;</script><script type="module">let a = 2;</script>'
,
'javascript'
,
[
' let a = 1; '
,
' let a = 2; \nexport {};'
]
)
;
}
)
;
test
(
'Script content - HTML escape characters'
,
function
(
)
:
any
{
assertEmbeddedLanguageContent
(
'<div style="font-family: "Arial""></div>'
,
'css'
,
' __{font-family: " Arial "} '
)
;
assertEmbeddedLanguageContent
(
'<div style="font-family: "Arial""></div>'
,
'css'
,
' __{font-family: " Arial "} '
)
;
assertEmbeddedLanguageContent
(
'<div style="font-family: "Arial""></div>'
,
'css'
,
' __{font-family: " Arial "} '
)
;
assertEmbeddedLanguageContent
(
'<div style="font-family:" Arial " "></div>'
,
'css'
,
' __{font-family: " Arial " } '
)
;
assertEmbeddedLanguageContent
(
'<div style="font-family: Arial"></div>'
,
'css'
,
' __{font-family: Arial} '
)
;
}
)
;
}
)
;