Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
fe9b6dba
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,体验更适合开发者的 AI 搜索 >>
提交
fe9b6dba
编写于
5月 19, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Convert IDeclarationSupport to DefinitionProvider
上级
f739556b
变更
22
隐藏空白更改
内联
并排
Showing
22 changed file
with
351 addition
and
305 deletion
+351
-305
src/vs/editor/common/modes.ts
src/vs/editor/common/modes.ts
+10
-15
src/vs/editor/contrib/goToDeclaration/browser/goToDeclaration.ts
...editor/contrib/goToDeclaration/browser/goToDeclaration.ts
+15
-15
src/vs/editor/contrib/goToDeclaration/common/goToDeclaration.ts
.../editor/contrib/goToDeclaration/common/goToDeclaration.ts
+10
-8
src/vs/editor/contrib/referenceSearch/browser/referenceSearch.ts
...editor/contrib/referenceSearch/browser/referenceSearch.ts
+2
-2
src/vs/editor/contrib/referenceSearch/browser/referencesController.ts
...r/contrib/referenceSearch/browser/referencesController.ts
+4
-4
src/vs/editor/contrib/referenceSearch/browser/referencesModel.ts
...editor/contrib/referenceSearch/browser/referencesModel.ts
+17
-17
src/vs/editor/contrib/referenceSearch/browser/referencesWidget.ts
...ditor/contrib/referenceSearch/browser/referencesWidget.ts
+4
-4
src/vs/editor/contrib/referenceSearch/common/referenceSearch.ts
.../editor/contrib/referenceSearch/common/referenceSearch.ts
+4
-4
src/vs/languages/css/common/css.ts
src/vs/languages/css/common/css.ts
+27
-20
src/vs/languages/css/common/cssWorker.ts
src/vs/languages/css/common/cssWorker.ts
+26
-26
src/vs/languages/handlebars/common/handlebars.ts
src/vs/languages/handlebars/common/handlebars.ts
+29
-15
src/vs/languages/html/common/html.ts
src/vs/languages/html/common/html.ts
+22
-17
src/vs/languages/html/common/htmlWorker.ts
src/vs/languages/html/common/htmlWorker.ts
+1
-1
src/vs/languages/json/common/json.ts
src/vs/languages/json/common/json.ts
+28
-28
src/vs/languages/less/common/less.ts
src/vs/languages/less/common/less.ts
+37
-33
src/vs/languages/razor/common/razor.ts
src/vs/languages/razor/common/razor.ts
+30
-16
src/vs/languages/sass/common/sass.ts
src/vs/languages/sass/common/sass.ts
+37
-34
src/vs/languages/typescript/common/languageFeatures.ts
src/vs/languages/typescript/common/languageFeatures.ts
+12
-10
src/vs/workbench/api/node/extHostApiCommands.ts
src/vs/workbench/api/node/extHostApiCommands.ts
+2
-2
src/vs/workbench/api/node/extHostLanguageFeatures.ts
src/vs/workbench/api/node/extHostLanguageFeatures.ts
+20
-20
src/vs/workbench/api/node/extHostTypeConverters.ts
src/vs/workbench/api/node/extHostTypeConverters.ts
+4
-4
src/vs/workbench/test/node/api/extHostLanguageFeatures.test.ts
...s/workbench/test/node/api/extHostLanguageFeatures.test.ts
+10
-10
未找到文件。
src/vs/editor/common/modes.ts
浏览文件 @
fe9b6dba
...
...
@@ -410,14 +410,6 @@ export interface DocumentHighlightProvider {
}
/**
* Interface used to find declarations on a symbol
*/
export
interface
IReference
{
resource
:
URI
;
range
:
editorCommon
.
IRange
;
}
/**
* Interface used to find references to a symbol
*/
...
...
@@ -427,15 +419,18 @@ export interface IReferenceSupport {
* @returns a list of reference of the symbol at the position in the
* given resource.
*/
findReferences
(
resource
:
URI
,
position
:
editorCommon
.
IPosition
,
includeDeclaration
:
boolean
):
TPromise
<
IReference
[]
>
;
findReferences
(
resource
:
URI
,
position
:
editorCommon
.
IPosition
,
includeDeclaration
:
boolean
):
TPromise
<
Location
[]
>
;
}
/**
* Interface used to find declarations on a symbol
*/
export
interface
IDeclarationSupport
{
findDeclaration
(
resource
:
URI
,
position
:
editorCommon
.
IPosition
):
TPromise
<
IReference
|
IReference
[]
>
;
export
class
Location
{
uri
:
URI
;
range
:
editorCommon
.
IRange
;
}
export
type
Definition
=
Location
|
Location
[];
export
interface
DefinitionProvider
{
provideDefinition
(
model
:
editorCommon
.
IReadOnlyModel
,
position
:
editorCommon
.
IEditorPosition
,
token
:
CancellationToken
):
Definition
|
Thenable
<
Definition
>
;
}
/**
* Interface used to compute an outline
...
...
@@ -712,7 +707,7 @@ export const OutlineRegistry = new LanguageFeatureRegistry<IOutlineSupport>();
export
const
DocumentHighlightProviderRegistry
=
new
LanguageFeatureRegistry
<
DocumentHighlightProvider
>
();
export
const
De
clarationRegistry
=
new
LanguageFeatureRegistry
<
IDeclarationSupport
>
();
export
const
De
finitionProviderRegistry
=
new
LanguageFeatureRegistry
<
DefinitionProvider
>
();
export
const
CodeLensRegistry
=
new
LanguageFeatureRegistry
<
ICodeLensSupport
>
();
...
...
src/vs/editor/contrib/goToDeclaration/browser/goToDeclaration.ts
浏览文件 @
fe9b6dba
...
...
@@ -25,7 +25,7 @@ import {EditorAction} from 'vs/editor/common/editorAction';
import
{
Behaviour
}
from
'
vs/editor/common/editorActionEnablement
'
;
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
{
CommonEditorRegistry
,
ContextKey
,
EditorActionDescriptor
}
from
'
vs/editor/common/editorCommonExtensions
'
;
import
{
IReference
,
Declaration
Registry
}
from
'
vs/editor/common/modes
'
;
import
{
Location
,
DefinitionProvider
Registry
}
from
'
vs/editor/common/modes
'
;
import
{
tokenizeToHtmlContent
}
from
'
vs/editor/common/modes/textToHtmlTokenizer
'
;
import
{
ICodeEditor
,
IEditorMouseEvent
,
IMouseTarget
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
EditorBrowserRegistry
}
from
'
vs/editor/browser/editorBrowserExtensions
'
;
...
...
@@ -62,7 +62,7 @@ export class DefinitionAction extends EditorAction {
}
public
isSupported
():
boolean
{
return
De
claration
Registry
.
has
(
this
.
editor
.
getModel
())
&&
super
.
isSupported
();
return
De
finitionProvider
Registry
.
has
(
this
.
editor
.
getModel
())
&&
super
.
isSupported
();
}
public
getEnablementState
():
boolean
{
...
...
@@ -70,7 +70,7 @@ export class DefinitionAction extends EditorAction {
return
false
;
}
return
De
claration
Registry
.
has
(
this
.
editor
.
getModel
());
return
De
finitionProvider
Registry
.
has
(
this
.
editor
.
getModel
());
}
public
run
():
TPromise
<
any
>
{
...
...
@@ -87,19 +87,19 @@ export class DefinitionAction extends EditorAction {
// * remove falsy references
// * remove reference at the current pos
// * collapse ranges to start pos
let
result
:
IReference
[]
=
[];
let
result
:
Location
[]
=
[];
for
(
let
i
=
0
;
i
<
references
.
length
;
i
++
)
{
let
reference
=
references
[
i
];
if
(
!
reference
)
{
continue
;
}
let
{
resource
,
range
}
=
reference
;
let
{
uri
,
range
}
=
reference
;
if
(
!
this
.
_configuration
.
filterCurrent
||
resource
.
toString
()
!==
model
.
getAssociatedResource
().
toString
()
||
uri
.
toString
()
!==
model
.
getAssociatedResource
().
toString
()
||
!
Range
.
containsPosition
(
range
,
pos
))
{
result
.
push
({
resource
,
uri
,
range
:
Range
.
collapseToStart
(
range
)
});
}
...
...
@@ -118,7 +118,7 @@ export class DefinitionAction extends EditorAction {
});
}
private
_onResult
(
references
:
IReference
[])
{
private
_onResult
(
references
:
Location
[])
{
if
(
this
.
_configuration
.
openInPeek
)
{
this
.
_openInPeek
(
this
.
editor
,
references
);
}
else
{
...
...
@@ -131,14 +131,14 @@ export class DefinitionAction extends EditorAction {
}
}
private
_openReference
(
reference
:
IReference
,
sideBySide
:
boolean
):
TPromise
<
editorCommon
.
ICommonCodeEditor
>
{
let
{
resource
,
range
}
=
reference
;
return
this
.
_editorService
.
openEditor
({
resource
,
options
:
{
selection
:
range
}
},
sideBySide
).
then
(
editor
=>
{
private
_openReference
(
reference
:
Location
,
sideBySide
:
boolean
):
TPromise
<
editorCommon
.
ICommonCodeEditor
>
{
let
{
uri
,
range
}
=
reference
;
return
this
.
_editorService
.
openEditor
({
resource
:
uri
,
options
:
{
selection
:
range
}
},
sideBySide
).
then
(
editor
=>
{
return
<
editorCommon
.
IEditor
>
editor
.
getControl
();
});
}
private
_openInPeek
(
target
:
editorCommon
.
ICommonCodeEditor
,
references
:
IReference
[])
{
private
_openInPeek
(
target
:
editorCommon
.
ICommonCodeEditor
,
references
:
Location
[])
{
let
controller
=
ReferencesController
.
getController
(
target
);
controller
.
toggleWidget
(
target
.
getSelection
(),
TPromise
.
as
(
new
ReferencesModel
(
references
)),
{
getMetaTitle
:
(
model
)
=>
{
...
...
@@ -288,7 +288,7 @@ class GotoDefinitionWithMouseEditorContribution implements editorCommon.IEditorC
// Single result
else
{
let
result
=
results
[
0
];
this
.
editorService
.
resolveEditorModel
({
resource
:
result
.
resource
}).
then
(
model
=>
{
this
.
editorService
.
resolveEditorModel
({
resource
:
result
.
uri
}).
then
(
model
=>
{
let
source
:
string
;
if
(
model
&&
model
.
textEditorModel
)
{
...
...
@@ -429,10 +429,10 @@ class GotoDefinitionWithMouseEditorContribution implements editorCommon.IEditorC
(
browser
.
isIE11orEarlier
||
mouseEvent
.
event
.
detail
<=
1
)
&&
// IE does not support event.detail properly
mouseEvent
.
target
.
type
===
editorCommon
.
MouseTargetType
.
CONTENT_TEXT
&&
(
mouseEvent
.
event
[
GotoDefinitionWithMouseEditorContribution
.
TRIGGER_MODIFIER
]
||
(
withKey
&&
withKey
.
keyCode
===
GotoDefinitionWithMouseEditorContribution
.
TRIGGER_KEY_VALUE
))
&&
De
claration
Registry
.
has
(
this
.
editor
.
getModel
());
De
finitionProvider
Registry
.
has
(
this
.
editor
.
getModel
());
}
private
findDefinition
(
target
:
IMouseTarget
):
TPromise
<
IReference
[]
>
{
private
findDefinition
(
target
:
IMouseTarget
):
TPromise
<
Location
[]
>
{
let
model
=
this
.
editor
.
getModel
();
if
(
!
model
)
{
return
TPromise
.
as
(
null
);
...
...
src/vs/editor/contrib/goToDeclaration/common/goToDeclaration.ts
浏览文件 @
fe9b6dba
...
...
@@ -7,19 +7,21 @@
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IReadOnlyModel
,
IPosition
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IReadOnlyModel
,
I
Editor
Position
}
from
'
vs/editor/common/editorCommon
'
;
import
{
CommonEditorRegistry
}
from
'
vs/editor/common/editorCommonExtensions
'
;
import
{
DeclarationRegistry
}
from
'
vs/editor/common/modes
'
;
import
{
IReference
}
from
'
vs/editor/common/modes
'
;
import
{
DefinitionProviderRegistry
}
from
'
vs/editor/common/modes
'
;
import
{
Location
}
from
'
vs/editor/common/modes
'
;
import
{
asWinJsPromise
}
from
'
vs/base/common/async
'
;
export
function
getDeclarationsAtPosition
(
model
:
IReadOnlyModel
,
position
:
I
Position
):
TPromise
<
IReference
[]
>
{
export
function
getDeclarationsAtPosition
(
model
:
IReadOnlyModel
,
position
:
I
EditorPosition
):
TPromise
<
Location
[]
>
{
const
resource
=
model
.
getAssociatedResource
();
const
provider
=
DeclarationRegistry
.
ordered
(
model
);
const
provider
=
DefinitionProviderRegistry
.
ordered
(
model
);
// get results
const
promises
=
provider
.
map
((
provider
,
idx
)
=>
{
return
provider
.
findDeclaration
(
resource
,
position
).
then
(
result
=>
{
return
asWinJsPromise
((
token
)
=>
{
return
provider
.
provideDefinition
(
model
,
position
,
token
);
}).
then
(
result
=>
{
return
result
;
},
err
=>
{
onUnexpectedError
(
err
);
...
...
@@ -27,7 +29,7 @@ export function getDeclarationsAtPosition(model: IReadOnlyModel, position: IPosi
});
return
TPromise
.
join
(
promises
).
then
(
allReferences
=>
{
let
result
:
IReference
[]
=
[];
let
result
:
Location
[]
=
[];
for
(
let
references
of
allReferences
)
{
if
(
Array
.
isArray
(
references
))
{
result
.
push
(...
references
);
...
...
src/vs/editor/contrib/referenceSearch/browser/referenceSearch.ts
浏览文件 @
fe9b6dba
...
...
@@ -18,7 +18,7 @@ import {EditorAction} from 'vs/editor/common/editorAction';
import
{
Behaviour
}
from
'
vs/editor/common/editorActionEnablement
'
;
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
{
CommonEditorRegistry
,
ContextKey
,
EditorActionDescriptor
}
from
'
vs/editor/common/editorCommonExtensions
'
;
import
{
IReference
,
ReferenceSearchRegistry
}
from
'
vs/editor/common/modes
'
;
import
{
Location
,
ReferenceSearchRegistry
}
from
'
vs/editor/common/modes
'
;
import
{
IPeekViewService
,
getOuterEditor
}
from
'
vs/editor/contrib/zoneWidget/browser/peekViewWidget
'
;
import
{
findReferences
}
from
'
../common/referenceSearch
'
;
import
{
ReferenceWidget
}
from
'
./referencesWidget
'
;
...
...
@@ -104,7 +104,7 @@ let findReferencesCommand: ICommandHandler = (accessor:ServicesAccessor, resourc
});
};
let
showReferencesCommand
:
ICommandHandler
=
(
accessor
:
ServicesAccessor
,
resource
:
URI
,
position
:
editorCommon
.
IPosition
,
references
:
IReference
[])
=>
{
let
showReferencesCommand
:
ICommandHandler
=
(
accessor
:
ServicesAccessor
,
resource
:
URI
,
position
:
editorCommon
.
IPosition
,
references
:
Location
[])
=>
{
if
(
!
(
resource
instanceof
URI
))
{
throw
new
Error
(
'
illegal argument, uri expected
'
);
}
...
...
src/vs/editor/contrib/referenceSearch/browser/referencesController.ts
浏览文件 @
fe9b6dba
...
...
@@ -184,10 +184,10 @@ export class ReferencesController implements editorCommon.IEditorContribution {
private
_gotoReference
(
ref
:
OneReference
):
void
{
this
.
_ignoreModelChangeEvent
=
true
;
const
{
resource
,
range
}
=
ref
;
const
{
uri
,
range
}
=
ref
;
this
.
_editorService
.
openEditor
({
resource
,
resource
:
uri
,
options
:
{
selection
:
range
}
}).
done
(
openedEditor
=>
{
this
.
_ignoreModelChangeEvent
=
false
;
...
...
@@ -214,9 +214,9 @@ export class ReferencesController implements editorCommon.IEditorContribution {
}
private
_openReference
(
ref
:
OneReference
,
sideBySide
:
boolean
):
void
{
const
{
resource
,
range
}
=
ref
;
const
{
uri
,
range
}
=
ref
;
this
.
_editorService
.
openEditor
({
resource
,
resource
:
uri
,
options
:
{
selection
:
range
}
},
sideBySide
);
...
...
src/vs/editor/contrib/referenceSearch/browser/referencesModel.ts
浏览文件 @
fe9b6dba
...
...
@@ -14,7 +14,7 @@ import {TPromise} from 'vs/base/common/winjs.base';
import
{
IEditorService
}
from
'
vs/platform/editor/common/editor
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
IModel
,
IPosition
,
IRange
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IReference
}
from
'
vs/editor/common/modes
'
;
import
{
Location
}
from
'
vs/editor/common/modes
'
;
export
class
OneReference
{
...
...
@@ -40,8 +40,8 @@ export class OneReference {
return
this
.
_parent
;
}
public
get
resource
():
URI
{
return
this
.
_parent
.
resource
;
public
get
uri
():
URI
{
return
this
.
_parent
.
uri
;
}
public
get
name
():
string
{
...
...
@@ -96,12 +96,12 @@ export class FileReferences {
private
_preview
:
FilePreview
;
private
_resolved
:
boolean
;
constructor
(
private
_parent
:
ReferencesModel
,
private
_
resource
:
URI
)
{
constructor
(
private
_parent
:
ReferencesModel
,
private
_
uri
:
URI
)
{
this
.
_children
=
[];
}
public
get
id
():
string
{
return
this
.
_
resource
.
toString
();
return
this
.
_
uri
.
toString
();
}
public
get
parent
():
ReferencesModel
{
...
...
@@ -112,16 +112,16 @@ export class FileReferences {
return
this
.
_children
;
}
public
get
resource
():
URI
{
return
this
.
_
resource
;
public
get
uri
():
URI
{
return
this
.
_
uri
;
}
public
get
name
():
string
{
return
basename
(
this
.
resource
.
fsPath
);
return
basename
(
this
.
uri
.
fsPath
);
}
public
get
directory
():
string
{
return
dirname
(
this
.
resource
.
fsPath
);
return
dirname
(
this
.
uri
.
fsPath
);
}
public
get
preview
():
FilePreview
{
...
...
@@ -134,7 +134,7 @@ export class FileReferences {
return
TPromise
.
as
(
this
);
}
return
editorService
.
resolveEditorModel
({
resource
:
this
.
_
resource
}).
then
(
model
=>
{
return
editorService
.
resolveEditorModel
({
resource
:
this
.
_
uri
}).
then
(
model
=>
{
this
.
_preview
=
new
FilePreview
((
<
IModel
>
model
.
textEditorModel
).
getValue
());
this
.
_resolved
=
true
;
return
this
;
...
...
@@ -150,16 +150,16 @@ export class ReferencesModel {
onDidChangeReferenceRange
:
Event
<
OneReference
>
=
fromEventEmitter
<
OneReference
>
(
this
.
_eventBus
,
'
ref/changed
'
);
constructor
(
references
:
IReference
[])
{
constructor
(
references
:
Location
[])
{
// grouping and sorting
references
.
sort
(
ReferencesModel
.
_compareReferences
);
let
current
:
FileReferences
;
for
(
let
ref
of
references
)
{
if
(
!
current
||
current
.
resource
.
toString
()
!==
ref
.
resource
.
toString
())
{
if
(
!
current
||
current
.
uri
.
toString
()
!==
ref
.
uri
.
toString
())
{
// new group
current
=
new
FileReferences
(
this
,
ref
.
resource
);
current
=
new
FileReferences
(
this
,
ref
.
uri
);
this
.
groups
.
push
(
current
);
}
...
...
@@ -206,7 +206,7 @@ export class ReferencesModel {
let
candidate
:
OneReference
;
let
candiateDist
:
number
;
for
(
let
ref
of
this
.
_references
)
{
if
(
ref
.
resource
.
toString
()
!==
resource
.
toString
())
{
if
(
ref
.
uri
.
toString
()
!==
resource
.
toString
())
{
continue
;
}
...
...
@@ -227,10 +227,10 @@ export class ReferencesModel {
return
candidate
||
this
.
_references
[
0
];
}
private
static
_compareReferences
(
a
:
IReference
,
b
:
IReference
):
number
{
if
(
a
.
resource
.
toString
()
<
b
.
resource
.
toString
())
{
private
static
_compareReferences
(
a
:
Location
,
b
:
Location
):
number
{
if
(
a
.
uri
.
toString
()
<
b
.
uri
.
toString
())
{
return
-
1
;
}
else
if
(
a
.
resource
.
toString
()
>
b
.
resource
.
toString
())
{
}
else
if
(
a
.
uri
.
toString
()
>
b
.
uri
.
toString
())
{
return
1
;
}
else
{
return
Range
.
compareRangesUsingStarts
(
a
.
range
,
b
.
range
);
...
...
src/vs/editor/contrib/referenceSearch/browser/referencesWidget.ts
浏览文件 @
fe9b6dba
...
...
@@ -73,7 +73,7 @@ class DecorationsManager implements IDisposable {
}
for
(
var
i
=
0
,
len
=
this
.
model
.
groups
.
length
;
i
<
len
;
i
++
)
{
if
(
this
.
model
.
groups
[
i
].
resource
.
toString
()
===
model
.
getAssociatedResource
().
toString
())
{
if
(
this
.
model
.
groups
[
i
].
uri
.
toString
()
===
model
.
getAssociatedResource
().
toString
())
{
this
.
_addDecorations
(
this
.
model
.
groups
[
i
]);
return
;
}
...
...
@@ -351,7 +351,7 @@ class Renderer extends LegacyRenderer {
/* tslint:disable:no-unused-expression */
new
LeftRightWidget
(
fileReferencesContainer
,
(
left
:
HTMLElement
)
=>
{
var
resource
=
fileReferences
.
resource
;
var
resource
=
fileReferences
.
uri
;
new
FileLabel
(
left
,
resource
,
this
.
_contextService
);
return
<
IDisposable
>
null
;
...
...
@@ -685,14 +685,14 @@ export class ReferenceWidget extends PeekViewWidget {
private
_revealReference
(
reference
:
OneReference
)
{
// Update widget header
if
(
reference
.
resource
.
scheme
!==
Schemas
.
inMemory
)
{
if
(
reference
.
uri
.
scheme
!==
Schemas
.
inMemory
)
{
this
.
setTitle
(
reference
.
name
,
getPathLabel
(
reference
.
directory
,
this
.
_contextService
));
}
else
{
this
.
setTitle
(
nls
.
localize
(
'
peekView.alternateTitle
'
,
"
References
"
));
}
return
TPromise
.
join
([
this
.
_editorService
.
resolveEditorModel
({
resource
:
reference
.
resource
}),
this
.
_editorService
.
resolveEditorModel
({
resource
:
reference
.
uri
}),
this
.
_tree
.
reveal
(
reference
)
]).
then
(
values
=>
{
if
(
!
this
.
_model
)
{
...
...
src/vs/editor/contrib/referenceSearch/common/referenceSearch.ts
浏览文件 @
fe9b6dba
...
...
@@ -9,15 +9,15 @@ import {onUnexpectedError} from 'vs/base/common/errors';
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IReadOnlyModel
,
IPosition
}
from
'
vs/editor/common/editorCommon
'
;
import
{
CommonEditorRegistry
}
from
'
vs/editor/common/editorCommonExtensions
'
;
import
{
IReference
,
ReferenceSearchRegistry
}
from
'
vs/editor/common/modes
'
;
import
{
Location
,
ReferenceSearchRegistry
}
from
'
vs/editor/common/modes
'
;
export
function
findReferences
(
model
:
IReadOnlyModel
,
position
:
IPosition
):
TPromise
<
IReference
[]
>
{
export
function
findReferences
(
model
:
IReadOnlyModel
,
position
:
IPosition
):
TPromise
<
Location
[]
>
{
// collect references from all providers
const
promises
=
ReferenceSearchRegistry
.
ordered
(
model
).
map
(
provider
=>
{
return
provider
.
findReferences
(
model
.
getAssociatedResource
(),
position
,
true
).
then
(
result
=>
{
if
(
Array
.
isArray
(
result
))
{
return
<
IReference
[]
>
result
;
return
<
Location
[]
>
result
;
}
},
err
=>
{
onUnexpectedError
(
err
);
...
...
@@ -25,7 +25,7 @@ export function findReferences(model: IReadOnlyModel, position: IPosition): TPro
});
return
TPromise
.
join
(
promises
).
then
(
references
=>
{
let
result
:
IReference
[]
=
[];
let
result
:
Location
[]
=
[];
for
(
let
ref
of
references
)
{
if
(
ref
)
{
result
.
push
(...
ref
);
...
...
src/vs/languages/css/common/css.ts
浏览文件 @
fe9b6dba
...
...
@@ -19,7 +19,6 @@ import {IInstantiationService} from 'vs/platform/instantiation/common/instantiat
import
{
IThreadService
,
ThreadAffinity
}
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
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
import
{
wireCancellationToken
}
from
'
vs/base/common/async
'
;
export
enum
States
{
...
...
@@ -327,18 +326,35 @@ export class CSSMode extends AbstractMode {
this
.
inplaceReplaceSupport
=
this
;
this
.
configSupport
=
this
;
// Modes.OccurrencesRegistry.register(this.getId(), this);
modes
.
HoverProviderRegistry
.
register
(
this
.
getId
(),
this
);
// Modes.ReferenceSearchRegistry.register(this.getId(), this);
// modes.DocumentHighlightProviderRegistry.register(this.getId(), {
// provideDocumentHighlights: (model, position, token): Thenable<modes.DocumentHighlight[]> => {
// return wireCancellationToken(token, this._provideDocumentHighlights(model.getAssociatedResource(), position));
// }
// });
modes
.
HoverProviderRegistry
.
register
(
this
.
getId
(),
{
provideHover
:
(
model
,
position
,
token
):
Thenable
<
modes
.
Hover
>
=>
{
return
wireCancellationToken
(
token
,
this
.
_provideHover
(
model
.
getAssociatedResource
(),
position
));
}
});
// modes.ReferenceSearchRegistry.register(this.getId(), this);
modes
.
OutlineRegistry
.
register
(
this
.
getId
(),
this
);
// Modes.DeclarationRegistry.register(this.getId(), {
// findDeclaration: (resource, position) => this.findDeclaration(resource, position)
// modes.DefinitionProviderRegistry.register(this.getId(), {
// provideDefinition: (model, position, token): Thenable<modes.Definition> => {
// return wireCancellationToken(token, this._provideDefinition(model.getAssociatedResource(), position));
// }
// });
modes
.
SuggestRegistry
.
register
(
this
.
getId
(),
{
triggerCharacters
:
[
'
'
,
'
:
'
],
shouldAutotriggerSuggest
:
true
,
provideCompletionItems
:
(
model
,
position
,
token
)
=>
this
.
provideCompletionItems
(
model
,
position
,
token
)
provideCompletionItems
:
(
model
,
position
,
token
):
Thenable
<
modes
.
ISuggestResult
[]
>
=>
{
return
wireCancellationToken
(
token
,
this
.
_provideCompletionItems
(
model
.
getAssociatedResource
(),
position
));
}
});
modes
.
QuickFixRegistry
.
register
(
this
.
getId
(),
this
);
...
...
@@ -378,37 +394,28 @@ export class CSSMode extends AbstractMode {
return
this
.
_worker
((
w
)
=>
w
.
enableValidator
());
}
public
provideDocumentHighlights
(
model
:
editorCommon
.
IReadOnlyModel
,
position
:
editorCommon
.
IEditorPosition
,
token
:
CancellationToken
):
Thenable
<
modes
.
DocumentHighlight
[]
>
{
return
wireCancellationToken
(
token
,
this
.
_provideDocumentHighlights
(
model
.
getAssociatedResource
(),
position
));
}
static
$_provideDocumentHighlights
=
OneWorkerAttr
(
CSSMode
,
CSSMode
.
prototype
.
_provideDocumentHighlights
);
private
_provideDocumentHighlights
(
resource
:
URI
,
position
:
editorCommon
.
IPosition
):
WinJS
.
TPromise
<
modes
.
DocumentHighlight
[]
>
{
return
this
.
_worker
((
w
)
=>
w
.
provideDocumentHighlights
(
resource
,
position
));
}
public
provideCompletionItems
(
model
:
editorCommon
.
IReadOnlyModel
,
position
:
editorCommon
.
IEditorPosition
,
token
:
CancellationToken
):
Thenable
<
modes
.
ISuggestResult
[]
>
{
return
wireCancellationToken
(
token
,
this
.
_provideCompletionItems
(
model
.
getAssociatedResource
(),
position
));
}
static
$_provideCompletionItems
=
OneWorkerAttr
(
CSSMode
,
CSSMode
.
prototype
.
_provideCompletionItems
);
private
_provideCompletionItems
(
resource
:
URI
,
position
:
editorCommon
.
IPosition
):
WinJS
.
TPromise
<
modes
.
ISuggestResult
[]
>
{
return
this
.
_worker
((
w
)
=>
w
.
provideCompletionItems
(
resource
,
position
));
}
static
$
findDeclaration
=
OneWorkerAttr
(
CSSMode
,
CSSMode
.
prototype
.
findDeclara
tion
);
p
ublic
findDeclaration
(
resource
:
URI
,
position
:
editorCommon
.
IPosition
):
WinJS
.
TPromise
<
modes
.
IReference
>
{
return
this
.
_worker
((
w
)
=>
w
.
findDeclara
tion
(
resource
,
position
));
static
$
_provideDefinition
=
OneWorkerAttr
(
CSSMode
,
CSSMode
.
prototype
.
_provideDefini
tion
);
p
rivate
_provideDefinition
(
resource
:
URI
,
position
:
editorCommon
.
IPosition
):
WinJS
.
TPromise
<
modes
.
Definition
>
{
return
this
.
_worker
((
w
)
=>
w
.
provideDefini
tion
(
resource
,
position
));
}
public
provideHover
(
model
:
editorCommon
.
IReadOnlyModel
,
position
:
editorCommon
.
IEditorPosition
,
token
:
CancellationToken
):
Thenable
<
modes
.
Hover
>
{
return
wireCancellationToken
(
token
,
this
.
_provideHover
(
model
.
getAssociatedResource
(),
position
));
}
static
$_provideHover
=
OneWorkerAttr
(
CSSMode
,
CSSMode
.
prototype
.
_provideHover
);
private
_provideHover
(
resource
:
URI
,
position
:
editorCommon
.
IPosition
):
WinJS
.
TPromise
<
modes
.
Hover
>
{
return
this
.
_worker
((
w
)
=>
w
.
provideHover
(
resource
,
position
));
}
static
$findReferences
=
OneWorkerAttr
(
CSSMode
,
CSSMode
.
prototype
.
findReferences
);
public
findReferences
(
resource
:
URI
,
position
:
editorCommon
.
IPosition
):
WinJS
.
TPromise
<
modes
.
IReference
[]
>
{
public
findReferences
(
resource
:
URI
,
position
:
editorCommon
.
IPosition
):
WinJS
.
TPromise
<
modes
.
Location
[]
>
{
return
this
.
_worker
((
w
)
=>
w
.
findReferences
(
resource
,
position
));
}
...
...
src/vs/languages/css/common/cssWorker.ts
浏览文件 @
fe9b6dba
...
...
@@ -13,8 +13,8 @@ import languageService = require('vs/languages/css/common/services/cssLanguageSe
import
languageFacts
=
require
(
'
vs/languages/css/common/services/languageFacts
'
);
import
occurrences
=
require
(
'
./services/occurrences
'
);
import
cssIntellisense
=
require
(
'
vs/languages/css/common/services/intelliSense
'
);
import
E
ditorCommon
=
require
(
'
vs/editor/common/editorCommon
'
);
import
M
odes
=
require
(
'
vs/editor/common/modes
'
);
import
e
ditorCommon
=
require
(
'
vs/editor/common/editorCommon
'
);
import
m
odes
=
require
(
'
vs/editor/common/modes
'
);
import
nodes
=
require
(
'
vs/languages/css/common/parser/cssNodes
'
);
import
_level
=
require
(
'
vs/languages/css/common/level
'
);
import
parser
=
require
(
'
vs/languages/css/common/parser/cssParser
'
);
...
...
@@ -59,7 +59,7 @@ export class CSSWorker {
this
.
validationEnabled
=
true
;
}
public
navigateValueSet
(
resource
:
URI
,
range
:
EditorCommon
.
IRange
,
up
:
boolean
):
winjs
.
TPromise
<
M
odes
.
IInplaceReplaceSupportResult
>
{
public
navigateValueSet
(
resource
:
URI
,
range
:
editorCommon
.
IRange
,
up
:
boolean
):
winjs
.
TPromise
<
m
odes
.
IInplaceReplaceSupportResult
>
{
return
this
.
languageService
.
join
().
then
(()
=>
{
let
model
=
this
.
resourceService
.
get
(
resource
);
...
...
@@ -99,7 +99,7 @@ export class CSSWorker {
nextIdx
=
len
-
1
;
}
}
let
result
:
M
odes
.
IInplaceReplaceSupportResult
=
{
let
result
:
m
odes
.
IInplaceReplaceSupportResult
=
{
value
:
values
[
nextIdx
],
range
:
this
.
_range
(
node
,
model
)
};
...
...
@@ -108,7 +108,7 @@ export class CSSWorker {
}
// if none matches, take the first one
if
(
values
.
length
>
0
)
{
let
result
:
M
odes
.
IInplaceReplaceSupportResult
=
{
let
result
:
m
odes
.
IInplaceReplaceSupportResult
=
{
value
:
values
[
0
],
range
:
this
.
_range
(
node
,
model
)
};
...
...
@@ -175,7 +175,7 @@ export class CSSWorker {
});
}
private
_createMarkerData
(
model
:
E
ditorCommon
.
IMirrorModel
,
marker
:
nodes
.
IMarker
):
IMarkerData
{
private
_createMarkerData
(
model
:
e
ditorCommon
.
IMirrorModel
,
marker
:
nodes
.
IMarker
):
IMarkerData
{
let
range
=
model
.
getRangeFromOffsetAndLength
(
marker
.
getOffset
(),
marker
.
getLength
());
return
<
IMarkerData
>
{
code
:
marker
.
getRule
().
id
,
...
...
@@ -196,11 +196,11 @@ export class CSSWorker {
return
new
cssIntellisense
.
CSSIntellisense
();
}
public
provideCompletionItems
(
resource
:
URI
,
position
:
EditorCommon
.
IPosition
):
winjs
.
TPromise
<
M
odes
.
ISuggestResult
[]
>
{
public
provideCompletionItems
(
resource
:
URI
,
position
:
editorCommon
.
IPosition
):
winjs
.
TPromise
<
m
odes
.
ISuggestResult
[]
>
{
return
this
.
doSuggest
(
resource
,
position
).
then
(
value
=>
filterSuggestions
(
value
));
}
private
doSuggest
(
resource
:
URI
,
position
:
EditorCommon
.
IPosition
):
winjs
.
TPromise
<
M
odes
.
ISuggestResult
>
{
private
doSuggest
(
resource
:
URI
,
position
:
editorCommon
.
IPosition
):
winjs
.
TPromise
<
m
odes
.
ISuggestResult
>
{
return
this
.
languageService
.
join
().
then
(()
=>
{
...
...
@@ -211,17 +211,17 @@ export class CSSWorker {
}
public
getOutline
(
resource
:
URI
):
winjs
.
TPromise
<
M
odes
.
IOutlineEntry
[]
>
{
public
getOutline
(
resource
:
URI
):
winjs
.
TPromise
<
m
odes
.
IOutlineEntry
[]
>
{
return
this
.
languageService
.
join
().
then
(()
=>
{
let
model
=
this
.
resourceService
.
get
(
resource
),
stylesheet
=
this
.
languageService
.
getStylesheet
(
resource
),
result
:
M
odes
.
IOutlineEntry
[]
=
[];
result
:
m
odes
.
IOutlineEntry
[]
=
[];
stylesheet
.
accept
((
node
)
=>
{
let
entry
:
M
odes
.
IOutlineEntry
=
{
let
entry
:
m
odes
.
IOutlineEntry
=
{
label
:
null
,
type
:
'
rule
'
,
range
:
null
,
...
...
@@ -257,7 +257,7 @@ export class CSSWorker {
});
}
public
provideHover
(
resource
:
URI
,
position
:
EditorCommon
.
IPosition
):
winjs
.
TPromise
<
M
odes
.
Hover
>
{
public
provideHover
(
resource
:
URI
,
position
:
editorCommon
.
IPosition
):
winjs
.
TPromise
<
m
odes
.
Hover
>
{
return
this
.
languageService
.
join
().
then
(()
=>
{
...
...
@@ -296,7 +296,7 @@ export class CSSWorker {
});
}
public
findDeclaration
(
resource
:
URI
,
position
:
EditorCommon
.
IPosition
):
winjs
.
TPromise
<
Modes
.
IReference
>
{
public
provideDefinition
(
resource
:
URI
,
position
:
editorCommon
.
IPosition
):
winjs
.
TPromise
<
modes
.
Location
>
{
return
this
.
languageService
.
join
().
then
(()
=>
{
...
...
@@ -308,14 +308,14 @@ export class CSSWorker {
return
null
;
}
return
<
Modes
.
IReference
>
{
resource
:
resource
,
return
{
uri
:
resource
,
range
:
this
.
_range
(
node
,
model
,
true
)
};
});
}
public
provideDocumentHighlights
(
resource
:
URI
,
position
:
EditorCommon
.
IPosition
):
winjs
.
TPromise
<
M
odes
.
DocumentHighlight
[]
>
{
public
provideDocumentHighlights
(
resource
:
URI
,
position
:
editorCommon
.
IPosition
):
winjs
.
TPromise
<
m
odes
.
DocumentHighlight
[]
>
{
return
this
.
languageService
.
join
().
then
(()
=>
{
...
...
@@ -332,7 +332,7 @@ export class CSSWorker {
});
}
public
findReferences
(
resource
:
URI
,
position
:
EditorCommon
.
IPosition
):
winjs
.
TPromise
<
Modes
.
IReference
[]
>
{
public
findReferences
(
resource
:
URI
,
position
:
editorCommon
.
IPosition
):
winjs
.
TPromise
<
modes
.
Location
[]
>
{
return
this
.
languageService
.
join
().
then
(()
=>
{
let
model
=
this
.
resourceService
.
get
(
resource
),
...
...
@@ -340,8 +340,8 @@ export class CSSWorker {
nodes
=
occurrences
.
findOccurrences
(
this
.
languageService
.
getStylesheet
(
resource
),
offset
);
return
nodes
.
map
((
occurrence
)
=>
{
return
<
Modes
.
IReference
>
{
resource
:
model
.
getAssociatedResource
(),
return
{
uri
:
model
.
getAssociatedResource
(),
range
:
this
.
_range
(
occurrence
.
node
,
model
)
};
});
...
...
@@ -354,7 +354,7 @@ export class CSSWorker {
let
model
=
this
.
resourceService
.
get
(
resource
),
styleSheet
=
this
.
languageService
.
getStylesheet
(
resource
),
result
:{
range
:
E
ditorCommon
.
IRange
;
value
:
string
;
}[]
=
[];
result
:{
range
:
e
ditorCommon
.
IRange
;
value
:
string
;
}[]
=
[];
styleSheet
.
accept
((
node
)
=>
{
if
(
languageFacts
.
isColorValue
(
node
))
{
...
...
@@ -370,7 +370,7 @@ export class CSSWorker {
});
}
_range
(
node
:{
offset
:
number
;
length
:
number
;},
model
:
EditorCommon
.
IMirrorModel
,
empty
:
boolean
=
false
):
E
ditorCommon
.
IRange
{
_range
(
node
:{
offset
:
number
;
length
:
number
;},
model
:
editorCommon
.
IMirrorModel
,
empty
:
boolean
=
false
):
e
ditorCommon
.
IRange
{
if
(
empty
)
{
let
position
=
model
.
getPositionFromOffset
(
node
.
offset
);
return
{
...
...
@@ -384,10 +384,10 @@ export class CSSWorker {
}
}
private
getFixesForUnknownProperty
(
property
:
nodes
.
Property
,
marker
:
IMarker
)
:
M
odes
.
IQuickFix
[]
{
private
getFixesForUnknownProperty
(
property
:
nodes
.
Property
,
marker
:
IMarker
)
:
m
odes
.
IQuickFix
[]
{
let
propertyName
=
property
.
getName
();
let
result
:
M
odes
.
IQuickFix
[]
=
[];
let
result
:
m
odes
.
IQuickFix
[]
=
[];
for
(
let
p
in
languageFacts
.
getProperties
())
{
let
score
=
strings
.
difference
(
propertyName
,
p
);
if
(
score
>=
propertyName
.
length
/
2
/*score_lim*/
)
{
...
...
@@ -410,7 +410,7 @@ export class CSSWorker {
return
result
.
slice
(
0
,
3
/*max_result*/
);
}
private
appendFixesForMarker
(
bucket
:
M
odes
.
IQuickFix
[],
marker
:
IMarker
):
void
{
private
appendFixesForMarker
(
bucket
:
m
odes
.
IQuickFix
[],
marker
:
IMarker
):
void
{
if
((
<
IMarker
>
marker
).
code
!==
lintRules
.
Rules
.
UnknownProperty
.
id
)
{
return
;
...
...
@@ -432,10 +432,10 @@ export class CSSWorker {
}
}
public
getQuickFixes
(
resource
:
URI
,
range
:
EditorCommon
.
IRange
):
winjs
.
TPromise
<
M
odes
.
IQuickFix
[]
>
{
public
getQuickFixes
(
resource
:
URI
,
range
:
editorCommon
.
IRange
):
winjs
.
TPromise
<
m
odes
.
IQuickFix
[]
>
{
return
this
.
languageService
.
join
().
then
(()
=>
{
const
result
:
M
odes
.
IQuickFix
[]
=
[];
const
result
:
m
odes
.
IQuickFix
[]
=
[];
this
.
markerService
.
read
({
resource
})
.
filter
(
marker
=>
Range
.
containsRange
(
range
,
marker
))
...
...
src/vs/languages/handlebars/common/handlebars.ts
浏览文件 @
fe9b6dba
...
...
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
M
odes
=
require
(
'
vs/editor/common/modes
'
);
import
m
odes
=
require
(
'
vs/editor/common/modes
'
);
import
htmlMode
=
require
(
'
vs/languages/html/common/html
'
);
import
handlebarsTokenTypes
=
require
(
'
vs/languages/handlebars/common/handlebarsTokenTypes
'
);
import
htmlWorker
=
require
(
'
vs/languages/html/common/htmlWorker
'
);
...
...
@@ -14,6 +14,7 @@ import {RichEditSupport} from 'vs/editor/common/modes/supports/richEditSupport';
import
{
createWordRegExp
}
from
'
vs/editor/common/modes/abstractMode
'
;
import
{
ILeavingNestedModeData
}
from
'
vs/editor/common/modes/supports/tokenizationSupport
'
;
import
{
IThreadService
}
from
'
vs/platform/thread/common/thread
'
;
import
{
wireCancellationToken
}
from
'
vs/base/common/async
'
;
export
enum
States
{
HTML
,
...
...
@@ -23,7 +24,7 @@ export enum States {
export
class
HandlebarsState
extends
htmlMode
.
State
{
constructor
(
mode
:
M
odes
.
IMode
,
constructor
(
mode
:
m
odes
.
IMode
,
public
kind
:
htmlMode
.
States
,
public
handlebarsKind
:
States
,
public
lastTagName
:
string
,
...
...
@@ -39,7 +40,7 @@ export class HandlebarsState extends htmlMode.State {
return
new
HandlebarsState
(
this
.
getMode
(),
this
.
kind
,
this
.
handlebarsKind
,
this
.
lastTagName
,
this
.
lastAttributeName
,
this
.
embeddedContentType
,
this
.
attributeValueQuote
,
this
.
attributeValue
);
}
public
equals
(
other
:
M
odes
.
IState
):
boolean
{
public
equals
(
other
:
m
odes
.
IState
):
boolean
{
if
(
other
instanceof
HandlebarsState
)
{
return
(
super
.
equals
(
other
)
...
...
@@ -48,7 +49,7 @@ export class HandlebarsState extends htmlMode.State {
return
false
;
}
public
tokenize
(
stream
:
Modes
.
IStream
)
:
M
odes
.
ITokenizationResult
{
public
tokenize
(
stream
:
modes
.
IStream
)
:
m
odes
.
ITokenizationResult
{
switch
(
this
.
handlebarsKind
)
{
case
States
.
HTML
:
if
(
stream
.
advanceIfString
(
'
{{{
'
).
length
>
0
)
{
...
...
@@ -107,7 +108,7 @@ export class HandlebarsState extends htmlMode.State {
export
class
HandlebarsMode
extends
htmlMode
.
HTMLMode
<
htmlWorker
.
HTMLWorker
>
{
constructor
(
descriptor
:
M
odes
.
IModeDescriptor
,
descriptor
:
m
odes
.
IModeDescriptor
,
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
IModeService
modeService
:
IModeService
,
@
IThreadService
threadService
:
IThreadService
...
...
@@ -116,17 +117,30 @@ export class HandlebarsMode extends htmlMode.HTMLMode<htmlWorker.HTMLWorker> {
}
protected
_registerSupports
():
void
{
Modes
.
HoverProviderRegistry
.
register
(
this
.
getId
(),
this
);
Modes
.
ReferenceSearchRegistry
.
register
(
this
.
getId
(),
this
);
Modes
.
SuggestRegistry
.
register
(
this
.
getId
(),
{
modes
.
HoverProviderRegistry
.
register
(
this
.
getId
(),
{
provideHover
:
(
model
,
position
,
token
):
Thenable
<
modes
.
Hover
>
=>
{
return
wireCancellationToken
(
token
,
this
.
_provideHover
(
model
.
getAssociatedResource
(),
position
));
}
});
modes
.
ReferenceSearchRegistry
.
register
(
this
.
getId
(),
this
);
modes
.
SuggestRegistry
.
register
(
this
.
getId
(),
{
triggerCharacters
:
[
'
.
'
,
'
:
'
,
'
<
'
,
'
"
'
,
'
=
'
,
'
/
'
],
shouldAutotriggerSuggest
:
true
,
provideCompletionItems
:
(
model
,
position
,
token
)
=>
this
.
provideCompletionItems
(
model
,
position
,
token
)
provideCompletionItems
:
(
model
,
position
,
token
):
Thenable
<
modes
.
ISuggestResult
[]
>
=>
{
return
wireCancellationToken
(
token
,
this
.
_provideCompletionItems
(
model
.
getAssociatedResource
(),
position
));
}
});
modes
.
DocumentHighlightProviderRegistry
.
register
(
this
.
getId
(),
{
provideDocumentHighlights
:
(
model
,
position
,
token
):
Thenable
<
modes
.
DocumentHighlight
[]
>
=>
{
return
wireCancellationToken
(
token
,
this
.
_provideDocumentHighlights
(
model
.
getAssociatedResource
(),
position
));
}
});
Modes
.
DocumentHighlightProviderRegistry
.
register
(
this
.
getId
(),
this
);
}
protected
_createRichEditSupport
():
M
odes
.
IRichEditSupport
{
protected
_createRichEditSupport
():
m
odes
.
IRichEditSupport
{
return
new
RichEditSupport
(
this
.
getId
(),
null
,
{
wordPattern
:
createWordRegExp
(
'
#-?%
'
),
...
...
@@ -164,21 +178,21 @@ export class HandlebarsMode extends htmlMode.HTMLMode<htmlWorker.HTMLWorker> {
{
beforeText
:
new
RegExp
(
`<(?!(?:
${
htmlMode
.
EMPTY_ELEMENTS
.
join
(
'
|
'
)}
))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`
,
'
i
'
),
afterText
:
/^<
\/(\w[\w\d]
*
)\s
*>$/i
,
action
:
{
indentAction
:
M
odes
.
IndentAction
.
IndentOutdent
}
action
:
{
indentAction
:
m
odes
.
IndentAction
.
IndentOutdent
}
},
{
beforeText
:
new
RegExp
(
`<(?!(?:
${
htmlMode
.
EMPTY_ELEMENTS
.
join
(
'
|
'
)}
))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`
,
'
i
'
),
action
:
{
indentAction
:
M
odes
.
IndentAction
.
Indent
}
action
:
{
indentAction
:
m
odes
.
IndentAction
.
Indent
}
}
],
});
}
public
getInitialState
()
:
M
odes
.
IState
{
public
getInitialState
()
:
m
odes
.
IState
{
return
new
HandlebarsState
(
this
,
htmlMode
.
States
.
Content
,
States
.
HTML
,
''
,
''
,
''
,
''
,
''
);
}
public
getLeavingNestedModeData
(
line
:
string
,
state
:
M
odes
.
IState
):
ILeavingNestedModeData
{
public
getLeavingNestedModeData
(
line
:
string
,
state
:
m
odes
.
IState
):
ILeavingNestedModeData
{
var
leavingNestedModeData
=
super
.
getLeavingNestedModeData
(
line
,
state
);
if
(
leavingNestedModeData
)
{
leavingNestedModeData
.
stateAfterNestedMode
=
new
HandlebarsState
(
this
,
htmlMode
.
States
.
Content
,
States
.
HTML
,
''
,
''
,
''
,
''
,
''
);
...
...
src/vs/languages/html/common/html.ts
浏览文件 @
fe9b6dba
...
...
@@ -19,7 +19,6 @@ 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
{
IThreadService
}
from
'
vs/platform/thread/common/thread
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
import
{
wireCancellationToken
}
from
'
vs/base/common/async
'
;
export
{
htmlTokenTypes
};
// export to be used by Razor. We are the main module, so Razor should get it from us.
...
...
@@ -328,15 +327,30 @@ export class HTMLMode<W extends htmlWorker.HTMLWorker> extends AbstractMode impl
throw
new
Error
(
'
This method must be overwritten!
'
);
}
modes
.
HoverProviderRegistry
.
register
(
this
.
getId
(),
this
);
modes
.
HoverProviderRegistry
.
register
(
this
.
getId
(),
{
provideHover
:
(
model
,
position
,
token
):
Thenable
<
modes
.
Hover
>
=>
{
return
wireCancellationToken
(
token
,
this
.
_provideHover
(
model
.
getAssociatedResource
(),
position
));
}
});
modes
.
ReferenceSearchRegistry
.
register
(
this
.
getId
(),
this
);
modes
.
SuggestRegistry
.
register
(
this
.
getId
(),
{
triggerCharacters
:
[
'
.
'
,
'
:
'
,
'
<
'
,
'
"
'
,
'
=
'
,
'
/
'
],
shouldAutotriggerSuggest
:
true
,
provideCompletionItems
:
(
model
,
position
,
token
)
=>
this
.
provideCompletionItems
(
model
,
position
,
token
)
provideCompletionItems
:
(
model
,
position
,
token
):
Thenable
<
modes
.
ISuggestResult
[]
>
=>
{
return
wireCancellationToken
(
token
,
this
.
_provideCompletionItems
(
model
.
getAssociatedResource
(),
position
));
}
});
modes
.
DocumentHighlightProviderRegistry
.
register
(
this
.
getId
(),
this
);
modes
.
DocumentHighlightProviderRegistry
.
register
(
this
.
getId
(),
{
provideDocumentHighlights
:
(
model
,
position
,
token
):
Thenable
<
modes
.
DocumentHighlight
[]
>
=>
{
return
wireCancellationToken
(
token
,
this
.
_provideDocumentHighlights
(
model
.
getAssociatedResource
(),
position
));
}
});
modes
.
FormatRegistry
.
register
(
this
.
getId
(),
this
);
modes
.
FormatOnTypeRegistry
.
register
(
this
.
getId
(),
this
);
}
...
...
@@ -474,32 +488,23 @@ export class HTMLMode<W extends htmlWorker.HTMLWorker> extends AbstractMode impl
return
this
.
_worker
((
w
)
=>
w
.
format
(
resource
,
range
,
options
));
}
public
provideHover
(
model
:
editorCommon
.
IReadOnlyModel
,
position
:
editorCommon
.
IEditorPosition
,
token
:
CancellationToken
):
Thenable
<
modes
.
Hover
>
{
return
wireCancellationToken
(
token
,
this
.
_provideHover
(
model
.
getAssociatedResource
(),
position
));
}
static
$_provideHover
=
OneWorkerAttr
(
HTMLMode
,
HTMLMode
.
prototype
.
_provideHover
);
pr
ivate
_provideHover
(
resource
:
URI
,
position
:
editorCommon
.
IPosition
):
winjs
.
TPromise
<
modes
.
Hover
>
{
pr
otected
_provideHover
(
resource
:
URI
,
position
:
editorCommon
.
IPosition
):
winjs
.
TPromise
<
modes
.
Hover
>
{
return
this
.
_worker
((
w
)
=>
w
.
provideHover
(
resource
,
position
));
}
static
$findReferences
=
OneWorkerAttr
(
HTMLMode
,
HTMLMode
.
prototype
.
findReferences
);
public
findReferences
(
resource
:
URI
,
position
:
editorCommon
.
IPosition
,
includeDeclaration
:
boolean
):
winjs
.
TPromise
<
modes
.
IReference
[]
>
{
public
findReferences
(
resource
:
URI
,
position
:
editorCommon
.
IPosition
,
includeDeclaration
:
boolean
):
winjs
.
TPromise
<
modes
.
Location
[]
>
{
return
this
.
_worker
((
w
)
=>
w
.
findReferences
(
resource
,
position
,
includeDeclaration
));
}
public
provideDocumentHighlights
(
model
:
editorCommon
.
IReadOnlyModel
,
position
:
editorCommon
.
IEditorPosition
,
token
:
CancellationToken
):
Thenable
<
modes
.
DocumentHighlight
[]
>
{
return
wireCancellationToken
(
token
,
this
.
_provideDocumentHighlights
(
model
.
getAssociatedResource
(),
position
));
}
static
$_provideDocumentHighlights
=
OneWorkerAttr
(
HTMLMode
,
HTMLMode
.
prototype
.
_provideDocumentHighlights
);
pr
ivate
_provideDocumentHighlights
(
resource
:
URI
,
position
:
editorCommon
.
IPosition
,
strict
:
boolean
=
false
):
winjs
.
TPromise
<
modes
.
DocumentHighlight
[]
>
{
pr
otected
_provideDocumentHighlights
(
resource
:
URI
,
position
:
editorCommon
.
IPosition
,
strict
:
boolean
=
false
):
winjs
.
TPromise
<
modes
.
DocumentHighlight
[]
>
{
return
this
.
_worker
((
w
)
=>
w
.
provideDocumentHighlights
(
resource
,
position
,
strict
));
}
public
provideCompletionItems
(
model
:
editorCommon
.
IReadOnlyModel
,
position
:
editorCommon
.
IEditorPosition
,
token
:
CancellationToken
):
Thenable
<
modes
.
ISuggestResult
[]
>
{
return
wireCancellationToken
(
token
,
this
.
_provideCompletionItems
(
model
.
getAssociatedResource
(),
position
));
}
static
$_provideCompletionItems
=
OneWorkerAttr
(
HTMLMode
,
HTMLMode
.
prototype
.
_provideCompletionItems
);
pr
ivate
_provideCompletionItems
(
resource
:
URI
,
position
:
editorCommon
.
IPosition
):
winjs
.
TPromise
<
modes
.
ISuggestResult
[]
>
{
pr
otected
_provideCompletionItems
(
resource
:
URI
,
position
:
editorCommon
.
IPosition
):
winjs
.
TPromise
<
modes
.
ISuggestResult
[]
>
{
return
this
.
_worker
((
w
)
=>
w
.
provideCompletionItems
(
resource
,
position
));
}
...
...
src/vs/languages/html/common/htmlWorker.ts
浏览文件 @
fe9b6dba
...
...
@@ -157,7 +157,7 @@ export class HTMLWorker {
});
}
public
findReferences
(
resource
:
URI
,
position
:
editorCommon
.
IPosition
,
includeDeclaration
:
boolean
):
winjs
.
TPromise
<
modes
.
IReference
[]
>
{
public
findReferences
(
resource
:
URI
,
position
:
editorCommon
.
IPosition
,
includeDeclaration
:
boolean
):
winjs
.
TPromise
<
modes
.
Location
[]
>
{
return
this
.
_delegateToModeAtPosition
(
resource
,
position
,
(
isEmbeddedMode
,
model
)
=>
{
if
(
isEmbeddedMode
)
{
return
findReferences
(
model
,
Position
.
lift
(
position
));
...
...
src/vs/languages/json/common/json.ts
浏览文件 @
fe9b6dba
...
...
@@ -5,7 +5,7 @@
'
use strict
'
;
import
EditorCommon
=
require
(
'
vs/editor/common/editorCommon
'
);
import
M
odes
=
require
(
'
vs/editor/common/modes
'
);
import
m
odes
=
require
(
'
vs/editor/common/modes
'
);
import
URI
from
'
vs/base/common/uri
'
;
import
WinJS
=
require
(
'
vs/base/common/winjs.base
'
);
import
Platform
=
require
(
'
vs/platform/platform
'
);
...
...
@@ -17,21 +17,20 @@ import {IThreadService, ThreadAffinity} from 'vs/platform/thread/common/thread';
import
{
IJSONContributionRegistry
,
Extensions
,
ISchemaContributions
}
from
'
vs/platform/jsonschemas/common/jsonContributionRegistry
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
RichEditSupport
}
from
'
vs/editor/common/modes/supports/richEditSupport
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
import
{
wireCancellationToken
}
from
'
vs/base/common/async
'
;
export
class
JSONMode
extends
AbstractMode
implements
Modes
.
HoverProvider
,
M
odes
.
IOutlineSupport
{
export
class
JSONMode
extends
AbstractMode
implements
m
odes
.
IOutlineSupport
{
public
tokenizationSupport
:
M
odes
.
ITokenizationSupport
;
public
richEditSupport
:
M
odes
.
IRichEditSupport
;
public
configSupport
:
M
odes
.
IConfigurationSupport
;
public
inplaceReplaceSupport
:
M
odes
.
IInplaceReplaceSupport
;
public
tokenizationSupport
:
m
odes
.
ITokenizationSupport
;
public
richEditSupport
:
m
odes
.
IRichEditSupport
;
public
configSupport
:
m
odes
.
IConfigurationSupport
;
public
inplaceReplaceSupport
:
m
odes
.
IInplaceReplaceSupport
;
private
_modeWorkerManager
:
ModeWorkerManager
<
jsonWorker
.
JSONWorker
>
;
private
_threadService
:
IThreadService
;
constructor
(
descriptor
:
M
odes
.
IModeDescriptor
,
descriptor
:
m
odes
.
IModeDescriptor
,
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
IThreadService
threadService
:
IThreadService
)
{
...
...
@@ -64,20 +63,29 @@ export class JSONMode extends AbstractMode implements Modes.HoverProvider, Modes
}
});
Modes
.
HoverProviderRegistry
.
register
(
this
.
getId
(),
this
);
modes
.
HoverProviderRegistry
.
register
(
this
.
getId
(),
{
provideHover
:
(
model
,
position
,
token
):
Thenable
<
modes
.
Hover
>
=>
{
return
wireCancellationToken
(
token
,
this
.
_provideHover
(
model
.
getAssociatedResource
(),
position
));
}
});
this
.
inplaceReplaceSupport
=
this
;
this
.
configSupport
=
this
;
// Initialize Outline support
Modes
.
OutlineRegistry
.
register
(
this
.
getId
(),
this
);
modes
.
OutlineRegistry
.
register
(
this
.
getId
(),
this
);
modes
.
FormatRegistry
.
register
(
this
.
getId
(),
this
);
Modes
.
FormatRegistry
.
register
(
this
.
getId
(),
this
);
Modes
.
FormatOnTypeRegistry
.
register
(
this
.
getId
(),
this
);
modes
.
FormatOnTypeRegistry
.
register
(
this
.
getId
(),
this
);
M
odes
.
SuggestRegistry
.
register
(
this
.
getId
(),
{
m
odes
.
SuggestRegistry
.
register
(
this
.
getId
(),
{
triggerCharacters
:
[],
shouldAutotriggerSuggest
:
true
,
provideCompletionItems
:
(
model
,
position
,
token
)
=>
this
.
provideCompletionItems
(
model
,
position
,
token
)
provideCompletionItems
:
(
model
,
position
,
token
):
Thenable
<
modes
.
ISuggestResult
[]
>
=>
{
return
wireCancellationToken
(
token
,
this
.
_provideCompletionItems
(
model
.
getAssociatedResource
(),
position
));
}
});
}
...
...
@@ -128,40 +136,32 @@ export class JSONMode extends AbstractMode implements Modes.HoverProvider, Modes
}
static
$navigateValueSet
=
OneWorkerAttr
(
JSONMode
,
JSONMode
.
prototype
.
navigateValueSet
);
public
navigateValueSet
(
resource
:
URI
,
position
:
EditorCommon
.
IRange
,
up
:
boolean
):
WinJS
.
TPromise
<
M
odes
.
IInplaceReplaceSupportResult
>
{
public
navigateValueSet
(
resource
:
URI
,
position
:
EditorCommon
.
IRange
,
up
:
boolean
):
WinJS
.
TPromise
<
m
odes
.
IInplaceReplaceSupportResult
>
{
return
this
.
_worker
((
w
)
=>
w
.
navigateValueSet
(
resource
,
position
,
up
));
}
public
provideCompletionItems
(
model
:
EditorCommon
.
IReadOnlyModel
,
position
:
EditorCommon
.
IEditorPosition
,
token
:
CancellationToken
):
Thenable
<
Modes
.
ISuggestResult
[]
>
{
return
wireCancellationToken
(
token
,
this
.
_provideCompletionItems
(
model
.
getAssociatedResource
(),
position
));
}
static
$_provideCompletionItems
=
OneWorkerAttr
(
JSONMode
,
JSONMode
.
prototype
.
_provideCompletionItems
);
private
_provideCompletionItems
(
resource
:
URI
,
position
:
EditorCommon
.
IPosition
):
WinJS
.
TPromise
<
M
odes
.
ISuggestResult
[]
>
{
private
_provideCompletionItems
(
resource
:
URI
,
position
:
EditorCommon
.
IPosition
):
WinJS
.
TPromise
<
m
odes
.
ISuggestResult
[]
>
{
return
this
.
_worker
((
w
)
=>
w
.
provideCompletionItems
(
resource
,
position
));
}
public
provideHover
(
model
:
EditorCommon
.
IReadOnlyModel
,
position
:
EditorCommon
.
IEditorPosition
,
token
:
CancellationToken
):
Thenable
<
Modes
.
Hover
>
{
return
wireCancellationToken
(
token
,
this
.
_provideHover
(
model
.
getAssociatedResource
(),
position
));
}
static
$_provideHover
=
OneWorkerAttr
(
JSONMode
,
JSONMode
.
prototype
.
_provideHover
);
private
_provideHover
(
resource
:
URI
,
position
:
EditorCommon
.
IPosition
):
WinJS
.
TPromise
<
M
odes
.
Hover
>
{
private
_provideHover
(
resource
:
URI
,
position
:
EditorCommon
.
IPosition
):
WinJS
.
TPromise
<
m
odes
.
Hover
>
{
return
this
.
_worker
((
w
)
=>
w
.
provideHover
(
resource
,
position
));
}
static
$getOutline
=
OneWorkerAttr
(
JSONMode
,
JSONMode
.
prototype
.
getOutline
);
public
getOutline
(
resource
:
URI
):
WinJS
.
TPromise
<
M
odes
.
IOutlineEntry
[]
>
{
public
getOutline
(
resource
:
URI
):
WinJS
.
TPromise
<
m
odes
.
IOutlineEntry
[]
>
{
return
this
.
_worker
((
w
)
=>
w
.
getOutline
(
resource
));
}
static
$formatDocument
=
OneWorkerAttr
(
JSONMode
,
JSONMode
.
prototype
.
formatDocument
);
public
formatDocument
(
resource
:
URI
,
options
:
M
odes
.
IFormattingOptions
):
WinJS
.
TPromise
<
EditorCommon
.
ISingleEditOperation
[]
>
{
public
formatDocument
(
resource
:
URI
,
options
:
m
odes
.
IFormattingOptions
):
WinJS
.
TPromise
<
EditorCommon
.
ISingleEditOperation
[]
>
{
return
this
.
_worker
((
w
)
=>
w
.
format
(
resource
,
null
,
options
));
}
static
$formatRange
=
OneWorkerAttr
(
JSONMode
,
JSONMode
.
prototype
.
formatRange
);
public
formatRange
(
resource
:
URI
,
range
:
EditorCommon
.
IRange
,
options
:
M
odes
.
IFormattingOptions
):
WinJS
.
TPromise
<
EditorCommon
.
ISingleEditOperation
[]
>
{
public
formatRange
(
resource
:
URI
,
range
:
EditorCommon
.
IRange
,
options
:
m
odes
.
IFormattingOptions
):
WinJS
.
TPromise
<
EditorCommon
.
ISingleEditOperation
[]
>
{
return
this
.
_worker
((
w
)
=>
w
.
format
(
resource
,
range
,
options
));
}
}
\ No newline at end of file
src/vs/languages/less/common/less.ts
浏览文件 @
fe9b6dba
...
...
@@ -6,8 +6,8 @@
import
winjs
=
require
(
'
vs/base/common/winjs.base
'
);
import
URI
from
'
vs/base/common/uri
'
;
import
E
ditorCommon
=
require
(
'
vs/editor/common/editorCommon
'
);
import
M
odes
=
require
(
'
vs/editor/common/modes
'
);
import
e
ditorCommon
=
require
(
'
vs/editor/common/editorCommon
'
);
import
m
odes
=
require
(
'
vs/editor/common/modes
'
);
import
Types
=
require
(
'
vs/editor/common/modes/monarch/monarchTypes
'
);
import
Compile
=
require
(
'
vs/editor/common/modes/monarch/monarchCompile
'
);
import
lessWorker
=
require
(
'
vs/languages/less/common/lessWorker
'
);
...
...
@@ -19,7 +19,6 @@ import {IInstantiationService} from 'vs/platform/instantiation/common/instantiat
import
{
IThreadService
,
ThreadAffinity
}
from
'
vs/platform/thread/common/thread
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
{
IEditorWorkerService
}
from
'
vs/editor/common/services/editorWorkerService
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
import
{
wireCancellationToken
}
from
'
vs/base/common/async
'
;
import
{
createRichEditSupport
}
from
'
vs/editor/common/modes/monarch/monarchDefinition
'
;
import
{
createTokenizationSupport
}
from
'
vs/editor/common/modes/monarch/monarchLexer
'
;
...
...
@@ -177,19 +176,19 @@ export var language: Types.ILanguage = <Types.ILanguage> {
}
};
export
class
LESSMode
extends
AbstractMode
implements
Modes
.
HoverProvider
,
M
odes
.
IOutlineSupport
{
export
class
LESSMode
extends
AbstractMode
implements
m
odes
.
IOutlineSupport
{
public
inplaceReplaceSupport
:
M
odes
.
IInplaceReplaceSupport
;
public
configSupport
:
M
odes
.
IConfigurationSupport
;
public
tokenizationSupport
:
M
odes
.
ITokenizationSupport
;
public
richEditSupport
:
M
odes
.
IRichEditSupport
;
public
inplaceReplaceSupport
:
m
odes
.
IInplaceReplaceSupport
;
public
configSupport
:
m
odes
.
IConfigurationSupport
;
public
tokenizationSupport
:
m
odes
.
ITokenizationSupport
;
public
richEditSupport
:
m
odes
.
IRichEditSupport
;
private
modeService
:
IModeService
;
private
_modeWorkerManager
:
ModeWorkerManager
<
lessWorker
.
LessWorker
>
;
private
_threadService
:
IThreadService
;
constructor
(
descriptor
:
M
odes
.
IModeDescriptor
,
descriptor
:
m
odes
.
IModeDescriptor
,
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
IThreadService
threadService
:
IThreadService
,
@
IModeService
modeService
:
IModeService
,
...
...
@@ -204,19 +203,32 @@ export class LESSMode extends AbstractMode implements Modes.HoverProvider, Modes
this
.
modeService
=
modeService
;
Modes
.
HoverProviderRegistry
.
register
(
this
.
getId
(),
this
);
modes
.
HoverProviderRegistry
.
register
(
this
.
getId
(),
{
provideHover
:
(
model
,
position
,
token
):
Thenable
<
modes
.
Hover
>
=>
{
return
wireCancellationToken
(
token
,
this
.
_provideHover
(
model
.
getAssociatedResource
(),
position
));
}
});
this
.
inplaceReplaceSupport
=
this
;
this
.
configSupport
=
this
;
Modes
.
ReferenceSearchRegistry
.
register
(
this
.
getId
(),
this
);
Modes
.
DeclarationRegistry
.
register
(
this
.
getId
(),
{
findDeclaration
:
(
resource
,
position
)
=>
this
.
findDeclaration
(
resource
,
position
)
modes
.
ReferenceSearchRegistry
.
register
(
this
.
getId
(),
this
);
modes
.
DefinitionProviderRegistry
.
register
(
this
.
getId
(),
{
provideDefinition
:
(
model
,
position
,
token
):
Thenable
<
modes
.
Definition
>
=>
{
return
wireCancellationToken
(
token
,
this
.
_provideDefinition
(
model
.
getAssociatedResource
(),
position
));
}
});
Modes
.
OutlineRegistry
.
register
(
this
.
getId
(),
this
);
Modes
.
SuggestRegistry
.
register
(
this
.
getId
(),
{
modes
.
OutlineRegistry
.
register
(
this
.
getId
(),
this
);
modes
.
SuggestRegistry
.
register
(
this
.
getId
(),
{
triggerCharacters
:
[],
shouldAutotriggerSuggest
:
true
,
provideCompletionItems
:
(
model
,
position
,
token
)
=>
this
.
provideCompletionItems
(
model
,
position
,
token
)
provideCompletionItems
:
(
model
,
position
,
token
):
Thenable
<
modes
.
ISuggestResult
[]
>
=>
{
return
wireCancellationToken
(
token
,
this
.
_provideCompletionItems
(
model
.
getAssociatedResource
(),
position
));
}
});
this
.
tokenizationSupport
=
createTokenizationSupport
(
modeService
,
this
,
lexer
);
...
...
@@ -249,7 +261,7 @@ export class LESSMode extends AbstractMode implements Modes.HoverProvider, Modes
}
static
$navigateValueSet
=
OneWorkerAttr
(
LESSMode
,
LESSMode
.
prototype
.
navigateValueSet
);
public
navigateValueSet
(
resource
:
URI
,
position
:
EditorCommon
.
IRange
,
up
:
boolean
):
winjs
.
TPromise
<
M
odes
.
IInplaceReplaceSupportResult
>
{
public
navigateValueSet
(
resource
:
URI
,
position
:
editorCommon
.
IRange
,
up
:
boolean
):
winjs
.
TPromise
<
m
odes
.
IInplaceReplaceSupportResult
>
{
return
this
.
_worker
((
w
)
=>
w
.
navigateValueSet
(
resource
,
position
,
up
));
}
...
...
@@ -259,40 +271,32 @@ export class LESSMode extends AbstractMode implements Modes.HoverProvider, Modes
}
static
$findReferences
=
OneWorkerAttr
(
LESSMode
,
LESSMode
.
prototype
.
findReferences
);
public
findReferences
(
resource
:
URI
,
position
:
EditorCommon
.
IPosition
):
winjs
.
TPromise
<
Modes
.
IReference
[]
>
{
public
findReferences
(
resource
:
URI
,
position
:
editorCommon
.
IPosition
):
winjs
.
TPromise
<
modes
.
Location
[]
>
{
return
this
.
_worker
((
w
)
=>
w
.
findReferences
(
resource
,
position
));
}
public
provideCompletionItems
(
model
:
EditorCommon
.
IReadOnlyModel
,
position
:
EditorCommon
.
IEditorPosition
,
token
:
CancellationToken
):
Thenable
<
Modes
.
ISuggestResult
[]
>
{
return
wireCancellationToken
(
token
,
this
.
_provideCompletionItems
(
model
.
getAssociatedResource
(),
position
));
}
static
$_provideCompletionItems
=
OneWorkerAttr
(
LESSMode
,
LESSMode
.
prototype
.
_provideCompletionItems
);
private
_provideCompletionItems
(
resource
:
URI
,
position
:
EditorCommon
.
IPosition
):
winjs
.
TPromise
<
M
odes
.
ISuggestResult
[]
>
{
private
_provideCompletionItems
(
resource
:
URI
,
position
:
editorCommon
.
IPosition
):
winjs
.
TPromise
<
m
odes
.
ISuggestResult
[]
>
{
return
this
.
_worker
((
w
)
=>
w
.
provideCompletionItems
(
resource
,
position
));
}
public
provideHover
(
model
:
EditorCommon
.
IReadOnlyModel
,
position
:
EditorCommon
.
IEditorPosition
,
token
:
CancellationToken
):
Thenable
<
Modes
.
Hover
>
{
return
wireCancellationToken
(
token
,
this
.
_provideHover
(
model
.
getAssociatedResource
(),
position
));
}
static
$_provideHover
=
OneWorkerAttr
(
LESSMode
,
LESSMode
.
prototype
.
_provideHover
);
private
_provideHover
(
resource
:
URI
,
position
:
EditorCommon
.
IPosition
):
winjs
.
TPromise
<
M
odes
.
Hover
>
{
private
_provideHover
(
resource
:
URI
,
position
:
editorCommon
.
IPosition
):
winjs
.
TPromise
<
m
odes
.
Hover
>
{
return
this
.
_worker
((
w
)
=>
w
.
provideHover
(
resource
,
position
));
}
static
$getOutline
=
OneWorkerAttr
(
LESSMode
,
LESSMode
.
prototype
.
getOutline
);
public
getOutline
(
resource
:
URI
):
winjs
.
TPromise
<
M
odes
.
IOutlineEntry
[]
>
{
public
getOutline
(
resource
:
URI
):
winjs
.
TPromise
<
m
odes
.
IOutlineEntry
[]
>
{
return
this
.
_worker
((
w
)
=>
w
.
getOutline
(
resource
));
}
static
$
findDeclaration
=
OneWorkerAttr
(
LESSMode
,
LESSMode
.
prototype
.
findDeclara
tion
);
p
ublic
findDeclaration
(
resource
:
URI
,
position
:
EditorCommon
.
IPosition
):
winjs
.
TPromise
<
Modes
.
IReference
>
{
return
this
.
_worker
((
w
)
=>
w
.
findDeclara
tion
(
resource
,
position
));
static
$
_provideDefinition
=
OneWorkerAttr
(
LESSMode
,
LESSMode
.
prototype
.
_provideDefini
tion
);
p
rivate
_provideDefinition
(
resource
:
URI
,
position
:
editorCommon
.
IPosition
):
winjs
.
TPromise
<
modes
.
Definition
>
{
return
this
.
_worker
((
w
)
=>
w
.
provideDefini
tion
(
resource
,
position
));
}
static
$findColorDeclarations
=
OneWorkerAttr
(
LESSMode
,
LESSMode
.
prototype
.
findColorDeclarations
);
public
findColorDeclarations
(
resource
:
URI
):
winjs
.
TPromise
<
{
range
:
E
ditorCommon
.
IRange
;
value
:
string
;
}[]
>
{
public
findColorDeclarations
(
resource
:
URI
):
winjs
.
TPromise
<
{
range
:
e
ditorCommon
.
IRange
;
value
:
string
;
}[]
>
{
return
this
.
_worker
((
w
)
=>
w
.
findColorDeclarations
(
resource
));
}
}
src/vs/languages/razor/common/razor.ts
浏览文件 @
fe9b6dba
...
...
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
M
odes
=
require
(
'
vs/editor/common/modes
'
);
import
m
odes
=
require
(
'
vs/editor/common/modes
'
);
import
htmlMode
=
require
(
'
vs/languages/html/common/html
'
);
import
csharpTokenization
=
require
(
'
vs/languages/razor/common/csharpTokenization
'
);
import
{
createWordRegExp
,
ModeWorkerManager
}
from
'
vs/editor/common/modes/abstractMode
'
;
...
...
@@ -15,12 +15,13 @@ import {IModeService} from 'vs/editor/common/services/modeService';
import
{
RichEditSupport
}
from
'
vs/editor/common/modes/supports/richEditSupport
'
;
import
{
ILeavingNestedModeData
}
from
'
vs/editor/common/modes/supports/tokenizationSupport
'
;
import
{
IThreadService
}
from
'
vs/platform/thread/common/thread
'
;
import
{
wireCancellationToken
}
from
'
vs/base/common/async
'
;
// for a brief description of the razor syntax see http://www.mikesdotnetting.com/Article/153/Inline-Razor-Syntax-Overview
class
RAZORState
extends
htmlMode
.
State
{
constructor
(
mode
:
M
odes
.
IMode
,
kind
:
htmlMode
.
States
,
lastTagName
:
string
,
lastAttributeName
:
string
,
embeddedContentType
:
string
,
attributeValueQuote
:
string
,
attributeValue
:
string
)
{
constructor
(
mode
:
m
odes
.
IMode
,
kind
:
htmlMode
.
States
,
lastTagName
:
string
,
lastAttributeName
:
string
,
embeddedContentType
:
string
,
attributeValueQuote
:
string
,
attributeValue
:
string
)
{
super
(
mode
,
kind
,
lastTagName
,
lastAttributeName
,
embeddedContentType
,
attributeValueQuote
,
attributeValue
);
}
...
...
@@ -28,7 +29,7 @@ class RAZORState extends htmlMode.State {
return
new
RAZORState
(
this
.
getMode
(),
this
.
kind
,
this
.
lastTagName
,
this
.
lastAttributeName
,
this
.
embeddedContentType
,
this
.
attributeValueQuote
,
this
.
attributeValue
);
}
public
equals
(
other
:
M
odes
.
IState
):
boolean
{
public
equals
(
other
:
m
odes
.
IState
):
boolean
{
if
(
other
instanceof
RAZORState
)
{
return
(
super
.
equals
(
other
)
...
...
@@ -37,7 +38,7 @@ class RAZORState extends htmlMode.State {
return
false
;
}
public
tokenize
(
stream
:
Modes
.
IStream
):
M
odes
.
ITokenizationResult
{
public
tokenize
(
stream
:
modes
.
IStream
):
m
odes
.
ITokenizationResult
{
if
(
!
stream
.
eos
()
&&
stream
.
peek
()
===
'
@
'
)
{
stream
.
next
();
...
...
@@ -56,7 +57,7 @@ class RAZORState extends htmlMode.State {
export
class
RAZORMode
extends
htmlMode
.
HTMLMode
<
RAZORWorker
>
{
constructor
(
descriptor
:
M
odes
.
IModeDescriptor
,
descriptor
:
m
odes
.
IModeDescriptor
,
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
IModeService
modeService
:
IModeService
,
@
IThreadService
threadService
:
IThreadService
...
...
@@ -65,21 +66,34 @@ export class RAZORMode extends htmlMode.HTMLMode<RAZORWorker> {
}
protected
_registerSupports
():
void
{
Modes
.
HoverProviderRegistry
.
register
(
this
.
getId
(),
this
);
Modes
.
ReferenceSearchRegistry
.
register
(
this
.
getId
(),
this
);
Modes
.
SuggestRegistry
.
register
(
this
.
getId
(),
{
modes
.
HoverProviderRegistry
.
register
(
this
.
getId
(),
{
provideHover
:
(
model
,
position
,
token
):
Thenable
<
modes
.
Hover
>
=>
{
return
wireCancellationToken
(
token
,
this
.
_provideHover
(
model
.
getAssociatedResource
(),
position
));
}
});
modes
.
ReferenceSearchRegistry
.
register
(
this
.
getId
(),
this
);
modes
.
SuggestRegistry
.
register
(
this
.
getId
(),
{
triggerCharacters
:
[
'
.
'
,
'
:
'
,
'
<
'
,
'
"
'
,
'
=
'
,
'
/
'
],
shouldAutotriggerSuggest
:
true
,
provideCompletionItems
:
(
model
,
position
,
token
)
=>
this
.
provideCompletionItems
(
model
,
position
,
token
)
provideCompletionItems
:
(
model
,
position
,
token
):
Thenable
<
modes
.
ISuggestResult
[]
>
=>
{
return
wireCancellationToken
(
token
,
this
.
_provideCompletionItems
(
model
.
getAssociatedResource
(),
position
));
}
});
modes
.
DocumentHighlightProviderRegistry
.
register
(
this
.
getId
(),
{
provideDocumentHighlights
:
(
model
,
position
,
token
):
Thenable
<
modes
.
DocumentHighlight
[]
>
=>
{
return
wireCancellationToken
(
token
,
this
.
_provideDocumentHighlights
(
model
.
getAssociatedResource
(),
position
));
}
});
Modes
.
DocumentHighlightProviderRegistry
.
register
(
this
.
getId
(),
this
);
}
protected
_createModeWorkerManager
(
descriptor
:
M
odes
.
IModeDescriptor
,
instantiationService
:
IInstantiationService
):
ModeWorkerManager
<
RAZORWorker
>
{
protected
_createModeWorkerManager
(
descriptor
:
m
odes
.
IModeDescriptor
,
instantiationService
:
IInstantiationService
):
ModeWorkerManager
<
RAZORWorker
>
{
return
new
ModeWorkerManager
<
RAZORWorker
>
(
descriptor
,
'
vs/languages/razor/common/razorWorker
'
,
'
RAZORWorker
'
,
'
vs/languages/html/common/htmlWorker
'
,
instantiationService
);
}
protected
_createRichEditSupport
():
M
odes
.
IRichEditSupport
{
protected
_createRichEditSupport
():
m
odes
.
IRichEditSupport
{
return
new
RichEditSupport
(
this
.
getId
(),
null
,
{
wordPattern
:
createWordRegExp
(
'
#?%
'
),
...
...
@@ -117,21 +131,21 @@ export class RAZORMode extends htmlMode.HTMLMode<RAZORWorker> {
{
beforeText
:
new
RegExp
(
`<(?!(?:
${
htmlMode
.
EMPTY_ELEMENTS
.
join
(
'
|
'
)}
))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`
,
'
i
'
),
afterText
:
/^<
\/(\w[\w\d]
*
)\s
*>$/i
,
action
:
{
indentAction
:
M
odes
.
IndentAction
.
IndentOutdent
}
action
:
{
indentAction
:
m
odes
.
IndentAction
.
IndentOutdent
}
},
{
beforeText
:
new
RegExp
(
`<(?!(?:
${
htmlMode
.
EMPTY_ELEMENTS
.
join
(
'
|
'
)}
))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`
,
'
i
'
),
action
:
{
indentAction
:
M
odes
.
IndentAction
.
Indent
}
action
:
{
indentAction
:
m
odes
.
IndentAction
.
Indent
}
}
],
});
}
public
getInitialState
():
M
odes
.
IState
{
public
getInitialState
():
m
odes
.
IState
{
return
new
RAZORState
(
this
,
htmlMode
.
States
.
Content
,
''
,
''
,
''
,
''
,
''
);
}
public
getLeavingNestedModeData
(
line
:
string
,
state
:
M
odes
.
IState
):
ILeavingNestedModeData
{
public
getLeavingNestedModeData
(
line
:
string
,
state
:
m
odes
.
IState
):
ILeavingNestedModeData
{
var
leavingNestedModeData
=
super
.
getLeavingNestedModeData
(
line
,
state
);
if
(
leavingNestedModeData
)
{
leavingNestedModeData
.
stateAfterNestedMode
=
new
RAZORState
(
this
,
htmlMode
.
States
.
Content
,
''
,
''
,
''
,
''
,
''
);
...
...
src/vs/languages/sass/common/sass.ts
浏览文件 @
fe9b6dba
...
...
@@ -8,8 +8,8 @@ import Types = require('vs/editor/common/modes/monarch/monarchTypes');
import
Compile
=
require
(
'
vs/editor/common/modes/monarch/monarchCompile
'
);
import
winjs
=
require
(
'
vs/base/common/winjs.base
'
);
import
URI
from
'
vs/base/common/uri
'
;
import
E
ditorCommon
=
require
(
'
vs/editor/common/editorCommon
'
);
import
M
odes
=
require
(
'
vs/editor/common/modes
'
);
import
e
ditorCommon
=
require
(
'
vs/editor/common/editorCommon
'
);
import
m
odes
=
require
(
'
vs/editor/common/modes
'
);
import
sassWorker
=
require
(
'
vs/languages/sass/common/sassWorker
'
);
import
*
as
sassTokenTypes
from
'
vs/languages/sass/common/sassTokenTypes
'
;
import
{
ModeWorkerManager
,
AbstractMode
}
from
'
vs/editor/common/modes/abstractMode
'
;
...
...
@@ -19,7 +19,6 @@ import {IInstantiationService} from 'vs/platform/instantiation/common/instantiat
import
{
IThreadService
,
ThreadAffinity
}
from
'
vs/platform/thread/common/thread
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
{
IEditorWorkerService
}
from
'
vs/editor/common/services/editorWorkerService
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
import
{
wireCancellationToken
}
from
'
vs/base/common/async
'
;
import
{
createRichEditSupport
}
from
'
vs/editor/common/modes/monarch/monarchDefinition
'
;
import
{
createTokenizationSupport
}
from
'
vs/editor/common/modes/monarch/monarchLexer
'
;
...
...
@@ -279,19 +278,19 @@ export var language = <Types.ILanguage>{
}
};
export
class
SASSMode
extends
AbstractMode
implements
Modes
.
HoverProvider
,
M
odes
.
IOutlineSupport
{
export
class
SASSMode
extends
AbstractMode
implements
m
odes
.
IOutlineSupport
{
public
inplaceReplaceSupport
:
M
odes
.
IInplaceReplaceSupport
;
public
configSupport
:
M
odes
.
IConfigurationSupport
;
public
tokenizationSupport
:
M
odes
.
ITokenizationSupport
;
public
richEditSupport
:
M
odes
.
IRichEditSupport
;
public
inplaceReplaceSupport
:
m
odes
.
IInplaceReplaceSupport
;
public
configSupport
:
m
odes
.
IConfigurationSupport
;
public
tokenizationSupport
:
m
odes
.
ITokenizationSupport
;
public
richEditSupport
:
m
odes
.
IRichEditSupport
;
private
modeService
:
IModeService
;
private
_modeWorkerManager
:
ModeWorkerManager
<
sassWorker
.
SassWorker
>
;
private
_threadService
:
IThreadService
;
constructor
(
descriptor
:
M
odes
.
IModeDescriptor
,
descriptor
:
m
odes
.
IModeDescriptor
,
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
IThreadService
threadService
:
IThreadService
,
@
IModeService
modeService
:
IModeService
,
...
...
@@ -305,20 +304,32 @@ export class SASSMode extends AbstractMode implements Modes.HoverProvider, Modes
this
.
modeService
=
modeService
;
Modes
.
HoverProviderRegistry
.
register
(
this
.
getId
(),
this
);
modes
.
HoverProviderRegistry
.
register
(
this
.
getId
(),
{
provideHover
:
(
model
,
position
,
token
):
Thenable
<
modes
.
Hover
>
=>
{
return
wireCancellationToken
(
token
,
this
.
_provideHover
(
model
.
getAssociatedResource
(),
position
));
}
});
this
.
inplaceReplaceSupport
=
this
;
this
.
configSupport
=
this
;
Modes
.
ReferenceSearchRegistry
.
register
(
this
.
getId
(),
this
);
Modes
.
DeclarationRegistry
.
register
(
this
.
getId
(),
{
findDeclaration
:
(
resource
,
position
)
=>
this
.
findDeclaration
(
resource
,
position
)
modes
.
ReferenceSearchRegistry
.
register
(
this
.
getId
(),
this
);
modes
.
DefinitionProviderRegistry
.
register
(
this
.
getId
(),
{
provideDefinition
:
(
model
,
position
,
token
):
Thenable
<
modes
.
Definition
>
=>
{
return
wireCancellationToken
(
token
,
this
.
_provideDefinition
(
model
.
getAssociatedResource
(),
position
));
}
});
Modes
.
OutlineRegistry
.
register
(
this
.
getId
(),
this
);
Modes
.
SuggestRegistry
.
register
(
this
.
getId
(),
{
modes
.
OutlineRegistry
.
register
(
this
.
getId
(),
this
);
modes
.
SuggestRegistry
.
register
(
this
.
getId
(),
{
triggerCharacters
:
[],
shouldAutotriggerSuggest
:
true
,
provideCompletionItems
:
(
model
,
position
,
token
)
=>
this
.
provideCompletionItems
(
model
,
position
,
token
)
});
provideCompletionItems
:
(
model
,
position
,
token
):
Thenable
<
modes
.
ISuggestResult
[]
>
=>
{
return
wireCancellationToken
(
token
,
this
.
_provideCompletionItems
(
model
.
getAssociatedResource
(),
position
));
}
});
this
.
tokenizationSupport
=
createTokenizationSupport
(
modeService
,
this
,
lexer
);
...
...
@@ -350,7 +361,7 @@ export class SASSMode extends AbstractMode implements Modes.HoverProvider, Modes
}
static
$navigateValueSet
=
OneWorkerAttr
(
SASSMode
,
SASSMode
.
prototype
.
navigateValueSet
);
public
navigateValueSet
(
resource
:
URI
,
position
:
EditorCommon
.
IRange
,
up
:
boolean
):
winjs
.
TPromise
<
M
odes
.
IInplaceReplaceSupportResult
>
{
public
navigateValueSet
(
resource
:
URI
,
position
:
editorCommon
.
IRange
,
up
:
boolean
):
winjs
.
TPromise
<
m
odes
.
IInplaceReplaceSupportResult
>
{
return
this
.
_worker
((
w
)
=>
w
.
navigateValueSet
(
resource
,
position
,
up
));
}
...
...
@@ -360,40 +371,32 @@ export class SASSMode extends AbstractMode implements Modes.HoverProvider, Modes
}
static
$findReferences
=
OneWorkerAttr
(
SASSMode
,
SASSMode
.
prototype
.
findReferences
);
public
findReferences
(
resource
:
URI
,
position
:
EditorCommon
.
IPosition
):
winjs
.
TPromise
<
Modes
.
IReference
[]
>
{
public
findReferences
(
resource
:
URI
,
position
:
editorCommon
.
IPosition
):
winjs
.
TPromise
<
modes
.
Location
[]
>
{
return
this
.
_worker
((
w
)
=>
w
.
findReferences
(
resource
,
position
));
}
public
provideCompletionItems
(
model
:
EditorCommon
.
IReadOnlyModel
,
position
:
EditorCommon
.
IEditorPosition
,
token
:
CancellationToken
):
Thenable
<
Modes
.
ISuggestResult
[]
>
{
return
wireCancellationToken
(
token
,
this
.
_provideCompletionItems
(
model
.
getAssociatedResource
(),
position
));
}
static
$_provideCompletionItems
=
OneWorkerAttr
(
SASSMode
,
SASSMode
.
prototype
.
_provideCompletionItems
);
private
_provideCompletionItems
(
resource
:
URI
,
position
:
EditorCommon
.
IPosition
):
winjs
.
TPromise
<
M
odes
.
ISuggestResult
[]
>
{
private
_provideCompletionItems
(
resource
:
URI
,
position
:
editorCommon
.
IPosition
):
winjs
.
TPromise
<
m
odes
.
ISuggestResult
[]
>
{
return
this
.
_worker
((
w
)
=>
w
.
provideCompletionItems
(
resource
,
position
));
}
public
provideHover
(
model
:
EditorCommon
.
IReadOnlyModel
,
position
:
EditorCommon
.
IEditorPosition
,
token
:
CancellationToken
):
Thenable
<
Modes
.
Hover
>
{
return
wireCancellationToken
(
token
,
this
.
_provideHover
(
model
.
getAssociatedResource
(),
position
));
}
static
$_provideHover
=
OneWorkerAttr
(
SASSMode
,
SASSMode
.
prototype
.
_provideHover
);
private
_provideHover
(
resource
:
URI
,
position
:
EditorCommon
.
IPosition
):
winjs
.
TPromise
<
M
odes
.
Hover
>
{
private
_provideHover
(
resource
:
URI
,
position
:
editorCommon
.
IPosition
):
winjs
.
TPromise
<
m
odes
.
Hover
>
{
return
this
.
_worker
((
w
)
=>
w
.
provideHover
(
resource
,
position
));
}
static
$getOutline
=
OneWorkerAttr
(
SASSMode
,
SASSMode
.
prototype
.
getOutline
);
public
getOutline
(
resource
:
URI
):
winjs
.
TPromise
<
M
odes
.
IOutlineEntry
[]
>
{
public
getOutline
(
resource
:
URI
):
winjs
.
TPromise
<
m
odes
.
IOutlineEntry
[]
>
{
return
this
.
_worker
((
w
)
=>
w
.
getOutline
(
resource
));
}
static
$
findDeclaration
=
OneWorkerAttr
(
SASSMode
,
SASSMode
.
prototype
.
findDeclara
tion
);
p
ublic
findDeclaration
(
resource
:
URI
,
position
:
EditorCommon
.
IPosition
):
winjs
.
TPromise
<
Modes
.
IReference
>
{
return
this
.
_worker
((
w
)
=>
w
.
findDeclara
tion
(
resource
,
position
));
static
$
_provideDefinition
=
OneWorkerAttr
(
SASSMode
,
SASSMode
.
prototype
.
_provideDefini
tion
);
p
rivate
_provideDefinition
(
resource
:
URI
,
position
:
editorCommon
.
IPosition
):
winjs
.
TPromise
<
modes
.
Definition
>
{
return
this
.
_worker
((
w
)
=>
w
.
provideDefini
tion
(
resource
,
position
));
}
static
$findColorDeclarations
=
OneWorkerAttr
(
SASSMode
,
SASSMode
.
prototype
.
findColorDeclarations
);
public
findColorDeclarations
(
resource
:
URI
):
winjs
.
TPromise
<
{
range
:
E
ditorCommon
.
IRange
;
value
:
string
;
}[]
>
{
public
findColorDeclarations
(
resource
:
URI
):
winjs
.
TPromise
<
{
range
:
e
ditorCommon
.
IRange
;
value
:
string
;
}[]
>
{
return
this
.
_worker
((
w
)
=>
w
.
findColorDeclarations
(
resource
));
}
}
\ No newline at end of file
src/vs/languages/typescript/common/languageFeatures.ts
浏览文件 @
fe9b6dba
...
...
@@ -26,7 +26,7 @@ export function register(modelService: IModelService, markerService: IMarkerServ
disposables
.
push
(
modes
.
SignatureHelpProviderRegistry
.
register
(
selector
,
new
SignatureHelpAdapter
(
modelService
,
worker
)));
disposables
.
push
(
modes
.
HoverProviderRegistry
.
register
(
selector
,
new
QuickInfoAdapter
(
modelService
,
worker
)));
disposables
.
push
(
modes
.
DocumentHighlightProviderRegistry
.
register
(
selector
,
new
OccurrencesAdapter
(
modelService
,
worker
)));
disposables
.
push
(
modes
.
De
clarationRegistry
.
register
(
selector
,
new
Declara
tionAdapter
(
modelService
,
worker
)));
disposables
.
push
(
modes
.
De
finitionProviderRegistry
.
register
(
selector
,
new
Defini
tionAdapter
(
modelService
,
worker
)));
disposables
.
push
(
modes
.
ReferenceSearchRegistry
.
register
(
selector
,
new
ReferenceAdapter
(
modelService
,
worker
)));
disposables
.
push
(
modes
.
OutlineRegistry
.
register
(
selector
,
new
OutlineAdapter
(
modelService
,
worker
)));
disposables
.
push
(
modes
.
FormatRegistry
.
register
(
selector
,
new
FormatAdapter
(
modelService
,
worker
)));
...
...
@@ -338,27 +338,29 @@ class OccurrencesAdapter extends Adapter implements modes.DocumentHighlightProvi
// --- definition ------
class
De
clarationAdapter
extends
Adapter
implements
modes
.
IDeclarationSupport
{
class
De
finitionAdapter
extends
Adapter
{
findDeclaration
(
resource
:
URI
,
position
:
editorCommon
.
IPosition
):
TPromise
<
modes
.
IReference
[]
>
{
return
this
.
_worker
(
resource
).
then
(
worker
=>
{
public
provideDefinition
(
model
:
editorCommon
.
IReadOnlyModel
,
position
:
editorCommon
.
IEditorPosition
,
token
:
CancellationToken
):
Thenable
<
modes
.
Definition
>
{
const
resource
=
model
.
getAssociatedResource
();
return
wireCancellationToken
(
token
,
this
.
_worker
(
resource
).
then
(
worker
=>
{
return
worker
.
getDefinitionAtPosition
(
resource
.
toString
(),
this
.
_positionToOffset
(
resource
,
position
));
}).
then
(
entries
=>
{
if
(
!
entries
)
{
return
;
}
const
result
:
modes
.
IReference
[]
=
[];
const
result
:
modes
.
Location
[]
=
[];
for
(
let
entry
of
entries
)
{
const
uri
=
URI
.
parse
(
entry
.
fileName
);
if
(
this
.
_modelService
.
getModel
(
uri
))
{
result
.
push
({
resource
:
uri
,
uri
:
uri
,
range
:
this
.
_textSpanToRange
(
uri
,
entry
.
textSpan
)
});
}
}
return
result
;
});
})
)
;
}
}
...
...
@@ -366,19 +368,19 @@ class DeclarationAdapter extends Adapter implements modes.IDeclarationSupport {
class
ReferenceAdapter
extends
Adapter
implements
modes
.
IReferenceSupport
{
findReferences
(
resource
:
URI
,
position
:
editorCommon
.
IPosition
,
includeDeclaration
:
boolean
):
TPromise
<
modes
.
IReference
[]
>
{
findReferences
(
resource
:
URI
,
position
:
editorCommon
.
IPosition
,
includeDeclaration
:
boolean
):
TPromise
<
modes
.
Location
[]
>
{
return
this
.
_worker
(
resource
).
then
(
worker
=>
{
return
worker
.
getReferencesAtPosition
(
resource
.
toString
(),
this
.
_positionToOffset
(
resource
,
position
));
}).
then
(
entries
=>
{
if
(
!
entries
)
{
return
;
}
const
result
:
modes
.
IReference
[]
=
[];
const
result
:
modes
.
Location
[]
=
[];
for
(
let
entry
of
entries
)
{
const
uri
=
URI
.
parse
(
entry
.
fileName
);
if
(
this
.
_modelService
.
getModel
(
uri
))
{
result
.
push
({
resource
:
uri
,
uri
:
uri
,
range
:
this
.
_textSpanToRange
(
uri
,
entry
.
textSpan
)
});
}
...
...
src/vs/workbench/api/node/extHostApiCommands.ts
浏览文件 @
fe9b6dba
...
...
@@ -236,7 +236,7 @@ class ExtHostApiCommands {
resource
,
position
:
position
&&
typeConverters
.
fromPosition
(
position
)
};
return
this
.
_commands
.
executeCommand
<
modes
.
IReference
[]
>
(
'
_executeDefinitionProvider
'
,
args
).
then
(
value
=>
{
return
this
.
_commands
.
executeCommand
<
modes
.
Location
[]
>
(
'
_executeDefinitionProvider
'
,
args
).
then
(
value
=>
{
if
(
Array
.
isArray
(
value
))
{
return
value
.
map
(
typeConverters
.
location
.
to
);
}
...
...
@@ -272,7 +272,7 @@ class ExtHostApiCommands {
resource
,
position
:
position
&&
typeConverters
.
fromPosition
(
position
)
};
return
this
.
_commands
.
executeCommand
<
modes
.
IReference
[]
>
(
'
_executeReferenceProvider
'
,
args
).
then
(
value
=>
{
return
this
.
_commands
.
executeCommand
<
modes
.
Location
[]
>
(
'
_executeReferenceProvider
'
,
args
).
then
(
value
=>
{
if
(
Array
.
isArray
(
value
))
{
return
value
.
map
(
typeConverters
.
location
.
to
);
}
...
...
src/vs/workbench/api/node/extHostLanguageFeatures.ts
浏览文件 @
fe9b6dba
...
...
@@ -152,7 +152,7 @@ class CodeLensAdapter implements modes.ICodeLensSupport {
}
}
class
De
clarationAdapter
implements
modes
.
IDeclarationSupport
{
class
De
finitionAdapter
{
private
_documents
:
ExtHostModelService
;
private
_provider
:
vscode
.
DefinitionProvider
;
...
...
@@ -162,24 +162,24 @@ class DeclarationAdapter implements modes.IDeclarationSupport {
this
.
_provider
=
provider
;
}
findDeclaration
(
resource
:
URI
,
position
:
IPosition
):
TPromise
<
modes
.
IReference
[]
>
{
provideDefinition
(
resource
:
URI
,
position
:
IPosition
):
TPromise
<
modes
.
Definition
>
{
let
doc
=
this
.
_documents
.
getDocumentData
(
resource
).
document
;
let
pos
=
TypeConverters
.
toPosition
(
position
);
return
asWinJsPromise
(
token
=>
this
.
_provider
.
provideDefinition
(
doc
,
pos
,
token
)).
then
(
value
=>
{
if
(
Array
.
isArray
(
value
))
{
return
value
.
map
(
De
clara
tionAdapter
.
_convertLocation
);
return
value
.
map
(
De
fini
tionAdapter
.
_convertLocation
);
}
else
if
(
value
)
{
return
De
clara
tionAdapter
.
_convertLocation
(
value
);
return
De
fini
tionAdapter
.
_convertLocation
(
value
);
}
});
}
private
static
_convertLocation
(
location
:
vscode
.
Location
):
modes
.
IReference
{
private
static
_convertLocation
(
location
:
vscode
.
Location
):
modes
.
Location
{
if
(
!
location
)
{
return
;
}
return
<
modes
.
IReference
>
{
resource
:
location
.
uri
,
return
<
modes
.
Location
>
{
uri
:
location
.
uri
,
range
:
TypeConverters
.
fromRange
(
location
.
range
)
};
}
...
...
@@ -256,7 +256,7 @@ class ReferenceAdapter implements modes.IReferenceSupport {
this
.
_provider
=
provider
;
}
findReferences
(
resource
:
URI
,
position
:
IPosition
,
includeDeclaration
:
boolean
):
TPromise
<
modes
.
IReference
[]
>
{
findReferences
(
resource
:
URI
,
position
:
IPosition
,
includeDeclaration
:
boolean
):
TPromise
<
modes
.
Location
[]
>
{
let
doc
=
this
.
_documents
.
getDocumentData
(
resource
).
document
;
let
pos
=
TypeConverters
.
toPosition
(
position
);
...
...
@@ -267,9 +267,9 @@ class ReferenceAdapter implements modes.IReferenceSupport {
});
}
private
static
_convertLocation
(
location
:
vscode
.
Location
):
modes
.
IReference
{
return
<
modes
.
IReference
>
{
resource
:
location
.
uri
,
private
static
_convertLocation
(
location
:
vscode
.
Location
):
modes
.
Location
{
return
<
modes
.
Location
>
{
uri
:
location
.
uri
,
range
:
TypeConverters
.
fromRange
(
location
.
range
)
};
}
...
...
@@ -594,7 +594,7 @@ class SignatureHelpAdapter {
}
}
type
Adapter
=
OutlineAdapter
|
CodeLensAdapter
|
De
clara
tionAdapter
|
HoverAdapter
type
Adapter
=
OutlineAdapter
|
CodeLensAdapter
|
De
fini
tionAdapter
|
HoverAdapter
|
DocumentHighlightAdapter
|
ReferenceAdapter
|
QuickFixAdapter
|
DocumentFormattingAdapter
|
RangeFormattingAdapter
|
OnTypeFormattingAdapter
|
NavigateTypeAdapter
|
RenameAdapter
|
SuggestAdapter
|
SignatureHelpAdapter
;
...
...
@@ -670,13 +670,13 @@ export class ExtHostLanguageFeatures {
registerDefinitionProvider
(
selector
:
vscode
.
DocumentSelector
,
provider
:
vscode
.
DefinitionProvider
):
vscode
.
Disposable
{
const
handle
=
this
.
_nextHandle
();
this
.
_adapter
[
handle
]
=
new
De
clara
tionAdapter
(
this
.
_documents
,
provider
);
this
.
_adapter
[
handle
]
=
new
De
fini
tionAdapter
(
this
.
_documents
,
provider
);
this
.
_proxy
.
$registerDeclaractionSupport
(
handle
,
selector
);
return
this
.
_createDisposable
(
handle
);
}
$
findDeclaration
(
handle
:
number
,
resource
:
URI
,
position
:
IPosition
):
TPromise
<
modes
.
IReference
[]
>
{
return
this
.
_withAdapter
(
handle
,
De
clarationAdapter
,
adapter
=>
adapter
.
findDeclara
tion
(
resource
,
position
));
$
provideDefinition
(
handle
:
number
,
resource
:
URI
,
position
:
IPosition
):
TPromise
<
modes
.
Definition
>
{
return
this
.
_withAdapter
(
handle
,
De
finitionAdapter
,
adapter
=>
adapter
.
provideDefini
tion
(
resource
,
position
));
}
// --- extra info
...
...
@@ -714,7 +714,7 @@ export class ExtHostLanguageFeatures {
return
this
.
_createDisposable
(
handle
);
}
$findReferences
(
handle
:
number
,
resource
:
URI
,
position
:
IPosition
,
includeDeclaration
:
boolean
):
TPromise
<
modes
.
IReference
[]
>
{
$findReferences
(
handle
:
number
,
resource
:
URI
,
position
:
IPosition
,
includeDeclaration
:
boolean
):
TPromise
<
modes
.
Location
[]
>
{
return
this
.
_withAdapter
(
handle
,
ReferenceAdapter
,
adapter
=>
adapter
.
findReferences
(
resource
,
position
,
includeDeclaration
));
}
...
...
@@ -874,9 +874,9 @@ export class MainThreadLanguageFeatures {
// --- declaration
$registerDeclaractionSupport
(
handle
:
number
,
selector
:
vscode
.
DocumentSelector
):
TPromise
<
any
>
{
this
.
_registrations
[
handle
]
=
modes
.
De
clarationRegistry
.
register
(
selector
,
<
modes
.
IDeclarationSupport
>
{
findDeclaration
:
(
resource
:
URI
,
position
:
IPosition
):
TPromise
<
modes
.
IReference
[]
>
=>
{
return
this
.
_proxy
.
$findDeclaration
(
handle
,
resource
,
position
);
this
.
_registrations
[
handle
]
=
modes
.
De
finitionProviderRegistry
.
register
(
selector
,
<
modes
.
DefinitionProvider
>
{
provideDefinition
:
(
model
,
position
,
token
):
Thenable
<
modes
.
Definition
>
=>
{
return
wireCancellationToken
(
token
,
this
.
_proxy
.
$provideDefinition
(
handle
,
model
.
getAssociatedResource
(),
position
)
);
}
});
return
undefined
;
...
...
@@ -908,7 +908,7 @@ export class MainThreadLanguageFeatures {
$registerReferenceSupport
(
handle
:
number
,
selector
:
vscode
.
DocumentSelector
):
TPromise
<
any
>
{
this
.
_registrations
[
handle
]
=
modes
.
ReferenceSearchRegistry
.
register
(
selector
,
<
modes
.
IReferenceSupport
>
{
findReferences
:
(
resource
:
URI
,
position
:
IPosition
,
includeDeclaration
:
boolean
):
TPromise
<
modes
.
IReference
[]
>
=>
{
findReferences
:
(
resource
:
URI
,
position
:
IPosition
,
includeDeclaration
:
boolean
):
TPromise
<
modes
.
Location
[]
>
=>
{
return
this
.
_proxy
.
$findReferences
(
handle
,
resource
,
position
,
includeDeclaration
);
}
});
...
...
src/vs/workbench/api/node/extHostTypeConverters.ts
浏览文件 @
fe9b6dba
...
...
@@ -327,14 +327,14 @@ export function toSymbolInformation(bearing: ITypeBearing): types.SymbolInformat
export
const
location
=
{
from
(
value
:
types
.
Location
):
modes
.
IReference
{
from
(
value
:
types
.
Location
):
modes
.
Location
{
return
{
range
:
fromRange
(
value
.
range
),
resource
:
value
.
uri
uri
:
value
.
uri
};
},
to
(
value
:
modes
.
IReference
):
types
.
Location
{
return
new
types
.
Location
(
value
.
resource
,
toRange
(
value
.
range
));
to
(
value
:
modes
.
Location
):
types
.
Location
{
return
new
types
.
Location
(
value
.
uri
,
toRange
(
value
.
range
));
}
};
...
...
src/vs/workbench/test/node/api/extHostLanguageFeatures.test.ts
浏览文件 @
fe9b6dba
...
...
@@ -243,11 +243,11 @@ suite('ExtHostLanguageFeatures', function() {
return
threadService
.
sync
().
then
(()
=>
{
return
getDeclarationsAtPosition
(
model
,
{
lineNumber
:
1
,
column
:
1
}
).
then
(
value
=>
{
return
getDeclarationsAtPosition
(
model
,
new
EditorPosition
(
1
,
1
)
).
then
(
value
=>
{
assert
.
equal
(
value
.
length
,
1
);
let
[
entry
]
=
value
;
assert
.
deepEqual
(
entry
.
range
,
{
startLineNumber
:
2
,
startColumn
:
3
,
endLineNumber
:
4
,
endColumn
:
5
});
assert
.
equal
(
entry
.
resource
.
toString
(),
model
.
getAssociatedResource
().
toString
());
assert
.
equal
(
entry
.
uri
.
toString
(),
model
.
getAssociatedResource
().
toString
());
});
});
});
...
...
@@ -267,7 +267,7 @@ suite('ExtHostLanguageFeatures', function() {
return
threadService
.
sync
().
then
(()
=>
{
return
getDeclarationsAtPosition
(
model
,
{
lineNumber
:
1
,
column
:
1
}
).
then
(
value
=>
{
return
getDeclarationsAtPosition
(
model
,
new
EditorPosition
(
1
,
1
)
).
then
(
value
=>
{
assert
.
equal
(
value
.
length
,
2
);
});
});
...
...
@@ -289,12 +289,12 @@ suite('ExtHostLanguageFeatures', function() {
return
threadService
.
sync
().
then
(()
=>
{
return
getDeclarationsAtPosition
(
model
,
{
lineNumber
:
1
,
column
:
1
}
).
then
(
value
=>
{
return
getDeclarationsAtPosition
(
model
,
new
EditorPosition
(
1
,
1
)
).
then
(
value
=>
{
assert
.
equal
(
value
.
length
,
2
);
// let [first, second] = value;
assert
.
equal
(
value
[
0
].
resource
.
authority
,
'
second
'
);
assert
.
equal
(
value
[
1
].
resource
.
authority
,
'
first
'
);
assert
.
equal
(
value
[
0
].
uri
.
authority
,
'
second
'
);
assert
.
equal
(
value
[
1
].
uri
.
authority
,
'
first
'
);
});
});
});
...
...
@@ -314,7 +314,7 @@ suite('ExtHostLanguageFeatures', function() {
return
threadService
.
sync
().
then
(()
=>
{
return
getDeclarationsAtPosition
(
model
,
{
lineNumber
:
1
,
column
:
1
}
).
then
(
value
=>
{
return
getDeclarationsAtPosition
(
model
,
new
EditorPosition
(
1
,
1
)
).
then
(
value
=>
{
assert
.
equal
(
value
.
length
,
1
);
});
});
...
...
@@ -519,8 +519,8 @@ suite('ExtHostLanguageFeatures', function() {
assert
.
equal
(
value
.
length
,
2
);
let
[
first
,
second
]
=
value
;
assert
.
equal
(
first
.
resource
.
path
,
'
/second
'
);
assert
.
equal
(
second
.
resource
.
path
,
'
/first
'
);
assert
.
equal
(
first
.
uri
.
path
,
'
/second
'
);
assert
.
equal
(
second
.
uri
.
path
,
'
/first
'
);
});
});
});
...
...
@@ -540,7 +540,7 @@ suite('ExtHostLanguageFeatures', function() {
let
[
item
]
=
value
;
assert
.
deepEqual
(
item
.
range
,
{
startLineNumber
:
1
,
startColumn
:
1
,
endLineNumber
:
1
,
endColumn
:
1
});
assert
.
equal
(
item
.
resource
.
toString
(),
model
.
getAssociatedResource
().
toString
());
assert
.
equal
(
item
.
uri
.
toString
(),
model
.
getAssociatedResource
().
toString
());
});
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录