Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
0d133e05
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,发现更多精彩内容 >>
提交
0d133e05
编写于
8月 29, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Reduce requirements for ILineContext
上级
be4eb525
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
34 addition
and
21 deletion
+34
-21
src/vs/editor/common/core/modeTransition.ts
src/vs/editor/common/core/modeTransition.ts
+18
-5
src/vs/editor/common/modes.ts
src/vs/editor/common/modes.ts
+2
-2
src/vs/editor/common/modes/supports.ts
src/vs/editor/common/modes/supports.ts
+14
-14
未找到文件。
src/vs/editor/common/core/modeTransition.ts
浏览文件 @
0d133e05
...
@@ -7,17 +7,30 @@
...
@@ -7,17 +7,30 @@
import
{
IMode
,
IModeTransition
}
from
'
vs/editor/common/modes
'
;
import
{
IMode
,
IModeTransition
}
from
'
vs/editor/common/modes
'
;
import
{
Arrays
}
from
'
vs/editor/common/core/arrays
'
;
import
{
Arrays
}
from
'
vs/editor/common/core/arrays
'
;
export
class
ModeTransition
{
export
class
Reduced
ModeTransition
{
_
m
odeTransitionBrand
:
void
;
_
reducedM
odeTransitionBrand
:
void
;
public
startIndex
:
number
;
public
startIndex
:
number
;
public
mode
:
IMode
;
public
modeId
:
string
;
public
modeId
:
string
;
constructor
(
startIndex
:
number
,
mode
:
IMode
)
{
constructor
(
startIndex
:
number
,
mode
Id
:
string
)
{
this
.
startIndex
=
startIndex
|
0
;
this
.
startIndex
=
startIndex
|
0
;
this
.
modeId
=
modeId
;
}
public
static
findIndexInSegmentsArray
(
arr
:
ReducedModeTransition
[],
desiredIndex
:
number
):
number
{
return
Arrays
.
findIndexInSegmentsArray
(
arr
,
desiredIndex
);
}
}
export
class
ModeTransition
extends
ReducedModeTransition
{
_modeTransitionBrand
:
void
;
public
mode
:
IMode
;
constructor
(
startIndex
:
number
,
mode
:
IMode
)
{
super
(
startIndex
,
mode
.
getId
());
this
.
mode
=
mode
;
this
.
mode
=
mode
;
this
.
modeId
=
mode
.
getId
();
}
}
public
static
findIndexInSegmentsArray
(
arr
:
ModeTransition
[],
desiredIndex
:
number
):
number
{
public
static
findIndexInSegmentsArray
(
arr
:
ModeTransition
[],
desiredIndex
:
number
):
number
{
...
...
src/vs/editor/common/modes.ts
浏览文件 @
0d133e05
...
@@ -10,7 +10,7 @@ import URI from 'vs/base/common/uri';
...
@@ -10,7 +10,7 @@ import URI from 'vs/base/common/uri';
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IFilter
}
from
'
vs/base/common/filters
'
;
import
{
IFilter
}
from
'
vs/base/common/filters
'
;
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
{
ModeTransition
}
from
'
vs/editor/common/core/modeTransition
'
;
import
{
Reduced
ModeTransition
}
from
'
vs/editor/common/core/modeTransition
'
;
import
LanguageFeatureRegistry
from
'
vs/editor/common/modes/languageFeatureRegistry
'
;
import
LanguageFeatureRegistry
from
'
vs/editor/common/modes/languageFeatureRegistry
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
...
@@ -170,7 +170,7 @@ export interface IModeDescriptor {
...
@@ -170,7 +170,7 @@ export interface IModeDescriptor {
export
interface
ILineContext
{
export
interface
ILineContext
{
getLineContent
():
string
;
getLineContent
():
string
;
modeTransitions
:
ModeTransition
[];
modeTransitions
:
Reduced
ModeTransition
[];
getTokenCount
():
number
;
getTokenCount
():
number
;
getTokenStartIndex
(
tokenIndex
:
number
):
number
;
getTokenStartIndex
(
tokenIndex
:
number
):
number
;
...
...
src/vs/editor/common/modes/supports.ts
浏览文件 @
0d133e05
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
*
as
modes
from
'
vs/editor/common/modes
'
;
import
*
as
modes
from
'
vs/editor/common/modes
'
;
import
{
ModeTransition
}
from
'
vs/editor/common/core/modeTransition
'
;
import
{
ModeTransition
,
ReducedModeTransition
}
from
'
vs/editor/common/core/modeTransition
'
;
export
class
Token
implements
modes
.
IToken
{
export
class
Token
implements
modes
.
IToken
{
_tokenBrand
:
void
;
_tokenBrand
:
void
;
...
@@ -43,18 +43,18 @@ export class LineTokens implements modes.ILineTokens {
...
@@ -43,18 +43,18 @@ export class LineTokens implements modes.ILineTokens {
}
}
export
function
handleEvent
<
T
>
(
context
:
modes
.
ILineContext
,
offset
:
number
,
runner
:(
modeId
:
string
,
newContext
:
modes
.
ILineContext
,
offset
:
number
)
=>
T
):
T
{
export
function
handleEvent
<
T
>
(
context
:
modes
.
ILineContext
,
offset
:
number
,
runner
:(
modeId
:
string
,
newContext
:
modes
.
ILineContext
,
offset
:
number
)
=>
T
):
T
{
var
modeTransitions
=
context
.
modeTransitions
;
let
modeTransitions
=
context
.
modeTransitions
;
if
(
modeTransitions
.
length
===
1
)
{
if
(
modeTransitions
.
length
===
1
)
{
return
runner
(
modeTransitions
[
0
].
modeId
,
context
,
offset
);
return
runner
(
modeTransitions
[
0
].
modeId
,
context
,
offset
);
}
}
var
modeIndex
=
ModeTransition
.
findIndexInSegmentsArray
(
modeTransitions
,
offset
);
let
modeIndex
=
Reduced
ModeTransition
.
findIndexInSegmentsArray
(
modeTransitions
,
offset
);
var
nestedMode
=
modeTransitions
[
modeIndex
].
mode
;
let
nestedModeId
=
modeTransitions
[
modeIndex
].
modeId
;
var
modeStartIndex
=
modeTransitions
[
modeIndex
].
startIndex
;
let
modeStartIndex
=
modeTransitions
[
modeIndex
].
startIndex
;
var
firstTokenInModeIndex
=
context
.
findIndexOfOffset
(
modeStartIndex
);
let
firstTokenInModeIndex
=
context
.
findIndexOfOffset
(
modeStartIndex
);
var
nextCharacterAfterModeIndex
=
-
1
;
let
nextCharacterAfterModeIndex
=
-
1
;
var
nextTokenAfterMode
=
-
1
;
let
nextTokenAfterMode
=
-
1
;
if
(
modeIndex
+
1
<
modeTransitions
.
length
)
{
if
(
modeIndex
+
1
<
modeTransitions
.
length
)
{
nextTokenAfterMode
=
context
.
findIndexOfOffset
(
modeTransitions
[
modeIndex
+
1
].
startIndex
);
nextTokenAfterMode
=
context
.
findIndexOfOffset
(
modeTransitions
[
modeIndex
+
1
].
startIndex
);
nextCharacterAfterModeIndex
=
context
.
getTokenStartIndex
(
nextTokenAfterMode
);
nextCharacterAfterModeIndex
=
context
.
getTokenStartIndex
(
nextTokenAfterMode
);
...
@@ -63,14 +63,14 @@ export function handleEvent<T>(context:modes.ILineContext, offset:number, runner
...
@@ -63,14 +63,14 @@ export function handleEvent<T>(context:modes.ILineContext, offset:number, runner
nextCharacterAfterModeIndex
=
context
.
getLineContent
().
length
;
nextCharacterAfterModeIndex
=
context
.
getLineContent
().
length
;
}
}
var
firstTokenCharacterOffset
=
context
.
getTokenStartIndex
(
firstTokenInModeIndex
);
let
firstTokenCharacterOffset
=
context
.
getTokenStartIndex
(
firstTokenInModeIndex
);
var
newCtx
=
new
FilteredLineContext
(
context
,
nestedMode
,
firstTokenInModeIndex
,
nextTokenAfterMode
,
firstTokenCharacterOffset
,
nextCharacterAfterModeIndex
);
let
newCtx
=
new
FilteredLineContext
(
context
,
nestedModeId
,
firstTokenInModeIndex
,
nextTokenAfterMode
,
firstTokenCharacterOffset
,
nextCharacterAfterModeIndex
);
return
runner
(
nestedMode
.
getId
()
,
newCtx
,
offset
-
firstTokenCharacterOffset
);
return
runner
(
nestedMode
Id
,
newCtx
,
offset
-
firstTokenCharacterOffset
);
}
}
export
class
FilteredLineContext
implements
modes
.
ILineContext
{
export
class
FilteredLineContext
implements
modes
.
ILineContext
{
public
modeTransitions
:
ModeTransition
[];
public
modeTransitions
:
Reduced
ModeTransition
[];
private
_actual
:
modes
.
ILineContext
;
private
_actual
:
modes
.
ILineContext
;
private
_firstTokenInModeIndex
:
number
;
private
_firstTokenInModeIndex
:
number
;
...
@@ -78,11 +78,11 @@ export class FilteredLineContext implements modes.ILineContext {
...
@@ -78,11 +78,11 @@ export class FilteredLineContext implements modes.ILineContext {
private
_firstTokenCharacterOffset
:
number
;
private
_firstTokenCharacterOffset
:
number
;
private
_nextCharacterAfterModeIndex
:
number
;
private
_nextCharacterAfterModeIndex
:
number
;
constructor
(
actual
:
modes
.
ILineContext
,
mode
:
modes
.
IMode
,
constructor
(
actual
:
modes
.
ILineContext
,
mode
Id
:
string
,
firstTokenInModeIndex
:
number
,
nextTokenAfterMode
:
number
,
firstTokenInModeIndex
:
number
,
nextTokenAfterMode
:
number
,
firstTokenCharacterOffset
:
number
,
nextCharacterAfterModeIndex
:
number
)
{
firstTokenCharacterOffset
:
number
,
nextCharacterAfterModeIndex
:
number
)
{
this
.
modeTransitions
=
[
new
ModeTransition
(
0
,
mode
)];
this
.
modeTransitions
=
[
new
ReducedModeTransition
(
0
,
modeId
)];
this
.
_actual
=
actual
;
this
.
_actual
=
actual
;
this
.
_firstTokenInModeIndex
=
firstTokenInModeIndex
;
this
.
_firstTokenInModeIndex
=
firstTokenInModeIndex
;
this
.
_nextTokenAfterMode
=
nextTokenAfterMode
;
this
.
_nextTokenAfterMode
=
nextTokenAfterMode
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录