Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
2d1e2559
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2d1e2559
编写于
12月 14, 2017
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ExtHostLanguageFeaturesShape, #40169
上级
35730c44
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
129 addition
and
52 deletion
+129
-52
src/vs/workbench/api/electron-browser/mainThreadLanguageFeatures.ts
...kbench/api/electron-browser/mainThreadLanguageFeatures.ts
+62
-12
src/vs/workbench/api/node/extHost.protocol.ts
src/vs/workbench/api/node/extHost.protocol.ts
+52
-25
src/vs/workbench/api/node/extHostLanguageFeatures.ts
src/vs/workbench/api/node/extHostLanguageFeatures.ts
+15
-15
未找到文件。
src/vs/workbench/api/electron-browser/mainThreadLanguageFeatures.ts
浏览文件 @
2d1e2559
...
...
@@ -15,13 +15,14 @@ import { wireCancellationToken } from 'vs/base/common/async';
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
import
{
Position
as
EditorPosition
}
from
'
vs/editor/common/core/position
'
;
import
{
Range
as
EditorRange
}
from
'
vs/editor/common/core/range
'
;
import
{
ExtHostContext
,
MainThreadLanguageFeaturesShape
,
ExtHostLanguageFeaturesShape
,
MainContext
,
IExtHostContext
,
ISerializedLanguageConfiguration
,
ISerializedRegExp
,
ISerializedIndentationRule
,
ISerializedOnEnterRule
}
from
'
../node/extHost.protocol
'
;
import
{
ExtHostContext
,
MainThreadLanguageFeaturesShape
,
ExtHostLanguageFeaturesShape
,
MainContext
,
IExtHostContext
,
ISerializedLanguageConfiguration
,
ISerializedRegExp
,
ISerializedIndentationRule
,
ISerializedOnEnterRule
,
LocationDto
,
SymbolInformationDto
,
WorkspaceEditDto
,
ResourceEditDto
,
CodeActionDto
}
from
'
../node/extHost.protocol
'
;
import
{
LanguageConfigurationRegistry
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
LanguageConfiguration
,
IndentationRule
,
OnEnterRule
}
from
'
vs/editor/common/modes/languageConfiguration
'
;
import
{
IHeapService
}
from
'
./mainThreadHeapService
'
;
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
extHostNamedCustomer
}
from
'
vs/workbench/api/electron-browser/extHostCustomers
'
;
import
{
toLanguageSelector
}
from
'
vs/workbench/api/node/extHostTypeConverters
'
;
import
URI
from
'
vs/base/common/uri
'
;
@
extHostNamedCustomer
(
MainContext
.
MainThreadLanguageFeatures
)
export
class
MainThreadLanguageFeatures
implements
MainThreadLanguageFeaturesShape
{
...
...
@@ -56,12 +57,63 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
return
undefined
;
}
//#region --- revive functions
private
static
_reviveLocationDto
(
data
:
LocationDto
):
modes
.
Location
;
private
static
_reviveLocationDto
(
data
:
LocationDto
[]):
modes
.
Location
[];
private
static
_reviveLocationDto
(
data
:
LocationDto
|
LocationDto
[]):
modes
.
Location
|
modes
.
Location
[]
{
if
(
!
data
)
{
return
<
modes
.
Location
>
data
;
}
else
if
(
Array
.
isArray
(
data
))
{
data
.
forEach
(
l
=>
MainThreadLanguageFeatures
.
_reviveLocationDto
(
l
));
return
<
modes
.
Location
[]
>
data
;
}
else
{
data
.
uri
=
URI
.
revive
(
data
.
uri
);
return
<
modes
.
Location
>
data
;
}
}
private
static
_reviveSymbolInformationDto
(
data
:
SymbolInformationDto
):
modes
.
SymbolInformation
;
private
static
_reviveSymbolInformationDto
(
data
:
SymbolInformationDto
[]):
modes
.
SymbolInformation
[];
private
static
_reviveSymbolInformationDto
(
data
:
SymbolInformationDto
|
SymbolInformationDto
[]):
modes
.
SymbolInformation
|
modes
.
SymbolInformation
[]
{
if
(
!
data
)
{
return
<
modes
.
SymbolInformation
>
data
;
}
else
if
(
Array
.
isArray
(
data
))
{
data
.
forEach
(
MainThreadLanguageFeatures
.
_reviveSymbolInformationDto
);
return
<
modes
.
SymbolInformation
[]
>
data
;
}
else
{
data
.
location
=
MainThreadLanguageFeatures
.
_reviveLocationDto
(
data
.
location
);
return
<
modes
.
SymbolInformation
>
data
;
}
}
private
static
_reviveResourceEditDto
(
data
:
ResourceEditDto
):
modes
.
IResourceEdit
{
data
.
resource
=
URI
.
revive
(
data
.
resource
);
return
<
modes
.
IResourceEdit
>
data
;
}
private
static
_reviveWorkspaceEditDto
(
data
:
WorkspaceEditDto
):
modes
.
WorkspaceEdit
{
if
(
data
&&
data
.
edits
)
{
data
.
edits
.
forEach
(
MainThreadLanguageFeatures
.
_reviveResourceEditDto
);
}
return
<
modes
.
WorkspaceEdit
>
data
;
}
private
static
_reviveCodeActionDto
(
data
:
CodeActionDto
[]):
modes
.
CodeAction
[]
{
if
(
data
)
{
data
.
forEach
(
code
=>
MainThreadLanguageFeatures
.
_reviveWorkspaceEditDto
(
code
.
edits
));
}
return
<
modes
.
CodeAction
[]
>
data
;
}
//#endregion
// --- outline
$registerOutlineSupport
(
handle
:
number
,
selector
:
vscode
.
DocumentSelector
):
TPromise
<
any
>
{
this
.
_registrations
[
handle
]
=
modes
.
DocumentSymbolProviderRegistry
.
register
(
toLanguageSelector
(
selector
),
<
modes
.
DocumentSymbolProvider
>
{
provideDocumentSymbols
:
(
model
:
IReadOnlyModel
,
token
:
CancellationToken
):
Thenable
<
modes
.
SymbolInformation
[]
>
=>
{
return
wireCancellationToken
(
token
,
this
.
_proxy
.
$provideDocumentSymbols
(
handle
,
model
.
uri
));
return
wireCancellationToken
(
token
,
this
.
_proxy
.
$provideDocumentSymbols
(
handle
,
model
.
uri
))
.
then
(
MainThreadLanguageFeatures
.
_reviveSymbolInformationDto
)
;
}
});
return
undefined
;
...
...
@@ -103,7 +155,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
$registerDeclaractionSupport
(
handle
:
number
,
selector
:
vscode
.
DocumentSelector
):
TPromise
<
any
>
{
this
.
_registrations
[
handle
]
=
modes
.
DefinitionProviderRegistry
.
register
(
toLanguageSelector
(
selector
),
<
modes
.
DefinitionProvider
>
{
provideDefinition
:
(
model
,
position
,
token
):
Thenable
<
modes
.
Definition
>
=>
{
return
wireCancellationToken
(
token
,
this
.
_proxy
.
$provideDefinition
(
handle
,
model
.
uri
,
position
));
return
wireCancellationToken
(
token
,
this
.
_proxy
.
$provideDefinition
(
handle
,
model
.
uri
,
position
))
.
then
(
MainThreadLanguageFeatures
.
_reviveLocationDto
)
;
}
});
return
undefined
;
...
...
@@ -112,7 +164,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
$registerImplementationSupport
(
handle
:
number
,
selector
:
vscode
.
DocumentSelector
):
TPromise
<
any
>
{
this
.
_registrations
[
handle
]
=
modes
.
ImplementationProviderRegistry
.
register
(
toLanguageSelector
(
selector
),
<
modes
.
ImplementationProvider
>
{
provideImplementation
:
(
model
,
position
,
token
):
Thenable
<
modes
.
Definition
>
=>
{
return
wireCancellationToken
(
token
,
this
.
_proxy
.
$provideImplementation
(
handle
,
model
.
uri
,
position
));
return
wireCancellationToken
(
token
,
this
.
_proxy
.
$provideImplementation
(
handle
,
model
.
uri
,
position
))
.
then
(
MainThreadLanguageFeatures
.
_reviveLocationDto
)
;
}
});
return
undefined
;
...
...
@@ -121,7 +173,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
$registerTypeDefinitionSupport
(
handle
:
number
,
selector
:
vscode
.
DocumentSelector
):
TPromise
<
any
>
{
this
.
_registrations
[
handle
]
=
modes
.
TypeDefinitionProviderRegistry
.
register
(
toLanguageSelector
(
selector
),
<
modes
.
TypeDefinitionProvider
>
{
provideTypeDefinition
:
(
model
,
position
,
token
):
Thenable
<
modes
.
Definition
>
=>
{
return
wireCancellationToken
(
token
,
this
.
_proxy
.
$provideTypeDefinition
(
handle
,
model
.
uri
,
position
));
return
wireCancellationToken
(
token
,
this
.
_proxy
.
$provideTypeDefinition
(
handle
,
model
.
uri
,
position
))
.
then
(
MainThreadLanguageFeatures
.
_reviveLocationDto
)
;
}
});
return
undefined
;
...
...
@@ -154,7 +206,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
$registerReferenceSupport
(
handle
:
number
,
selector
:
vscode
.
DocumentSelector
):
TPromise
<
any
>
{
this
.
_registrations
[
handle
]
=
modes
.
ReferenceProviderRegistry
.
register
(
toLanguageSelector
(
selector
),
<
modes
.
ReferenceProvider
>
{
provideReferences
:
(
model
:
IReadOnlyModel
,
position
:
EditorPosition
,
context
:
modes
.
ReferenceContext
,
token
:
CancellationToken
):
Thenable
<
modes
.
Location
[]
>
=>
{
return
wireCancellationToken
(
token
,
this
.
_proxy
.
$provideReferences
(
handle
,
model
.
uri
,
position
,
context
));
return
wireCancellationToken
(
token
,
this
.
_proxy
.
$provideReferences
(
handle
,
model
.
uri
,
position
,
context
))
.
then
(
MainThreadLanguageFeatures
.
_reviveLocationDto
)
;
}
});
return
undefined
;
...
...
@@ -165,7 +217,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
$registerQuickFixSupport
(
handle
:
number
,
selector
:
vscode
.
DocumentSelector
):
TPromise
<
any
>
{
this
.
_registrations
[
handle
]
=
modes
.
CodeActionProviderRegistry
.
register
(
toLanguageSelector
(
selector
),
<
modes
.
CodeActionProvider
>
{
provideCodeActions
:
(
model
:
IReadOnlyModel
,
range
:
EditorRange
,
token
:
CancellationToken
):
Thenable
<
modes
.
CodeAction
[]
>
=>
{
return
this
.
_heapService
.
trackRecursive
(
wireCancellationToken
(
token
,
this
.
_proxy
.
$provideCodeActions
(
handle
,
model
.
uri
,
range
)));
return
this
.
_heapService
.
trackRecursive
(
wireCancellationToken
(
token
,
this
.
_proxy
.
$provideCodeActions
(
handle
,
model
.
uri
,
range
)))
.
then
(
MainThreadLanguageFeatures
.
_reviveCodeActionDto
)
;
}
});
return
undefined
;
...
...
@@ -209,17 +261,16 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
let
lastResultId
:
number
;
this
.
_registrations
[
handle
]
=
WorkspaceSymbolProviderRegistry
.
register
(
<
IWorkspaceSymbolProvider
>
{
provideWorkspaceSymbols
:
(
search
:
string
):
TPromise
<
modes
.
SymbolInformation
[]
>
=>
{
return
this
.
_proxy
.
$provideWorkspaceSymbols
(
handle
,
search
).
then
(
result
=>
{
if
(
lastResultId
!==
undefined
)
{
this
.
_proxy
.
$releaseWorkspaceSymbols
(
handle
,
lastResultId
);
}
lastResultId
=
result
.
_id
;
return
result
.
symbols
;
return
MainThreadLanguageFeatures
.
_reviveSymbolInformationDto
(
result
.
symbols
)
;
});
},
resolveWorkspaceSymbol
:
(
item
:
modes
.
SymbolInformation
):
TPromise
<
modes
.
SymbolInformation
>
=>
{
return
this
.
_proxy
.
$resolveWorkspaceSymbol
(
handle
,
item
);
return
this
.
_proxy
.
$resolveWorkspaceSymbol
(
handle
,
item
)
.
then
(
i
=>
MainThreadLanguageFeatures
.
_reviveSymbolInformationDto
(
i
))
;
}
});
return
undefined
;
...
...
@@ -230,7 +281,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
$registerRenameSupport
(
handle
:
number
,
selector
:
vscode
.
DocumentSelector
):
TPromise
<
any
>
{
this
.
_registrations
[
handle
]
=
modes
.
RenameProviderRegistry
.
register
(
toLanguageSelector
(
selector
),
<
modes
.
RenameProvider
>
{
provideRenameEdits
:
(
model
:
IReadOnlyModel
,
position
:
EditorPosition
,
newName
:
string
,
token
:
CancellationToken
):
Thenable
<
modes
.
WorkspaceEdit
>
=>
{
return
wireCancellationToken
(
token
,
this
.
_proxy
.
$provideRenameEdits
(
handle
,
model
.
uri
,
position
,
newName
));
return
wireCancellationToken
(
token
,
this
.
_proxy
.
$provideRenameEdits
(
handle
,
model
.
uri
,
position
,
newName
))
.
then
(
MainThreadLanguageFeatures
.
_reviveWorkspaceEditDto
)
;
}
});
return
undefined
;
...
...
@@ -239,7 +290,6 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
// --- suggest
$registerSuggestSupport
(
handle
:
number
,
selector
:
vscode
.
DocumentSelector
,
triggerCharacters
:
string
[],
supportsResolveDetails
:
boolean
):
TPromise
<
any
>
{
this
.
_registrations
[
handle
]
=
modes
.
SuggestRegistry
.
register
(
toLanguageSelector
(
selector
),
<
modes
.
ISuggestSupport
>
{
triggerCharacters
,
provideCompletionItems
:
(
model
:
IReadOnlyModel
,
position
:
EditorPosition
,
context
:
modes
.
SuggestContext
,
token
:
CancellationToken
):
Thenable
<
modes
.
ISuggestResult
>
=>
{
...
...
src/vs/workbench/api/node/extHost.protocol.ts
浏览文件 @
2d1e2559
...
...
@@ -580,51 +580,78 @@ export interface IRawColorInfo {
range
:
IRange
;
}
export
interface
IExtHostSuggestion
extends
modes
.
ISuggestion
{
export
class
IdObject
{
_id
?:
number
;
private
static
_n
=
0
;
static
mixin
<
T
extends
object
>
(
object
:
T
):
T
&
IdObject
{
(
<
any
>
object
).
_id
=
IdObject
.
_n
++
;
return
<
any
>
object
;
}
}
export
interface
SuggestionDto
extends
modes
.
ISuggestion
{
_id
:
number
;
_parentId
:
number
;
}
export
interface
IExtHostSuggestResult
{
_id
:
number
;
suggestions
:
IExtHostSuggestion
[];
export
interface
SuggestResultDto
extends
IdObject
{
suggestions
:
SuggestionDto
[];
incomplete
?:
boolean
;
}
export
interface
IdObject
{
_id
:
number
;
export
interface
LocationDto
{
uri
:
UriComponents
;
range
:
IRange
;
}
export
namespace
IdObject
{
let
n
=
0
;
export
function
mixin
<
T
extends
object
>
(
object
:
T
):
T
&
IdObject
{
(
<
any
>
object
).
_id
=
n
++
;
return
<
any
>
object
;
}
export
interface
SymbolInformationDto
extends
IdObject
{
name
:
string
;
containerName
?:
string
;
kind
:
modes
.
SymbolKind
;
location
:
LocationDto
;
}
export
interface
WorkspaceSymbolsDto
extends
IdObject
{
symbols
:
SymbolInformationDto
[];
}
export
interface
ResourceEditDto
{
resource
:
UriComponents
;
range
:
IRange
;
newText
:
string
;
}
export
type
IWorkspaceSymbol
=
IdObject
&
modes
.
SymbolInformation
;
export
interface
IWorkspaceSymbols
extends
IdObject
{
symbols
:
IWorkspaceSymbol
[];
}
export
interface
WorkspaceEditDto
{
edits
:
ResourceEditDto
[];
rejectReason
?:
string
;
}
export
interface
CodeActionDto
{
title
:
string
;
edits
?:
WorkspaceEditDto
;
diagnostics
?:
IMarkerData
[];
command
?:
modes
.
Command
;
}
export
interface
ExtHostLanguageFeaturesShape
{
$provideDocumentSymbols
(
handle
:
number
,
resource
:
UriComponents
):
TPromise
<
modes
.
SymbolInformation
[]
>
;
$provideDocumentSymbols
(
handle
:
number
,
resource
:
UriComponents
):
TPromise
<
SymbolInformationDto
[]
>
;
$provideCodeLenses
(
handle
:
number
,
resource
:
UriComponents
):
TPromise
<
modes
.
ICodeLensSymbol
[]
>
;
$resolveCodeLens
(
handle
:
number
,
resource
:
UriComponents
,
symbol
:
modes
.
ICodeLensSymbol
):
TPromise
<
modes
.
ICodeLensSymbol
>
;
$provideDefinition
(
handle
:
number
,
resource
:
UriComponents
,
position
:
IPosition
):
TPromise
<
modes
.
Definition
>
;
$provideImplementation
(
handle
:
number
,
resource
:
UriComponents
,
position
:
IPosition
):
TPromise
<
modes
.
Definition
>
;
$provideTypeDefinition
(
handle
:
number
,
resource
:
UriComponents
,
position
:
IPosition
):
TPromise
<
modes
.
Definition
>
;
$provideDefinition
(
handle
:
number
,
resource
:
UriComponents
,
position
:
IPosition
):
TPromise
<
LocationDto
|
LocationDto
[]
>
;
$provideImplementation
(
handle
:
number
,
resource
:
UriComponents
,
position
:
IPosition
):
TPromise
<
LocationDto
|
LocationDto
[]
>
;
$provideTypeDefinition
(
handle
:
number
,
resource
:
UriComponents
,
position
:
IPosition
):
TPromise
<
LocationDto
|
LocationDto
[]
>
;
$provideHover
(
handle
:
number
,
resource
:
UriComponents
,
position
:
IPosition
):
TPromise
<
modes
.
Hover
>
;
$provideDocumentHighlights
(
handle
:
number
,
resource
:
UriComponents
,
position
:
IPosition
):
TPromise
<
modes
.
DocumentHighlight
[]
>
;
$provideReferences
(
handle
:
number
,
resource
:
UriComponents
,
position
:
IPosition
,
context
:
modes
.
ReferenceContext
):
TPromise
<
modes
.
Location
[]
>
;
$provideCodeActions
(
handle
:
number
,
resource
:
UriComponents
,
range
:
IRange
):
TPromise
<
modes
.
CodeAction
[]
>
;
$provideReferences
(
handle
:
number
,
resource
:
UriComponents
,
position
:
IPosition
,
context
:
modes
.
ReferenceContext
):
TPromise
<
LocationDto
[]
>
;
$provideCodeActions
(
handle
:
number
,
resource
:
UriComponents
,
range
:
IRange
):
TPromise
<
CodeActionDto
[]
>
;
$provideDocumentFormattingEdits
(
handle
:
number
,
resource
:
UriComponents
,
options
:
modes
.
FormattingOptions
):
TPromise
<
editorCommon
.
ISingleEditOperation
[]
>
;
$provideDocumentRangeFormattingEdits
(
handle
:
number
,
resource
:
UriComponents
,
range
:
IRange
,
options
:
modes
.
FormattingOptions
):
TPromise
<
editorCommon
.
ISingleEditOperation
[]
>
;
$provideOnTypeFormattingEdits
(
handle
:
number
,
resource
:
UriComponents
,
position
:
IPosition
,
ch
:
string
,
options
:
modes
.
FormattingOptions
):
TPromise
<
editorCommon
.
ISingleEditOperation
[]
>
;
$provideWorkspaceSymbols
(
handle
:
number
,
search
:
string
):
TPromise
<
IWorkspaceSymbols
>
;
$resolveWorkspaceSymbol
(
handle
:
number
,
symbol
:
modes
.
SymbolInformation
):
TPromise
<
IWorkspaceSymbol
>
;
$provideWorkspaceSymbols
(
handle
:
number
,
search
:
string
):
TPromise
<
WorkspaceSymbolsDto
>
;
$resolveWorkspaceSymbol
(
handle
:
number
,
symbol
:
SymbolInformationDto
):
TPromise
<
SymbolInformationDto
>
;
$releaseWorkspaceSymbols
(
handle
:
number
,
id
:
number
):
void
;
$provideRenameEdits
(
handle
:
number
,
resource
:
UriComponents
,
position
:
IPosition
,
newName
:
string
):
TPromise
<
modes
.
WorkspaceEdit
>
;
$provideCompletionItems
(
handle
:
number
,
resource
:
UriComponents
,
position
:
IPosition
,
context
:
modes
.
SuggestContext
):
TPromise
<
IExtHostSuggestResult
>
;
$provideRenameEdits
(
handle
:
number
,
resource
:
UriComponents
,
position
:
IPosition
,
newName
:
string
):
TPromise
<
WorkspaceEditDto
>
;
$provideCompletionItems
(
handle
:
number
,
resource
:
UriComponents
,
position
:
IPosition
,
context
:
modes
.
SuggestContext
):
TPromise
<
SuggestResultDto
>
;
$resolveCompletionItem
(
handle
:
number
,
resource
:
UriComponents
,
position
:
IPosition
,
suggestion
:
modes
.
ISuggestion
):
TPromise
<
modes
.
ISuggestion
>
;
$releaseCompletionItems
(
handle
:
number
,
id
:
number
):
void
;
$provideSignatureHelp
(
handle
:
number
,
resource
:
UriComponents
,
position
:
IPosition
):
TPromise
<
modes
.
SignatureHelp
>
;
...
...
@@ -748,7 +775,7 @@ export const ExtHostContext = {
ExtHostFileSystem
:
createExtId
<
ExtHostFileSystemShape
>
(
'
ExtHostFileSystem
'
),
ExtHostFileSystemEventService
:
createExtId
<
ExtHostFileSystemEventServiceShape
>
(
'
ExtHostFileSystemEventService
'
),
ExtHostHeapService
:
createExtId
<
ExtHostHeapServiceShape
>
(
'
ExtHostHeapMonitor
'
),
ExtHostLanguageFeatures
:
createExtId
<
ExtHostLanguageFeaturesShape
>
(
'
ExtHostLanguageFeatures
'
,
ProxyType
.
CustomMarshaller
),
ExtHostLanguageFeatures
:
createExtId
<
ExtHostLanguageFeaturesShape
>
(
'
ExtHostLanguageFeatures
'
),
ExtHostQuickOpen
:
createExtId
<
ExtHostQuickOpenShape
>
(
'
ExtHostQuickOpen
'
),
ExtHostExtensionService
:
createExtId
<
ExtHostExtensionServiceShape
>
(
'
ExtHostExtensionService
'
),
ExtHostTerminalService
:
createExtId
<
ExtHostTerminalServiceShape
>
(
'
ExtHostTerminalService
'
),
...
...
src/vs/workbench/api/node/extHostLanguageFeatures.ts
浏览文件 @
2d1e2559
...
...
@@ -17,7 +17,7 @@ import { ExtHostDocuments } from 'vs/workbench/api/node/extHostDocuments';
import
{
ExtHostCommands
,
CommandsConverter
}
from
'
vs/workbench/api/node/extHostCommands
'
;
import
{
ExtHostDiagnostics
,
DiagnosticCollection
}
from
'
vs/workbench/api/node/extHostDiagnostics
'
;
import
{
asWinJsPromise
}
from
'
vs/base/common/async
'
;
import
{
MainContext
,
MainThreadLanguageFeaturesShape
,
ExtHostLanguageFeaturesShape
,
ObjectIdentifier
,
IRawColorInfo
,
IMainContext
,
I
ExtHostSuggestResult
,
IExtHostSuggestion
,
IWorkspaceSymbols
,
IWorkspaceSymbol
,
IdObject
,
ISerializedRegExp
,
ISerializedIndentationRule
,
ISerializedOnEnterRule
,
ISerializedLanguageConfiguration
}
from
'
./extHost.protocol
'
;
import
{
MainContext
,
MainThreadLanguageFeaturesShape
,
ExtHostLanguageFeaturesShape
,
ObjectIdentifier
,
IRawColorInfo
,
IMainContext
,
I
dObject
,
ISerializedRegExp
,
ISerializedIndentationRule
,
ISerializedOnEnterRule
,
ISerializedLanguageConfiguration
,
SymbolInformationDto
,
SuggestResultDto
,
WorkspaceSymbolsDto
,
SuggestionDto
}
from
'
./extHost.protocol
'
;
import
{
regExpLeadsToEndlessLoop
}
from
'
vs/base/common/strings
'
;
import
{
IPosition
}
from
'
vs/editor/common/core/position
'
;
import
{
IRange
}
from
'
vs/editor/common/core/range
'
;
...
...
@@ -35,11 +35,11 @@ class OutlineAdapter {
this
.
_provider
=
provider
;
}
provideDocumentSymbols
(
resource
:
URI
):
TPromise
<
modes
.
SymbolInformation
[]
>
{
provideDocumentSymbols
(
resource
:
URI
):
TPromise
<
SymbolInformationDto
[]
>
{
let
doc
=
this
.
_documents
.
getDocumentData
(
resource
).
document
;
return
asWinJsPromise
(
token
=>
this
.
_provider
.
provideDocumentSymbols
(
doc
,
token
)).
then
(
value
=>
{
if
(
Array
.
isArray
(
value
))
{
return
value
.
map
(
TypeConverters
.
fromSymbolInformation
);
return
value
.
map
(
symbol
=>
IdObject
.
mixin
(
TypeConverters
.
fromSymbolInformation
(
symbol
))
);
}
return
undefined
;
});
...
...
@@ -413,8 +413,8 @@ class NavigateTypeAdapter {
this
.
_provider
=
provider
;
}
provideWorkspaceSymbols
(
search
:
string
):
TPromise
<
IWorkspaceSymbols
>
{
const
result
:
IWorkspaceSymbols
=
IdObject
.
mixin
({
symbols
:
[]
});
provideWorkspaceSymbols
(
search
:
string
):
TPromise
<
WorkspaceSymbolsDto
>
{
const
result
:
WorkspaceSymbolsDto
=
IdObject
.
mixin
({
symbols
:
[]
});
return
asWinJsPromise
(
token
=>
this
.
_provider
.
provideWorkspaceSymbols
(
search
,
token
)).
then
(
value
=>
{
if
(
!
isFalsyOrEmpty
(
value
))
{
for
(
const
item
of
value
)
{
...
...
@@ -439,7 +439,7 @@ class NavigateTypeAdapter {
});
}
resolveWorkspaceSymbol
(
symbol
:
IWorkspaceSymbol
):
TPromise
<
IWorkspaceSymbol
>
{
resolveWorkspaceSymbol
(
symbol
:
SymbolInformationDto
):
TPromise
<
SymbolInformationDto
>
{
if
(
typeof
this
.
_provider
.
resolveWorkspaceSymbol
!==
'
function
'
)
{
return
TPromise
.
as
(
symbol
);
...
...
@@ -524,7 +524,7 @@ class SuggestAdapter {
this
.
_provider
=
provider
;
}
provideCompletionItems
(
resource
:
URI
,
position
:
IPosition
,
context
:
modes
.
SuggestContext
):
TPromise
<
IExtHostSuggestResult
>
{
provideCompletionItems
(
resource
:
URI
,
position
:
IPosition
,
context
:
modes
.
SuggestContext
):
TPromise
<
SuggestResultDto
>
{
const
doc
=
this
.
_documents
.
getDocumentData
(
resource
).
document
;
const
pos
=
TypeConverters
.
toPosition
(
position
);
...
...
@@ -535,7 +535,7 @@ class SuggestAdapter {
const
_id
=
this
.
_idPool
++
;
const
result
:
IExtHostSuggestResult
=
{
const
result
:
SuggestResultDto
=
{
_id
,
suggestions
:
[],
};
...
...
@@ -577,7 +577,7 @@ class SuggestAdapter {
return
TPromise
.
as
(
suggestion
);
}
const
{
_parentId
,
_id
}
=
(
<
IExtHostSuggestion
>
suggestion
);
const
{
_parentId
,
_id
}
=
(
<
SuggestionDto
>
suggestion
);
const
item
=
this
.
_cache
.
has
(
_parentId
)
&&
this
.
_cache
.
get
(
_parentId
)[
_id
];
if
(
!
item
)
{
return
TPromise
.
as
(
suggestion
);
...
...
@@ -605,13 +605,13 @@ class SuggestAdapter {
this
.
_cache
.
delete
(
id
);
}
private
_convertCompletionItem
(
item
:
vscode
.
CompletionItem
,
position
:
vscode
.
Position
,
defaultRange
:
vscode
.
Range
,
_id
:
number
,
_parentId
:
number
):
IExtHostSuggestion
{
private
_convertCompletionItem
(
item
:
vscode
.
CompletionItem
,
position
:
vscode
.
Position
,
defaultRange
:
vscode
.
Range
,
_id
:
number
,
_parentId
:
number
):
SuggestionDto
{
if
(
typeof
item
.
label
!==
'
string
'
||
item
.
label
.
length
===
0
)
{
console
.
warn
(
'
INVALID text edit -> must have at least a label
'
);
return
undefined
;
}
const
result
:
IExtHostSuggestion
=
{
const
result
:
SuggestionDto
=
{
//
_id
,
_parentId
,
...
...
@@ -835,7 +835,7 @@ export class ExtHostLanguageFeatures implements ExtHostLanguageFeaturesShape {
return
this
.
_createDisposable
(
handle
);
}
$provideDocumentSymbols
(
handle
:
number
,
resource
:
UriComponents
):
TPromise
<
modes
.
SymbolInformation
[]
>
{
$provideDocumentSymbols
(
handle
:
number
,
resource
:
UriComponents
):
TPromise
<
SymbolInformationDto
[]
>
{
return
this
.
_withAdapter
(
handle
,
OutlineAdapter
,
adapter
=>
adapter
.
provideDocumentSymbols
(
URI
.
revive
(
resource
)));
}
...
...
@@ -996,11 +996,11 @@ export class ExtHostLanguageFeatures implements ExtHostLanguageFeaturesShape {
return
this
.
_createDisposable
(
handle
);
}
$provideWorkspaceSymbols
(
handle
:
number
,
search
:
string
):
TPromise
<
IWorkspaceSymbols
>
{
$provideWorkspaceSymbols
(
handle
:
number
,
search
:
string
):
TPromise
<
WorkspaceSymbolsDto
>
{
return
this
.
_withAdapter
(
handle
,
NavigateTypeAdapter
,
adapter
=>
adapter
.
provideWorkspaceSymbols
(
search
));
}
$resolveWorkspaceSymbol
(
handle
:
number
,
symbol
:
IWorkspaceSymbol
):
TPromise
<
IWorkspaceSymbol
>
{
$resolveWorkspaceSymbol
(
handle
:
number
,
symbol
:
SymbolInformationDto
):
TPromise
<
SymbolInformationDto
>
{
return
this
.
_withAdapter
(
handle
,
NavigateTypeAdapter
,
adapter
=>
adapter
.
resolveWorkspaceSymbol
(
symbol
));
}
...
...
@@ -1030,7 +1030,7 @@ export class ExtHostLanguageFeatures implements ExtHostLanguageFeaturesShape {
return
this
.
_createDisposable
(
handle
);
}
$provideCompletionItems
(
handle
:
number
,
resource
:
UriComponents
,
position
:
IPosition
,
context
:
modes
.
SuggestContext
):
TPromise
<
IExtHostSuggestResult
>
{
$provideCompletionItems
(
handle
:
number
,
resource
:
UriComponents
,
position
:
IPosition
,
context
:
modes
.
SuggestContext
):
TPromise
<
SuggestResultDto
>
{
return
this
.
_withAdapter
(
handle
,
SuggestAdapter
,
adapter
=>
adapter
.
provideCompletionItems
(
URI
.
revive
(
resource
),
position
,
context
));
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录