Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
12ea2146
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,发现更多精彩内容 >>
提交
12ea2146
编写于
2月 08, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Extract ReferenceSupport to its own file
上级
64ab2947
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
65 addition
and
45 deletion
+65
-45
src/vs/editor/common/modes/supports.ts
src/vs/editor/common/modes/supports.ts
+0
-36
src/vs/editor/common/modes/supports/referenceSupport.ts
src/vs/editor/common/modes/supports/referenceSupport.ts
+48
-0
src/vs/editor/common/services/modeService.ts
src/vs/editor/common/services/modeService.ts
+2
-1
src/vs/editor/common/services/modeServiceImpl.ts
src/vs/editor/common/services/modeServiceImpl.ts
+3
-2
src/vs/languages/css/common/css.ts
src/vs/languages/css/common/css.ts
+2
-1
src/vs/languages/html/common/html.ts
src/vs/languages/html/common/html.ts
+2
-1
src/vs/languages/javascript/common/javascript.ts
src/vs/languages/javascript/common/javascript.ts
+2
-1
src/vs/languages/less/common/less.ts
src/vs/languages/less/common/less.ts
+2
-1
src/vs/languages/sass/common/sass.ts
src/vs/languages/sass/common/sass.ts
+2
-1
src/vs/languages/typescript/common/typescriptMode.ts
src/vs/languages/typescript/common/typescriptMode.ts
+2
-1
未找到文件。
src/vs/editor/common/modes/supports.ts
浏览文件 @
12ea2146
...
...
@@ -222,42 +222,6 @@ export class TypeDeclarationSupport extends AbstractSupport implements Modes.ITy
}
}
export
interface
IReferenceContribution
{
tokens
:
string
[];
findReferences
:
(
resource
:
URI
,
position
:
EditorCommon
.
IPosition
,
includeDeclaration
:
boolean
)
=>
TPromise
<
Modes
.
IReference
[]
>
;
}
export
class
ReferenceSupport
extends
AbstractSupport
implements
Modes
.
IReferenceSupport
{
private
contribution
:
IReferenceContribution
;
/**
* Provide the token type postfixes for the tokens where a reference can be found in the 'tokens' argument.
*/
constructor
(
mode
:
Modes
.
IMode
,
contribution
:
IReferenceContribution
)
{
super
(
mode
);
this
.
contribution
=
contribution
;
}
public
canFindReferences
(
context
:
Modes
.
ILineContext
,
offset
:
number
):
boolean
{
return
handleEvent
(
context
,
offset
,
(
nestedMode
:
Modes
.
IMode
,
context
:
Modes
.
ILineContext
,
offset
:
number
)
=>
{
if
(
this
.
mode
===
nestedMode
)
{
return
(
!
Array
.
isArray
(
this
.
contribution
.
tokens
)
||
this
.
contribution
.
tokens
.
length
<
1
||
isLineToken
(
context
,
offset
,
this
.
contribution
.
tokens
));
}
else
if
(
nestedMode
.
referenceSupport
)
{
return
nestedMode
.
referenceSupport
.
canFindReferences
(
context
,
offset
);
}
else
{
return
false
;
}
});
}
public
findReferences
(
resource
:
URI
,
position
:
EditorCommon
.
IPosition
,
includeDeclaration
:
boolean
):
TPromise
<
Modes
.
IReference
[]
>
{
return
this
.
contribution
.
findReferences
(
resource
,
position
,
includeDeclaration
);
}
}
export
class
ParameterHintsSupport
extends
AbstractSupport
implements
Modes
.
IParameterHintsSupport
{
private
contribution
:
Modes
.
IParameterHintsContribution
;
...
...
src/vs/editor/common/modes/supports/referenceSupport.ts
0 → 100644
浏览文件 @
12ea2146
/*---------------------------------------------------------------------------------------------
* 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
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
*
as
Modes
from
'
vs/editor/common/modes
'
;
import
EditorCommon
=
require
(
'
vs/editor/common/editorCommon
'
);
import
URI
from
'
vs/base/common/uri
'
;
import
{
handleEvent
,
isLineToken
}
from
'
vs/editor/common/modes/supports
'
;
export
interface
IReferenceContribution
{
tokens
:
string
[];
findReferences
:
(
resource
:
URI
,
position
:
EditorCommon
.
IPosition
,
includeDeclaration
:
boolean
)
=>
TPromise
<
Modes
.
IReference
[]
>
;
}
export
class
ReferenceSupport
implements
Modes
.
IReferenceSupport
{
private
_modeId
:
string
;
private
contribution
:
IReferenceContribution
;
/**
* Provide the token type postfixes for the tokens where a reference can be found in the 'tokens' argument.
*/
constructor
(
modeId
:
string
,
contribution
:
IReferenceContribution
)
{
this
.
_modeId
=
modeId
;
this
.
contribution
=
contribution
;
}
public
canFindReferences
(
context
:
Modes
.
ILineContext
,
offset
:
number
):
boolean
{
return
handleEvent
(
context
,
offset
,
(
nestedMode
:
Modes
.
IMode
,
context
:
Modes
.
ILineContext
,
offset
:
number
)
=>
{
if
(
this
.
_modeId
===
nestedMode
.
getId
())
{
return
(
!
Array
.
isArray
(
this
.
contribution
.
tokens
)
||
this
.
contribution
.
tokens
.
length
<
1
||
isLineToken
(
context
,
offset
,
this
.
contribution
.
tokens
));
}
else
if
(
nestedMode
.
referenceSupport
)
{
return
nestedMode
.
referenceSupport
.
canFindReferences
(
context
,
offset
);
}
else
{
return
false
;
}
});
}
public
findReferences
(
resource
:
URI
,
position
:
EditorCommon
.
IPosition
,
includeDeclaration
:
boolean
):
TPromise
<
Modes
.
IReference
[]
>
{
return
this
.
contribution
.
findReferences
(
resource
,
position
,
includeDeclaration
);
}
}
src/vs/editor/common/services/modeService.ts
浏览文件 @
12ea2146
...
...
@@ -13,6 +13,7 @@ import {IOnEnterSupportOptions} from 'vs/editor/common/modes/supports/onEnter';
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IRichEditConfiguration
}
from
'
vs/editor/common/modes/supports/richEditSupport
'
;
import
{
IDeclarationContribution
}
from
'
vs/editor/common/modes/supports/declarationSupport
'
;
import
{
IReferenceContribution
}
from
'
vs/editor/common/modes/supports/referenceSupport
'
;
export
var
IModeService
=
createDecorator
<
IModeService
>
(
'
modeService
'
);
...
...
@@ -45,7 +46,7 @@ export interface IModeService {
registerOutlineSupport
(
modeId
:
string
,
support
:
Modes
.
IOutlineSupport
):
IDisposable
;
registerDeclarativeParameterHintsSupport
(
modeId
:
string
,
support
:
Modes
.
IParameterHintsContribution
):
IDisposable
;
registerQuickFixSupport
(
modeId
:
string
,
support
:
Modes
.
IQuickFixSupport
):
IDisposable
;
registerDeclarativeReferenceSupport
(
modeId
:
string
,
contribution
:
Supports
.
IReferenceContribution
):
IDisposable
;
registerDeclarativeReferenceSupport
(
modeId
:
string
,
contribution
:
IReferenceContribution
):
IDisposable
;
registerRenameSupport
(
modeId
:
string
,
support
:
Modes
.
IRenameSupport
):
IDisposable
;
registerDeclarativeSuggestSupport
(
modeId
:
string
,
declaration
:
Supports
.
ISuggestContribution
):
IDisposable
;
registerTokenizationSupport
(
modeId
:
string
,
callback
:
(
mode
:
Modes
.
IMode
)
=>
Modes
.
ITokenizationSupport
):
IDisposable
;
...
...
src/vs/editor/common/services/modeServiceImpl.ts
浏览文件 @
12ea2146
...
...
@@ -27,6 +27,7 @@ import {IDisposable, combinedDispose, empty as EmptyDisposable} from 'vs/base/co
import
{
createAsyncDescriptor0
,
createAsyncDescriptor1
}
from
'
vs/platform/instantiation/common/descriptors
'
;
import
{
RichEditSupport
,
IRichEditConfiguration
}
from
'
vs/editor/common/modes/supports/richEditSupport
'
;
import
{
DeclarationSupport
,
IDeclarationContribution
}
from
'
vs/editor/common/modes/supports/declarationSupport
'
;
import
{
ReferenceSupport
,
IReferenceContribution
}
from
'
vs/editor/common/modes/supports/referenceSupport
'
;
interface
IModeConfigurationMap
{
[
modeId
:
string
]:
any
;
}
...
...
@@ -314,8 +315,8 @@ export class ModeServiceImpl implements IModeService {
return
this
.
registerModeSupport
(
modeId
,
'
quickFixSupport
'
,
(
mode
)
=>
support
);
}
public
registerDeclarativeReferenceSupport
(
modeId
:
string
,
contribution
:
Supports
.
IReferenceContribution
):
IDisposable
{
return
this
.
registerModeSupport
(
modeId
,
'
referenceSupport
'
,
(
mode
)
=>
new
Supports
.
ReferenceSupport
(
mode
,
contribution
));
public
registerDeclarativeReferenceSupport
(
modeId
:
string
,
contribution
:
IReferenceContribution
):
IDisposable
{
return
this
.
registerModeSupport
(
modeId
,
'
referenceSupport
'
,
(
mode
)
=>
new
ReferenceSupport
(
modeId
,
contribution
));
}
public
registerRenameSupport
(
modeId
:
string
,
support
:
Modes
.
IRenameSupport
):
IDisposable
{
...
...
src/vs/languages/css/common/css.ts
浏览文件 @
12ea2146
...
...
@@ -23,6 +23,7 @@ import {IThreadService} from 'vs/platform/thread/common/thread';
import
{
RichEditSupport
}
from
'
vs/editor/common/modes/supports/richEditSupport
'
;
import
{
TokenizationSupport
}
from
'
vs/editor/common/modes/supports/tokenizationSupport
'
;
import
{
DeclarationSupport
}
from
'
vs/editor/common/modes/supports/declarationSupport
'
;
import
{
ReferenceSupport
}
from
'
vs/editor/common/modes/supports/referenceSupport
'
;
export
enum
States
{
Selector
,
...
...
@@ -337,7 +338,7 @@ export class CSSMode extends AbstractMode<cssWorker.CSSWorker> {
this
.
occurrencesSupport
=
this
;
this
.
extraInfoSupport
=
this
;
this
.
referenceSupport
=
new
supports
.
ReferenceSupport
(
this
,
{
this
.
referenceSupport
=
new
ReferenceSupport
(
this
.
getId
()
,
{
tokens
:
[
cssTokenTypes
.
TOKEN_PROPERTY
+
'
.css
'
,
cssTokenTypes
.
TOKEN_VALUE
+
'
.css
'
,
cssTokenTypes
.
TOKEN_SELECTOR_TAG
+
'
.css
'
],
findReferences
:
(
resource
,
position
,
/*unused*/
includeDeclaration
)
=>
this
.
findReferences
(
resource
,
position
)});
this
.
logicalSelectionSupport
=
this
;
...
...
src/vs/languages/html/common/html.ts
浏览文件 @
12ea2146
...
...
@@ -28,6 +28,7 @@ import {EMPTY_ELEMENTS} from 'vs/languages/html/common/htmlEmptyTagsShared';
import
{
RichEditSupport
}
from
'
vs/editor/common/modes/supports/richEditSupport
'
;
import
{
TokenizationSupport
,
IEnteringNestedModeData
,
ILeavingNestedModeData
,
ITokenizationCustomization
}
from
'
vs/editor/common/modes/supports/tokenizationSupport
'
;
// import {DeclarationSupport} from 'vs/editor/common/modes/supports/declarationSupport';
import
{
ReferenceSupport
}
from
'
vs/editor/common/modes/supports/referenceSupport
'
;
export
{
htmlTokenTypes
};
// export to be used by Razor. We are the main module, so Razor should get ot from use.
export
{
EMPTY_ELEMENTS
};
// export to be used by Razor. We are the main module, so Razor should get ot from use.
...
...
@@ -304,7 +305,7 @@ export class HTMLMode<W extends htmlWorker.HTMLWorker> extends AbstractMode<W> i
this
.
formattingSupport
=
this
;
this
.
extraInfoSupport
=
this
;
this
.
occurrencesSupport
=
this
;
this
.
referenceSupport
=
new
supports
.
ReferenceSupport
(
this
,
{
this
.
referenceSupport
=
new
ReferenceSupport
(
this
.
getId
()
,
{
tokens
:
[
'
invalid
'
],
findReferences
:
(
resource
,
position
,
includeDeclaration
)
=>
this
.
findReferences
(
resource
,
position
,
includeDeclaration
)});
this
.
logicalSelectionSupport
=
this
;
...
...
src/vs/languages/javascript/common/javascript.ts
浏览文件 @
12ea2146
...
...
@@ -21,6 +21,7 @@ import {IInstantiationService} from 'vs/platform/instantiation/common/instantiat
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
RichEditSupport
}
from
'
vs/editor/common/modes/supports/richEditSupport
'
;
import
{
DeclarationSupport
}
from
'
vs/editor/common/modes/supports/declarationSupport
'
;
import
{
ReferenceSupport
}
from
'
vs/editor/common/modes/supports/referenceSupport
'
;
export
class
JSMode
extends
typescriptMode
.
TypeScriptMode
<
javascriptWorker
.
JavaScriptWorker
>
{
...
...
@@ -41,7 +42,7 @@ export class JSMode extends typescriptMode.TypeScriptMode<javascriptWorker.JavaS
super
(
descriptor
,
instantiationService
,
threadService
,
telemetryService
);
this
.
tokenizationSupport
=
tokenization
.
createTokenizationSupport
(
this
,
tokenization
.
Language
.
EcmaScript5
);
this
.
referenceSupport
=
new
supports
.
ReferenceSupport
(
this
,
{
this
.
referenceSupport
=
new
ReferenceSupport
(
this
.
getId
()
,
{
tokens
:
[],
findReferences
:
(
resource
,
position
,
includeDeclaration
)
=>
this
.
findReferences
(
resource
,
position
,
includeDeclaration
)});
...
...
src/vs/languages/less/common/less.ts
浏览文件 @
12ea2146
...
...
@@ -22,6 +22,7 @@ import {IInstantiationService} from 'vs/platform/instantiation/common/instantiat
import
{
IThreadService
}
from
'
vs/platform/thread/common/thread
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
{
DeclarationSupport
}
from
'
vs/editor/common/modes/supports/declarationSupport
'
;
import
{
ReferenceSupport
}
from
'
vs/editor/common/modes/supports/referenceSupport
'
;
export
var
language
:
Types
.
ILanguage
=
<
Types
.
ILanguage
>
{
displayName
:
'
LESS
'
,
...
...
@@ -198,7 +199,7 @@ export class LESSMode extends Monarch.MonarchMode<lessWorker.LessWorker> impleme
this
.
modeService
=
modeService
;
this
.
extraInfoSupport
=
this
;
this
.
referenceSupport
=
new
supports
.
ReferenceSupport
(
this
,
{
this
.
referenceSupport
=
new
ReferenceSupport
(
this
.
getId
()
,
{
tokens
:
[
lessTokenTypes
.
TOKEN_PROPERTY
+
'
.less
'
,
lessTokenTypes
.
TOKEN_VALUE
+
'
.less
'
,
'
variable.less
'
,
lessTokenTypes
.
TOKEN_SELECTOR
+
'
.class.less
'
,
lessTokenTypes
.
TOKEN_SELECTOR
+
'
.id.less
'
,
'
selector.less
'
],
findReferences
:
(
resource
,
position
,
/*unused*/
includeDeclaration
)
=>
this
.
findReferences
(
resource
,
position
)});
this
.
logicalSelectionSupport
=
this
;
...
...
src/vs/languages/sass/common/sass.ts
浏览文件 @
12ea2146
...
...
@@ -22,6 +22,7 @@ import {IInstantiationService} from 'vs/platform/instantiation/common/instantiat
import
{
IThreadService
}
from
'
vs/platform/thread/common/thread
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
{
DeclarationSupport
}
from
'
vs/editor/common/modes/supports/declarationSupport
'
;
import
{
ReferenceSupport
}
from
'
vs/editor/common/modes/supports/referenceSupport
'
;
export
var
language
=
<
Types
.
ILanguage
>
{
displayName
:
'
Sass
'
,
...
...
@@ -300,7 +301,7 @@ export class SASSMode extends Monarch.MonarchMode<sassWorker.SassWorker> impleme
this
.
modeService
=
modeService
;
this
.
extraInfoSupport
=
this
;
this
.
referenceSupport
=
new
supports
.
ReferenceSupport
(
this
,
{
this
.
referenceSupport
=
new
ReferenceSupport
(
this
.
getId
()
,
{
tokens
:
[
sassTokenTypes
.
TOKEN_PROPERTY
+
'
.sass
'
,
sassTokenTypes
.
TOKEN_VALUE
+
'
.sass
'
,
'
variable.decl.sass
'
,
'
variable.ref.sass
'
,
'
support.function.name.sass
'
,
sassTokenTypes
.
TOKEN_PROPERTY
+
'
.sass
'
,
sassTokenTypes
.
TOKEN_SELECTOR
+
'
.sass
'
],
findReferences
:
(
resource
,
position
,
/*unused*/
includeDeclaration
)
=>
this
.
findReferences
(
resource
,
position
)});
this
.
logicalSelectionSupport
=
this
;
...
...
src/vs/languages/typescript/common/typescriptMode.ts
浏览文件 @
12ea2146
...
...
@@ -28,6 +28,7 @@ import {OnEnterSupport} from 'vs/editor/common/modes/supports/onEnter';
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
RichEditSupport
}
from
'
vs/editor/common/modes/supports/richEditSupport
'
;
import
{
DeclarationSupport
}
from
'
vs/editor/common/modes/supports/declarationSupport
'
;
import
{
ReferenceSupport
}
from
'
vs/editor/common/modes/supports/referenceSupport
'
;
class
SemanticValidator
{
...
...
@@ -253,7 +254,7 @@ export class TypeScriptMode<W extends typescriptWorker.TypeScriptWorker2> extend
}
});
this
.
referenceSupport
=
new
supports
.
ReferenceSupport
(
this
,
{
this
.
referenceSupport
=
new
ReferenceSupport
(
this
.
getId
()
,
{
tokens
:
[
'
identifier.ts
'
],
findReferences
:
(
resource
,
position
,
includeDeclaration
)
=>
this
.
findReferences
(
resource
,
position
,
includeDeclaration
)});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录