Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
6708b021
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,发现更多精彩内容 >>
提交
6708b021
编写于
12月 04, 2015
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debt - remove ISuggestion#hightlights
上级
1a8d530f
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
59 addition
and
77 deletion
+59
-77
src/vs/editor/common/modes.ts
src/vs/editor/common/modes.ts
+5
-29
src/vs/editor/common/modes/abstractMode.ts
src/vs/editor/common/modes/abstractMode.ts
+1
-1
src/vs/editor/common/modes/abstractModeWorker.ts
src/vs/editor/common/modes/abstractModeWorker.ts
+4
-4
src/vs/editor/common/modes/modesFilters.ts
src/vs/editor/common/modes/modesFilters.ts
+18
-16
src/vs/editor/common/modes/supports.ts
src/vs/editor/common/modes/supports.ts
+1
-1
src/vs/editor/contrib/suggest/browser/suggestModel.ts
src/vs/editor/contrib/suggest/browser/suggestModel.ts
+29
-25
src/vs/editor/contrib/suggest/browser/suggestWidget.ts
src/vs/editor/contrib/suggest/browser/suggestWidget.ts
+1
-1
未找到文件。
src/vs/editor/common/modes.ts
浏览文件 @
6708b021
...
...
@@ -5,6 +5,7 @@
'
use strict
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IMatch
}
from
'
vs/base/common/filters
'
;
import
{
IMarker
,
IMarkerService
}
from
'
vs/platform/markers/common/markers
'
;
import
EditorCommon
=
require
(
'
vs/editor/common/editorCommon
'
);
import
{
IHTMLContentElement
}
from
'
vs/base/common/htmlContent
'
;
...
...
@@ -29,7 +30,7 @@ export interface IValidateParticipant extends IWorkerParticipant {
}
export
interface
ISuggestParticipant
extends
IWorkerParticipant
{
filter
?:(
word
:
string
,
suggestion
:
ISuggestion
)
=>
boolean
;
filter
?:(
word
:
string
,
suggestion
:
ISuggestion
)
=>
IMatch
[]
;
suggest
?:(
resource
:
URI
,
position
:
EditorCommon
.
IPosition
,
context
?:
any
)
=>
TPromise
<
ISuggestResult
>
;
}
...
...
@@ -396,7 +397,6 @@ export interface ISuggestion {
codeSnippet
:
string
;
type
:
string
;
textEdit
?:
EditorCommon
.
ISingleEditOperation
;
highlights
?:
IHighlight
[];
typeLabel
?:
string
;
documentationLabel
?:
string
;
filterText
?:
string
;
...
...
@@ -404,30 +404,6 @@ export interface ISuggestion {
noAutoAccept
?:
boolean
;
}
/**
* Returns true if the provided object looks like
* an ISuggestion. That means they are structural
* compatible.
*/
export
function
isISuggestion
(
obj
:
any
):
boolean
{
if
(
obj
===
null
||
typeof
obj
!==
'
object
'
)
{
return
false
;
}
if
(
typeof
obj
.
label
!==
'
string
'
||
typeof
obj
.
codeSnippet
!==
'
string
'
||
typeof
obj
.
type
!==
'
string
'
)
{
return
false
;
}
if
(
obj
.
highlights
&&
!
Array
.
isArray
(
obj
.
highlights
))
{
return
false
;
}
if
(
obj
.
typeLabel
&&
typeof
obj
.
typeLabel
!==
'
string
'
)
{
return
false
;
}
if
(
obj
.
documentationLabel
&&
typeof
obj
.
documentationLabel
!==
'
string
'
)
{
return
false
;
}
return
true
;
}
export
interface
ISuggestResult
{
currentWord
:
string
;
suggestions
:
ISuggestion
[];
...
...
@@ -436,9 +412,9 @@ export interface ISuggestResult {
overwriteAfter
?:
number
;
}
export
interface
IFilter
{
export
interface
I
Suggestion
Filter
{
// Should return whether `suggestion` is a good suggestion for `word`
(
word
:
string
,
suggestion
:
ISuggestion
):
boolean
;
(
word
:
string
,
suggestion
:
ISuggestion
):
IMatch
[]
;
}
export
interface
ISorter
{
...
...
@@ -460,7 +436,7 @@ export interface ISuggestSupport {
*/
getSuggestionDetails
?:(
resource
:
URI
,
position
:
EditorCommon
.
IPosition
,
suggestion
:
ISuggestion
)
=>
TPromise
<
ISuggestion
>
;
getFilter
():
IFilter
;
getFilter
():
I
Suggestion
Filter
;
getSorter
?():
ISorter
;
getTriggerCharacters
():
string
[];
shouldShowEmptySuggestionList
():
boolean
;
...
...
src/vs/editor/common/modes/abstractMode.ts
浏览文件 @
6708b021
...
...
@@ -138,7 +138,7 @@ export class AbstractMode<W extends AbstractModeWorker> implements Modes.IMode {
return
this
.
_worker
((
w
)
=>
w
.
enableValidator
());
}
public
getFilter
():
Modes
.
IFilter
{
public
getFilter
():
Modes
.
I
Suggestion
Filter
{
return
StrictPrefix
;
}
...
...
src/vs/editor/common/modes/abstractModeWorker.ts
浏览文件 @
6708b021
...
...
@@ -28,7 +28,7 @@ function isISuggestParticipant(thing:any):boolean {
export
class
AbstractModeWorker
{
static
filter
:
Modes
.
IFilter
=
DefaultFilter
;
static
filter
:
Modes
.
I
Suggestion
Filter
=
DefaultFilter
;
private
_validationParticipants
:
Modes
.
IValidateParticipant
[]
=
[];
private
_suggestParticipants
:
Modes
.
ISuggestParticipant
[]
=
[];
...
...
@@ -152,7 +152,7 @@ export class AbstractModeWorker {
}
result
.
push
(
<
Modes
.
ISuggestResult
>
{
currentWord
:
value
.
currentWord
,
suggestions
:
value
.
suggestions
.
filter
((
element
)
=>
accept
(
values
[
i
].
currentWord
,
element
)),
suggestions
:
value
.
suggestions
.
filter
((
element
)
=>
!!
accept
(
values
[
i
].
currentWord
,
element
)),
incomplete
:
value
.
incomplete
,
overwriteBefore
:
value
.
overwriteBefore
,
overwriteAfter
:
value
.
overwriteAfter
...
...
@@ -223,7 +223,7 @@ export class AbstractModeWorker {
return
[];
}
private
getSuggestionFilterMain
():
Modes
.
IFilter
{
private
getSuggestionFilterMain
():
Modes
.
I
Suggestion
Filter
{
var
filter
=
this
.
getSuggestionFilter
();
// Collect Suggestion Participants
...
...
@@ -236,7 +236,7 @@ export class AbstractModeWorker {
return
filter
;
}
public
getSuggestionFilter
():
Modes
.
IFilter
{
public
getSuggestionFilter
():
Modes
.
I
Suggestion
Filter
{
return
AbstractModeWorker
.
filter
;
}
...
...
src/vs/editor/common/modes/modesFilters.ts
浏览文件 @
6708b021
...
...
@@ -4,32 +4,34 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
IFilter
,
ISuggestion
}
from
'
vs/editor/common/modes
'
;
import
Filters
=
require
(
'
vs/base/common/filters
'
);
function
wrapBaseFilter
(
filter
:
Filters
.
IFilter
):
IFilter
{
return
(
word
:
string
,
suggestion
:
ISuggestion
):
boolean
=>
{
var
highlights
=
filter
(
word
,
suggestion
.
filterText
||
suggestion
.
label
);
suggestion
.
highlights
=
highlights
||
[];
return
!!
highlights
;
import
{
ISuggestionFilter
,
ISuggestion
}
from
'
vs/editor/common/modes
'
;
import
*
as
Filters
from
'
vs/base/common/filters
'
;
import
{
isFalsyOrEmpty
}
from
'
vs/base/common/arrays
'
;
export
type
IMatch
=
Filters
.
IMatch
;
function
wrapBaseFilter
(
filter
:
Filters
.
IFilter
):
ISuggestionFilter
{
return
(
word
:
string
,
suggestion
:
ISuggestion
):
Filters
.
IMatch
[]
=>
{
const
result
=
filter
(
word
,
suggestion
.
filterText
||
suggestion
.
label
);
return
isFalsyOrEmpty
(
result
)
?
undefined
:
result
;
};
}
export
var
StrictPrefix
:
IFilter
=
wrapBaseFilter
(
Filters
.
matchesStrictPrefix
);
export
var
Prefix
:
I
Filter
=
wrapBaseFilter
(
Filters
.
matchesPrefix
);
export
var
CamelCase
:
IFilter
=
wrapBaseFilter
(
Filters
.
matchesCamelCase
);
export
var
ContiguousSubString
:
I
Filter
=
wrapBaseFilter
(
Filters
.
matchesContiguousSubString
);
export
var
StrictPrefix
:
I
Suggestion
Filter
=
wrapBaseFilter
(
Filters
.
matchesStrictPrefix
);
export
var
Prefix
:
ISuggestion
Filter
=
wrapBaseFilter
(
Filters
.
matchesPrefix
);
export
var
CamelCase
:
I
Suggestion
Filter
=
wrapBaseFilter
(
Filters
.
matchesCamelCase
);
export
var
ContiguousSubString
:
ISuggestion
Filter
=
wrapBaseFilter
(
Filters
.
matchesContiguousSubString
);
// Combined Filters
export
function
or
(
first
:
IFilter
,
second
:
IFilter
):
I
Filter
{
return
(
word
:
string
,
suggestion
:
ISuggestion
):
boolean
=>
{
export
function
or
(
first
:
ISuggestionFilter
,
second
:
ISuggestionFilter
):
ISuggestion
Filter
{
return
(
word
:
string
,
suggestion
:
ISuggestion
):
Filters
.
IMatch
[]
=>
{
return
first
(
word
,
suggestion
)
||
second
(
word
,
suggestion
);
};
}
export
function
and
(
first
:
IFilter
,
second
:
IFilter
):
I
Filter
{
return
(
word
:
string
,
suggestion
:
ISuggestion
):
boolean
=>
{
export
function
and
(
first
:
ISuggestionFilter
,
second
:
ISuggestionFilter
):
ISuggestion
Filter
{
return
(
word
:
string
,
suggestion
:
ISuggestion
):
Filters
.
IMatch
[]
=>
{
return
first
(
word
,
suggestion
)
&&
second
(
word
,
suggestion
);
};
}
...
...
src/vs/editor/common/modes/supports.ts
浏览文件 @
6708b021
...
...
@@ -772,7 +772,7 @@ export class SuggestSupport extends AbstractSupport implements Modes.ISuggestSup
});
}
public
getFilter
():
Modes
.
IFilter
{
public
getFilter
():
Modes
.
I
Suggestion
Filter
{
return
DefaultFilter
;
}
...
...
src/vs/editor/contrib/suggest/browser/suggestModel.ts
浏览文件 @
6708b021
...
...
@@ -11,11 +11,12 @@ import { EventEmitter, ListenerUnbind } from 'vs/base/common/eventEmitter';
import
{
onUnexpectedError
,
isPromiseCanceledError
}
from
'
vs/base/common/errors
'
;
import
strings
=
require
(
'
vs/base/common/strings
'
);
import
URI
from
'
vs/base/common/uri
'
;
import
{
isFalsyOrEmpty
}
from
'
vs/base/common/arrays
'
;
import
timer
=
require
(
'
vs/base/common/timer
'
);
import
{
getSnippets
}
from
'
vs/editor/common/modes/modesRegistry
'
;
import
EditorCommon
=
require
(
'
vs/editor/common/editorCommon
'
);
import
{
ISuggestSupport
,
ISuggestResult
,
ISuggestion
,
ISorter
}
from
'
vs/editor/common/modes
'
;
import
{
DefaultFilter
}
from
'
vs/editor/common/modes/modesFilters
'
;
import
{
DefaultFilter
,
IMatch
}
from
'
vs/editor/common/modes/modesFilters
'
;
import
{
CodeSnippet
}
from
'
vs/editor/contrib/snippet/common/snippet
'
;
import
{
IDisposable
,
disposeAll
}
from
'
vs/base/common/lifecycle
'
;
import
{
SuggestRegistry
,
ISuggestResult2
,
suggest
}
from
'
../common/suggest
'
;
...
...
@@ -36,9 +37,11 @@ export class CompletionItem {
private
static
_idPool
=
0
;
public
id
:
string
;
public
support
:
ISuggestSupport
;
public
suggestion
:
ISuggestion
;
public
highlights
:
IMatch
[];
public
support
:
ISuggestSupport
;
public
container
:
ISuggestResult
;
private
_resolveDetails
:
TPromise
<
CompletionItem
>
constructor
(
support
:
ISuggestSupport
,
suggestion
:
ISuggestion
,
container
:
ISuggestResult
)
{
...
...
@@ -96,36 +99,37 @@ class RawModel {
select
(
ctx
:
SuggestionContext
):
CompletionItem
[]
{
let
result
:
CompletionItem
[]
=
[];
let
seen
:
{
[
codeSnippet
:
string
]:
boolean
}
=
Object
.
create
(
null
);
for
(
let
item
of
this
.
_items
)
{
RawModel
.
_sortAndFilter
(
ctx
,
result
,
seen
,
item
);
RawModel
.
_sortAndFilter
(
item
,
ctx
,
result
);
}
return
result
;
}
private
static
_sortAndFilter
(
ctx
:
SuggestionContext
,
bucket
:
CompletionItem
[],
seen
:
{
[
codeSnippet
:
string
]:
boolean
},
items
:
CompletionItem
[]):
void
{
if
(
items
&&
items
.
length
)
{
let
compare
=
RawModel
.
_compare
;
let
filter
=
DefaultFilter
;
let
[
item
]
=
items
;
if
(
item
.
support
)
{
compare
=
item
.
support
.
getSorter
&&
item
.
support
.
getSorter
()
||
compare
;
filter
=
item
.
support
.
getFilter
&&
item
.
support
.
getFilter
()
||
DefaultFilter
;
}
items
=
items
.
filter
(
item
=>
{
if
(
!
seen
[
item
.
suggestion
.
codeSnippet
])
{
seen
[
item
.
suggestion
.
codeSnippet
]
=
true
;
return
filter
(
ctx
.
wordBefore
,
item
.
suggestion
)
}
})
.
sort
((
a
,
b
)
=>
{
return
compare
(
a
.
suggestion
,
b
.
suggestion
)
});
private
static
_sortAndFilter
(
items
:
CompletionItem
[],
ctx
:
SuggestionContext
,
bucket
:
CompletionItem
[]):
void
{
if
(
isFalsyOrEmpty
(
items
))
{
return
;
}
bucket
.
push
(...
items
);
// all items have the same (origin) support. derive sorter and filter
// from first
const
[
first
]
=
items
;
let
compare
=
RawModel
.
_compare
;
let
filter
=
DefaultFilter
;
if
(
first
.
support
)
{
compare
=
first
.
support
.
getSorter
&&
first
.
support
.
getSorter
()
||
compare
;
filter
=
first
.
support
.
getFilter
&&
first
.
support
.
getFilter
()
||
filter
;
}
items
=
items
.
filter
(
item
=>
{
// set hightlight and filter those that have none
item
.
highlights
=
filter
(
ctx
.
wordBefore
,
item
.
suggestion
);
return
!
isFalsyOrEmpty
(
item
.
highlights
);
}).
sort
((
a
,
b
)
=>
{
// sort suggestions by custom strategy
return
compare
(
a
.
suggestion
,
b
.
suggestion
)
});
bucket
.
push
(...
items
);
}
private
static
_compare
(
a
:
ISuggestion
,
b
:
ISuggestion
):
number
{
...
...
src/vs/editor/contrib/suggest/browser/suggestWidget.ts
浏览文件 @
6708b021
...
...
@@ -203,7 +203,7 @@ class Renderer implements Tree.IRenderer {
data
.
colorspan
.
style
.
backgroundColor
=
''
;
}
data
.
highlightedLabel
.
set
(
suggestion
.
label
,
suggestion
.
highlights
);
data
.
highlightedLabel
.
set
(
suggestion
.
label
,
(
<
CompletionItem
>
element
)
.
highlights
);
data
.
typeLabel
.
textContent
=
suggestion
.
typeLabel
||
''
;
data
.
documentationLabel
.
textContent
=
suggestion
.
documentationLabel
||
''
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录