Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
baf54ef0
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,发现更多精彩内容 >>
提交
baf54ef0
编写于
6月 15, 2017
作者:
R
Ramya Achutha Rao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Collapse html,css completion provider for emmet
上级
ec959699
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
23 addition
and
49 deletion
+23
-49
extensions/emmet/src/emmetCompletionProvider.ts
extensions/emmet/src/emmetCompletionProvider.ts
+17
-34
extensions/emmet/src/extension.ts
extensions/emmet/src/extension.ts
+6
-15
未找到文件。
extensions/emmet/src/emmetCompletionProvider.ts
浏览文件 @
baf54ef0
...
...
@@ -6,12 +6,12 @@
import
*
as
vscode
from
'
vscode
'
;
import
{
expand
,
createSnippetsRegistry
}
from
'
@emmetio/expand-abbreviation
'
;
import
{
getSyntax
,
getProfile
,
extractAbbreviation
}
from
'
./util
'
;
import
{
getSyntax
,
getProfile
,
extractAbbreviation
,
isStyleSheet
}
from
'
./util
'
;
const
field
=
(
index
,
placeholder
)
=>
`
\$
{
${
index
}${
placeholder
?
'
:
'
+
placeholder
:
''
}
}`
;
const
snippetCompletionsCache
=
new
Map
<
string
,
vscode
.
CompletionItem
[]
>
();
export
abstract
class
EmmetCompletionItemProviderBase
implements
vscode
.
CompletionItemProvider
{
export
class
EmmetCompletionItemProvider
implements
vscode
.
CompletionItemProvider
{
public
provideCompletionItems
(
document
:
vscode
.
TextDocument
,
position
:
vscode
.
Position
,
token
:
vscode
.
CancellationToken
):
Thenable
<
vscode
.
CompletionList
>
{
...
...
@@ -19,15 +19,27 @@ export abstract class EmmetCompletionItemProviderBase implements vscode.Completi
return
Promise
.
resolve
(
null
);
}
let
completionItems
:
vscode
.
CompletionItem
[]
=
[];
let
syntax
=
getSyntax
(
document
);
let
currentWord
=
getCurrentWord
(
document
,
position
);
let
expandedAbbr
=
this
.
getExpandedAbbreviation
(
document
,
position
);
let
abbreviationSuggestions
=
this
.
getAbbreviationSuggestions
(
getSyntax
(
document
),
currentWord
,
(
expandedAbbr
&&
currentWord
===
expandedAbbr
.
label
));
let
completionItems
=
expandedAbbr
?
[
expandedAbbr
,
...
abbreviationSuggestions
]
:
abbreviationSuggestions
;
if
(
!
isStyleSheet
(
syntax
))
{
if
(
expandedAbbr
)
{
// In non stylesheet like syntax, this extension returns expanded abbr plus posssible abbr completions
// To differentiate between the 2, the former is given CompletionItemKind.Value so that it gets a different icon
expandedAbbr
.
kind
=
vscode
.
CompletionItemKind
.
Value
;
}
let
abbreviationSuggestions
=
this
.
getAbbreviationSuggestions
(
syntax
,
currentWord
,
(
expandedAbbr
&&
currentWord
===
expandedAbbr
.
label
));
completionItems
=
expandedAbbr
?
[
expandedAbbr
,
...
abbreviationSuggestions
]
:
abbreviationSuggestions
;
}
else
{
completionItems
=
expandedAbbr
?
[
expandedAbbr
]
:
[];
}
return
Promise
.
resolve
(
new
vscode
.
CompletionList
(
completionItems
,
true
));
}
protected
getExpandedAbbreviation
(
document
:
vscode
.
TextDocument
,
position
:
vscode
.
Position
):
vscode
.
CompletionItem
{
getExpandedAbbreviation
(
document
:
vscode
.
TextDocument
,
position
:
vscode
.
Position
):
vscode
.
CompletionItem
{
if
(
!
vscode
.
workspace
.
getConfiguration
(
'
emmet
'
)[
'
showExpandedAbbreviation
'
])
{
return
;
}
...
...
@@ -53,25 +65,6 @@ export abstract class EmmetCompletionItemProviderBase implements vscode.Completi
return
completionitem
;
}
abstract
getAbbreviationSuggestions
(
syntax
:
string
,
prefix
:
string
,
skipExactMatch
:
boolean
):
vscode
.
CompletionItem
[];
}
export
class
EmmetCompletionItemProviderHtml
extends
EmmetCompletionItemProviderBase
{
protected
getExpandedAbbreviation
(
document
:
vscode
.
TextDocument
,
position
:
vscode
.
Position
):
vscode
.
CompletionItem
{
let
completionItem
=
super
.
getExpandedAbbreviation
(
document
,
position
);
if
(
completionItem
)
{
// In non stylesheet like syntax, this extension returns expanded abbr plus posssible abbr completions
// To differentiate between the 2, the former is given CompletionItemKind.Value so that it gets a different icon
completionItem
.
kind
=
vscode
.
CompletionItemKind
.
Value
;
}
return
completionItem
;
}
getAbbreviationSuggestions
(
syntax
:
string
,
prefix
:
string
,
skipExactMatch
:
boolean
)
{
if
(
!
vscode
.
workspace
.
getConfiguration
(
'
emmet
'
)[
'
showAbbreviationSuggestions
'
]
||
!
prefix
)
{
return
[];
...
...
@@ -102,19 +95,9 @@ export class EmmetCompletionItemProviderHtml extends EmmetCompletionItemProvider
}
}
export
class
EmmetCompletionItemProviderCss
extends
EmmetCompletionItemProviderBase
{
public
provideCompletionItems
(
document
:
vscode
.
TextDocument
,
position
:
vscode
.
Position
,
token
:
vscode
.
CancellationToken
):
Thenable
<
vscode
.
CompletionList
>
{
return
super
.
provideCompletionItems
(
document
,
position
,
token
);
}
getAbbreviationSuggestions
(
syntax
:
string
,
prefix
:
string
,
skipExactMatch
:
boolean
)
{
return
[];
}
}
function
getCurrentWord
(
document
:
vscode
.
TextDocument
,
position
:
vscode
.
Position
):
string
{
let
wordAtPosition
=
document
.
getWordRangeAtPosition
(
position
);
...
...
extensions/emmet/src/extension.ts
浏览文件 @
baf54ef0
...
...
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import
*
as
vscode
from
'
vscode
'
;
import
{
EmmetCompletionItemProvider
Html
,
EmmetCompletionItemProviderCss
}
from
'
./emmetCompletionProvider
'
;
import
{
EmmetCompletionItemProvider
}
from
'
./emmetCompletionProvider
'
;
import
{
expandAbbreviation
,
wrapWithAbbreviation
}
from
'
./abbreviationActions
'
;
import
{
removeTag
}
from
'
./removeTag
'
;
import
{
updateTag
}
from
'
./updateTag
'
;
...
...
@@ -21,7 +21,7 @@ interface ISupportedLanguageMode {
triggerCharacters
:
string
[];
}
const
HTML_
LANGUAGE_MODES
:
ISupportedLanguageMode
[]
=
[
const
LANGUAGE_MODES
:
ISupportedLanguageMode
[]
=
[
{
id
:
'
html
'
,
triggerCharacters
:
[
'
!
'
,
'
.
'
,
'
}
'
]
},
{
id
:
'
jade
'
,
triggerCharacters
:
[
'
!
'
,
'
.
'
,
'
}
'
]
},
{
id
:
'
slim
'
,
triggerCharacters
:
[
'
!
'
,
'
.
'
,
'
}
'
]
},
...
...
@@ -30,10 +30,8 @@ const HTML_LANGUAGE_MODES: ISupportedLanguageMode[] = [
{
id
:
'
xsl
'
,
triggerCharacters
:
[
'
.
'
,
'
}
'
]
},
{
id
:
'
javascriptreact
'
,
triggerCharacters
:
[
'
.
'
]
},
{
id
:
'
typescriptreact
'
,
triggerCharacters
:
[
'
.
'
]
}
];
{
id
:
'
typescriptreact
'
,
triggerCharacters
:
[
'
.
'
]
},
const
CSS_LANGUAGE_MODES
:
ISupportedLanguageMode
[]
=
[
{
id
:
'
css
'
,
triggerCharacters
:
[
'
:
'
]
},
{
id
:
'
scss
'
,
triggerCharacters
:
[
'
:
'
]
},
{
id
:
'
sass
'
,
triggerCharacters
:
[
'
:
'
]
},
...
...
@@ -42,16 +40,9 @@ const CSS_LANGUAGE_MODES: ISupportedLanguageMode[] = [
];
export
function
activate
(
context
:
vscode
.
ExtensionContext
)
{
let
completionProviderHtml
=
new
EmmetCompletionItemProviderHtml
();
let
completionProviderCss
=
new
EmmetCompletionItemProviderCss
();
for
(
let
language
of
HTML_LANGUAGE_MODES
)
{
const
provider
=
vscode
.
languages
.
registerCompletionItemProvider
({
language
:
language
.
id
},
completionProviderHtml
,
...
language
.
triggerCharacters
);
context
.
subscriptions
.
push
(
provider
);
}
for
(
let
language
of
CSS_LANGUAGE_MODES
)
{
const
provider
=
vscode
.
languages
.
registerCompletionItemProvider
({
language
:
language
.
id
},
completionProviderCss
,
...
language
.
triggerCharacters
);
let
completionProvider
=
new
EmmetCompletionItemProvider
();
for
(
let
language
of
LANGUAGE_MODES
)
{
const
provider
=
vscode
.
languages
.
registerCompletionItemProvider
({
language
:
language
.
id
},
completionProvider
,
...
language
.
triggerCharacters
);
context
.
subscriptions
.
push
(
provider
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录