Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
b5063c42
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,发现更多精彩内容 >>
提交
b5063c42
编写于
6月 05, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Reduce dependencies on IMode
上级
92b91cf3
变更
22
隐藏空白更改
内联
并排
Showing
22 changed file
with
86 addition
and
119 deletion
+86
-119
src/vs/editor/common/controller/cursorCollection.ts
src/vs/editor/common/controller/cursorCollection.ts
+2
-2
src/vs/editor/common/controller/oneCursor.ts
src/vs/editor/common/controller/oneCursor.ts
+2
-2
src/vs/editor/common/core/modeTransition.ts
src/vs/editor/common/core/modeTransition.ts
+2
-0
src/vs/editor/common/editorCommon.ts
src/vs/editor/common/editorCommon.ts
+4
-3
src/vs/editor/common/model/mirrorModel.ts
src/vs/editor/common/model/mirrorModel.ts
+5
-5
src/vs/editor/common/model/textModelWithTokens.ts
src/vs/editor/common/model/textModelWithTokens.ts
+13
-13
src/vs/editor/common/model/textModelWithTokensHelpers.ts
src/vs/editor/common/model/textModelWithTokensHelpers.ts
+1
-1
src/vs/editor/common/modes.ts
src/vs/editor/common/modes.ts
+0
-35
src/vs/editor/common/modes/languageConfigurationRegistry.ts
src/vs/editor/common/modes/languageConfigurationRegistry.ts
+20
-20
src/vs/editor/common/modes/supports.ts
src/vs/editor/common/modes/supports.ts
+3
-3
src/vs/editor/common/modes/supports/characterPair.ts
src/vs/editor/common/modes/supports/characterPair.ts
+4
-4
src/vs/editor/common/modes/supports/electricCharacter.ts
src/vs/editor/common/modes/supports/electricCharacter.ts
+3
-3
src/vs/editor/common/modes/supports/onEnter.ts
src/vs/editor/common/modes/supports/onEnter.ts
+4
-4
src/vs/editor/common/modes/supports/richEditBrackets.ts
src/vs/editor/common/modes/supports/richEditBrackets.ts
+3
-3
src/vs/editor/contrib/comment/common/blockCommentCommand.ts
src/vs/editor/contrib/comment/common/blockCommentCommand.ts
+2
-2
src/vs/editor/contrib/comment/common/lineCommentCommand.ts
src/vs/editor/contrib/comment/common/lineCommentCommand.ts
+5
-7
src/vs/editor/contrib/smartSelect/common/tokenTree.ts
src/vs/editor/contrib/smartSelect/common/tokenTree.ts
+4
-3
src/vs/editor/test/common/modes/tokenization.test.ts
src/vs/editor/test/common/modes/tokenization.test.ts
+4
-4
src/vs/languages/css/test/common/css.test.ts
src/vs/languages/css/test/common/css.test.ts
+1
-1
src/vs/languages/html/test/common/html.test.ts
src/vs/languages/html/test/common/html.test.ts
+1
-1
src/vs/languages/php/test/common/php.test.ts
src/vs/languages/php/test/common/php.test.ts
+1
-1
src/vs/workbench/parts/emmet/node/editorAccessor.ts
src/vs/workbench/parts/emmet/node/editorAccessor.ts
+2
-2
未找到文件。
src/vs/editor/common/controller/cursorCollection.ts
浏览文件 @
b5063c42
...
...
@@ -328,7 +328,7 @@ export class CursorCollection {
};
let
electricCharSupport
=
LanguageConfigurationRegistry
.
getElectricCharacterSupport
(
this
.
model
.
getMode
());
let
electricCharSupport
=
LanguageConfigurationRegistry
.
getElectricCharacterSupport
(
this
.
model
.
getMode
()
.
getId
()
);
if
(
electricCharSupport
)
{
let
electricChars
:
string
[]
=
null
;
try
{
...
...
@@ -344,7 +344,7 @@ export class CursorCollection {
}
}
let
characterPairSupport
=
LanguageConfigurationRegistry
.
getCharacterPairSupport
(
this
.
model
.
getMode
());
let
characterPairSupport
=
LanguageConfigurationRegistry
.
getCharacterPairSupport
(
this
.
model
.
getMode
()
.
getId
()
);
if
(
characterPairSupport
)
{
let
autoClosingPairs
:
IAutoClosingPair
[];
try
{
...
...
src/vs/editor/common/controller/oneCursor.ts
浏览文件 @
b5063c42
...
...
@@ -1269,7 +1269,7 @@ export class OneCursorOp {
return
false
;
}
let
characterPairSupport
=
LanguageConfigurationRegistry
.
getCharacterPairSupport
(
cursor
.
model
.
getMode
());
let
characterPairSupport
=
LanguageConfigurationRegistry
.
getCharacterPairSupport
(
cursor
.
model
.
getMode
()
.
getId
()
);
if
(
!
characterPairSupport
)
{
return
false
;
...
...
@@ -1380,7 +1380,7 @@ export class OneCursorOp {
let
lineContext
=
cursor
.
model
.
getLineContext
(
position
.
lineNumber
);
let
electricAction
:
IElectricAction
;
let
electricCharSupport
=
LanguageConfigurationRegistry
.
getElectricCharacterSupport
(
cursor
.
model
.
getMode
());
let
electricCharSupport
=
LanguageConfigurationRegistry
.
getElectricCharacterSupport
(
cursor
.
model
.
getMode
()
.
getId
()
);
if
(
electricCharSupport
)
{
try
{
electricAction
=
electricCharSupport
.
onElectricCharacter
(
lineContext
,
position
.
column
-
2
);
...
...
src/vs/editor/common/core/modeTransition.ts
浏览文件 @
b5063c42
...
...
@@ -12,10 +12,12 @@ export class ModeTransition {
public
startIndex
:
number
;
public
mode
:
IMode
;
public
modeId
:
string
;
constructor
(
startIndex
:
number
,
mode
:
IMode
)
{
this
.
startIndex
=
startIndex
|
0
;
this
.
mode
=
mode
;
this
.
modeId
=
mode
.
getId
();
}
public
static
findIndexInSegmentsArray
(
arr
:
ModeTransition
[],
desiredIndex
:
number
):
number
{
...
...
src/vs/editor/common/editorCommon.ts
浏览文件 @
b5063c42
...
...
@@ -10,13 +10,14 @@ import {IHTMLContentElement} from 'vs/base/common/htmlContent';
import
URI
from
'
vs/base/common/uri
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IInstantiationService
,
IConstructorSignature1
,
IConstructorSignature2
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
ILineContext
,
IMode
,
I
ModeTransition
,
I
Token
}
from
'
vs/editor/common/modes
'
;
import
{
ILineContext
,
IMode
,
IToken
}
from
'
vs/editor/common/modes
'
;
import
{
ViewLineToken
}
from
'
vs/editor/common/core/viewLineToken
'
;
import
{
ScrollbarVisibility
}
from
'
vs/base/browser/ui/scrollbar/scrollableElementOptions
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
import
{
ModeTransition
}
from
'
vs/editor/common/core/modeTransition
'
;
/**
* @internal
...
...
@@ -1676,7 +1677,7 @@ export interface ITokenizedModel extends ITextModel {
/**
* @internal
*/
_getLineModeTransitions
(
lineNumber
:
number
):
I
ModeTransition
[];
_getLineModeTransitions
(
lineNumber
:
number
):
ModeTransition
[];
/**
* Get the current language mode associated with the model.
...
...
@@ -1701,7 +1702,7 @@ export interface ITokenizedModel extends ITextModel {
* Returns the true (inner-most) language mode at a given position.
* @internal
*/
getMode
AtPosition
(
lineNumber
:
number
,
column
:
number
):
IMode
;
getMode
IdAtPosition
(
lineNumber
:
number
,
column
:
number
):
string
;
/**
* Get the word under or besides `position`.
...
...
src/vs/editor/common/model/mirrorModel.ts
浏览文件 @
b5063c42
...
...
@@ -255,9 +255,9 @@ export class MirrorModel extends AbstractMirrorModel implements editorCommon.IMi
}
public
getEmbeddedAtPosition
(
position
:
editorCommon
.
IPosition
):
editorCommon
.
IMirrorModel
{
var
mode
AtPosition
=
this
.
getMode
AtPosition
(
position
.
lineNumber
,
position
.
column
);
if
(
this
.
_embeddedModels
.
hasOwnProperty
(
mode
AtPosition
.
getId
()
))
{
return
this
.
_embeddedModels
[
mode
AtPosition
.
getId
()
];
var
mode
IdAtPosition
=
this
.
getModeId
AtPosition
(
position
.
lineNumber
,
position
.
column
);
if
(
this
.
_embeddedModels
.
hasOwnProperty
(
mode
IdAtPosition
))
{
return
this
.
_embeddedModels
[
mode
IdAtPosition
];
}
return
null
;
}
...
...
@@ -299,7 +299,7 @@ export class MirrorModel extends AbstractMirrorModel implements editorCommon.IMi
for
(
var
i
=
0
;
i
<
modeTransitions
.
length
;
i
++
)
{
var
modeTransition
=
modeTransitions
[
i
];
if
(
modeTransition
.
mode
.
getId
()
!==
currentModeId
)
{
if
(
modeTransition
.
mode
Id
!==
currentModeId
)
{
var
modeRange
=
getOrCreateEmbeddedModeRange
(
currentModeId
,
currentMode
);
modeRange
.
ranges
.
push
({
...
...
@@ -309,7 +309,7 @@ export class MirrorModel extends AbstractMirrorModel implements editorCommon.IMi
endColumn
:
modeTransition
.
startIndex
+
1
});
currentModeId
=
modeTransition
.
mode
.
getId
()
;
currentModeId
=
modeTransition
.
mode
Id
;
currentMode
=
modeTransition
.
mode
;
currentStartLineNumber
=
lineNumber
;
currentStartColumn
=
modeTransition
.
startIndex
+
1
;
...
...
src/vs/editor/common/model/textModelWithTokens.ts
浏览文件 @
b5063c42
...
...
@@ -441,7 +441,7 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
}
}
public
getMode
AtPosition
(
_lineNumber
:
number
,
_column
:
number
):
IMode
{
public
getMode
IdAtPosition
(
_lineNumber
:
number
,
_column
:
number
):
string
{
var
validPosition
=
this
.
validatePosition
({
lineNumber
:
_lineNumber
,
column
:
_column
...
...
@@ -451,13 +451,13 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
var
column
=
validPosition
.
column
;
if
(
column
===
1
)
{
return
this
.
getStateBeforeLine
(
lineNumber
).
getMode
();
return
this
.
getStateBeforeLine
(
lineNumber
).
getMode
()
.
getId
()
;
}
else
if
(
column
===
this
.
getLineMaxColumn
(
lineNumber
))
{
return
this
.
getStateAfterLine
(
lineNumber
).
getMode
();
return
this
.
getStateAfterLine
(
lineNumber
).
getMode
()
.
getId
()
;
}
else
{
var
modeTransitions
=
this
.
_getLineModeTransitions
(
lineNumber
);
var
modeTransitionIndex
=
ModeTransition
.
findIndexInSegmentsArray
(
modeTransitions
,
column
-
1
);
return
modeTransitions
[
modeTransitionIndex
].
mode
;
return
modeTransitions
[
modeTransitionIndex
].
mode
Id
;
}
}
...
...
@@ -762,7 +762,7 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
let
modeTransitions
=
this
.
_lines
[
position
.
lineNumber
-
1
].
getModeTransitions
(
this
.
_mode
);
let
currentModeIndex
=
ModeTransition
.
findIndexInSegmentsArray
(
modeTransitions
,
position
.
column
-
1
);
let
currentMode
=
modeTransitions
[
currentModeIndex
];
let
currentModeBrackets
=
LanguageConfigurationRegistry
.
getBracketsSupport
(
currentMode
.
mode
);
let
currentModeBrackets
=
LanguageConfigurationRegistry
.
getBracketsSupport
(
currentMode
.
mode
Id
);
if
(
!
currentModeBrackets
)
{
return
null
;
...
...
@@ -792,7 +792,7 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
let
modeTransitions
=
this
.
_lines
[
lineNumber
-
1
].
getModeTransitions
(
this
.
_mode
);
let
currentModeIndex
=
ModeTransition
.
findIndexInSegmentsArray
(
modeTransitions
,
position
.
column
-
1
);
let
currentMode
=
modeTransitions
[
currentModeIndex
];
let
currentModeBrackets
=
LanguageConfigurationRegistry
.
getBracketsSupport
(
currentMode
.
mode
);
let
currentModeBrackets
=
LanguageConfigurationRegistry
.
getBracketsSupport
(
currentMode
.
mode
Id
);
// If position is in between two tokens, try first looking in the previous token
if
(
currentTokenIndex
>
0
&&
currentTokenStart
===
position
.
column
-
1
)
{
...
...
@@ -808,7 +808,7 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
// check if previous token is in a different mode
if
(
currentModeIndex
>
0
&&
currentMode
.
startIndex
===
position
.
column
-
1
)
{
prevMode
=
modeTransitions
[
currentModeIndex
-
1
];
prevModeBrackets
=
LanguageConfigurationRegistry
.
getBracketsSupport
(
prevMode
.
mode
);
prevModeBrackets
=
LanguageConfigurationRegistry
.
getBracketsSupport
(
prevMode
.
mode
Id
);
}
if
(
prevModeBrackets
)
{
...
...
@@ -898,7 +898,7 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
let
modeTransitions
=
this
.
_lines
[
lineNumber
-
1
].
getModeTransitions
(
this
.
_mode
);
let
currentModeIndex
=
modeTransitions
.
length
-
1
;
let
currentModeStart
=
modeTransitions
[
currentModeIndex
].
startIndex
;
let
currentModeId
=
modeTransitions
[
currentModeIndex
].
mode
.
getId
()
;
let
currentModeId
=
modeTransitions
[
currentModeIndex
].
mode
Id
;
let
tokensLength
=
lineTokens
.
getTokenCount
()
-
1
;
let
currentTokenEnd
=
lineText
.
length
;
...
...
@@ -908,7 +908,7 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
currentModeIndex
=
ModeTransition
.
findIndexInSegmentsArray
(
modeTransitions
,
position
.
column
-
1
);
currentModeStart
=
modeTransitions
[
currentModeIndex
].
startIndex
;
currentModeId
=
modeTransitions
[
currentModeIndex
].
mode
.
getId
()
;
currentModeId
=
modeTransitions
[
currentModeIndex
].
mode
Id
;
}
for
(
let
tokenIndex
=
tokensLength
;
tokenIndex
>=
0
;
tokenIndex
--
)
{
...
...
@@ -918,7 +918,7 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
if
(
currentTokenStart
<
currentModeStart
)
{
currentModeIndex
--
;
currentModeStart
=
modeTransitions
[
currentModeIndex
].
startIndex
;
currentModeId
=
modeTransitions
[
currentModeIndex
].
mode
.
getId
()
;
currentModeId
=
modeTransitions
[
currentModeIndex
].
mode
Id
;
}
if
(
currentModeId
===
modeId
&&
!
ignoreBracketsInToken
(
currentTokenType
))
{
...
...
@@ -965,7 +965,7 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
let
modeTransitions
=
this
.
_lines
[
lineNumber
-
1
].
getModeTransitions
(
this
.
_mode
);
let
currentModeIndex
=
0
;
let
nextModeStart
=
(
currentModeIndex
+
1
<
modeTransitions
.
length
?
modeTransitions
[
currentModeIndex
+
1
].
startIndex
:
lineText
.
length
+
1
);
let
currentModeId
=
modeTransitions
[
currentModeIndex
].
mode
.
getId
()
;
let
currentModeId
=
modeTransitions
[
currentModeIndex
].
mode
Id
;
let
startTokenIndex
=
0
;
let
currentTokenStart
=
lineTokens
.
getTokenStartIndex
(
startTokenIndex
);
...
...
@@ -975,7 +975,7 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
currentModeIndex
=
ModeTransition
.
findIndexInSegmentsArray
(
modeTransitions
,
position
.
column
-
1
);
nextModeStart
=
(
currentModeIndex
+
1
<
modeTransitions
.
length
?
modeTransitions
[
currentModeIndex
+
1
].
startIndex
:
lineText
.
length
+
1
);
currentModeId
=
modeTransitions
[
currentModeIndex
].
mode
.
getId
()
;
currentModeId
=
modeTransitions
[
currentModeIndex
].
mode
Id
;
}
for
(
let
tokenIndex
=
startTokenIndex
,
tokensLength
=
lineTokens
.
getTokenCount
();
tokenIndex
<
tokensLength
;
tokenIndex
++
)
{
...
...
@@ -985,7 +985,7 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
if
(
currentTokenStart
>=
nextModeStart
)
{
currentModeIndex
++
;
nextModeStart
=
(
currentModeIndex
+
1
<
modeTransitions
.
length
?
modeTransitions
[
currentModeIndex
+
1
].
startIndex
:
lineText
.
length
+
1
);
currentModeId
=
modeTransitions
[
currentModeIndex
].
mode
.
getId
()
;
currentModeId
=
modeTransitions
[
currentModeIndex
].
mode
Id
;
}
if
(
currentModeId
===
modeId
&&
!
ignoreBracketsInToken
(
currentTokenType
))
{
...
...
src/vs/editor/common/model/textModelWithTokensHelpers.ts
浏览文件 @
b5063c42
...
...
@@ -28,7 +28,7 @@ export interface INonWordTokenMap {
export
class
WordHelper
{
private
static
_safeGetWordDefinition
(
mode
:
IMode
):
RegExp
{
return
LanguageConfigurationRegistry
.
getWordDefinition
(
mode
);
return
LanguageConfigurationRegistry
.
getWordDefinition
(
mode
.
getId
()
);
}
public
static
ensureValidWordDefinition
(
wordDefinition
?:
RegExp
):
RegExp
{
...
...
src/vs/editor/common/modes.ts
浏览文件 @
b5063c42
...
...
@@ -760,41 +760,6 @@ export interface IRichEditBrackets {
textIsOpenBracket
:
{[
text
:
string
]:
boolean
;};
}
/**
* @internal
*/
export
interface
IRichEditSupport
{
/**
* Optional adapter for electric characters.
*/
electricCharacter
?:
IRichEditElectricCharacter
;
/**
* Optional adapter for comment insertion.
*/
comments
?:
ICommentsConfiguration
;
/**
* Optional adapter for insertion of character pair.
*/
characterPair
?:
IRichEditCharacterPair
;
/**
* Optional adapter for classification of tokens.
*/
wordDefinition
?:
RegExp
;
/**
* Optional adapter for custom Enter handling.
*/
onEnter
?:
IRichEditOnEnter
;
/**
* Optional adapter for brackets.
*/
brackets
?:
IRichEditBrackets
;
}
// --- feature registries ------
/**
...
...
src/vs/editor/common/modes/languageConfigurationRegistry.ts
浏览文件 @
b5063c42
...
...
@@ -5,8 +5,8 @@
'
use strict
'
;
import
{
ICommentsConfiguration
,
IRichEditBrackets
,
IRichEditCharacterPair
,
IAutoClosingPair
,
IAutoClosingPairConditional
,
IRichEditOnEnter
,
IRichEditSupport
,
CharacterPair
,
I
Mode
,
I
RichEditElectricCharacter
,
IEnterAction
,
IndentAction
}
from
'
vs/editor/common/modes
'
;
IAutoClosingPairConditional
,
IRichEditOnEnter
,
CharacterPair
,
IRichEditElectricCharacter
,
IEnterAction
,
IndentAction
}
from
'
vs/editor/common/modes
'
;
import
{
NullMode
}
from
'
vs/editor/common/modes/nullMode
'
;
import
{
CharacterPairSupport
}
from
'
vs/editor/common/modes/supports/characterPair
'
;
import
{
BracketElectricCharacterSupport
,
IBracketElectricCharacterContribution
}
from
'
vs/editor/common/modes/supports/electricCharacter
'
;
...
...
@@ -35,7 +35,7 @@ export interface IRichLanguageConfiguration {
__electricCharacterSupport
?:
IBracketElectricCharacterContribution
;
}
export
class
RichEditSupport
implements
IRichEditSupport
{
export
class
RichEditSupport
{
private
_conf
:
IRichLanguageConfiguration
;
...
...
@@ -46,10 +46,10 @@ export class RichEditSupport implements IRichEditSupport {
public
onEnter
:
IRichEditOnEnter
;
public
brackets
:
IRichEditBrackets
;
constructor
(
modeId
:
string
,
previous
:
I
RichEditSupport
,
rawConf
:
IRichLanguageConfiguration
)
{
constructor
(
modeId
:
string
,
previous
:
RichEditSupport
,
rawConf
:
IRichLanguageConfiguration
)
{
let
prev
:
IRichLanguageConfiguration
=
null
;
if
(
previous
instanceof
RichEditSupport
)
{
if
(
previous
)
{
prev
=
previous
.
_conf
;
}
...
...
@@ -150,44 +150,44 @@ export class LanguageConfigurationRegistryImpl {
};
}
private
_getRichEditSupport
(
mode
:
IMode
):
I
RichEditSupport
{
return
this
.
_entries
[
mode
.
getId
()
];
private
_getRichEditSupport
(
mode
Id
:
string
):
RichEditSupport
{
return
this
.
_entries
[
mode
Id
];
}
public
getElectricCharacterSupport
(
mode
:
IMode
):
IRichEditElectricCharacter
{
let
value
=
this
.
_getRichEditSupport
(
mode
);
public
getElectricCharacterSupport
(
mode
Id
:
string
):
IRichEditElectricCharacter
{
let
value
=
this
.
_getRichEditSupport
(
mode
Id
);
if
(
!
value
)
{
return
null
;
}
return
value
.
electricCharacter
||
null
;
}
public
getComments
(
mode
:
IMode
):
ICommentsConfiguration
{
let
value
=
this
.
_getRichEditSupport
(
mode
);
public
getComments
(
mode
Id
:
string
):
ICommentsConfiguration
{
let
value
=
this
.
_getRichEditSupport
(
mode
Id
);
if
(
!
value
)
{
return
null
;
}
return
value
.
comments
||
null
;
}
public
getCharacterPairSupport
(
mode
:
IMode
):
IRichEditCharacterPair
{
let
value
=
this
.
_getRichEditSupport
(
mode
);
public
getCharacterPairSupport
(
mode
Id
:
string
):
IRichEditCharacterPair
{
let
value
=
this
.
_getRichEditSupport
(
mode
Id
);
if
(
!
value
)
{
return
null
;
}
return
value
.
characterPair
||
null
;
}
public
getWordDefinition
(
mode
:
IMode
):
RegExp
{
let
value
=
this
.
_getRichEditSupport
(
mode
);
public
getWordDefinition
(
mode
Id
:
string
):
RegExp
{
let
value
=
this
.
_getRichEditSupport
(
mode
Id
);
if
(
!
value
)
{
return
null
;
}
return
value
.
wordDefinition
||
null
;
}
public
getOnEnterSupport
(
mode
:
IMode
):
IRichEditOnEnter
{
let
value
=
this
.
_getRichEditSupport
(
mode
);
public
getOnEnterSupport
(
mode
Id
:
string
):
IRichEditOnEnter
{
let
value
=
this
.
_getRichEditSupport
(
mode
Id
);
if
(
!
value
)
{
return
null
;
}
...
...
@@ -197,7 +197,7 @@ export class LanguageConfigurationRegistryImpl {
public
getRawEnterActionAtPosition
(
model
:
ITokenizedModel
,
lineNumber
:
number
,
column
:
number
):
IEnterAction
{
let
result
:
IEnterAction
;
let
onEnterSupport
=
this
.
getOnEnterSupport
(
model
.
getMode
());
let
onEnterSupport
=
this
.
getOnEnterSupport
(
model
.
getMode
()
.
getId
()
);
if
(
onEnterSupport
)
{
try
{
...
...
@@ -246,8 +246,8 @@ export class LanguageConfigurationRegistryImpl {
};
}
public
getBracketsSupport
(
mode
:
IMode
):
IRichEditBrackets
{
let
value
=
this
.
_getRichEditSupport
(
mode
);
public
getBracketsSupport
(
mode
Id
:
string
):
IRichEditBrackets
{
let
value
=
this
.
_getRichEditSupport
(
mode
Id
);
if
(
!
value
)
{
return
null
;
}
...
...
src/vs/editor/common/modes/supports.ts
浏览文件 @
b5063c42
...
...
@@ -45,10 +45,10 @@ export class LineTokens implements modes.ILineTokens {
}
}
export
function
handleEvent
<
T
>
(
context
:
modes
.
ILineContext
,
offset
:
number
,
runner
:(
mode
:
modes
.
IMode
,
newContext
:
modes
.
ILineContext
,
offset
:
number
)
=>
T
):
T
{
export
function
handleEvent
<
T
>
(
context
:
modes
.
ILineContext
,
offset
:
number
,
runner
:(
mode
Id
:
string
,
newContext
:
modes
.
ILineContext
,
offset
:
number
)
=>
T
):
T
{
var
modeTransitions
=
context
.
modeTransitions
;
if
(
modeTransitions
.
length
===
1
)
{
return
runner
(
modeTransitions
[
0
].
mode
,
context
,
offset
);
return
runner
(
modeTransitions
[
0
].
mode
Id
,
context
,
offset
);
}
var
modeIndex
=
ModeTransition
.
findIndexInSegmentsArray
(
modeTransitions
,
offset
);
...
...
@@ -68,7 +68,7 @@ export function handleEvent<T>(context:modes.ILineContext, offset:number, runner
var
firstTokenCharacterOffset
=
context
.
getTokenStartIndex
(
firstTokenInModeIndex
);
var
newCtx
=
new
FilteredLineContext
(
context
,
nestedMode
,
firstTokenInModeIndex
,
nextTokenAfterMode
,
firstTokenCharacterOffset
,
nextCharacterAfterModeIndex
);
return
runner
(
nestedMode
,
newCtx
,
offset
-
firstTokenCharacterOffset
);
return
runner
(
nestedMode
.
getId
()
,
newCtx
,
offset
-
firstTokenCharacterOffset
);
}
export
class
FilteredLineContext
implements
modes
.
ILineContext
{
...
...
src/vs/editor/common/modes/supports/characterPair.ts
浏览文件 @
b5063c42
...
...
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
IAutoClosingPair
,
IAutoClosingPairConditional
,
ILineContext
,
I
Mode
,
I
RichEditCharacterPair
,
CharacterPair
}
from
'
vs/editor/common/modes
'
;
import
{
IAutoClosingPair
,
IAutoClosingPairConditional
,
ILineContext
,
IRichEditCharacterPair
,
CharacterPair
}
from
'
vs/editor/common/modes
'
;
import
{
handleEvent
}
from
'
vs/editor/common/modes/supports
'
;
import
{
LanguageConfigurationRegistryImpl
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
...
...
@@ -30,8 +30,8 @@ export class CharacterPairSupport implements IRichEditCharacterPair {
}
public
shouldAutoClosePair
(
character
:
string
,
context
:
ILineContext
,
offset
:
number
):
boolean
{
return
handleEvent
(
context
,
offset
,
(
nestedMode
:
IMode
,
context
:
ILineContext
,
offset
:
number
)
=>
{
if
(
this
.
_modeId
===
nestedMode
.
getId
()
)
{
return
handleEvent
(
context
,
offset
,
(
nestedMode
Id
:
string
,
context
:
ILineContext
,
offset
:
number
)
=>
{
if
(
this
.
_modeId
===
nestedMode
Id
)
{
// Always complete on empty line
if
(
context
.
getTokenCount
()
===
0
)
{
...
...
@@ -57,7 +57,7 @@ export class CharacterPairSupport implements IRichEditCharacterPair {
return
true
;
}
let
characterPairSupport
=
this
.
_registry
.
getCharacterPairSupport
(
nestedMode
);
let
characterPairSupport
=
this
.
_registry
.
getCharacterPairSupport
(
nestedMode
Id
);
if
(
characterPairSupport
)
{
return
characterPairSupport
.
shouldAutoClosePair
(
character
,
context
,
offset
);
}
...
...
src/vs/editor/common/modes/supports/electricCharacter.ts
浏览文件 @
b5063c42
...
...
@@ -47,11 +47,11 @@ export class BracketElectricCharacterSupport implements modes.IRichEditElectricC
}
public
onElectricCharacter
(
context
:
modes
.
ILineContext
,
offset
:
number
):
modes
.
IElectricAction
{
return
handleEvent
(
context
,
offset
,
(
nestedMode
:
modes
.
IMode
,
context
:
modes
.
ILineContext
,
offset
:
number
)
=>
{
if
(
this
.
_modeId
===
nestedMode
.
getId
()
)
{
return
handleEvent
(
context
,
offset
,
(
nestedMode
Id
:
string
,
context
:
modes
.
ILineContext
,
offset
:
number
)
=>
{
if
(
this
.
_modeId
===
nestedMode
Id
)
{
return
this
.
brackets
.
onElectricCharacter
(
context
,
offset
);
}
let
electricCharacterSupport
=
this
.
_registry
.
getElectricCharacterSupport
(
nestedMode
);
let
electricCharacterSupport
=
this
.
_registry
.
getElectricCharacterSupport
(
nestedMode
Id
);
if
(
electricCharacterSupport
)
{
return
electricCharacterSupport
.
onElectricCharacter
(
context
,
offset
);
}
...
...
src/vs/editor/common/modes/supports/onEnter.ts
浏览文件 @
b5063c42
...
...
@@ -7,7 +7,7 @@
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
{
IPosition
,
ITextModel
,
ITokenizedModel
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IEnterAction
,
ILineContext
,
I
Mode
,
I
RichEditOnEnter
,
IndentAction
,
CharacterPair
}
from
'
vs/editor/common/modes
'
;
import
{
IEnterAction
,
ILineContext
,
IRichEditOnEnter
,
IndentAction
,
CharacterPair
}
from
'
vs/editor/common/modes
'
;
import
{
handleEvent
}
from
'
vs/editor/common/modes/supports
'
;
import
{
LanguageConfigurationRegistryImpl
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
...
...
@@ -74,12 +74,12 @@ export class OnEnterSupport implements IRichEditOnEnter {
public
onEnter
(
model
:
ITokenizedModel
,
position
:
IPosition
):
IEnterAction
{
var
context
=
model
.
getLineContext
(
position
.
lineNumber
);
return
handleEvent
(
context
,
position
.
column
-
1
,
(
nestedMode
:
IMode
,
context
:
ILineContext
,
offset
:
number
)
=>
{
if
(
this
.
_modeId
===
nestedMode
.
getId
()
)
{
return
handleEvent
(
context
,
position
.
column
-
1
,
(
nestedMode
Id
:
string
,
context
:
ILineContext
,
offset
:
number
)
=>
{
if
(
this
.
_modeId
===
nestedMode
Id
)
{
return
this
.
_onEnter
(
model
,
position
);
}
let
onEnterSupport
=
this
.
_registry
.
getOnEnterSupport
(
nestedMode
);
let
onEnterSupport
=
this
.
_registry
.
getOnEnterSupport
(
nestedMode
Id
);
if
(
onEnterSupport
)
{
return
onEnterSupport
.
onEnter
(
model
,
position
);
}
...
...
src/vs/editor/common/modes/supports/richEditBrackets.ts
浏览文件 @
b5063c42
...
...
@@ -7,14 +7,14 @@
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
IRichEditBracket
}
from
'
vs/editor/common/editorCommon
'
;
import
*
as
modes
from
'
vs/editor/common/modes
'
;
import
{
IRichEditBrackets
,
CharacterPair
}
from
'
vs/editor/common/modes
'
;
interface
ISimpleInternalBracket
{
open
:
string
;
close
:
string
;
}
export
class
RichEditBrackets
implements
modes
.
IRichEditBrackets
{
export
class
RichEditBrackets
implements
IRichEditBrackets
{
public
brackets
:
IRichEditBracket
[];
public
forwardRegex
:
RegExp
;
...
...
@@ -23,7 +23,7 @@ export class RichEditBrackets implements modes.IRichEditBrackets {
public
textIsBracket
:
{[
text
:
string
]:
IRichEditBracket
;};
public
textIsOpenBracket
:
{[
text
:
string
]:
boolean
;};
constructor
(
modeId
:
string
,
brackets
:
modes
.
CharacterPair
[])
{
constructor
(
modeId
:
string
,
brackets
:
CharacterPair
[])
{
this
.
brackets
=
brackets
.
map
((
b
)
=>
{
return
{
modeId
:
modeId
,
...
...
src/vs/editor/contrib/comment/common/blockCommentCommand.ts
浏览文件 @
b5063c42
...
...
@@ -122,8 +122,8 @@ export class BlockCommentCommand implements editorCommon.ICommand {
var
endLineNumber
=
this
.
_selection
.
endLineNumber
;
var
endColumn
=
this
.
_selection
.
endColumn
;
let
mode
=
model
.
getMode
AtPosition
(
startLineNumber
,
startColumn
);
let
config
=
LanguageConfigurationRegistry
.
getComments
(
mode
);
let
mode
Id
=
model
.
getModeId
AtPosition
(
startLineNumber
,
startColumn
);
let
config
=
LanguageConfigurationRegistry
.
getComments
(
mode
Id
);
if
(
!
config
||
!
config
.
blockCommentStartToken
||
!
config
.
blockCommentEndToken
)
{
// Mode does not support block comments
return
;
...
...
src/vs/editor/contrib/comment/common/lineCommentCommand.ts
浏览文件 @
b5063c42
...
...
@@ -10,7 +10,7 @@ import {Position} from 'vs/editor/common/core/position';
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
{
ICommentsConfiguration
,
IMode
}
from
'
vs/editor/common/modes
'
;
import
{
ICommentsConfiguration
}
from
'
vs/editor/common/modes
'
;
import
{
BlockCommentCommand
}
from
'
./blockCommentCommand
'
;
import
{
LanguageConfigurationRegistry
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
...
...
@@ -70,19 +70,17 @@ export class LineCommentCommand implements editorCommon.ICommand {
i
:
number
,
lineCount
:
number
,
lineNumber
:
number
,
mode
:
IMode
,
modeId
:
string
;
for
(
i
=
0
,
lineCount
=
endLineNumber
-
startLineNumber
+
1
;
i
<
lineCount
;
i
++
)
{
lineNumber
=
startLineNumber
+
i
;
mode
=
model
.
getModeAtPosition
(
lineNumber
,
1
);
modeId
=
mode
.
getId
();
modeId
=
model
.
getModeIdAtPosition
(
lineNumber
,
1
);
// Find the commentStr for this line, if none is found then bail out: we cannot do line comments
if
(
seenModes
[
modeId
])
{
commentStr
=
seenModes
[
modeId
];
}
else
{
config
=
LanguageConfigurationRegistry
.
getComments
(
mode
);
config
=
LanguageConfigurationRegistry
.
getComments
(
mode
Id
);
commentStr
=
(
config
?
config
.
lineCommentToken
:
null
);
if
(
!
commentStr
)
{
// Mode does not support line comments
...
...
@@ -274,8 +272,8 @@ export class LineCommentCommand implements editorCommon.ICommand {
* Given an unsuccessful analysis, delegate to the block comment command
*/
private
_executeBlockComment
(
model
:
editorCommon
.
ITokenizedModel
,
builder
:
editorCommon
.
IEditOperationBuilder
,
s
:
Selection
):
void
{
let
mode
=
model
.
getMode
AtPosition
(
s
.
startLineNumber
,
s
.
startColumn
);
let
config
=
LanguageConfigurationRegistry
.
getComments
(
mode
);
let
mode
Id
=
model
.
getModeId
AtPosition
(
s
.
startLineNumber
,
s
.
startColumn
);
let
config
=
LanguageConfigurationRegistry
.
getComments
(
mode
Id
);
if
(
!
config
||
!
config
.
blockCommentStartToken
||
!
config
.
blockCommentEndToken
)
{
// Mode does not support block comments
return
;
...
...
src/vs/editor/contrib/smartSelect/common/tokenTree.ts
浏览文件 @
b5063c42
...
...
@@ -7,10 +7,11 @@
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
ILineTokens
,
IModel
,
IPosition
,
IRange
,
IRichEditBracket
}
from
'
vs/editor/common/editorCommon
'
;
import
{
I
ModeTransition
,
I
RichEditBrackets
}
from
'
vs/editor/common/modes
'
;
import
{
IRichEditBrackets
}
from
'
vs/editor/common/modes
'
;
import
{
ignoreBracketsInToken
}
from
'
vs/editor/common/modes/supports
'
;
import
{
BracketsUtils
}
from
'
vs/editor/common/modes/supports/richEditBrackets
'
;
import
{
LanguageConfigurationRegistry
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
ModeTransition
}
from
'
vs/editor/common/core/modeTransition
'
;
export
enum
TokenTreeBracket
{
None
=
0
,
...
...
@@ -118,7 +119,7 @@ class TokenScanner {
private
_currentTokenIndex
:
number
;
private
_currentTokenStart
:
number
;
private
_currentLineTokens
:
ILineTokens
;
private
_currentLineModeTransitions
:
I
ModeTransition
[];
private
_currentLineModeTransitions
:
ModeTransition
[];
private
_currentModeIndex
:
number
;
private
_nextModeStart
:
number
;
private
_currentModeBrackets
:
IRichEditBrackets
;
...
...
@@ -160,7 +161,7 @@ class TokenScanner {
this
.
_currentModeIndex
++
;
this
.
_nextModeStart
=
(
this
.
_currentModeIndex
+
1
<
this
.
_currentLineModeTransitions
.
length
?
this
.
_currentLineModeTransitions
[
this
.
_currentModeIndex
+
1
].
startIndex
:
this
.
_currentLineText
.
length
+
1
);
let
mode
=
(
this
.
_currentModeIndex
<
this
.
_currentLineModeTransitions
.
length
?
this
.
_currentLineModeTransitions
[
this
.
_currentModeIndex
]
:
null
);
this
.
_currentModeBrackets
=
(
mode
?
LanguageConfigurationRegistry
.
getBracketsSupport
(
mode
.
mode
)
:
null
);
this
.
_currentModeBrackets
=
(
mode
?
LanguageConfigurationRegistry
.
getBracketsSupport
(
mode
.
mode
Id
)
:
null
);
}
let
tokenType
=
this
.
_currentLineTokens
.
getTokenType
(
this
.
_currentTokenIndex
);
...
...
src/vs/editor/test/common/modes/tokenization.test.ts
浏览文件 @
b5063c42
...
...
@@ -336,8 +336,8 @@ suite('Editor Modes - Tokenization', () => {
{
startIndex
:
5
,
id
:
'
B
'
}
]);
handleEvent
(
createMockLineContext
(
'
abc (def
'
,
lineTokens
),
0
,
(
mode
:
modes
.
IMode
,
context
:
modes
.
ILineContext
,
offset
:
number
)
=>
{
assert
.
deepEqual
(
mode
.
getId
()
,
'
A
'
);
handleEvent
(
createMockLineContext
(
'
abc (def
'
,
lineTokens
),
0
,
(
mode
Id
:
string
,
context
:
modes
.
ILineContext
,
offset
:
number
)
=>
{
assert
.
deepEqual
(
mode
Id
,
'
A
'
);
assert
.
equal
(
context
.
getTokenCount
(),
3
);
assert
.
equal
(
context
.
getTokenStartIndex
(
0
),
0
);
assert
.
equal
(
context
.
getTokenType
(
0
),
'
A.abc
'
);
...
...
@@ -349,8 +349,8 @@ suite('Editor Modes - Tokenization', () => {
assert
.
equal
(
context
.
getLineContent
(),
'
abc (
'
);
});
handleEvent
(
createMockLineContext
(
'
abc (def
'
,
lineTokens
),
6
,
(
mode
:
modes
.
IMode
,
context
:
modes
.
ILineContext
,
offset
:
number
)
=>
{
assert
.
deepEqual
(
mode
.
getId
()
,
'
B
'
);
handleEvent
(
createMockLineContext
(
'
abc (def
'
,
lineTokens
),
6
,
(
mode
Id
:
string
,
context
:
modes
.
ILineContext
,
offset
:
number
)
=>
{
assert
.
deepEqual
(
mode
Id
,
'
B
'
);
assert
.
equal
(
context
.
getTokenCount
(),
1
);
assert
.
equal
(
context
.
getTokenStartIndex
(
0
),
0
);
assert
.
equal
(
context
.
getTokenType
(
0
),
'
B.def
'
);
...
...
src/vs/languages/css/test/common/css.test.ts
浏览文件 @
b5063c42
...
...
@@ -33,7 +33,7 @@ suite('CSS Colorizing', () => {
tokenizationSupport
=
mode
.
tokenizationSupport
;
assertOnEnter
=
modesUtil
.
createOnEnterAsserter
(
mode
.
getId
(),
CSSMode
.
LANG_CONFIG
);
wordDefinition
=
LanguageConfigurationRegistry
.
getWordDefinition
(
mode
);
wordDefinition
=
LanguageConfigurationRegistry
.
getWordDefinition
(
mode
.
getId
()
);
})();
test
(
'
Skip whitespace
'
,
()
=>
{
...
...
src/vs/languages/html/test/common/html.test.ts
浏览文件 @
b5063c42
...
...
@@ -113,7 +113,7 @@ suite('Colorizing - HTML', () => {
tokenizationSupport
=
_mode
.
tokenizationSupport
;
onEnterSupport
=
LanguageConfigurationRegistry
.
getOnEnterSupport
(
_mode
);
onEnterSupport
=
LanguageConfigurationRegistry
.
getOnEnterSupport
(
_mode
.
getId
()
);
})();
test
(
'
Open Start Tag #1
'
,
()
=>
{
...
...
src/vs/languages/php/test/common/php.test.ts
浏览文件 @
b5063c42
...
...
@@ -76,7 +76,7 @@ suite('Syntax Highlighting - PHP', () => {
tokenizationSupport
=
mode
.
tokenizationSupport
;
assertOnEnter
=
modesUtil
.
createOnEnterAsserter
(
mode
.
getId
(),
PHPMode
.
LANG_CONFIG
);
wordDefinition
=
LanguageConfigurationRegistry
.
getWordDefinition
(
mode
);
wordDefinition
=
LanguageConfigurationRegistry
.
getWordDefinition
(
mode
.
getId
()
);
})();
test
(
''
,
()
=>
{
...
...
src/vs/workbench/parts/emmet/node/editorAccessor.ts
浏览文件 @
b5063c42
...
...
@@ -113,8 +113,8 @@ export class EditorAccessor implements emmet.Editor {
public
getSyntax
():
string
{
let
position
=
this
.
editor
.
getSelection
().
getStartPosition
();
let
mode
=
this
.
editor
.
getModel
().
getMode
AtPosition
(
position
.
lineNumber
,
position
.
column
);
let
syntax
=
mode
.
getId
()
.
split
(
'
.
'
).
pop
();
let
mode
Id
=
this
.
editor
.
getModel
().
getModeId
AtPosition
(
position
.
lineNumber
,
position
.
column
);
let
syntax
=
mode
Id
.
split
(
'
.
'
).
pop
();
if
(
/
\b(
razor|handlebars|erb|php|hbs|ejs|twig
)\b
/
.
test
(
syntax
))
{
// treat like html
return
'
html
'
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录