Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
徽霖
Vscode
提交
3d1c8e47
V
Vscode
项目概览
徽霖
/
Vscode
通知
9
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,发现更多精彩内容 >>
提交
3d1c8e47
编写于
10月 07, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move tokenize down from IState to AbstractState
上级
b457326a
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
48 addition
and
51 deletion
+48
-51
src/vs/editor/common/modes.ts
src/vs/editor/common/modes.ts
+0
-10
src/vs/editor/common/modes/TMState.ts
src/vs/editor/common/modes/TMState.ts
+1
-5
src/vs/editor/common/modes/abstractState.ts
src/vs/editor/common/modes/abstractState.ts
+12
-1
src/vs/editor/common/modes/monarch/monarchLexer.ts
src/vs/editor/common/modes/monarch/monarchLexer.ts
+3
-3
src/vs/editor/common/modes/nullMode.ts
src/vs/editor/common/modes/nullMode.ts
+2
-1
src/vs/editor/common/modes/supports/tokenizationSupport.ts
src/vs/editor/common/modes/supports/tokenizationSupport.ts
+17
-11
src/vs/editor/common/services/modelServiceImpl.ts
src/vs/editor/common/services/modelServiceImpl.ts
+0
-7
src/vs/editor/test/common/mocks/mockMode.ts
src/vs/editor/test/common/mocks/mockMode.ts
+2
-2
src/vs/editor/test/common/model/model.modes.test.ts
src/vs/editor/test/common/model/model.modes.test.ts
+5
-5
src/vs/editor/test/common/modes/textToHtmlTokenizer.test.ts
src/vs/editor/test/common/modes/textToHtmlTokenizer.test.ts
+2
-2
src/vs/editor/test/common/modes/tokenization.test.ts
src/vs/editor/test/common/modes/tokenization.test.ts
+4
-4
未找到文件。
src/vs/editor/common/modes.ts
浏览文件 @
3d1c8e47
...
...
@@ -18,15 +18,6 @@ import {Position} from 'vs/editor/common/core/position';
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
/**
* @internal
*/
export
interface
ITokenizationResult
{
type
?:
string
;
dontMergeWithPrev
?:
boolean
;
nextState
?:
IState
;
}
/**
* @internal
*/
...
...
@@ -34,7 +25,6 @@ export interface IState {
clone
():
IState
;
equals
(
other
:
IState
):
boolean
;
getModeId
():
string
;
tokenize
(
stream
:
IStream
):
ITokenizationResult
;
getStateData
():
IState
;
setStateData
(
state
:
IState
):
void
;
}
...
...
src/vs/editor/common/modes/TMState.ts
浏览文件 @
3d1c8e47
...
...
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
IState
,
ITokenizationResult
}
from
'
vs/editor/common/modes
'
;
import
{
IState
}
from
'
vs/editor/common/modes
'
;
import
{
AbstractState
}
from
'
vs/editor/common/modes/abstractState
'
;
import
{
StackElement
}
from
'
vscode-textmate
'
;
...
...
@@ -50,10 +50,6 @@ export class TMState implements IState {
return
this
.
_modeId
;
}
public
tokenize
(
stream
:
any
):
ITokenizationResult
{
throw
new
Error
();
}
public
getStateData
():
IState
{
return
this
.
_parentEmbedderState
;
}
...
...
src/vs/editor/common/modes/abstractState.ts
浏览文件 @
3d1c8e47
...
...
@@ -4,10 +4,21 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
IState
,
IStream
,
ITokenizationResult
}
from
'
vs/editor/common/modes
'
;
import
{
IState
,
IStream
}
from
'
vs/editor/common/modes
'
;
/**
* @internal
*/
export
interface
ITokenizationResult
{
type
?:
string
;
dontMergeWithPrev
?:
boolean
;
nextState
?:
AbstractState
;
}
export
abstract
class
AbstractState
implements
IState
{
_abstractStateBrand
:
void
;
private
modeId
:
string
;
private
stateData
:
IState
;
...
...
src/vs/editor/common/modes/monarch/monarchLexer.ts
浏览文件 @
3d1c8e47
...
...
@@ -10,7 +10,7 @@
*/
import
*
as
modes
from
'
vs/editor/common/modes
'
;
import
{
AbstractState
}
from
'
vs/editor/common/modes/abstractState
'
;
import
{
AbstractState
,
ITokenizationResult
}
from
'
vs/editor/common/modes/abstractState
'
;
import
{
LineStream
}
from
'
vs/editor/common/modes/lineStream
'
;
import
*
as
monarchCommon
from
'
vs/editor/common/modes/monarch/monarchCommon
'
;
import
{
IModeLocator
,
TokenizationSupport
}
from
'
vs/editor/common/modes/supports/tokenizationSupport
'
;
...
...
@@ -94,7 +94,7 @@ export class MonarchLexer extends AbstractState {
* TODO: there are many optimizations possible here for the common cases
* but for now I concentrated on functionality and correctness.
*/
public
tokenize
(
stream
:
modes
.
IStream
,
noConsumeIsOk
?:
boolean
):
modes
.
ITokenizationResult
{
public
tokenize
(
stream
:
modes
.
IStream
,
noConsumeIsOk
?:
boolean
):
ITokenizationResult
{
var
stackLen0
=
this
.
stack
.
length
;
// these are saved to check progress
var
groupLen0
=
0
;
var
state
:
string
=
this
.
stack
[
0
];
// the current state
...
...
@@ -388,7 +388,7 @@ function findBracket(lexer: monarchCommon.ILexer, matched: string) {
export
function
createTokenizationSupport
(
_modeService
:
IModeService
,
modeId
:
string
,
lexer
:
monarchCommon
.
ILexer
):
modes
.
ITokenizationSupport
{
return
new
TokenizationSupport
(
_modeService
,
modeId
,
{
getInitialState
:
():
modes
.
I
State
=>
{
getInitialState
:
():
Abstract
State
=>
{
return
new
MonarchLexer
(
modeId
,
_modeService
,
lexer
);
},
...
...
src/vs/editor/common/modes/nullMode.ts
浏览文件 @
3d1c8e47
...
...
@@ -4,9 +4,10 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
IState
,
IStream
,
I
TokenizationResult
,
I
LineTokens
}
from
'
vs/editor/common/modes
'
;
import
{
IState
,
IStream
,
ILineTokens
}
from
'
vs/editor/common/modes
'
;
import
{
ModeTransition
}
from
'
vs/editor/common/core/modeTransition
'
;
import
{
Token
}
from
'
vs/editor/common/core/token
'
;
import
{
ITokenizationResult
}
from
'
vs/editor/common/modes/abstractState
'
;
export
class
NullState
implements
IState
{
...
...
src/vs/editor/common/modes/supports/tokenizationSupport.ts
浏览文件 @
3d1c8e47
...
...
@@ -11,6 +11,7 @@ import {NullState, nullTokenize, NULL_MODE_ID} from 'vs/editor/common/modes/null
import
{
Token
}
from
'
vs/editor/common/core/token
'
;
import
{
ModeTransition
}
from
'
vs/editor/common/core/modeTransition
'
;
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
AbstractState
,
ITokenizationResult
}
from
'
vs/editor/common/modes/abstractState
'
;
export
interface
ILeavingNestedModeData
{
/**
...
...
@@ -26,7 +27,7 @@ export interface ILeavingNestedModeData {
/**
* The state that will be used for continuing tokenization by the parent mode after the nested mode
*/
stateAfterNestedMode
:
modes
.
I
State
;
stateAfterNestedMode
:
Abstract
State
;
}
export
interface
IModeLocator
{
...
...
@@ -35,11 +36,11 @@ export interface IModeLocator {
export
interface
ITokenizationCustomization
{
getInitialState
():
modes
.
I
State
;
getInitialState
():
Abstract
State
;
enterNestedMode
?:
(
state
:
modes
.
I
State
)
=>
boolean
;
enterNestedMode
?:
(
state
:
Abstract
State
)
=>
boolean
;
getNestedMode
?:
(
state
:
modes
.
I
State
,
locator
:
IModeLocator
)
=>
modes
.
IMode
;
getNestedMode
?:
(
state
:
Abstract
State
,
locator
:
IModeLocator
)
=>
modes
.
IMode
;
/**
* Return null if the line does not leave the nested mode
...
...
@@ -109,7 +110,7 @@ export class TokenizationSupport implements modes.ITokenizationSupport, IDisposa
if
(
state
.
getModeId
()
!==
this
.
_modeId
)
{
return
this
.
_nestedTokenize
(
line
,
state
,
deltaOffset
,
stopAtOffset
,
[],
[]);
}
else
{
return
this
.
_myTokenize
(
line
,
state
,
deltaOffset
,
stopAtOffset
,
[],
[]);
return
this
.
_myTokenize
(
line
,
<
AbstractState
>
state
,
deltaOffset
,
stopAtOffset
,
[],
[]);
}
}
...
...
@@ -178,9 +179,9 @@ export class TokenizationSupport implements modes.ITokenizationSupport, IDisposa
* Precondition is: state.getMode() === this
* This means we are in the current mode when parsing starts on this line.
*/
private
_myTokenize
(
buffer
:
string
,
myState
:
modes
.
I
State
,
deltaOffset
:
number
,
stopAtOffset
:
number
,
prependTokens
:
Token
[],
prependModeTransitions
:
ModeTransition
[]):
modes
.
ILineTokens
{
private
_myTokenize
(
buffer
:
string
,
myState
:
Abstract
State
,
deltaOffset
:
number
,
stopAtOffset
:
number
,
prependTokens
:
Token
[],
prependModeTransitions
:
ModeTransition
[]):
modes
.
ILineTokens
{
let
lineStream
=
new
LineStream
(
buffer
);
let
tokenResult
:
modes
.
ITokenizationResult
,
beforeTokenizeStreamPos
:
number
;
let
tokenResult
:
ITokenizationResult
,
beforeTokenizeStreamPos
:
number
;
let
previousType
:
string
=
null
;
myState
=
myState
.
clone
();
...
...
@@ -228,7 +229,12 @@ export class TokenizationSupport implements modes.ITokenizationSupport, IDisposa
return
result
;
}
else
{
// Transition to the nested mode state
myState
=
nestedModeState
;
return
{
tokens
:
prependTokens
,
actualStopOffset
:
lineStream
.
pos
()
+
deltaOffset
,
modeTransitions
:
prependModeTransitions
,
endState
:
nestedModeState
};
}
}
}
...
...
@@ -251,7 +257,7 @@ export class TokenizationSupport implements modes.ITokenizationSupport, IDisposa
return
result
;
}
private
_enterNestedMode
(
state
:
modes
.
I
State
):
boolean
{
private
_enterNestedMode
(
state
:
Abstract
State
):
boolean
{
if
(
this
.
defaults
.
enterNestedMode
)
{
return
false
;
}
...
...
@@ -259,7 +265,7 @@ export class TokenizationSupport implements modes.ITokenizationSupport, IDisposa
}
private
_getNestedMode
(
state
:
modes
.
I
State
):
modes
.
IMode
{
private
_getNestedMode
(
state
:
Abstract
State
):
modes
.
IMode
{
if
(
this
.
defaults
.
getNestedMode
)
{
return
null
;
}
...
...
@@ -291,7 +297,7 @@ export class TokenizationSupport implements modes.ITokenizationSupport, IDisposa
return
this
.
customization
.
getNestedMode
(
state
,
locator
);
}
private
_getNestedModeInitialState
(
state
:
modes
.
I
State
):
modes
.
IState
{
private
_getNestedModeInitialState
(
state
:
Abstract
State
):
modes
.
IState
{
let
nestedMode
=
this
.
_getNestedMode
(
state
);
if
(
nestedMode
)
{
let
tokenizationSupport
=
modes
.
TokenizationRegistry
.
get
(
nestedMode
.
getId
());
...
...
src/vs/editor/common/services/modelServiceImpl.ts
浏览文件 @
3d1c8e47
...
...
@@ -26,13 +26,6 @@ import {DEFAULT_INDENTATION, DEFAULT_TRIM_AUTO_WHITESPACE} from 'vs/editor/commo
import
{
IMessageService
}
from
'
vs/platform/message/common/message
'
;
import
{
PLAINTEXT_MODE_ID
}
from
'
vs/editor/common/modes/modesRegistry
'
;
export
interface
IRawModelData
{
url
:
URI
;
versionId
:
number
;
value
:
editorCommon
.
IRawText
;
modeId
:
string
;
}
function
MODEL_ID
(
resource
:
URI
):
string
{
return
resource
.
toString
();
}
...
...
src/vs/editor/test/common/mocks/mockMode.ts
浏览文件 @
3d1c8e47
...
...
@@ -4,8 +4,8 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
IMode
,
IState
,
IStream
,
ITokenizationResult
,
TokenizationRegistry
}
from
'
vs/editor/common/modes
'
;
import
{
AbstractState
}
from
'
vs/editor/common/modes/abstractState
'
;
import
{
IMode
,
IState
,
IStream
,
TokenizationRegistry
}
from
'
vs/editor/common/modes
'
;
import
{
AbstractState
,
ITokenizationResult
}
from
'
vs/editor/common/modes/abstractState
'
;
import
{
TokenizationSupport
}
from
'
vs/editor/common/modes/supports/tokenizationSupport
'
;
let
instanceCount
=
0
;
...
...
src/vs/editor/test/common/model/model.modes.test.ts
浏览文件 @
3d1c8e47
...
...
@@ -9,7 +9,7 @@ import {EditOperation} from 'vs/editor/common/core/editOperation';
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
Model
}
from
'
vs/editor/common/model/model
'
;
import
{
AbstractState
}
from
'
vs/editor/common/modes/abstractState
'
;
import
{
AbstractState
,
ITokenizationResult
}
from
'
vs/editor/common/modes/abstractState
'
;
import
*
as
modes
from
'
vs/editor/common/modes
'
;
import
{
TokenizationSupport
}
from
'
vs/editor/common/modes/supports/tokenizationSupport
'
;
...
...
@@ -38,7 +38,7 @@ suite('Editor Model - Model Modes 1', () => {
public
equals
(
other
:
modes
.
IState
):
boolean
{
return
this
===
other
;
}
public
tokenize
(
stream
:
modes
.
IStream
):
modes
.
ITokenizationResult
{
public
tokenize
(
stream
:
modes
.
IStream
):
ITokenizationResult
{
calledState
.
calledFor
.
push
(
stream
.
next
());
stream
.
advanceToEOS
();
return
{
type
:
''
};
...
...
@@ -188,7 +188,7 @@ suite('Editor Model - Model Modes 2', () => {
return
(
other
instanceof
ModelState2
)
&&
(
this
.
prevLineContent
===
(
<
ModelState2
>
other
).
prevLineContent
);
}
public
tokenize
(
stream
:
modes
.
IStream
):
modes
.
ITokenizationResult
{
public
tokenize
(
stream
:
modes
.
IStream
):
ITokenizationResult
{
var
line
=
''
;
while
(
!
stream
.
eos
())
{
line
+=
stream
.
next
();
...
...
@@ -309,7 +309,7 @@ suite('Editor Model - Token Iterator', () => {
class
NState
extends
AbstractState
{
private
n
:
number
;
private
allResults
:
modes
.
ITokenizationResult
[];
private
allResults
:
ITokenizationResult
[];
constructor
(
modeId
:
string
,
n
:
number
)
{
super
(
modeId
);
...
...
@@ -325,7 +325,7 @@ suite('Editor Model - Token Iterator', () => {
return
true
;
}
public
tokenize
(
stream
:
modes
.
IStream
):
modes
.
ITokenizationResult
{
public
tokenize
(
stream
:
modes
.
IStream
):
ITokenizationResult
{
var
ndash
=
this
.
n
,
value
=
''
;
while
(
!
stream
.
eos
()
&&
ndash
>
0
)
{
value
+=
stream
.
next
();
...
...
src/vs/editor/test/common/modes/textToHtmlTokenizer.test.ts
浏览文件 @
3d1c8e47
...
...
@@ -5,8 +5,8 @@
'
use strict
'
;
import
*
as
assert
from
'
assert
'
;
import
{
IStream
,
ITokenizationResult
,
TokenizationRegistry
}
from
'
vs/editor/common/modes
'
;
import
{
AbstractState
}
from
'
vs/editor/common/modes/abstractState
'
;
import
{
IStream
,
TokenizationRegistry
}
from
'
vs/editor/common/modes
'
;
import
{
AbstractState
,
ITokenizationResult
}
from
'
vs/editor/common/modes/abstractState
'
;
import
{
TokenizationSupport
}
from
'
vs/editor/common/modes/supports/tokenizationSupport
'
;
import
{
tokenizeToHtmlContent
}
from
'
vs/editor/common/modes/textToHtmlTokenizer
'
;
import
{
MockMode
}
from
'
vs/editor/test/common/mocks/mockMode
'
;
...
...
src/vs/editor/test/common/modes/tokenization.test.ts
浏览文件 @
3d1c8e47
...
...
@@ -6,7 +6,7 @@
import
*
as
assert
from
'
assert
'
;
import
*
as
modes
from
'
vs/editor/common/modes
'
;
import
{
AbstractState
}
from
'
vs/editor/common/modes/abstractState
'
;
import
{
AbstractState
,
ITokenizationResult
}
from
'
vs/editor/common/modes/abstractState
'
;
import
{
handleEvent
}
from
'
vs/editor/common/modes/supports
'
;
import
{
IModeLocator
,
ILeavingNestedModeData
,
TokenizationSupport
}
from
'
vs/editor/common/modes/supports/tokenizationSupport
'
;
import
{
createMockLineContext
}
from
'
vs/editor/test/common/modesTestUtils
'
;
...
...
@@ -36,7 +36,7 @@ export class StateMemorizingLastWord extends AbstractState {
return
new
StateMemorizingLastWord
(
this
.
getModeId
(),
this
.
descriptor
,
this
.
lastWord
);
}
public
tokenize
(
stream
:
modes
.
IStream
):
modes
.
ITokenizationResult
{
public
tokenize
(
stream
:
modes
.
IStream
):
ITokenizationResult
{
stream
.
setTokenRules
(
'
[]{}()==--
'
,
'
\t
\
u00a0
'
);
if
(
stream
.
skipWhitespace
()
!==
''
)
{
return
{
...
...
@@ -61,7 +61,7 @@ export class SwitchingMode extends MockMode {
modes
.
TokenizationRegistry
.
register
(
this
.
getId
(),
new
TokenizationSupport
(
null
,
this
.
getId
(),
this
,
true
));
}
public
getInitialState
():
modes
.
I
State
{
public
getInitialState
():
Abstract
State
{
return
new
StateMemorizingLastWord
(
this
.
getId
(),
this
.
_switchingModeDescriptor
,
null
);
}
...
...
@@ -167,7 +167,7 @@ suite('Editor Modes - Tokenization', () => {
return
new
State
(
this
.
getModeId
());
}
public
tokenize
(
stream
:
modes
.
IStream
):
modes
.
ITokenizationResult
{
public
tokenize
(
stream
:
modes
.
IStream
):
ITokenizationResult
{
return
{
type
:
stream
.
next
()
===
'
.
'
?
''
:
'
text
'
};
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录