Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
d5b3efd8
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,发现更多精彩内容 >>
提交
d5b3efd8
编写于
11月 01, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adopt StandardTokenType in electricCharacter
上级
ca6a1f10
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
7 addition
and
28 deletion
+7
-28
src/vs/editor/common/modes/supports.ts
src/vs/editor/common/modes/supports.ts
+0
-4
src/vs/editor/common/modes/supports/electricCharacter.ts
src/vs/editor/common/modes/supports/electricCharacter.ts
+7
-20
src/vs/editor/test/common/modes/tokenization.test.ts
src/vs/editor/test/common/modes/tokenization.test.ts
+0
-4
未找到文件。
src/vs/editor/common/modes/supports.ts
浏览文件 @
d5b3efd8
...
@@ -96,10 +96,6 @@ export class ScopedLineTokens {
...
@@ -96,10 +96,6 @@ export class ScopedLineTokens {
return
this
.
_actual
.
getTokenStartOffset
(
tokenIndex
+
this
.
_firstTokenIndex
)
-
this
.
firstCharOffset
;
return
this
.
_actual
.
getTokenStartOffset
(
tokenIndex
+
this
.
_firstTokenIndex
)
-
this
.
firstCharOffset
;
}
}
public
getTokenType
(
tokenIndex
:
number
):
string
{
return
this
.
_actual
.
getTokenType
(
tokenIndex
+
this
.
_firstTokenIndex
);
}
public
getStandardTokenType
(
tokenIndex
:
number
):
StandardTokenType
{
public
getStandardTokenType
(
tokenIndex
:
number
):
StandardTokenType
{
return
this
.
_actual
.
getStandardTokenType
(
tokenIndex
+
this
.
_firstTokenIndex
);
return
this
.
_actual
.
getStandardTokenType
(
tokenIndex
+
this
.
_firstTokenIndex
);
}
}
...
...
src/vs/editor/common/modes/supports/electricCharacter.ts
浏览文件 @
d5b3efd8
...
@@ -8,7 +8,7 @@ import * as strings from 'vs/base/common/strings';
...
@@ -8,7 +8,7 @@ import * as strings from 'vs/base/common/strings';
import
{
ScopedLineTokens
,
ignoreBracketsInToken
}
from
'
vs/editor/common/modes/supports
'
;
import
{
ScopedLineTokens
,
ignoreBracketsInToken
}
from
'
vs/editor/common/modes/supports
'
;
import
{
BracketsUtils
}
from
'
vs/editor/common/modes/supports/richEditBrackets
'
;
import
{
BracketsUtils
}
from
'
vs/editor/common/modes/supports/richEditBrackets
'
;
import
{
RichEditBrackets
}
from
'
vs/editor/common/modes/supports/richEditBrackets
'
;
import
{
RichEditBrackets
}
from
'
vs/editor/common/modes/supports/richEditBrackets
'
;
import
{
IAutoClosingPairConditional
,
IBracketElectricCharacterContribution
}
from
'
vs/editor/common/modes/languageConfiguration
'
;
import
{
IAutoClosingPairConditional
,
IBracketElectricCharacterContribution
,
StandardAutoClosingPairConditional
}
from
'
vs/editor/common/modes/languageConfiguration
'
;
/**
/**
* Interface used to support electric characters
* Interface used to support electric characters
...
@@ -31,15 +31,15 @@ export interface IElectricAction {
...
@@ -31,15 +31,15 @@ export interface IElectricAction {
export
class
BracketElectricCharacterSupport
{
export
class
BracketElectricCharacterSupport
{
private
readonly
_richEditBrackets
:
RichEditBrackets
;
private
readonly
_richEditBrackets
:
RichEditBrackets
;
private
readonly
_complexAutoClosePairs
:
I
AutoClosingPairConditional
[];
private
readonly
_complexAutoClosePairs
:
Standard
AutoClosingPairConditional
[];
constructor
(
richEditBrackets
:
RichEditBrackets
,
autoClosePairs
:
IAutoClosingPairConditional
[],
contribution
:
IBracketElectricCharacterContribution
)
{
constructor
(
richEditBrackets
:
RichEditBrackets
,
autoClosePairs
:
IAutoClosingPairConditional
[],
contribution
:
IBracketElectricCharacterContribution
)
{
contribution
=
contribution
||
{};
contribution
=
contribution
||
{};
this
.
_richEditBrackets
=
richEditBrackets
;
this
.
_richEditBrackets
=
richEditBrackets
;
this
.
_complexAutoClosePairs
=
autoClosePairs
.
filter
(
pair
=>
pair
.
open
.
length
>
1
&&
!!
pair
.
close
);
this
.
_complexAutoClosePairs
=
autoClosePairs
.
filter
(
pair
=>
pair
.
open
.
length
>
1
&&
!!
pair
.
close
)
.
map
(
el
=>
new
StandardAutoClosingPairConditional
(
el
))
;
if
(
contribution
.
docComment
)
{
if
(
contribution
.
docComment
)
{
// IDocComment is legacy, only partially supported
// IDocComment is legacy, only partially supported
this
.
_complexAutoClosePairs
.
push
(
{
open
:
contribution
.
docComment
.
open
,
close
:
contribution
.
docComment
.
close
}
);
this
.
_complexAutoClosePairs
.
push
(
new
StandardAutoClosingPairConditional
({
open
:
contribution
.
docComment
.
open
,
close
:
contribution
.
docComment
.
close
})
);
}
}
}
}
...
@@ -76,16 +76,6 @@ export class BracketElectricCharacterSupport {
...
@@ -76,16 +76,6 @@ export class BracketElectricCharacterSupport {
this
.
_onElectricAutoIndent
(
context
,
offset
));
this
.
_onElectricAutoIndent
(
context
,
offset
));
}
}
private
containsTokenTypes
(
fullTokenSpec
:
string
,
tokensToLookFor
:
string
):
boolean
{
var
array
=
tokensToLookFor
.
split
(
'
.
'
);
for
(
var
i
=
0
;
i
<
array
.
length
;
++
i
)
{
if
(
fullTokenSpec
.
indexOf
(
array
[
i
])
<
0
)
{
return
false
;
}
}
return
true
;
}
private
_onElectricAutoIndent
(
context
:
ScopedLineTokens
,
offset
:
number
):
IElectricAction
{
private
_onElectricAutoIndent
(
context
:
ScopedLineTokens
,
offset
:
number
):
IElectricAction
{
if
(
!
this
.
_richEditBrackets
||
this
.
_richEditBrackets
.
brackets
.
length
===
0
)
{
if
(
!
this
.
_richEditBrackets
||
this
.
_richEditBrackets
.
brackets
.
length
===
0
)
{
...
@@ -150,13 +140,10 @@ export class BracketElectricCharacterSupport {
...
@@ -150,13 +140,10 @@ export class BracketElectricCharacterSupport {
continue
;
continue
;
}
}
// If we're in a scope listen in 'notIn', do nothing
// If we're in a scope listed in 'notIn', do nothing
if
(
pair
.
notIn
)
{
if
(
!
pair
.
isOK
(
context
.
getStandardTokenType
(
lastTokenIndex
)))
{
let
tokenType
=
context
.
getTokenType
(
lastTokenIndex
);
if
(
pair
.
notIn
.
some
(
scope
=>
this
.
containsTokenTypes
(
tokenType
,
scope
)))
{
continue
;
continue
;
}
}
}
return
{
appendText
:
pair
.
close
};
return
{
appendText
:
pair
.
close
};
}
}
...
...
src/vs/editor/test/common/modes/tokenization.test.ts
浏览文件 @
d5b3efd8
...
@@ -319,11 +319,8 @@ suite('Editor Modes - Tokenization', () => {
...
@@ -319,11 +319,8 @@ suite('Editor Modes - Tokenization', () => {
assert
.
deepEqual
(
scopedLineTokens1
.
modeId
,
'
A
'
);
assert
.
deepEqual
(
scopedLineTokens1
.
modeId
,
'
A
'
);
assert
.
equal
(
scopedLineTokens1
.
getTokenCount
(),
3
);
assert
.
equal
(
scopedLineTokens1
.
getTokenCount
(),
3
);
assert
.
equal
(
scopedLineTokens1
.
getTokenStartOffset
(
0
),
0
);
assert
.
equal
(
scopedLineTokens1
.
getTokenStartOffset
(
0
),
0
);
assert
.
equal
(
scopedLineTokens1
.
getTokenType
(
0
),
'
A.abc
'
);
assert
.
equal
(
scopedLineTokens1
.
getTokenStartOffset
(
1
),
3
);
assert
.
equal
(
scopedLineTokens1
.
getTokenStartOffset
(
1
),
3
);
assert
.
equal
(
scopedLineTokens1
.
getTokenType
(
1
),
''
);
assert
.
equal
(
scopedLineTokens1
.
getTokenStartOffset
(
2
),
4
);
assert
.
equal
(
scopedLineTokens1
.
getTokenStartOffset
(
2
),
4
);
assert
.
equal
(
scopedLineTokens1
.
getTokenType
(
2
),
'
A.(
'
);
assert
.
deepEqual
(
scopedLineTokens1
.
firstCharOffset
,
0
);
assert
.
deepEqual
(
scopedLineTokens1
.
firstCharOffset
,
0
);
assert
.
equal
(
scopedLineTokens1
.
getLineContent
(),
'
abc (
'
);
assert
.
equal
(
scopedLineTokens1
.
getLineContent
(),
'
abc (
'
);
...
@@ -331,7 +328,6 @@ suite('Editor Modes - Tokenization', () => {
...
@@ -331,7 +328,6 @@ suite('Editor Modes - Tokenization', () => {
assert
.
deepEqual
(
scopedLineTokens2
.
modeId
,
'
B
'
);
assert
.
deepEqual
(
scopedLineTokens2
.
modeId
,
'
B
'
);
assert
.
equal
(
scopedLineTokens2
.
getTokenCount
(),
1
);
assert
.
equal
(
scopedLineTokens2
.
getTokenCount
(),
1
);
assert
.
equal
(
scopedLineTokens2
.
getTokenStartOffset
(
0
),
0
);
assert
.
equal
(
scopedLineTokens2
.
getTokenStartOffset
(
0
),
0
);
assert
.
equal
(
scopedLineTokens2
.
getTokenType
(
0
),
'
B.def
'
);
assert
.
deepEqual
(
scopedLineTokens2
.
firstCharOffset
,
5
);
assert
.
deepEqual
(
scopedLineTokens2
.
firstCharOffset
,
5
);
assert
.
equal
(
scopedLineTokens2
.
getLineContent
(),
'
def
'
);
assert
.
equal
(
scopedLineTokens2
.
getLineContent
(),
'
def
'
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录