Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
5aa37a74
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,发现更多精彩内容 >>
提交
5aa37a74
编写于
7月 06, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add and use MinimalModelLine (#30180)
上级
3f34ed5b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
102 addition
and
14 deletion
+102
-14
src/vs/editor/common/model/modelLine.ts
src/vs/editor/common/model/modelLine.ts
+96
-13
src/vs/editor/common/model/textModel.ts
src/vs/editor/common/model/textModel.ts
+6
-1
未找到文件。
src/vs/editor/common/model/modelLine.ts
浏览文件 @
5aa37a74
...
...
@@ -193,7 +193,7 @@ export abstract class AbstractModelLine {
///
p
rotected
abstract
get
text
():
string
;
p
ublic
abstract
get
text
():
string
;
protected
abstract
_setText
(
text
:
string
,
tabSize
:
number
);
protected
abstract
_createTokensAdjuster
():
ITokensAdjuster
;
protected
abstract
_createModelLine
(
text
:
string
,
tabSize
:
number
):
IModelLine
;
...
...
@@ -632,16 +632,6 @@ export class ModelLine extends AbstractModelLine implements IModelLine {
// --- BEGIN TOKENS
private
static
_getDefaultMetadata
(
topLevelLanguageId
:
LanguageId
):
number
{
return
(
(
topLevelLanguageId
<<
MetadataConsts
.
LANGUAGEID_OFFSET
)
|
(
StandardTokenType
.
Other
<<
MetadataConsts
.
TOKEN_TYPE_OFFSET
)
|
(
FontStyle
.
None
<<
MetadataConsts
.
FONT_STYLE_OFFSET
)
|
(
ColorId
.
DefaultForeground
<<
MetadataConsts
.
FOREGROUND_OFFSET
)
|
(
ColorId
.
DefaultBackground
<<
MetadataConsts
.
BACKGROUND_OFFSET
)
)
>>>
0
;
}
public
setTokens
(
topLevelLanguageId
:
LanguageId
,
tokens
:
Uint32Array
):
void
{
if
(
!
tokens
||
tokens
.
length
===
0
)
{
this
.
_lineTokens
=
null
;
...
...
@@ -649,7 +639,7 @@ export class ModelLine extends AbstractModelLine implements IModelLine {
}
if
(
tokens
.
length
===
2
)
{
// there is one token
if
(
tokens
[
0
]
===
0
&&
tokens
[
1
]
===
ModelLine
.
_
getDefaultMetadata
(
topLevelLanguageId
))
{
if
(
tokens
[
0
]
===
0
&&
tokens
[
1
]
===
getDefaultMetadata
(
topLevelLanguageId
))
{
this
.
_lineTokens
=
null
;
return
;
}
...
...
@@ -665,7 +655,7 @@ export class ModelLine extends AbstractModelLine implements IModelLine {
let
lineTokens
=
new
Uint32Array
(
2
);
lineTokens
[
0
]
=
0
;
lineTokens
[
1
]
=
ModelLine
.
_
getDefaultMetadata
(
topLevelLanguageId
);
lineTokens
[
1
]
=
getDefaultMetadata
(
topLevelLanguageId
);
return
new
LineTokens
(
lineTokens
,
this
.
_text
);
}
...
...
@@ -806,3 +796,96 @@ export class ModelLine extends AbstractModelLine implements IModelLine {
}
}
/**
* A model line that cannot store any tokenization state, nor does it compute indentation levels.
* It has no fields except the text.
*/
export
class
MinimalModelLine
extends
AbstractModelLine
implements
IModelLine
{
private
_text
:
string
;
public
get
text
():
string
{
return
this
.
_text
;
}
public
isInvalid
():
boolean
{
return
false
;
}
public
setIsInvalid
(
isInvalid
:
boolean
):
void
{
}
/**
* Returns:
* - -1 => the line consists of whitespace
* - otherwise => the indent level is returned value
*/
public
getIndentLevel
():
number
{
return
0
;
}
public
updateTabSize
(
tabSize
:
number
):
void
{
}
constructor
(
text
:
string
,
tabSize
:
number
)
{
super
();
this
.
_setText
(
text
,
tabSize
);
}
protected
_createModelLine
(
text
:
string
,
tabSize
:
number
):
IModelLine
{
return
new
MinimalModelLine
(
text
,
tabSize
);
}
public
split
(
markersTracker
:
MarkersTracker
,
splitColumn
:
number
,
forceMoveMarkers
:
boolean
,
tabSize
:
number
):
IModelLine
{
return
super
.
split
(
markersTracker
,
splitColumn
,
forceMoveMarkers
,
tabSize
);
}
public
append
(
markersTracker
:
MarkersTracker
,
myLineNumber
:
number
,
other
:
IModelLine
,
tabSize
:
number
):
void
{
super
.
append
(
markersTracker
,
myLineNumber
,
other
,
tabSize
);
}
// --- BEGIN STATE
public
resetTokenizationState
():
void
{
}
public
setState
(
state
:
IState
):
void
{
}
public
getState
():
IState
{
return
null
;
}
// --- END STATE
// --- BEGIN TOKENS
public
setTokens
(
topLevelLanguageId
:
LanguageId
,
tokens
:
Uint32Array
):
void
{
}
public
getTokens
(
topLevelLanguageId
:
LanguageId
):
LineTokens
{
let
lineTokens
=
new
Uint32Array
(
2
);
lineTokens
[
0
]
=
0
;
lineTokens
[
1
]
=
getDefaultMetadata
(
topLevelLanguageId
);
return
new
LineTokens
(
lineTokens
,
this
.
_text
);
}
// --- END TOKENS
protected
_createTokensAdjuster
():
ITokensAdjuster
{
// This line does not have real tokens, so there is nothing to adjust
return
NO_OP_TOKENS_ADJUSTER
;
}
protected
_setText
(
text
:
string
,
tabSize
:
number
):
void
{
this
.
_text
=
text
;
}
}
function
getDefaultMetadata
(
topLevelLanguageId
:
LanguageId
):
number
{
return
(
(
topLevelLanguageId
<<
MetadataConsts
.
LANGUAGEID_OFFSET
)
|
(
StandardTokenType
.
Other
<<
MetadataConsts
.
TOKEN_TYPE_OFFSET
)
|
(
FontStyle
.
None
<<
MetadataConsts
.
FONT_STYLE_OFFSET
)
|
(
ColorId
.
DefaultForeground
<<
MetadataConsts
.
FOREGROUND_OFFSET
)
|
(
ColorId
.
DefaultBackground
<<
MetadataConsts
.
BACKGROUND_OFFSET
)
)
>>>
0
;
}
src/vs/editor/common/model/textModel.ts
浏览文件 @
5aa37a74
...
...
@@ -9,7 +9,7 @@ import * as strings from 'vs/base/common/strings';
import
{
Position
,
IPosition
}
from
'
vs/editor/common/core/position
'
;
import
{
Range
,
IRange
}
from
'
vs/editor/common/core/range
'
;
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
{
ModelLine
,
IModelLine
}
from
'
vs/editor/common/model/modelLine
'
;
import
{
ModelLine
,
IModelLine
,
MinimalModelLine
}
from
'
vs/editor/common/model/modelLine
'
;
import
{
guessIndentation
}
from
'
vs/editor/common/model/indentationGuesser
'
;
import
{
EDITOR_MODEL_DEFAULTS
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
PrefixSumComputer
}
from
'
vs/editor/common/viewModel/prefixSumComputer
'
;
...
...
@@ -19,6 +19,8 @@ import { TextSource, ITextSource, IRawTextSource, RawTextSource } from 'vs/edito
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
*
as
textModelEvents
from
'
vs/editor/common/model/textModelEvents
'
;
const
USE_MIMINAL_MODEL_LINE
=
true
;
const
LIMIT_FIND_COUNT
=
999
;
export
const
LONG_LINE_BOUNDARY
=
10000
;
...
...
@@ -116,6 +118,9 @@ export class TextModel implements editorCommon.ITextModel {
}
protected
_createModelLine
(
text
:
string
,
tabSize
:
number
):
IModelLine
{
if
(
USE_MIMINAL_MODEL_LINE
&&
this
.
_isTooLargeForTokenization
)
{
return
new
MinimalModelLine
(
text
,
tabSize
);
}
return
new
ModelLine
(
text
,
tabSize
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录