Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
cb994975
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
cb994975
编写于
7月 30, 2019
作者:
P
Pine
提交者:
GitHub
7月 30, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #78207 from microsoft/pine/fast-emmet
Redo emmet change. Fix #70371
上级
183deef5
99d5ff9c
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
121 addition
and
43 deletion
+121
-43
extensions/emmet/.vscode/launch.json
extensions/emmet/.vscode/launch.json
+30
-20
extensions/emmet/package.json
extensions/emmet/package.json
+4
-3
extensions/emmet/src/abbreviationActions.ts
extensions/emmet/src/abbreviationActions.ts
+1
-1
extensions/emmet/src/defaultCompletionProvider.ts
extensions/emmet/src/defaultCompletionProvider.ts
+47
-9
extensions/emmet/src/test/abbreviationAction.test.ts
extensions/emmet/src/test/abbreviationAction.test.ts
+0
-10
extensions/emmet/src/util.ts
extensions/emmet/src/util.ts
+15
-0
extensions/emmet/yarn.lock
extensions/emmet/yarn.lock
+24
-0
未找到文件。
extensions/emmet/.vscode/launch.json
浏览文件 @
cb994975
...
...
@@ -9,13 +9,23 @@
"request"
:
"launch"
,
"name"
:
"Launch Extension"
,
"runtimeExecutable"
:
"${execPath}"
,
"args"
:
[
"--extensionDevelopmentPath=${workspaceFolder}"
],
"sourceMaps"
:
true
,
"outFiles"
:
[
"${workspaceFolder}/out/**/*.js"
]
},
{
"type"
:
"extensionHost"
,
"request"
:
"launch"
,
"name"
:
"Launch Tests"
,
"runtimeExecutable"
:
"${execPath}"
,
"args"
:
[
"--extensionDevelopmentPath=${workspaceFolder}"
"--extensionDevelopmentPath=${workspaceFolder}"
,
"--extensionTestsPath=${workspaceFolder}/out/test"
,
"--disable-extensions"
,
"--skip-getting-started"
,
],
"sourceMaps"
:
true
,
"outFiles"
:
[
"${workspaceFolder}/out/**/*.js"
]
"outFiles"
:
[
"${workspaceFolder}/out/**/*.js"
]
}
]
}
extensions/emmet/package.json
浏览文件 @
cb994975
...
...
@@ -450,6 +450,7 @@
"@emmetio/html-matcher"
:
"^0.3.3"
,
"@emmetio/math-expression"
:
"^0.1.1"
,
"image-size"
:
"^0.5.2"
,
"vscode-emmet-helper"
:
"^1.2.15"
"vscode-emmet-helper"
:
"^1.2.15"
,
"vscode-html-languageservice"
:
"^3.0.3"
}
}
extensions/emmet/src/abbreviationActions.ts
浏览文件 @
cb994975
...
...
@@ -635,7 +635,7 @@ function expandAbbr(input: ExpandAbbreviationInput): string {
return
expandedText
;
}
function
getSyntaxFromArgs
(
args
:
{
[
x
:
string
]:
string
}):
string
|
undefined
{
export
function
getSyntaxFromArgs
(
args
:
{
[
x
:
string
]:
string
}):
string
|
undefined
{
const
mappedModes
=
getMappingForIncludedLanguages
();
const
language
:
string
=
args
[
'
language
'
];
const
parentMode
:
string
=
args
[
'
parentMode
'
];
...
...
extensions/emmet/src/defaultCompletionProvider.ts
浏览文件 @
cb994975
...
...
@@ -5,13 +5,16 @@
import
*
as
vscode
from
'
vscode
'
;
import
{
Node
,
Stylesheet
}
from
'
EmmetNode
'
;
import
{
isValidLocationForEmmetAbbreviation
}
from
'
./abbreviationActions
'
;
import
{
getEmmetHelper
,
getMappingForIncludedLanguages
,
parsePartialStylesheet
,
getEmmetConfiguration
,
getEmmetMode
,
isStyleSheet
,
parseDocument
,
getEmbeddedCssNodeIfAny
,
isStyleAttribute
,
getNode
}
from
'
./util
'
;
import
{
isValidLocationForEmmetAbbreviation
,
getSyntaxFromArgs
}
from
'
./abbreviationActions
'
;
import
{
getEmmetHelper
,
getMappingForIncludedLanguages
,
parsePartialStylesheet
,
getEmmetConfiguration
,
getEmmetMode
,
isStyleSheet
,
parseDocument
,
getNode
,
allowedMimeTypesInScriptTag
,
trimQuotes
}
from
'
./util
'
;
import
{
getLanguageService
,
TextDocument
,
TokenType
}
from
'
vscode-html-languageservice
'
;
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
)
{
...
...
@@ -76,19 +79,54 @@ export class DefaultCompletionItemProvider implements vscode.CompletionItemProvi
}
if
(
validateLocation
)
{
rootNode
=
parseDocument
(
document
,
false
);
currentNode
=
getNode
(
rootNode
,
position
,
true
);
if
(
isStyleAttribute
(
currentNode
,
position
))
{
const
lsDoc
=
TextDocument
.
create
(
document
.
uri
.
toString
(),
'
html
'
,
0
,
document
.
getText
());
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
(
rawTypeAttrValue
)
{
const
typeAttrValue
=
trimQuotes
(
rawTypeAttrValue
);
if
(
typeAttrValue
===
'
application/javascript
'
||
typeAttrValue
===
'
text/javascript
'
)
{
if
(
!
getSyntaxFromArgs
({
language
:
'
javascript
'
}))
{
return
;
}
else
{
validateLocation
=
false
;
}
}
else
if
(
allowedMimeTypesInScriptTag
.
indexOf
(
trimQuotes
(
rawTypeAttrValue
))
>
-
1
)
{
validateLocation
=
false
;
}
}
}
else
{
return
;
}
}
else
if
(
node
.
tag
===
'
style
'
)
{
syntax
=
'
css
'
;
validateLocation
=
false
;
}
else
{
const
embeddedCssNode
=
getEmbeddedCssNodeIfAny
(
document
,
currentNode
,
position
);
if
(
embeddedCssNode
)
{
currentNode
=
getNode
(
embeddedCssNode
,
position
,
true
);
if
(
node
.
attributes
&&
node
.
attributes
[
'
style
'
])
{
const
scanner
=
this
.
htmlLS
.
createScanner
(
document
.
getText
(),
node
.
start
);
let
tokenType
=
scanner
.
scan
();
let
prevAttr
=
undefined
;
while
(
tokenType
!==
TokenType
.
EOS
&&
(
scanner
.
getTokenEnd
()
<=
positionOffset
))
{
tokenType
=
scanner
.
scan
();
if
(
tokenType
===
TokenType
.
AttributeName
)
{
prevAttr
=
scanner
.
getTokenText
();
}
}
if
(
prevAttr
===
'
style
'
)
{
syntax
=
'
css
'
;
validateLocation
=
false
;
}
}
}
}
}
...
...
extensions/emmet/src/test/abbreviationAction.test.ts
浏览文件 @
cb994975
...
...
@@ -264,16 +264,6 @@ suite('Tests for Expand Abbreviations (HTML)', () => {
});
});
test
(
'
No expanding text in completion list inside style tag if position is not for property name (HTML)
'
,
()
=>
{
return
withRandomFileEditor
(
htmlContents
,
'
html
'
,
(
editor
,
_doc
)
=>
{
editor
.
selection
=
new
Selection
(
13
,
14
,
13
,
14
);
const
cancelSrc
=
new
CancellationTokenSource
();
const
completionPromise
=
completionProvider
.
provideCompletionItems
(
editor
.
document
,
editor
.
selection
.
active
,
cancelSrc
.
token
,
{
triggerKind
:
CompletionTriggerKind
.
Invoke
});
assert
.
equal
(
!
completionPromise
,
true
,
`Got unexpected comapletion promise instead of undefined`
);
return
Promise
.
resolve
();
});
});
test
(
'
Expand css when inside style attribute (HTML)
'
,
()
=>
{
const
styleAttributeContent
=
'
<div style="m10" class="hello"></div>
'
;
return
withRandomFileEditor
(
styleAttributeContent
,
'
html
'
,
async
(
editor
,
_doc
)
=>
{
...
...
extensions/emmet/src/util.ts
浏览文件 @
cb994975
...
...
@@ -608,3 +608,18 @@ export function isStyleAttribute(currentNode: Node | null, position: vscode.Posi
}
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
;
}
\ No newline at end of file
extensions/emmet/yarn.lock
浏览文件 @
cb994975
...
...
@@ -2478,11 +2478,35 @@ vscode-emmet-helper@^1.2.15:
jsonc-parser "^1.0.0"
vscode-languageserver-types "^3.6.0-next.1"
vscode-html-languageservice@^3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/vscode-html-languageservice/-/vscode-html-languageservice-3.0.3.tgz#0aeae18a59000e317447ea34965f72680a2140ef"
integrity sha512-U+upM3gHp3HaF3wXAnUduA6IDKcz6frWS/dTAju3cZVIyZwOLBBFElQVlLH0ycHyMzqUFrjvdv+kEyPAEWfQ/g==
dependencies:
vscode-languageserver-types "^3.15.0-next.2"
vscode-nls "^4.1.1"
vscode-uri "^2.0.3"
vscode-languageserver-types@^3.15.0-next.2:
version "3.15.0-next.2"
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.15.0-next.2.tgz#a0601332cdaafac21931f497bb080cfb8d73f254"
integrity sha512-2JkrMWWUi2rlVLSo9OFR2PIGUzdiowEM8NgNYiwLKnXTjpwpjjIrJbNNxDik7Rv4oo9KtikcFQZKXbrKilL/MQ==
vscode-languageserver-types@^3.6.0-next.1:
version "3.6.0-next.1"
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.6.0-next.1.tgz#98e488d3f87b666b4ee1a3d89f0023e246d358f3"
integrity sha512-n4G+hCgZwAhtcJSCkwJP153TLdcEBWwrIrb3Su/SpOkhmU7KjDgxaQBLA45hf+QbhB8uKQb+TVStPvbuYFHSMA==
vscode-nls@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-4.1.1.tgz#f9916b64e4947b20322defb1e676a495861f133c"
integrity sha512-4R+2UoUUU/LdnMnFjePxfLqNhBS8lrAFyX7pjb2ud/lqDkrUavFUTcG7wR0HBZFakae0Q6KLBFjMS6W93F403A==
vscode-uri@^2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-2.0.3.tgz#25e5f37f552fbee3cec7e5f80cef8469cefc6543"
integrity sha512-4D3DI3F4uRy09WNtDGD93H9q034OHImxiIcSq664Hq1Y1AScehlP3qqZyTkX/RWxeu0MRMHGkrxYqm2qlDF/aw==
vscode@1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/vscode/-/vscode-1.0.1.tgz#3d161200615fe2af1d92ddc650751159411a513b"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录