Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
a5a583eb
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,发现更多精彩内容 >>
提交
a5a583eb
编写于
1月 09, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Skip tokenizing with TM lines over 20k chars
上级
88c45c4e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
20 addition
and
4 deletion
+20
-4
src/vs/editor/electron-browser/textMate/TMSyntax.ts
src/vs/editor/electron-browser/textMate/TMSyntax.ts
+20
-4
未找到文件。
src/vs/editor/electron-browser/textMate/TMSyntax.ts
浏览文件 @
a5a583eb
...
...
@@ -20,6 +20,7 @@ import { ITextMateService } from 'vs/editor/node/textMate/textMateService';
import
{
grammarsExtPoint
,
IEmbeddedLanguagesMap
,
ITMSyntaxExtensionPoint
}
from
'
vs/editor/node/textMate/TMGrammars
'
;
import
{
TokenizationResult
,
TokenizationResult2
}
from
'
vs/editor/common/core/token
'
;
import
{
TokenMetadata
}
from
'
vs/editor/common/model/tokensBinaryEncoding
'
;
import
{
nullTokenize2
}
from
'
vs/editor/common/modes/nullMode
'
;
export
class
TMScopeRegistry
{
...
...
@@ -88,6 +89,12 @@ export class TMLanguageRegistration {
}
}
interface
ICreateGrammarResult
{
languageId
:
LanguageId
;
grammar
:
IGrammar
;
containsEmbeddedLanguages
:
boolean
;
}
export
class
MainProcessTextMateSyntax
implements
ITextMateService
{
public
_serviceBrand
:
any
;
...
...
@@ -226,18 +233,19 @@ export class MainProcessTextMateSyntax implements ITextMateService {
return
this
.
_createGrammar
(
modeId
).
then
(
r
=>
r
.
grammar
);
}
private
_createGrammar
(
modeId
:
string
):
TPromise
<
{
grammar
:
IGrammar
;
containsEmbeddedLanguages
:
boolean
;
}
>
{
private
_createGrammar
(
modeId
:
string
):
TPromise
<
ICreateGrammarResult
>
{
let
scopeName
=
this
.
_languageToScope
[
modeId
];
let
languageRegistration
=
this
.
_scopeRegistry
.
getLanguageRegistration
(
scopeName
);
let
embeddedLanguages
=
this
.
_resolveEmbeddedLanguages
(
languageRegistration
.
embeddedLanguages
);
let
languageId
=
this
.
_modeService
.
getLanguageIdentifier
(
modeId
).
id
;
let
containsEmbeddedLanguages
=
(
Object
.
keys
(
embeddedLanguages
).
length
>
0
);
return
new
TPromise
<
{
grammar
:
IGrammar
;
containsEmbeddedLanguages
:
boolean
;
}
>
((
c
,
e
,
p
)
=>
{
return
new
TPromise
<
ICreateGrammarResult
>
((
c
,
e
,
p
)
=>
{
this
.
_grammarRegistry
.
loadGrammarWithEmbeddedLanguages
(
scopeName
,
languageId
,
embeddedLanguages
,
(
err
,
grammar
)
=>
{
if
(
err
)
{
return
e
(
err
);
}
c
({
languageId
:
languageId
,
grammar
:
grammar
,
containsEmbeddedLanguages
:
containsEmbeddedLanguages
});
...
...
@@ -247,7 +255,7 @@ export class MainProcessTextMateSyntax implements ITextMateService {
private
registerDefinition
(
modeId
:
string
):
void
{
this
.
_createGrammar
(
modeId
).
then
((
r
)
=>
{
TokenizationRegistry
.
register
(
modeId
,
new
TMTokenization
(
this
.
_scopeRegistry
,
r
.
grammar
,
r
.
containsEmbeddedLanguages
));
TokenizationRegistry
.
register
(
modeId
,
new
TMTokenization
(
this
.
_scopeRegistry
,
r
.
languageId
,
r
.
grammar
,
r
.
containsEmbeddedLanguages
));
},
onUnexpectedError
);
}
}
...
...
@@ -255,12 +263,14 @@ export class MainProcessTextMateSyntax implements ITextMateService {
class
TMTokenization
implements
ITokenizationSupport
{
private
readonly
_scopeRegistry
:
TMScopeRegistry
;
private
readonly
_languageId
:
LanguageId
;
private
readonly
_grammar
:
IGrammar
;
private
readonly
_containsEmbeddedLanguages
:
boolean
;
private
readonly
_seenLanguages
:
boolean
[];
constructor
(
scopeRegistry
:
TMScopeRegistry
,
grammar
:
IGrammar
,
containsEmbeddedLanguages
:
boolean
)
{
constructor
(
scopeRegistry
:
TMScopeRegistry
,
languageId
:
LanguageId
,
grammar
:
IGrammar
,
containsEmbeddedLanguages
:
boolean
)
{
this
.
_scopeRegistry
=
scopeRegistry
;
this
.
_languageId
=
languageId
;
this
.
_grammar
=
grammar
;
this
.
_containsEmbeddedLanguages
=
containsEmbeddedLanguages
;
this
.
_seenLanguages
=
[];
...
...
@@ -279,6 +289,12 @@ class TMTokenization implements ITokenizationSupport {
throw
new
Error
(
'
Unexpected: offsetDelta should be 0.
'
);
}
// Do not attempt to tokenize if a line has over 20k
if
(
line
.
length
>=
20000
)
{
console
.
log
(
`Line (
${
line
.
substr
(
0
,
15
)}
...): longer than 20k characters, tokenization skipped.`
);
return
nullTokenize2
(
this
.
_languageId
,
line
,
state
,
offsetDelta
);
}
let
textMateResult
=
this
.
_grammar
.
tokenizeLine2
(
line
,
state
);
if
(
this
.
_containsEmbeddedLanguages
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录