Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
b84858ba
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
b84858ba
编写于
12月 30, 2020
作者:
R
Raymond Zhao
提交者:
GitHub
12月 30, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Emmet remove dependency on vscode-html-languageservice (#113599)
上级
94facfcf
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
19 addition
and
72 deletion
+19
-72
extensions/emmet/package.json
extensions/emmet/package.json
+1
-1
extensions/emmet/src/defaultCompletionProvider.ts
extensions/emmet/src/defaultCompletionProvider.ts
+18
-38
extensions/emmet/src/imageSizeHelper.ts
extensions/emmet/src/imageSizeHelper.ts
+0
-1
extensions/emmet/src/util.ts
extensions/emmet/src/util.ts
+0
-17
extensions/emmet/yarn.lock
extensions/emmet/yarn.lock
+0
-15
未找到文件。
extensions/emmet/package.json
浏览文件 @
b84858ba
...
...
@@ -438,6 +438,6 @@
"@emmetio/math-expression"
:
"^1.0.4"
,
"image-size"
:
"^0.5.2"
,
"vscode-emmet-helper"
:
"~2.0.0"
,
"vscode-
html-languageservice"
:
"^3.0.3
"
"vscode-
languageserver-textdocument"
:
"^1.0.1
"
}
}
extensions/emmet/src/defaultCompletionProvider.ts
浏览文件 @
b84858ba
...
...
@@ -6,16 +6,14 @@
import
*
as
vscode
from
'
vscode
'
;
import
{
Node
,
Stylesheet
}
from
'
EmmetFlatNode
'
;
import
{
isValidLocationForEmmetAbbreviation
,
getSyntaxFromArgs
}
from
'
./abbreviationActions
'
;
import
{
getEmmetHelper
,
getMappingForIncludedLanguages
,
parsePartialStylesheet
,
getEmmetConfiguration
,
getEmmetMode
,
isStyleSheet
,
getFlatNode
,
allowedMimeTypesInScriptTag
,
t
rimQuotes
,
toLSTextDocument
}
from
'
./util
'
;
import
{
getLanguageService
,
TokenType
,
Range
as
LSRange
}
from
'
vscode-html-languageservice
'
;
import
{
getEmmetHelper
,
getMappingForIncludedLanguages
,
parsePartialStylesheet
,
getEmmetConfiguration
,
getEmmetMode
,
isStyleSheet
,
getFlatNode
,
allowedMimeTypesInScriptTag
,
t
oLSTextDocument
,
getHtmlFlatNode
}
from
'
./util
'
;
import
{
Range
as
LSRange
}
from
'
vscode-languageserver-textdocument
'
;
import
{
getRootNode
}
from
'
./parseDocument
'
;
export
class
DefaultCompletionItemProvider
implements
vscode
.
CompletionItemProvider
{
private
lastCompletionType
:
string
|
undefined
;
private
htmlLS
=
getLanguageService
();
public
provideCompletionItems
(
document
:
vscode
.
TextDocument
,
position
:
vscode
.
Position
,
_
:
vscode
.
CancellationToken
,
context
:
vscode
.
CompletionContext
):
Thenable
<
vscode
.
CompletionList
|
undefined
>
|
undefined
{
const
completionResult
=
this
.
provideCompletionItemsInternal
(
document
,
position
,
context
);
if
(
!
completionResult
)
{
...
...
@@ -82,19 +80,16 @@ export class DefaultCompletionItemProvider implements vscode.CompletionItemProvi
default
:
break
;
}
}
if
(
validateLocation
)
{
const
parsedLsDoc
=
this
.
htmlLS
.
parseHTMLDocument
(
lsDoc
);
const
positionOffset
=
document
.
offsetAt
(
position
);
const
node
=
parsedLsDoc
.
findNodeAt
(
positionOffset
);
if
(
node
.
tag
===
'
script
'
)
{
if
(
node
.
attributes
&&
'
type
'
in
node
.
attributes
)
{
const
rawTypeAttrValue
=
node
.
attributes
[
'
type
'
]
;
if
(
rawTypeAttrValu
e
)
{
const
typeAttrValue
=
t
rimQuotes
(
rawTypeAttrValue
);
const
emmetRootNode
=
getRootNode
(
document
,
true
);
const
foundNode
=
getHtmlFlatNode
(
document
.
getText
(),
emmetRootNode
,
positionOffset
,
false
);
if
(
foundNode
)
{
if
(
foundNode
.
name
===
'
script
'
)
{
const
typeNode
=
foundNode
.
attributes
.
find
(
attr
=>
attr
.
name
.
toString
()
===
'
type
'
)
;
if
(
typeNod
e
)
{
const
typeAttrValue
=
t
ypeNode
.
value
.
toString
(
);
if
(
typeAttrValue
===
'
application/javascript
'
||
typeAttrValue
===
'
text/javascript
'
)
{
if
(
!
getSyntaxFromArgs
({
language
:
'
javascript
'
}))
{
return
;
...
...
@@ -102,34 +97,19 @@ export class DefaultCompletionItemProvider implements vscode.CompletionItemProvi
validateLocation
=
false
;
}
}
else
if
(
allowedMimeTypesInScriptTag
.
indexOf
(
trimQuotes
(
rawTypeAttrValue
))
>
-
1
)
{
else
if
(
allowedMimeTypesInScriptTag
.
includes
(
typeAttrValue
))
{
validateLocation
=
false
;
}
}
else
{
return
;
}
}
else
{
return
;
}
}
else
if
(
node
.
tag
===
'
style
'
)
{
syntax
=
'
css
'
;
validateLocation
=
false
;
}
else
{
if
(
node
.
attributes
&&
node
.
attributes
[
'
style
'
])
{
const
scanner
=
this
.
htmlLS
.
createScanner
(
document
.
getText
(),
node
.
start
);
let
tokenType
=
scanner
.
scan
();
let
prevAttr
=
undefined
;
let
styleAttrValueRange
:
[
number
,
number
]
|
undefined
=
undefined
;
while
(
tokenType
!==
TokenType
.
EOS
&&
(
scanner
.
getTokenEnd
()
<=
positionOffset
))
{
tokenType
=
scanner
.
scan
();
if
(
tokenType
===
TokenType
.
AttributeName
)
{
prevAttr
=
scanner
.
getTokenText
();
}
else
if
(
tokenType
===
TokenType
.
AttributeValue
&&
prevAttr
===
'
style
'
)
{
styleAttrValueRange
=
[
scanner
.
getTokenOffset
(),
scanner
.
getTokenEnd
()];
}
}
if
(
prevAttr
===
'
style
'
&&
styleAttrValueRange
&&
positionOffset
>
styleAttrValueRange
[
0
]
&&
positionOffset
<
styleAttrValueRange
[
1
])
{
else
if
(
foundNode
.
name
===
'
style
'
)
{
syntax
=
'
css
'
;
validateLocation
=
false
;
}
else
{
const
styleNode
=
foundNode
.
attributes
.
find
(
attr
=>
attr
.
name
.
toString
()
===
'
style
'
);
if
(
styleNode
&&
styleNode
.
value
.
start
<=
positionOffset
&&
positionOffset
<=
styleNode
.
value
.
end
)
{
syntax
=
'
css
'
;
validateLocation
=
false
;
}
...
...
extensions/emmet/src/imageSizeHelper.ts
浏览文件 @
b84858ba
...
...
@@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/
// Based on @sergeche's work on the emmet plugin for atom
// TODO: Move to https://github.com/emmetio/image-size
import
*
as
path
from
'
path
'
;
import
*
as
http
from
'
http
'
;
...
...
extensions/emmet/src/util.ts
浏览文件 @
b84858ba
...
...
@@ -639,23 +639,6 @@ export function isStyleAttribute(currentNode: FlatNode | undefined, offset: numb
return
offset
>=
styleAttribute
.
value
.
start
&&
offset
<=
styleAttribute
.
value
.
end
;
}
export
function
trimQuotes
(
s
:
string
)
{
if
(
s
.
length
<=
1
)
{
return
s
.
replace
(
/
[
'"
]
/
,
''
);
}
if
(
s
[
0
]
===
`'`
||
s
[
0
]
===
`"`
)
{
s
=
s
.
slice
(
1
);
}
if
(
s
[
s
.
length
-
1
]
===
`'`
||
s
[
s
.
length
-
1
]
===
`"`
)
{
s
=
s
.
slice
(
0
,
-
1
);
}
return
s
;
}
export
function
isNumber
(
obj
:
any
):
obj
is
number
{
return
typeof
obj
===
'
number
'
;
}
...
...
extensions/emmet/yarn.lock
浏览文件 @
b84858ba
...
...
@@ -88,26 +88,11 @@ vscode-emmet-helper@~2.0.0:
vscode-nls "^5.0.0"
vscode-uri "^2.1.2"
vscode-html-languageservice@^3.0.3:
version "3.1.4"
resolved "https://registry.yarnpkg.com/vscode-html-languageservice/-/vscode-html-languageservice-3.1.4.tgz#0316dff77ee38dc176f40560cbf55e4f64f4f433"
integrity sha512-3M+bm+hNvwQcScVe5/ok9BXvctOiGJ4nlOkkFf+WKSDrYNkarZ/RByKOa1/iylbvZxJUPzbeziembWPe/dMvhw==
dependencies:
vscode-languageserver-textdocument "^1.0.1"
vscode-languageserver-types "3.16.0-next.2"
vscode-nls "^5.0.0"
vscode-uri "^2.1.2"
vscode-languageserver-textdocument@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/vscode-languageserver-textdocument/-/vscode-languageserver-textdocument-1.0.1.tgz#178168e87efad6171b372add1dea34f53e5d330f"
integrity sha512-UIcJDjX7IFkck7cSkNNyzIz5FyvpQfY7sdzVy+wkKN/BLaD4DQ0ppXQrKePomCxTS7RrolK1I0pey0bG9eh8dA==
vscode-languageserver-types@3.16.0-next.2:
version "3.16.0-next.2"
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.16.0-next.2.tgz#940bd15c992295a65eae8ab6b8568a1e8daa3083"
integrity sha512-QjXB7CKIfFzKbiCJC4OWC8xUncLsxo19FzGVp/ADFvvi87PlmBSCAtZI5xwGjF5qE0xkLf0jjKUn3DzmpDP52Q==
vscode-languageserver-types@^3.15.1:
version "3.15.1"
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.15.1.tgz#17be71d78d2f6236d414f0001ce1ef4d23e6b6de"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录