Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
7d3b7c03
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,发现更多精彩内容 >>
提交
7d3b7c03
编写于
4月 04, 2016
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
move modesFilter logic into the single place at which it is used, remove the rest
上级
8144bc31
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
35 addition
and
95 deletion
+35
-95
src/vs/base/common/filters.ts
src/vs/base/common/filters.ts
+1
-1
src/vs/editor/common/modes.ts
src/vs/editor/common/modes.ts
+2
-7
src/vs/editor/common/modes/modesFilters.ts
src/vs/editor/common/modes/modesFilters.ts
+0
-50
src/vs/editor/common/modes/supports/suggestSupport.ts
src/vs/editor/common/modes/supports/suggestSupport.ts
+6
-10
src/vs/editor/common/services/editorSimpleWorker.ts
src/vs/editor/common/services/editorSimpleWorker.ts
+2
-3
src/vs/editor/contrib/suggest/browser/completionModel.ts
src/vs/editor/contrib/suggest/browser/completionModel.ts
+24
-13
src/vs/languages/typescript/common/languageFeatures.ts
src/vs/languages/typescript/common/languageFeatures.ts
+0
-4
src/vs/workbench/api/node/extHostLanguageFeatures.ts
src/vs/workbench/api/node/extHostLanguageFeatures.ts
+0
-7
未找到文件。
src/vs/base/common/filters.ts
浏览文件 @
7d3b7c03
...
...
@@ -297,7 +297,7 @@ export enum SubstringMatching {
Separate
}
const
fuzzyContiguousFilter
=
or
(
matchesPrefix
,
matchesCamelCase
,
matchesContiguousSubString
);
export
const
fuzzyContiguousFilter
=
or
(
matchesPrefix
,
matchesCamelCase
,
matchesContiguousSubString
);
const
fuzzySeparateFilter
=
or
(
matchesPrefix
,
matchesCamelCase
,
matchesSubString
);
const
fuzzyRegExpCache
:
{
[
key
:
string
]:
RegExp
;
}
=
{};
...
...
src/vs/editor/common/modes.ts
浏览文件 @
7d3b7c03
...
...
@@ -4,11 +4,11 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
IMatch
}
from
'
vs/base/common/filters
'
;
import
{
IHTMLContentElement
}
from
'
vs/base/common/htmlContent
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IFilter
}
from
'
vs/base/common/filters
'
;
import
{
IMarker
}
from
'
vs/platform/markers/common/markers
'
;
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
{
ModeTransition
}
from
'
vs/editor/common/core/modeTransition
'
;
...
...
@@ -365,11 +365,6 @@ export interface ISuggestResult {
incomplete
?:
boolean
;
}
export
interface
ISuggestionFilter
{
// Should return whether `suggestion` is a good suggestion for `word`
(
word
:
string
,
suggestion
:
ISuggestion
):
IMatch
[];
}
/**
* Interface used to get completion suggestions at a specific location.
*/
...
...
@@ -385,7 +380,7 @@ export interface ISuggestSupport {
*/
getSuggestionDetails
?:
(
resource
:
URI
,
position
:
editorCommon
.
IPosition
,
suggestion
:
ISuggestion
)
=>
TPromise
<
ISuggestion
>
;
getFilter
():
ISuggestion
Filter
;
filter
?:
I
Filter
;
getTriggerCharacters
():
string
[];
shouldShowEmptySuggestionList
():
boolean
;
shouldAutotriggerSuggest
(
context
:
ILineContext
,
offset
:
number
,
triggeredByCharacter
:
string
):
boolean
;
...
...
src/vs/editor/common/modes/modesFilters.ts
已删除
100644 → 0
浏览文件 @
8144bc31
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
isFalsyOrEmpty
}
from
'
vs/base/common/arrays
'
;
import
*
as
filters
from
'
vs/base/common/filters
'
;
import
{
ISuggestion
,
ISuggestionFilter
}
from
'
vs/editor/common/modes
'
;
export
type
IMatch
=
filters
.
IMatch
;
function
wrapBaseFilter
(
filter
:
filters
.
IFilter
):
ISuggestionFilter
{
return
(
word
:
string
,
suggestion
:
ISuggestion
):
filters
.
IMatch
[]
=>
{
let
result
=
filter
(
word
,
suggestion
.
label
);
if
(
!
isFalsyOrEmpty
(
result
))
{
return
result
;
}
// check for match but don't produce highlights
if
(
suggestion
.
codeSnippet
!==
suggestion
.
label
)
{
if
(
!
isFalsyOrEmpty
(
filter
(
word
,
suggestion
.
codeSnippet
.
replace
(
/{{.+
?
}}/g
,
''
))))
{
// filters {{text}}-snippet syntax
return
[{
start
:
0
,
end
:
0
}];
}
}
if
(
typeof
suggestion
.
filterText
===
'
string
'
)
{
if
(
!
isFalsyOrEmpty
(
filter
(
word
,
suggestion
.
filterText
)))
{
return
[{
start
:
0
,
end
:
0
}];
}
}
};
}
export
var
StrictPrefix
:
ISuggestionFilter
=
wrapBaseFilter
(
filters
.
matchesStrictPrefix
);
export
var
Prefix
:
ISuggestionFilter
=
wrapBaseFilter
(
filters
.
matchesPrefix
);
export
var
CamelCase
:
ISuggestionFilter
=
wrapBaseFilter
(
filters
.
matchesCamelCase
);
export
var
ContiguousSubString
:
ISuggestionFilter
=
wrapBaseFilter
(
filters
.
matchesContiguousSubString
);
// Combined Filters
export
function
or
(
first
:
ISuggestionFilter
,
second
:
ISuggestionFilter
):
ISuggestionFilter
{
return
(
word
,
suggestion
)
=>
first
(
word
,
suggestion
)
||
second
(
word
,
suggestion
);
}
export
function
and
(
first
:
ISuggestionFilter
,
second
:
ISuggestionFilter
):
ISuggestionFilter
{
return
(
word
,
suggestion
)
=>
first
(
word
,
suggestion
)
&&
second
(
word
,
suggestion
);
}
export
var
DefaultFilter
=
or
(
or
(
Prefix
,
CamelCase
),
ContiguousSubString
);
\ No newline at end of file
src/vs/editor/common/modes/supports/suggestSupport.ts
浏览文件 @
7d3b7c03
...
...
@@ -7,8 +7,8 @@
import
URI
from
'
vs/base/common/uri
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IModel
,
IPosition
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ILineContext
,
IMode
,
ISuggestResult
,
ISuggestSupport
,
ISuggestion
,
ISuggestionFilter
}
from
'
vs/editor/common/modes
'
;
import
{
DefaultFilter
,
StrictPrefix
}
from
'
vs/editor/common/modes/modesF
ilters
'
;
import
{
ILineContext
,
IMode
,
ISuggestResult
,
ISuggestSupport
,
ISuggestion
}
from
'
vs/editor/common/modes
'
;
import
{
IFilter
,
matchesStrictPrefix
,
fuzzyContiguousFilter
}
from
'
vs/base/common/f
ilters
'
;
import
{
handleEvent
,
isLineToken
}
from
'
vs/editor/common/modes/supports
'
;
import
{
IEditorWorkerService
}
from
'
vs/editor/common/services/editorWorkerService
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
...
...
@@ -60,10 +60,6 @@ export class SuggestSupport implements ISuggestSupport {
});
}
public
getFilter
():
ISuggestionFilter
{
return
DefaultFilter
;
}
public
getTriggerCharacters
():
string
[]
{
return
this
.
contribution
.
triggerCharacters
;
}
...
...
@@ -87,8 +83,8 @@ export class TextualSuggestSupport implements ISuggestSupport {
return
this
.
_editorWorkerService
.
textualSuggest
(
resource
,
position
);
}
public
get
Filter
():
ISuggestion
Filter
{
return
StrictPrefix
;
public
get
filter
():
I
Filter
{
return
matches
StrictPrefix
;
}
public
getTriggerCharacters
():
string
[]
{
...
...
@@ -171,12 +167,12 @@ export function filterSuggestions(value: ISuggestResult): ISuggestResult[] {
return
;
}
// filter suggestions
var
accept
=
Default
Filter
,
var
accept
=
fuzzyContiguous
Filter
,
result
:
ISuggestResult
[]
=
[];
result
.
push
({
currentWord
:
value
.
currentWord
,
suggestions
:
value
.
suggestions
.
filter
((
element
)
=>
!!
accept
(
value
.
currentWord
,
element
)),
suggestions
:
value
.
suggestions
.
filter
((
element
)
=>
!!
accept
(
value
.
currentWord
,
element
.
label
)),
incomplete
:
value
.
incomplete
});
...
...
src/vs/editor/common/services/editorSimpleWorker.ts
浏览文件 @
7d3b7c03
...
...
@@ -9,13 +9,13 @@ import URI from 'vs/base/common/uri';
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IRequestHandler
}
from
'
vs/base/common/worker/simpleWorker
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
fuzzyContiguousFilter
}
from
'
vs/base/common/filters
'
;
import
{
DiffComputer
}
from
'
vs/editor/common/diff/diffComputer
'
;
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
{
MirrorModel2
}
from
'
vs/editor/common/model/mirrorModel2
'
;
import
{
WordHelper
}
from
'
vs/editor/common/model/textModelWithTokensHelpers
'
;
import
{
IInplaceReplaceSupportResult
,
ILink
,
ISuggestResult
,
ISuggestion
}
from
'
vs/editor/common/modes
'
;
import
{
computeLinks
}
from
'
vs/editor/common/modes/linkComputer
'
;
import
{
DefaultFilter
}
from
'
vs/editor/common/modes/modesFilters
'
;
import
{
BasicInplaceReplace
}
from
'
vs/editor/common/modes/supports/inplaceReplaceSupport
'
;
import
{
EditorSimpleWorker
,
IRawModelData
}
from
'
vs/editor/common/services/editorSimpleWorkerCommon
'
;
...
...
@@ -214,12 +214,11 @@ export class EditorSimpleWorkerImpl extends EditorSimpleWorker implements IReque
private
_suggestFiltered
(
model
:
MirrorModel
,
position
:
editorCommon
.
IPosition
,
wordDefRegExp
:
RegExp
):
ISuggestResult
[]
{
let
value
=
this
.
_suggestUnfiltered
(
model
,
position
,
wordDefRegExp
);
let
accept
=
DefaultFilter
;
// filter suggestions
return
[{
currentWord
:
value
.
currentWord
,
suggestions
:
value
.
suggestions
.
filter
((
element
)
=>
!!
accept
(
value
.
currentWord
,
element
)),
suggestions
:
value
.
suggestions
.
filter
((
element
)
=>
!!
fuzzyContiguousFilter
(
value
.
currentWord
,
element
.
label
)),
incomplete
:
value
.
incomplete
}];
}
...
...
src/vs/editor/contrib/suggest/browser/completionModel.ts
浏览文件 @
7d3b7c03
...
...
@@ -10,8 +10,8 @@ import {assign} from 'vs/base/common/objects';
import
URI
from
'
vs/base/common/uri
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IPosition
}
from
'
vs/editor/common/editorCommon
'
;
import
{
I
SuggestResult
,
ISuggestSupport
,
ISuggestion
,
ISuggestionFilter
}
from
'
vs/editor/common/mode
s
'
;
import
{
DefaultFilter
,
IMatch
}
from
'
vs/editor/common/modes/modesFilter
s
'
;
import
{
I
Filter
,
IMatch
,
fuzzyContiguousFilter
}
from
'
vs/base/common/filter
s
'
;
import
{
ISuggestResult
,
ISuggestSupport
,
ISuggestion
}
from
'
vs/editor/common/mode
s
'
;
import
{
ISuggestResult2
}
from
'
../common/suggest
'
;
export
class
CompletionItem
{
...
...
@@ -19,15 +19,15 @@ export class CompletionItem {
suggestion
:
ISuggestion
;
highlights
:
IMatch
[];
container
:
ISuggestResult
;
filter
:
IFilter
;
private
_filter
:
ISuggestionFilter
;
private
_support
:
ISuggestSupport
;
constructor
(
suggestion
:
ISuggestion
,
container
:
ISuggestResult2
)
{
this
.
_support
=
container
.
support
;
this
.
suggestion
=
suggestion
;
this
.
container
=
container
;
this
.
_filter
=
container
.
support
&&
container
.
support
.
getFilter
()
||
Default
Filter
;
this
.
filter
=
container
.
support
&&
container
.
support
.
filter
||
fuzzyContiguous
Filter
;
}
resolveDetails
(
resource
:
URI
,
position
:
IPosition
):
TPromise
<
ISuggestion
>
{
...
...
@@ -42,10 +42,6 @@ export class CompletionItem {
this
.
suggestion
=
assign
(
this
.
suggestion
,
value
);
}
updateHighlights
(
word
:
string
):
void
{
this
.
highlights
=
this
.
_filter
(
word
,
this
.
suggestion
);
}
static
compare
(
item
:
CompletionItem
,
otherItem
:
CompletionItem
):
number
{
const
suggestion
=
item
.
suggestion
;
const
otherSuggestion
=
otherItem
.
suggestion
;
...
...
@@ -115,12 +111,27 @@ export class CompletionModel {
overwriteBefore
=
item
.
container
.
currentWord
.
length
;
}
let
start
=
leadingLineContent
.
length
-
(
overwriteBefore
+
characterCountDelta
);
let
word
=
leadingLineContent
.
substr
(
start
);
const
start
=
leadingLineContent
.
length
-
(
overwriteBefore
+
characterCountDelta
);
const
word
=
leadingLineContent
.
substr
(
start
);
const
{
filter
,
suggestion
}
=
item
;
let
match
=
false
;
// compute highlights based on 'label'
item
.
highlights
=
filter
(
word
,
suggestion
.
label
);
match
=
!
isFalsyOrEmpty
(
item
.
highlights
);
// no match on label -> check on codeSnippet
if
(
!
match
&&
suggestion
.
codeSnippet
!==
suggestion
.
label
)
{
match
=
!
isFalsyOrEmpty
((
filter
(
word
,
suggestion
.
codeSnippet
.
replace
(
/{{.+
?
}}/g
,
''
))));
// filters {{text}}-snippet syntax
}
// no match on label nor codeSnippet -> check on filterText
if
(
!
match
&&
typeof
suggestion
.
filterText
===
'
string
'
)
{
match
=
!
isFalsyOrEmpty
(
filter
(
word
,
suggestion
.
filterText
));
}
// filter word
item
.
updateHighlights
(
word
);
if
(
!
isFalsyOrEmpty
(
item
.
highlights
))
{
if
(
match
)
{
this
.
_filteredItems
.
push
(
item
);
}
}
...
...
src/vs/languages/typescript/common/languageFeatures.ts
浏览文件 @
7d3b7c03
...
...
@@ -240,10 +240,6 @@ class SuggestAdapter extends Adapter implements modes.ISuggestSupport {
return
'
variable
'
;
}
getFilter
():
modes
.
ISuggestionFilter
{
return
;
}
getTriggerCharacters
():
string
[]
{
return
[
'
.
'
];
}
...
...
src/vs/workbench/api/node/extHostLanguageFeatures.ts
浏览文件 @
7d3b7c03
...
...
@@ -5,7 +5,6 @@
'
use strict
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
DefaultFilter
}
from
'
vs/editor/common/modes/modesFilters
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
Remotable
,
IThreadService
}
from
'
vs/platform/thread/common/thread
'
;
...
...
@@ -579,9 +578,6 @@ class SuggestAdapter implements modes.ISuggestSupport {
});
}
getFilter
():
any
{
throw
new
Error
(
'
illegal state
'
);
}
getTriggerCharacters
():
string
[]
{
throw
new
Error
(
'
illegal state
'
);
}
...
...
@@ -1035,9 +1031,6 @@ export class MainThreadLanguageFeatures {
getSuggestionDetails
:
(
resource
:
URI
,
position
:
IPosition
,
suggestion
:
modes
.
ISuggestion
):
TPromise
<
modes
.
ISuggestion
>
=>
{
return
this
.
_proxy
.
$getSuggestionDetails
(
handle
,
resource
,
position
,
suggestion
);
},
getFilter
()
{
return
DefaultFilter
;
},
getTriggerCharacters
():
string
[]
{
return
triggerCharacters
;
},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录