Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
f9c4ac5a
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,发现更多精彩内容 >>
提交
f9c4ac5a
编写于
8月 29, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Merge LineToken -> Token
上级
a69c750e
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
232 addition
and
264 deletion
+232
-264
src/vs/editor/common/core/token.ts
src/vs/editor/common/core/token.ts
+28
-1
src/vs/editor/common/model/lineToken.ts
src/vs/editor/common/model/lineToken.ts
+0
-47
src/vs/editor/common/model/modelLine.ts
src/vs/editor/common/model/modelLine.ts
+3
-3
src/vs/editor/common/model/textModelWithTokens.ts
src/vs/editor/common/model/textModelWithTokens.ts
+1
-13
src/vs/editor/common/model/tokensBinaryEncoding.ts
src/vs/editor/common/model/tokensBinaryEncoding.ts
+3
-3
src/vs/editor/test/common/model/model.line.test.ts
src/vs/editor/test/common/model/model.line.test.ts
+197
-197
未找到文件。
src/vs/editor/common/core/token.ts
浏览文件 @
f9c4ac5a
...
...
@@ -4,6 +4,8 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
Arrays
}
from
'
vs/editor/common/core/arrays
'
;
export
class
Token
{
_tokenBrand
:
void
;
...
...
@@ -11,11 +13,36 @@ export class Token {
public
type
:
string
;
constructor
(
startIndex
:
number
,
type
:
string
)
{
this
.
startIndex
=
startIndex
;
this
.
startIndex
=
startIndex
|
0
;
// @perf
this
.
type
=
type
;
}
public
toString
():
string
{
return
'
(
'
+
this
.
startIndex
+
'
,
'
+
this
.
type
+
'
)
'
;
}
public
equals
(
other
:
Token
):
boolean
{
return
(
this
.
startIndex
===
other
.
startIndex
&&
this
.
type
===
other
.
type
);
}
public
static
findIndexInSegmentsArray
(
arr
:
Token
[],
desiredIndex
:
number
):
number
{
return
Arrays
.
findIndexInSegmentsArray
(
arr
,
desiredIndex
);
}
public
static
equalsArray
(
a
:
Token
[],
b
:
Token
[]):
boolean
{
let
aLen
=
a
.
length
;
let
bLen
=
b
.
length
;
if
(
aLen
!==
bLen
)
{
return
false
;
}
for
(
let
i
=
0
;
i
<
aLen
;
i
++
)
{
if
(
!
a
[
i
].
equals
(
b
[
i
]))
{
return
false
;
}
}
return
true
;
}
}
src/vs/editor/common/model/lineToken.ts
已删除
100644 → 0
浏览文件 @
a69c750e
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
Arrays
}
from
'
vs/editor/common/core/arrays
'
;
/**
* A token on a line.
*/
export
class
LineToken
{
public
_lineTokenBrand
:
void
;
public
startIndex
:
number
;
public
type
:
string
;
constructor
(
startIndex
:
number
,
type
:
string
)
{
this
.
startIndex
=
startIndex
|
0
;
// @perf
this
.
type
=
type
;
}
public
equals
(
other
:
LineToken
):
boolean
{
return
(
this
.
startIndex
===
other
.
startIndex
&&
this
.
type
===
other
.
type
);
}
public
static
findIndexInSegmentsArray
(
arr
:
LineToken
[],
desiredIndex
:
number
):
number
{
return
Arrays
.
findIndexInSegmentsArray
(
arr
,
desiredIndex
);
}
public
static
equalsArray
(
a
:
LineToken
[],
b
:
LineToken
[]):
boolean
{
let
aLen
=
a
.
length
;
let
bLen
=
b
.
length
;
if
(
aLen
!==
bLen
)
{
return
false
;
}
for
(
let
i
=
0
;
i
<
aLen
;
i
++
)
{
if
(
!
a
[
i
].
equals
(
b
[
i
]))
{
return
false
;
}
}
return
true
;
}
}
\ No newline at end of file
src/vs/editor/common/model/modelLine.ts
浏览文件 @
f9c4ac5a
...
...
@@ -9,7 +9,7 @@ import {ILineTokens, IReadOnlyLineMarker} from 'vs/editor/common/editorCommon';
import
{
IState
}
from
'
vs/editor/common/modes
'
;
import
{
TokensBinaryEncoding
,
TokensInflatorMap
}
from
'
vs/editor/common/model/tokensBinaryEncoding
'
;
import
{
ModeTransition
}
from
'
vs/editor/common/core/modeTransition
'
;
import
{
LineToken
}
from
'
vs/editor/common/model/lineT
oken
'
;
import
{
Token
}
from
'
vs/editor/common/core/t
oken
'
;
import
{
ViewLineToken
}
from
'
vs/editor/common/core/viewLineToken
'
;
const
START_INDEX_MASK
=
TokensBinaryEncoding
.
START_INDEX_MASK
;
...
...
@@ -190,7 +190,7 @@ export class ModelLine {
// --- BEGIN TOKENS
public
setTokens
(
map
:
TokensInflatorMap
,
tokens
:
Line
Token
[],
topLevelModeId
:
string
,
modeTransitions
:
ModeTransition
[]):
void
{
public
setTokens
(
map
:
TokensInflatorMap
,
tokens
:
Token
[],
topLevelModeId
:
string
,
modeTransitions
:
ModeTransition
[]):
void
{
this
.
_lineTokens
=
toLineTokensFromInflated
(
map
,
tokens
,
this
.
_text
.
length
);
this
.
_modeTransitions
=
toModeTransitions
(
topLevelModeId
,
modeTransitions
);
}
...
...
@@ -697,7 +697,7 @@ export class ModelLine {
}
}
function
toLineTokensFromInflated
(
map
:
TokensInflatorMap
,
tokens
:
Line
Token
[],
textLength
:
number
):
number
[]
{
function
toLineTokensFromInflated
(
map
:
TokensInflatorMap
,
tokens
:
Token
[],
textLength
:
number
):
number
[]
{
if
(
textLength
===
0
)
{
return
null
;
}
...
...
src/vs/editor/common/model/textModelWithTokens.ts
浏览文件 @
f9c4ac5a
...
...
@@ -22,7 +22,6 @@ import {NullMode, NullState, nullTokenize} from 'vs/editor/common/modes/nullMode
import
{
ignoreBracketsInToken
}
from
'
vs/editor/common/modes/supports
'
;
import
{
BracketsUtils
}
from
'
vs/editor/common/modes/supports/richEditBrackets
'
;
import
{
ModeTransition
}
from
'
vs/editor/common/core/modeTransition
'
;
import
{
LineToken
}
from
'
vs/editor/common/model/lineToken
'
;
import
{
TokensInflatorMap
}
from
'
vs/editor/common/model/tokensBinaryEncoding
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
LanguageConfigurationRegistry
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
...
...
@@ -476,17 +475,6 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
}
}
private
static
_toLineTokens
(
tokens
:
Token
[]):
LineToken
[]
{
if
(
!
tokens
||
tokens
.
length
===
0
)
{
return
[];
}
let
result
:
LineToken
[]
=
[];
for
(
let
i
=
0
,
len
=
tokens
.
length
;
i
<
len
;
i
++
)
{
result
[
i
]
=
new
LineToken
(
tokens
[
i
].
startIndex
,
tokens
[
i
].
type
);
}
return
result
;
}
private
_beginBackgroundTokenization
():
void
{
if
(
this
.
_shouldAutoTokenize
()
&&
this
.
_revalidateTokensTimeout
===
-
1
)
{
this
.
_revalidateTokensTimeout
=
setTimeout
(()
=>
{
...
...
@@ -638,7 +626,7 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
// Make sure there is at least the transition to the top-most mode
r
.
modeTransitions
.
push
(
new
ModeTransition
(
0
,
this
.
getModeId
()));
}
this
.
_lines
[
lineIndex
].
setTokens
(
this
.
_tokensInflatorMap
,
TextModelWithTokens
.
_toLineTokens
(
r
.
tokens
)
,
this
.
getModeId
(),
r
.
modeTransitions
);
this
.
_lines
[
lineIndex
].
setTokens
(
this
.
_tokensInflatorMap
,
r
.
tokens
,
this
.
getModeId
(),
r
.
modeTransitions
);
if
(
this
.
_lines
[
lineIndex
].
isInvalid
)
{
this
.
_lines
[
lineIndex
].
isInvalid
=
false
;
...
...
src/vs/editor/common/model/tokensBinaryEncoding.ts
浏览文件 @
f9c4ac5a
...
...
@@ -7,7 +7,7 @@
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
{
ViewLineToken
}
from
'
vs/editor/common/core/viewLineToken
'
;
import
{
LineToken
}
from
'
vs/editor/common/model/lineT
oken
'
;
import
{
Token
}
from
'
vs/editor/common/core/t
oken
'
;
const
START_INDEX_MASK
=
0xffffffff
;
const
TYPE_MASK
=
0xffff
;
...
...
@@ -40,7 +40,7 @@ export class TokensBinaryEncoding {
public
static
START_INDEX_OFFSET
=
START_INDEX_OFFSET
;
public
static
TYPE_OFFSET
=
TYPE_OFFSET
;
public
static
deflateArr
(
map
:
TokensInflatorMap
,
tokens
:
Line
Token
[]):
number
[]
{
public
static
deflateArr
(
map
:
TokensInflatorMap
,
tokens
:
Token
[]):
number
[]
{
if
(
tokens
.
length
===
0
)
{
return
DEFLATED_TOKENS_EMPTY_TEXT
;
}
...
...
@@ -52,7 +52,7 @@ export class TokensBinaryEncoding {
len
:
number
,
deflatedToken
:
number
,
deflated
:
number
,
token
:
Line
Token
,
token
:
Token
,
inflateMap
=
map
.
_inflate
,
deflateMap
=
map
.
_deflate
,
prevStartIndex
:
number
=
-
1
,
...
...
src/vs/editor/test/common/model/model.line.test.ts
浏览文件 @
f9c4ac5a
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录