Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
631e22aa
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,发现更多精彩内容 >>
提交
631e22aa
编写于
7月 03, 2019
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
renames
上级
2d1aec3c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
29 addition
and
29 deletion
+29
-29
src/vs/editor/common/model/textModelTokens.ts
src/vs/editor/common/model/textModelTokens.ts
+29
-29
未找到文件。
src/vs/editor/common/model/textModelTokens.ts
浏览文件 @
631e22aa
...
...
@@ -31,44 +31,44 @@ const enum Constants {
}
class
ModelLineTokens
{
_
state
:
IState
|
null
;
_
lineTokens
:
ArrayBuffer
|
null
;
_
valid
:
boolean
;
public
state
:
IState
|
null
;
public
lineTokens
:
ArrayBuffer
|
null
;
public
valid
:
boolean
;
constructor
(
state
:
IState
|
null
)
{
this
.
_
state
=
state
;
this
.
_
lineTokens
=
null
;
this
.
_
valid
=
false
;
this
.
state
=
state
;
this
.
lineTokens
=
null
;
this
.
valid
=
false
;
}
public
deleteBeginning
(
toChIndex
:
number
):
void
{
if
(
this
.
_lineTokens
===
null
||
this
.
_
lineTokens
===
EMPTY_LINE_TOKENS
)
{
if
(
this
.
lineTokens
===
null
||
this
.
lineTokens
===
EMPTY_LINE_TOKENS
)
{
return
;
}
this
.
delete
(
0
,
toChIndex
);
}
public
deleteEnding
(
fromChIndex
:
number
):
void
{
if
(
this
.
_lineTokens
===
null
||
this
.
_
lineTokens
===
EMPTY_LINE_TOKENS
)
{
if
(
this
.
lineTokens
===
null
||
this
.
lineTokens
===
EMPTY_LINE_TOKENS
)
{
return
;
}
const
tokens
=
new
Uint32Array
(
this
.
_
lineTokens
);
const
tokens
=
new
Uint32Array
(
this
.
lineTokens
);
const
lineTextLength
=
tokens
[
tokens
.
length
-
2
];
this
.
delete
(
fromChIndex
,
lineTextLength
);
}
public
delete
(
fromChIndex
:
number
,
toChIndex
:
number
):
void
{
if
(
this
.
_lineTokens
===
null
||
this
.
_
lineTokens
===
EMPTY_LINE_TOKENS
||
fromChIndex
===
toChIndex
)
{
if
(
this
.
lineTokens
===
null
||
this
.
lineTokens
===
EMPTY_LINE_TOKENS
||
fromChIndex
===
toChIndex
)
{
return
;
}
const
tokens
=
new
Uint32Array
(
this
.
_
lineTokens
);
const
tokens
=
new
Uint32Array
(
this
.
lineTokens
);
const
tokensCount
=
(
tokens
.
length
>>>
1
);
// special case: deleting everything
if
(
fromChIndex
===
0
&&
tokens
[
tokens
.
length
-
2
]
===
toChIndex
)
{
this
.
_
lineTokens
=
EMPTY_LINE_TOKENS
;
this
.
lineTokens
=
EMPTY_LINE_TOKENS
;
return
;
}
...
...
@@ -113,26 +113,26 @@ class ModelLineTokens {
let
tmp
=
new
Uint32Array
(
dest
);
tmp
.
set
(
tokens
.
subarray
(
0
,
dest
),
0
);
this
.
_
lineTokens
=
tmp
.
buffer
;
this
.
lineTokens
=
tmp
.
buffer
;
}
public
append
(
_otherTokens
:
ArrayBuffer
|
null
):
void
{
if
(
_otherTokens
===
EMPTY_LINE_TOKENS
)
{
return
;
}
if
(
this
.
_
lineTokens
===
EMPTY_LINE_TOKENS
)
{
this
.
_
lineTokens
=
_otherTokens
;
if
(
this
.
lineTokens
===
EMPTY_LINE_TOKENS
)
{
this
.
lineTokens
=
_otherTokens
;
return
;
}
if
(
this
.
_
lineTokens
===
null
)
{
if
(
this
.
lineTokens
===
null
)
{
return
;
}
if
(
_otherTokens
===
null
)
{
// cannot determine combined line length...
this
.
_
lineTokens
=
null
;
this
.
lineTokens
=
null
;
return
;
}
const
myTokens
=
new
Uint32Array
(
this
.
_
lineTokens
);
const
myTokens
=
new
Uint32Array
(
this
.
lineTokens
);
const
otherTokens
=
new
Uint32Array
(
_otherTokens
);
const
otherTokensCount
=
(
otherTokens
.
length
>>>
1
);
...
...
@@ -144,16 +144,16 @@ class ModelLineTokens {
result
[
dest
++
]
=
otherTokens
[(
i
<<
1
)]
+
delta
;
result
[
dest
++
]
=
otherTokens
[(
i
<<
1
)
+
1
];
}
this
.
_
lineTokens
=
result
.
buffer
;
this
.
lineTokens
=
result
.
buffer
;
}
public
insert
(
chIndex
:
number
,
textLength
:
number
):
void
{
if
(
!
this
.
_
lineTokens
)
{
if
(
!
this
.
lineTokens
)
{
// nothing to do
return
;
}
const
tokens
=
new
Uint32Array
(
this
.
_
lineTokens
);
const
tokens
=
new
Uint32Array
(
this
.
lineTokens
);
const
tokensCount
=
(
tokens
.
length
>>>
1
);
let
fromTokenIndex
=
LineTokens
.
findIndexInTokensArray
(
tokens
,
chIndex
);
...
...
@@ -211,7 +211,7 @@ export class TokensStore implements ITokensStore {
public
getTokens
(
topLevelLanguageId
:
LanguageId
,
lineIndex
:
number
,
lineText
:
string
):
LineTokens
{
let
rawLineTokens
:
ArrayBuffer
|
null
=
null
;
if
(
lineIndex
<
this
.
_tokens
.
length
&&
this
.
_tokens
[
lineIndex
])
{
rawLineTokens
=
this
.
_tokens
[
lineIndex
].
_
lineTokens
;
rawLineTokens
=
this
.
_tokens
[
lineIndex
].
lineTokens
;
}
if
(
rawLineTokens
!==
null
&&
rawLineTokens
!==
EMPTY_LINE_TOKENS
)
{
...
...
@@ -234,20 +234,20 @@ export class TokensStore implements ITokensStore {
private
_setIsValid
(
lineIndex
:
number
,
valid
:
boolean
):
void
{
if
(
lineIndex
<
this
.
_tokens
.
length
&&
this
.
_tokens
[
lineIndex
])
{
this
.
_tokens
[
lineIndex
].
_
valid
=
valid
;
this
.
_tokens
[
lineIndex
].
valid
=
valid
;
}
}
private
_isValid
(
lineIndex
:
number
):
boolean
{
if
(
lineIndex
<
this
.
_tokens
.
length
&&
this
.
_tokens
[
lineIndex
])
{
return
this
.
_tokens
[
lineIndex
].
_
valid
;
return
this
.
_tokens
[
lineIndex
].
valid
;
}
return
false
;
}
public
getState
(
lineIndex
:
number
):
IState
|
null
{
if
(
lineIndex
<
this
.
_tokens
.
length
&&
this
.
_tokens
[
lineIndex
])
{
return
this
.
_tokens
[
lineIndex
].
_
state
;
return
this
.
_tokens
[
lineIndex
].
state
;
}
return
null
;
}
...
...
@@ -268,7 +268,7 @@ export class TokensStore implements ITokensStore {
}
if
(
!
hasDifferentLanguageId
)
{
target
.
_
lineTokens
=
EMPTY_LINE_TOKENS
;
target
.
lineTokens
=
EMPTY_LINE_TOKENS
;
return
;
}
}
...
...
@@ -281,7 +281,7 @@ export class TokensStore implements ITokensStore {
LineTokens
.
convertToEndOffset
(
tokens
,
lineTextLength
);
target
.
_
lineTokens
=
tokens
.
buffer
;
target
.
lineTokens
=
tokens
.
buffer
;
}
public
setGoodTokens
(
topLevelLanguageId
:
LanguageId
,
linesLength
:
number
,
lineIndex
:
number
,
text
:
string
,
r
:
TokenizationResult2
):
void
{
...
...
@@ -322,7 +322,7 @@ export class TokensStore implements ITokensStore {
public
setState
(
lineIndex
:
number
,
state
:
IState
):
void
{
if
(
lineIndex
<
this
.
_tokens
.
length
&&
this
.
_tokens
[
lineIndex
])
{
this
.
_tokens
[
lineIndex
].
_
state
=
state
;
this
.
_tokens
[
lineIndex
].
state
=
state
;
}
else
{
const
tmp
=
new
ModelLineTokens
(
state
);
this
.
_tokens
[
lineIndex
]
=
tmp
;
...
...
@@ -374,7 +374,7 @@ export class TokensStore implements ITokensStore {
if
(
lastLineIndex
<
this
.
_tokens
.
length
)
{
const
lastLine
=
this
.
_tokens
[
lastLineIndex
];
lastLine
.
deleteBeginning
(
range
.
endColumn
-
1
);
lastLineTokens
=
lastLine
.
_
lineTokens
;
lastLineTokens
=
lastLine
.
lineTokens
;
}
// Take remaining text on last line and append it to remaining text on first line
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录