Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
徽霖
Vscode
提交
64ab2947
V
Vscode
项目概览
徽霖
/
Vscode
通知
9
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,发现更多精彩内容 >>
提交
64ab2947
编写于
2月 08, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Extract DeclarationSupport to its own file
上级
ba55cc21
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
64 addition
and
43 deletion
+64
-43
src/vs/editor/common/modes/supports.ts
src/vs/editor/common/modes/supports.ts
+0
-34
src/vs/editor/common/modes/supports/declarationSupport.ts
src/vs/editor/common/modes/supports/declarationSupport.ts
+47
-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
浏览文件 @
64ab2947
...
...
@@ -186,40 +186,6 @@ export function getBracketFor(tokenType:string, tokenText:string, mode:Modes.IMo
return
Modes
.
Bracket
.
None
;
}
export
interface
IDeclarationContribution
{
tokens
?:
string
[];
findDeclaration
:
(
resource
:
URI
,
position
:
EditorCommon
.
IPosition
)
=>
TPromise
<
Modes
.
IReference
>
;
}
export
class
DeclarationSupport
extends
AbstractSupport
implements
Modes
.
IDeclarationSupport
{
private
contribution
:
IDeclarationContribution
;
/**
* Provide the token type postfixes for the tokens where a declaration can be found in the 'tokens' argument.
*/
constructor
(
mode
:
Modes
.
IMode
,
contribution
:
IDeclarationContribution
)
{
super
(
mode
);
this
.
contribution
=
contribution
;
}
public
canFindDeclaration
(
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
.
declarationSupport
)
{
return
nestedMode
.
declarationSupport
.
canFindDeclaration
(
context
,
offset
);
}
else
{
return
false
;
}
});
}
public
findDeclaration
(
resource
:
URI
,
position
:
EditorCommon
.
IPosition
):
TPromise
<
Modes
.
IReference
>
{
return
this
.
contribution
.
findDeclaration
(
resource
,
position
);
}
}
export
interface
ITypeDeclarationContribution
{
tokens
:
string
[];
...
...
src/vs/editor/common/modes/supports/declarationSupport.ts
0 → 100644
浏览文件 @
64ab2947
/*---------------------------------------------------------------------------------------------
* 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
IDeclarationContribution
{
tokens
?:
string
[];
findDeclaration
:
(
resource
:
URI
,
position
:
EditorCommon
.
IPosition
)
=>
TPromise
<
Modes
.
IReference
>
;
}
export
class
DeclarationSupport
implements
Modes
.
IDeclarationSupport
{
private
_modeId
:
string
;
private
contribution
:
IDeclarationContribution
;
/**
* Provide the token type postfixes for the tokens where a declaration can be found in the 'tokens' argument.
*/
constructor
(
modeId
:
string
,
contribution
:
IDeclarationContribution
)
{
this
.
_modeId
=
modeId
;
this
.
contribution
=
contribution
;
}
public
canFindDeclaration
(
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
.
declarationSupport
)
{
return
nestedMode
.
declarationSupport
.
canFindDeclaration
(
context
,
offset
);
}
else
{
return
false
;
}
});
}
public
findDeclaration
(
resource
:
URI
,
position
:
EditorCommon
.
IPosition
):
TPromise
<
Modes
.
IReference
>
{
return
this
.
contribution
.
findDeclaration
(
resource
,
position
);
}
}
src/vs/editor/common/services/modeService.ts
浏览文件 @
64ab2947
...
...
@@ -12,6 +12,7 @@ import MonarchTypes = require('vs/editor/common/modes/monarch/monarchTypes');
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
'
;
export
var
IModeService
=
createDecorator
<
IModeService
>
(
'
modeService
'
);
...
...
@@ -36,7 +37,7 @@ export interface IModeService {
getOrCreateModeByFilenameOrFirstLine
(
filename
:
string
,
firstLine
?:
string
):
TPromise
<
Modes
.
IMode
>
;
registerCodeLensSupport
(
modeId
:
string
,
support
:
Modes
.
ICodeLensSupport
):
IDisposable
;
registerDeclarativeDeclarationSupport
(
modeId
:
string
,
contribution
:
Supports
.
IDeclarationContribution
):
IDisposable
;
registerDeclarativeDeclarationSupport
(
modeId
:
string
,
contribution
:
IDeclarationContribution
):
IDisposable
;
registerExtraInfoSupport
(
modeId
:
string
,
support
:
Modes
.
IExtraInfoSupport
):
IDisposable
;
registerFormattingSupport
(
modeId
:
string
,
support
:
Modes
.
IFormattingSupport
):
IDisposable
;
registerInplaceReplaceSupport
(
modeId
:
string
,
support
:
Modes
.
IInplaceReplaceSupport
):
IDisposable
;
...
...
src/vs/editor/common/services/modeServiceImpl.ts
浏览文件 @
64ab2947
...
...
@@ -26,6 +26,7 @@ import {OnEnterSupport, IOnEnterSupportOptions} from 'vs/editor/common/modes/sup
import
{
IDisposable
,
combinedDispose
,
empty
as
EmptyDisposable
}
from
'
vs/base/common/lifecycle
'
;
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
'
;
interface
IModeConfigurationMap
{
[
modeId
:
string
]:
any
;
}
...
...
@@ -281,8 +282,8 @@ export class ModeServiceImpl implements IModeService {
return
this
.
registerModeSupport
(
modeId
,
'
richEditSupport
'
,
(
mode
)
=>
new
RichEditSupport
(
modeId
,
support
));
}
public
registerDeclarativeDeclarationSupport
(
modeId
:
string
,
contribution
:
Supports
.
IDeclarationContribution
):
IDisposable
{
return
this
.
registerModeSupport
(
modeId
,
'
declarationSupport
'
,
(
mode
)
=>
new
Supports
.
DeclarationSupport
(
mode
,
contribution
));
public
registerDeclarativeDeclarationSupport
(
modeId
:
string
,
contribution
:
IDeclarationContribution
):
IDisposable
{
return
this
.
registerModeSupport
(
modeId
,
'
declarationSupport
'
,
(
mode
)
=>
new
DeclarationSupport
(
modeId
,
contribution
));
}
public
registerExtraInfoSupport
(
modeId
:
string
,
support
:
Modes
.
IExtraInfoSupport
):
IDisposable
{
...
...
src/vs/languages/css/common/css.ts
浏览文件 @
64ab2947
...
...
@@ -22,6 +22,7 @@ import {IInstantiationService} from 'vs/platform/instantiation/common/instantiat
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
'
;
export
enum
States
{
Selector
,
...
...
@@ -341,7 +342,7 @@ export class CSSMode extends AbstractMode<cssWorker.CSSWorker> {
findReferences
:
(
resource
,
position
,
/*unused*/
includeDeclaration
)
=>
this
.
findReferences
(
resource
,
position
)});
this
.
logicalSelectionSupport
=
this
;
this
.
outlineSupport
=
this
;
this
.
declarationSupport
=
new
supports
.
DeclarationSupport
(
this
,
{
this
.
declarationSupport
=
new
DeclarationSupport
(
this
.
getId
()
,
{
tokens
:
[
cssTokenTypes
.
TOKEN_VALUE
+
'
.css
'
],
findDeclaration
:
(
resource
,
position
)
=>
this
.
findDeclaration
(
resource
,
position
)});
...
...
src/vs/languages/html/common/html.ts
浏览文件 @
64ab2947
...
...
@@ -27,6 +27,7 @@ import * as htmlTokenTypes from 'vs/languages/html/common/htmlTokenTypes';
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';
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.
...
...
@@ -313,7 +314,7 @@ export class HTMLMode<W extends htmlWorker.HTMLWorker> extends AbstractMode<W> i
excludeTokens
:
[
'
*
'
],
getParameterHints
:
(
resource
,
position
)
=>
this
.
getParameterHints
(
resource
,
position
)});
// TODO@Alex TODO@Joh: there is something off about declaration support of embedded JS in HTML
// this.declarationSupport = new
supports.
DeclarationSupport(this, {
// this.declarationSupport = new DeclarationSupport(this, {
// tokens: ['invalid'],
// findDeclaration: (resource, position) => this.findDeclaration(resource, position)});
...
...
src/vs/languages/javascript/common/javascript.ts
浏览文件 @
64ab2947
...
...
@@ -20,6 +20,7 @@ import {IThreadService} from 'vs/platform/thread/common/thread';
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
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
'
;
export
class
JSMode
extends
typescriptMode
.
TypeScriptMode
<
javascriptWorker
.
JavaScriptWorker
>
{
...
...
@@ -44,7 +45,7 @@ export class JSMode extends typescriptMode.TypeScriptMode<javascriptWorker.JavaS
tokens
:
[],
findReferences
:
(
resource
,
position
,
includeDeclaration
)
=>
this
.
findReferences
(
resource
,
position
,
includeDeclaration
)});
this
.
declarationSupport
=
new
supports
.
DeclarationSupport
(
this
,
{
this
.
declarationSupport
=
new
DeclarationSupport
(
this
.
getId
()
,
{
tokens
:
[],
findDeclaration
:
(
resource
,
position
)
=>
this
.
findDeclaration
(
resource
,
position
)});
...
...
src/vs/languages/less/common/less.ts
浏览文件 @
64ab2947
...
...
@@ -21,6 +21,7 @@ import {IModeService} from 'vs/editor/common/services/modeService';
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
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
'
;
export
var
language
:
Types
.
ILanguage
=
<
Types
.
ILanguage
>
{
displayName
:
'
LESS
'
,
...
...
@@ -201,7 +202,7 @@ export class LESSMode extends Monarch.MonarchMode<lessWorker.LessWorker> impleme
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
;
this
.
declarationSupport
=
new
supports
.
DeclarationSupport
(
this
,
{
this
.
declarationSupport
=
new
DeclarationSupport
(
this
.
getId
()
,
{
tokens
:
[
'
variable.less
'
,
lessTokenTypes
.
TOKEN_SELECTOR
+
'
.class.less
'
,
lessTokenTypes
.
TOKEN_SELECTOR
+
'
.id.less
'
,
'
selector.less
'
],
findDeclaration
:
(
resource
,
position
)
=>
this
.
findDeclaration
(
resource
,
position
)});
this
.
outlineSupport
=
this
;
...
...
src/vs/languages/sass/common/sass.ts
浏览文件 @
64ab2947
...
...
@@ -21,6 +21,7 @@ import {IModeService} from 'vs/editor/common/services/modeService';
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
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
'
;
export
var
language
=
<
Types
.
ILanguage
>
{
displayName
:
'
Sass
'
,
...
...
@@ -303,7 +304,7 @@ export class SASSMode extends Monarch.MonarchMode<sassWorker.SassWorker> impleme
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
;
this
.
declarationSupport
=
new
supports
.
DeclarationSupport
(
this
,
{
this
.
declarationSupport
=
new
DeclarationSupport
(
this
.
getId
()
,
{
tokens
:
[
'
variable.decl.sass
'
,
'
variable.ref.sass
'
,
'
support.function.name.sass
'
,
sassTokenTypes
.
TOKEN_PROPERTY
+
'
.sass
'
,
sassTokenTypes
.
TOKEN_SELECTOR
+
'
.sass
'
],
findDeclaration
:
(
resource
,
position
)
=>
this
.
findDeclaration
(
resource
,
position
)});
this
.
outlineSupport
=
this
;
...
...
src/vs/languages/typescript/common/typescriptMode.ts
浏览文件 @
64ab2947
...
...
@@ -27,6 +27,7 @@ import {IThreadService, ThreadAffinity} from 'vs/platform/thread/common/thread';
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
'
;
class
SemanticValidator
{
...
...
@@ -256,7 +257,7 @@ export class TypeScriptMode<W extends typescriptWorker.TypeScriptWorker2> extend
tokens
:
[
'
identifier.ts
'
],
findReferences
:
(
resource
,
position
,
includeDeclaration
)
=>
this
.
findReferences
(
resource
,
position
,
includeDeclaration
)});
this
.
declarationSupport
=
new
supports
.
DeclarationSupport
(
this
,
{
this
.
declarationSupport
=
new
DeclarationSupport
(
this
.
getId
()
,
{
tokens
:
[
'
identifier.ts
'
,
'
string.ts
'
,
'
attribute.value.vs
'
],
findDeclaration
:
(
resource
,
position
)
=>
this
.
findDeclaration
(
resource
,
position
)});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录