Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
cb30cde0
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,发现更多精彩内容 >>
提交
cb30cde0
编写于
1月 19, 2016
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debt - remove ISuggestionCompare interface and usage
上级
fca50805
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
11 addition
and
94 deletion
+11
-94
src/vs/editor/common/modes.ts
src/vs/editor/common/modes.ts
+5
-10
src/vs/editor/common/modes/supports.ts
src/vs/editor/common/modes/supports.ts
+0
-75
src/vs/editor/contrib/suggest/browser/suggestWidget.ts
src/vs/editor/contrib/suggest/browser/suggestWidget.ts
+6
-7
src/vs/languages/javascript/common/javascript.ts
src/vs/languages/javascript/common/javascript.ts
+0
-1
src/vs/languages/typescript/common/typescriptMode.ts
src/vs/languages/typescript/common/typescriptMode.ts
+0
-1
未找到文件。
src/vs/editor/common/modes.ts
浏览文件 @
cb30cde0
...
...
@@ -396,10 +396,6 @@ export interface ISuggestionFilter {
(
word
:
string
,
suggestion
:
ISuggestion
):
IMatch
[];
}
export
interface
ISuggestionCompare
{
(
one
:
ISuggestion
,
other
:
ISuggestion
):
number
;
}
/**
* Interface used to get completion suggestions at a specific location.
*/
...
...
@@ -413,13 +409,12 @@ export interface ISuggestSupport {
/**
* Compute more details for the given suggestion.
*/
getSuggestionDetails
?:
(
resource
:
URI
,
position
:
EditorCommon
.
IPosition
,
suggestion
:
ISuggestion
)
=>
TPromise
<
ISuggestion
>
;
getSuggestionDetails
?:
(
resource
:
URI
,
position
:
EditorCommon
.
IPosition
,
suggestion
:
ISuggestion
)
=>
TPromise
<
ISuggestion
>
;
getFilter
():
ISuggestionFilter
;
getSorter
?():
ISuggestionCompare
;
getTriggerCharacters
():
string
[];
shouldShowEmptySuggestionList
():
boolean
;
shouldAutotriggerSuggest
(
context
:
ILineContext
,
offset
:
number
,
triggeredByCharacter
:
string
):
boolean
;
getFilter
():
ISuggestionFilter
;
getTriggerCharacters
():
string
[];
shouldShowEmptySuggestionList
():
boolean
;
shouldAutotriggerSuggest
(
context
:
ILineContext
,
offset
:
number
,
triggeredByCharacter
:
string
):
boolean
;
}
/**
...
...
src/vs/editor/common/modes/supports.ts
浏览文件 @
cb30cde0
...
...
@@ -711,23 +711,13 @@ export interface ISuggestContribution {
triggerCharacters
:
string
[];
disableAutoTrigger
?:
boolean
;
excludeTokens
:
string
[];
sortBy
?:
ISortingTypeAndSeparator
[];
suggest
:
(
resource
:
URI
,
position
:
EditorCommon
.
IPosition
)
=>
TPromise
<
Modes
.
ISuggestResult
[]
>
;
getSuggestionDetails
?
:
(
resource
:
URI
,
position
:
EditorCommon
.
IPosition
,
suggestion
:
Modes
.
ISuggestion
)
=>
TPromise
<
Modes
.
ISuggestion
>
;
}
export
interface
ISortingTypeAndSeparator
{
type
:
string
;
partSeparator
?:
string
;
}
export
class
SuggestSupport
extends
AbstractSupport
implements
Modes
.
ISuggestSupport
{
private
contribution
:
ISuggestContribution
;
private
sortByType
:
string
[];
private
separatorForType
:
string
[];
// Must have identical size to the above
public
suggest
:
(
resource
:
URI
,
position
:
EditorCommon
.
IPosition
)
=>
TPromise
<
Modes
.
ISuggestResult
[]
>
;
public
getSuggestionDetails
:
(
resource
:
URI
,
position
:
EditorCommon
.
IPosition
,
suggestion
:
Modes
.
ISuggestion
)
=>
TPromise
<
Modes
.
ISuggestion
>
;
...
...
@@ -740,15 +730,6 @@ export class SuggestSupport extends AbstractSupport implements Modes.ISuggestSup
if
(
typeof
contribution
.
getSuggestionDetails
===
'
function
'
)
{
this
.
getSuggestionDetails
=
(
resource
,
position
,
suggestion
)
=>
contribution
.
getSuggestionDetails
(
resource
,
position
,
suggestion
);
}
this
.
sortByType
=
[];
this
.
separatorForType
=
[];
if
(
Array
.
isArray
(
contribution
.
sortBy
)
&&
contribution
.
sortBy
.
length
>
0
)
{
for
(
var
i
=
0
;
i
<
contribution
.
sortBy
.
length
;
++
i
)
{
this
.
sortByType
.
push
(
contribution
.
sortBy
[
i
].
type
);
this
.
separatorForType
.
push
(
contribution
.
sortBy
[
i
].
partSeparator
);
}
}
}
shouldAutotriggerSuggest
(
context
:
Modes
.
ILineContext
,
offset
:
number
,
triggeredByCharacter
:
string
):
boolean
{
...
...
@@ -776,62 +757,6 @@ export class SuggestSupport extends AbstractSupport implements Modes.ISuggestSup
return
DefaultFilter
;
}
public
getSorter
():
Modes
.
ISuggestionCompare
{
return
(
one
,
other
)
=>
{
if
(
this
.
sortByType
.
length
>
0
)
{
var
oneTypeIndex
=
this
.
sortByType
.
indexOf
(
one
.
type
);
var
otherTypeIndex
=
this
.
sortByType
.
indexOf
(
other
.
type
);
if
(
oneTypeIndex
<
0
)
{
oneTypeIndex
=
this
.
sortByType
.
length
;
}
if
(
otherTypeIndex
<
0
)
{
otherTypeIndex
=
this
.
sortByType
.
length
;
}
if
(
oneTypeIndex
<
otherTypeIndex
)
{
return
-
1
;
}
if
(
otherTypeIndex
<
oneTypeIndex
)
{
return
1
;
}
// TypeIndices are equal
if
(
oneTypeIndex
<
this
.
sortByType
.
length
)
{
var
separator
=
this
.
separatorForType
[
oneTypeIndex
];
var
oneParts
=
((
typeof
separator
===
'
string
'
&&
separator
.
length
>
0
)
?
one
.
label
.
split
(
separator
)
:
[
one
.
label
]);
var
otherParts
=
((
typeof
separator
===
'
string
'
&&
separator
.
length
>
0
)
?
other
.
label
.
split
(
separator
)
:
[
other
.
label
]);
if
(
oneParts
.
length
<
otherParts
.
length
)
{
return
-
1
;
}
else
if
(
oneParts
.
length
>
otherParts
.
length
)
{
return
1
;
}
else
{
for
(
var
i
=
0
;
i
<
oneParts
.
length
;
i
++
)
{
var
result
=
Strings
.
localeCompare
(
oneParts
[
i
],
otherParts
[
i
]);
if
(
result
!==
0
)
{
return
result
;
}
}
return
0
;
}
}
}
let
cmp
=
0
;
if
(
one
.
sortText
&&
other
.
sortText
)
{
cmp
=
one
.
sortText
.
localeCompare
(
other
.
sortText
);
}
if
(
!
cmp
)
{
cmp
=
Strings
.
localeCompare
(
one
.
label
.
toLowerCase
(),
other
.
label
.
toLowerCase
());
}
return
Strings
.
localeCompare
(
one
.
documentationLabel
||
''
,
other
.
documentationLabel
||
''
);
};
}
public
getTriggerCharacters
():
string
[]
{
return
this
.
contribution
.
triggerCharacters
;
}
...
...
src/vs/editor/contrib/suggest/browser/suggestWidget.ts
浏览文件 @
cb30cde0
...
...
@@ -24,7 +24,7 @@ import * as Timer from 'vs/base/common/timer';
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
SuggestRegistry
,
CONTEXT_SUGGESTION_SUPPORTS_ACCEPT_ON_KEY
}
from
'
../common/suggest
'
;
import
{
IKeybindingService
,
IKeybindingContextKey
}
from
'
vs/platform/keybinding/common/keybindingService
'
;
import
{
ISuggestSupport
,
ISuggestResult
,
ISuggestion
,
ISuggestion
Compare
,
ISuggestion
Filter
}
from
'
vs/editor/common/modes
'
;
import
{
ISuggestSupport
,
ISuggestResult
,
ISuggestion
,
ISuggestionFilter
}
from
'
vs/editor/common/modes
'
;
import
{
DefaultFilter
,
IMatch
}
from
'
vs/editor/common/modes/modesFilters
'
;
import
{
ISuggestResult2
}
from
'
../common/suggest
'
;
import
URI
from
'
vs/base/common/uri
'
;
...
...
@@ -70,14 +70,11 @@ class CompletionItem {
}
}
const
defaultCompare
:
ISuggestionCompare
=
(
a
,
b
)
=>
(
a
.
sortText
||
a
.
label
).
localeCompare
((
b
.
sortText
||
b
.
label
));
class
CompletionGroup
{
incomplete
:
boolean
;
items
:
CompletionItem
[];
size
:
number
;
compare
:
ISuggestionCompare
;
filter
:
ISuggestionFilter
;
constructor
(
public
model
:
CompletionModel
,
public
index
:
number
,
raw
:
ISuggestResult2
[])
{
...
...
@@ -94,14 +91,12 @@ class CompletionGroup {
);
},
[]);
this
.
compare
=
defaultCompare
;
this
.
filter
=
DefaultFilter
;
if
(
this
.
items
.
length
>
0
)
{
const
[
first
]
=
this
.
items
;
if
(
first
.
support
)
{
this
.
compare
=
first
.
support
.
getSorter
&&
first
.
support
.
getSorter
()
||
this
.
compare
;
this
.
filter
=
first
.
support
.
getFilter
&&
first
.
support
.
getFilter
()
||
this
.
filter
;
}
}
...
...
@@ -248,7 +243,11 @@ class Sorter implements Tree.ISorter {
return
result
;
}
return
group
.
compare
(
item
.
suggestion
,
otherItem
.
suggestion
);
return
Sorter
.
suggestionCompare
(
item
.
suggestion
,
otherItem
.
suggestion
);
}
private
static
suggestionCompare
(
a
:
ISuggestion
,
b
:
ISuggestion
):
number
{
return
(
a
.
sortText
||
a
.
label
).
localeCompare
((
b
.
sortText
||
b
.
label
));
}
}
...
...
src/vs/languages/javascript/common/javascript.ts
浏览文件 @
cb30cde0
...
...
@@ -105,7 +105,6 @@ export class JSMode extends typescriptMode.TypeScriptMode<javascriptWorker.JavaS
this
.
suggestSupport
=
new
supports
.
SuggestSupport
(
this
,
{
triggerCharacters
:
[
'
.
'
],
excludeTokens
:
[
'
string
'
,
'
comment
'
,
'
number
'
,
'
numeric
'
],
sortBy
:
[{
type
:
'
reference
'
,
partSeparator
:
'
/
'
}],
suggest
:
(
resource
,
position
)
=>
this
.
suggest
(
resource
,
position
),
getSuggestionDetails
:
(
resource
,
position
,
suggestion
)
=>
this
.
getSuggestionDetails
(
resource
,
position
,
suggestion
)});
}
...
...
src/vs/languages/typescript/common/typescriptMode.ts
浏览文件 @
cb30cde0
...
...
@@ -229,7 +229,6 @@ export class TypeScriptMode<W extends typescriptWorker.TypeScriptWorker2> extend
this
.
suggestSupport
=
new
supports
.
SuggestSupport
(
this
,
{
triggerCharacters
:
[
'
.
'
],
excludeTokens
:
[
'
string
'
,
'
comment
'
,
'
number
'
],
sortBy
:
[{
type
:
'
reference
'
,
partSeparator
:
'
/
'
}],
suggest
:
(
resource
,
position
)
=>
this
.
suggest
(
resource
,
position
),
getSuggestionDetails
:
(
resource
,
position
,
suggestion
)
=>
this
.
getSuggestionDetails
(
resource
,
position
,
suggestion
)});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录