Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
f192e04e
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,发现更多精彩内容 >>
提交
f192e04e
编写于
11月 26, 2015
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove old stuff
上级
7d1de2c6
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
0 addition
and
299 deletion
+0
-299
src/vs/workbench/api/browser/pluginHost.api.impl.ts
src/vs/workbench/api/browser/pluginHost.api.impl.ts
+0
-2
src/vs/workbench/api/common/languageFeatures.ts
src/vs/workbench/api/common/languageFeatures.ts
+0
-295
src/vs/workbench/electron-browser/shell.ts
src/vs/workbench/electron-browser/shell.ts
+0
-2
未找到文件。
src/vs/workbench/api/browser/pluginHost.api.impl.ts
浏览文件 @
f192e04e
...
...
@@ -17,7 +17,6 @@ import {PluginHostQuickOpen} from 'vs/workbench/api/browser/pluginHostQuickOpen'
import
{
PluginHostStatusBar
}
from
'
vs/workbench/api/browser/pluginHostStatusBar
'
;
import
{
PluginHostCommands
}
from
'
vs/workbench/api/common/pluginHostCommands
'
;
import
{
ExtHostOutputService
}
from
'
vs/workbench/api/browser/extHostOutputService
'
;
import
{
LanguageFeatures
}
from
'
vs/workbench/api/common/languageFeatures
'
;
import
{
PluginHostMessageService
}
from
'
vs/workbench/api/common/pluginHostMessageService
'
;
import
{
PluginHostTelemetryService
}
from
'
vs/workbench/api/common/pluginHostTelemetry
'
;
import
{
PluginHostEditors
}
from
'
vs/workbench/api/common/pluginHostEditors
'
;
...
...
@@ -251,7 +250,6 @@ export class PluginHostAPIImplementation {
//
const
languages
=
new
ExtHostLanguages
(
this
.
_threadService
);
const
pluginHostDiagnostics
=
new
PluginHostDiagnostics
(
this
.
_threadService
);
const
features
=
LanguageFeatures
.
createExtensionHostInstances
(
this
.
_threadService
);
const
languageFeatures
=
threadService
.
getRemotable
(
ExtHostLanguageFeatures
);
this
.
languages
=
{
...
...
src/vs/workbench/api/common/languageFeatures.ts
已删除
100644 → 0
浏览文件 @
7d1de2c6
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
Severity
from
'
vs/base/common/severity
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
sequence
}
from
'
vs/base/common/async
'
;
import
{
Range
as
EditorRange
}
from
'
vs/editor/common/core/range
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybindingService
'
;
import
{
Remotable
,
IThreadService
}
from
'
vs/platform/thread/common/thread
'
;
import
*
as
vscode
from
'
vscode
'
;
import
*
as
TypeConverters
from
'
vs/workbench/api/common/pluginHostTypeConverters
'
;
import
{
Position
,
Range
,
SymbolKind
,
DocumentHighlightKind
,
Disposable
,
Diagnostic
,
DiagnosticSeverity
,
Location
,
SignatureHelp
,
CompletionItemKind
}
from
'
vs/workbench/api/common/pluginHostTypes
'
;
import
{
IPosition
,
IRange
,
ISingleEditOperation
}
from
'
vs/editor/common/editorCommon
'
;
import
*
as
modes
from
'
vs/editor/common/modes
'
;
import
{
CancellationTokenSource
}
from
'
vs/base/common/cancellation
'
;
import
{
PluginHostModelService
}
from
'
vs/workbench/api/common/pluginHostDocuments
'
;
import
{
IMarkerService
,
IMarker
}
from
'
vs/platform/markers/common/markers
'
;
import
{
PluginHostCommands
,
MainThreadCommands
}
from
'
vs/workbench/api/common/pluginHostCommands
'
;
import
LanguageFeatureRegistry
from
'
vs/editor/common/modes/languageFeatureRegistry
'
;
import
{
NavigateTypesSupportRegistry
,
INavigateTypesSupport
,
ITypeBearing
}
from
'
vs/workbench/parts/search/common/search
'
import
{
RenameRegistry
}
from
'
vs/editor/contrib/rename/common/rename
'
;
import
{
FormatRegistry
,
FormatOnTypeRegistry
}
from
'
vs/editor/contrib/format/common/format
'
;
import
{
ParameterHintsRegistry
}
from
'
vs/editor/contrib/parameterHints/common/parameterHints
'
;
import
{
SuggestRegistry
}
from
'
vs/editor/contrib/suggest/common/suggest
'
;
function
isThenable
<
T
>
(
obj
:
any
):
obj
is
Thenable
<
T
>
{
return
obj
&&
typeof
obj
[
'
then
'
]
===
'
function
'
;
}
function
asWinJsPromise
<
T
>
(
callback
:
(
token
:
vscode
.
CancellationToken
)
=>
T
|
Thenable
<
T
>
):
TPromise
<
T
>
{
let
source
=
new
CancellationTokenSource
();
return
new
TPromise
<
T
>
((
resolve
,
reject
)
=>
{
let
item
=
callback
(
source
.
token
);
if
(
isThenable
<
T
>
(
item
))
{
item
.
then
(
resolve
,
reject
);
}
else
{
resolve
(
item
);
}
},
()
=>
{
source
.
cancel
();
});
}
export
abstract
class
AbstractMainThreadFeature
<
T
>
{
private
_id
:
string
;
protected
_commands
:
PluginHostCommands
;
protected
_refCount
=
0
;
protected
_disposable
:
IDisposable
;
protected
_registry
:
LanguageFeatureRegistry
<
T
>
;
constructor
(
id
:
string
,
registry
:
LanguageFeatureRegistry
<
T
>
,
@
IThreadService
threadService
:
IThreadService
)
{
this
.
_id
=
id
;
this
.
_registry
=
registry
;
this
.
_commands
=
threadService
.
getRemotable
(
PluginHostCommands
);
}
_getId
():
TPromise
<
string
>
{
return
TPromise
.
as
(
this
.
_id
);
}
_register
(
selector
:
vscode
.
DocumentSelector
):
TPromise
<
any
>
{
if
(
this
.
_refCount
++
===
0
)
{
this
.
_disposable
=
this
.
_registry
.
register
(
selector
,
<
any
>
this
);
}
return
undefined
;
}
_unregister
():
TPromise
<
any
>
{
if
(
--
this
.
_refCount
===
0
)
{
this
.
_disposable
.
dispose
();
}
return
undefined
;
}
_executeCommand
<
T
>
(...
args
:
any
[]):
TPromise
<
T
>
{
let
result
=
this
.
_commands
.
executeCommand
<
any
>
(
this
.
_id
,
...
args
);
return
new
TPromise
<
T
>
((
c
,
e
)
=>
{
result
.
then
(
c
,
e
);
});
}
}
export
abstract
class
AbstractExtensionHostFeature
<
T
,
P
extends
AbstractMainThreadFeature
<
any
>>
{
protected
_commands
:
PluginHostCommands
;
protected
_proxy
:
P
;
protected
_registry
=
new
LanguageFeatureRegistry
<
T
>
();
protected
_models
:
PluginHostModelService
;
constructor
(
proxy
:
P
,
@
IThreadService
threadService
:
IThreadService
)
{
this
.
_proxy
=
proxy
;
this
.
_models
=
threadService
.
getRemotable
(
PluginHostModelService
);
this
.
_commands
=
threadService
.
getRemotable
(
PluginHostCommands
);
proxy
.
_getId
().
then
(
value
=>
this
.
_commands
.
registerCommand
(
value
,
this
.
_runAsCommand
,
this
));
}
register
(
selector
:
vscode
.
DocumentSelector
,
provider
:
T
):
vscode
.
Disposable
{
let
disposable
=
this
.
_registry
.
register
(
selector
,
provider
);
let
registered
=
this
.
_proxy
.
_register
(
selector
);
return
new
Disposable
(()
=>
{
disposable
.
dispose
();
// remove locally
registered
.
then
(()
=>
this
.
_proxy
.
_unregister
());
});
}
protected
abstract
_runAsCommand
(...
args
:
any
[]):
any
;
protected
_getAllFor
(
document
:
vscode
.
TextDocument
):
T
[]
{
return
this
.
_registry
.
all
({
language
:
document
.
languageId
,
uri
:
<
any
>
document
.
uri
});
}
protected
_getOrderedFor
(
document
:
vscode
.
TextDocument
):
T
[]
{
return
this
.
_registry
.
ordered
({
language
:
document
.
languageId
,
uri
:
<
any
>
document
.
uri
});
}
}
// --- format
export
class
ExtHostFormatDocument
extends
AbstractExtensionHostFeature
<
vscode
.
DocumentFormattingEditProvider
,
MainThreadFormatDocument
>
{
constructor
(
@
IThreadService
threadService
:
IThreadService
)
{
super
(
threadService
.
getRemotable
(
MainThreadFormatDocument
),
threadService
);
}
_runAsCommand
(
resource
:
URI
,
options
:
modes
.
IFormattingOptions
):
TPromise
<
ISingleEditOperation
[]
>
{
let
document
=
this
.
_models
.
getDocument
(
resource
);
let
provider
=
this
.
_getOrderedFor
(
document
)[
0
];
return
asWinJsPromise
(
token
=>
provider
.
provideDocumentFormattingEdits
(
document
,
<
any
>
options
,
token
)).
then
(
result
=>
{
if
(
Array
.
isArray
(
result
))
{
return
result
.
map
(
ExtHostFormatDocument
.
convertTextEdit
);
}
});
}
static
convertTextEdit
(
edit
:
vscode
.
TextEdit
):
ISingleEditOperation
{
return
<
ISingleEditOperation
>
{
text
:
edit
.
newText
,
range
:
TypeConverters
.
fromRange
(
edit
.
range
)
}
}
}
@
Remotable
.
MainContext
(
'
MainThreadFormatDocument
'
)
export
class
MainThreadFormatDocument
extends
AbstractMainThreadFeature
<
modes
.
IFormattingSupport
>
implements
modes
.
IFormattingSupport
{
constructor
(
@
IThreadService
threadService
:
IThreadService
)
{
super
(
'
vscode.executeFormatDocumentProvider
'
,
FormatRegistry
,
threadService
);
}
formatDocument
(
resource
:
URI
,
options
:
modes
.
IFormattingOptions
):
TPromise
<
ISingleEditOperation
[]
>
{
return
this
.
_executeCommand
(
resource
,
options
);
}
}
export
class
ExtHostFormatRange
extends
AbstractExtensionHostFeature
<
vscode
.
DocumentRangeFormattingEditProvider
,
MainThreadFormatRange
>
{
constructor
(
@
IThreadService
threadService
:
IThreadService
)
{
super
(
threadService
.
getRemotable
(
MainThreadFormatRange
),
threadService
);
}
_runAsCommand
(
resource
:
URI
,
range
:
IRange
,
options
:
modes
.
IFormattingOptions
):
TPromise
<
ISingleEditOperation
[]
>
{
let
document
=
this
.
_models
.
getDocument
(
resource
);
let
provider
=
this
.
_getOrderedFor
(
document
)[
0
];
let
ran
:
Range
;
if
(
range
)
{
ran
=
TypeConverters
.
toRange
(
range
);
}
else
{
let
lastLine
=
document
.
lineAt
(
document
.
lineCount
-
1
);
let
{
line
,
character
}
=
lastLine
.
range
.
end
;
ran
=
new
Range
(
0
,
0
,
line
,
character
);
}
return
asWinJsPromise
(
token
=>
provider
.
provideDocumentRangeFormattingEdits
(
document
,
ran
,
<
any
>
options
,
token
)).
then
(
result
=>
{
if
(
Array
.
isArray
(
result
))
{
return
result
.
map
(
ExtHostFormatDocument
.
convertTextEdit
);
}
});
}
}
@
Remotable
.
MainContext
(
'
MainThreadFormatRange
'
)
export
class
MainThreadFormatRange
extends
AbstractMainThreadFeature
<
modes
.
IFormattingSupport
>
implements
modes
.
IFormattingSupport
{
constructor
(
@
IThreadService
threadService
:
IThreadService
)
{
super
(
'
vscode.executeFormatRangeProvider
'
,
FormatRegistry
,
threadService
);
}
formatRange
(
resource
:
URI
,
range
:
IRange
,
options
:
modes
.
IFormattingOptions
):
TPromise
<
ISingleEditOperation
[]
>
{
return
this
.
_executeCommand
(
resource
,
range
,
options
);
}
}
// --- format on type
export
interface
FormatOnTypeEntry
{
triggerCharacters
:
string
[];
provider
:
vscode
.
OnTypeFormattingEditProvider
;
}
export
class
ExtHostFormatOnType
extends
AbstractExtensionHostFeature
<
FormatOnTypeEntry
,
MainThreadFormatOnType
>
{
constructor
(
@
IThreadService
threadService
:
IThreadService
)
{
super
(
threadService
.
getRemotable
(
MainThreadFormatOnType
),
threadService
);
}
register
(
selector
:
vscode
.
DocumentSelector
,
provider
:
FormatOnTypeEntry
):
vscode
.
Disposable
{
let
disposable
=
this
.
_registry
.
register
(
selector
,
provider
);
let
registered
=
this
.
_proxy
.
_register
(
selector
,
provider
.
triggerCharacters
);
return
new
Disposable
(()
=>
{
disposable
.
dispose
();
registered
.
then
(()
=>
this
.
_proxy
.
_unregister
());
});
}
_runAsCommand
(
resource
:
URI
,
position
:
IPosition
,
ch
:
string
,
options
:
modes
.
IFormattingOptions
):
TPromise
<
ISingleEditOperation
[]
>
{
let
document
=
this
.
_models
.
getDocument
(
resource
);
let
pos
=
TypeConverters
.
toPosition
(
position
);
let
ordered
=
this
.
_getOrderedFor
(
document
);
let
provider
:
vscode
.
OnTypeFormattingEditProvider
;
for
(
let
entry
of
ordered
)
{
if
(
entry
.
triggerCharacters
.
indexOf
(
ch
)
>=
0
)
{
provider
=
entry
.
provider
;
break
;
}
}
if
(
provider
)
{
return
asWinJsPromise
(
token
=>
provider
.
provideOnTypeFormattingEdits
(
document
,
pos
,
ch
,
<
any
>
options
,
token
)).
then
(
result
=>
{
if
(
Array
.
isArray
(
result
))
{
return
result
.
map
(
ExtHostFormatDocument
.
convertTextEdit
);
}
});
}
}
}
@
Remotable
.
MainContext
(
'
MainThreadFormatOnType
'
)
export
class
MainThreadFormatOnType
extends
AbstractMainThreadFeature
<
modes
.
IFormattingSupport
>
implements
modes
.
IFormattingSupport
{
autoFormatTriggerCharacters
:
string
[]
=
[];
constructor
(
@
IThreadService
threadService
:
IThreadService
)
{
super
(
'
vscode.executeFormatOnTypeProvider
'
,
FormatOnTypeRegistry
,
threadService
);
}
_register
(
selector
:
vscode
.
DocumentSelector
,
triggerCharacters
:
string
[]
=
[]):
TPromise
<
number
>
{
this
.
autoFormatTriggerCharacters
.
push
(...
triggerCharacters
);
return
super
.
_register
(
selector
);
}
formatDocument
(
resource
:
URI
,
options
:
modes
.
IFormattingOptions
):
TPromise
<
ISingleEditOperation
[]
>
{
throw
new
Error
(
'
format on type only
'
);
}
formatAfterKeystroke
(
resource
:
URI
,
position
:
IPosition
,
ch
:
string
,
options
:
modes
.
IFormattingOptions
):
TPromise
<
ISingleEditOperation
[]
>
{
return
this
.
_executeCommand
(
resource
,
position
,
ch
,
options
);
}
}
export
namespace
LanguageFeatures
{
export
function
createMainThreadInstances
(
threadService
:
IThreadService
):
void
{
}
export
function
createExtensionHostInstances
(
threadService
:
IThreadService
)
{
return
{
};
}
}
\ No newline at end of file
src/vs/workbench/electron-browser/shell.ts
浏览文件 @
f192e04e
...
...
@@ -67,7 +67,6 @@ import {MainThreadLanguages} from 'vs/workbench/api/common/extHostLanguages';
import
{
MainThreadEditors
}
from
'
vs/workbench/api/common/pluginHostEditors
'
;
import
{
MainThreadWorkspace
}
from
'
vs/workbench/api/browser/pluginHostWorkspace
'
;
import
{
MainThreadConfiguration
}
from
'
vs/workbench/api/common/pluginHostConfiguration
'
;
import
{
LanguageFeatures
}
from
'
vs/workbench/api/common/languageFeatures
'
;
import
{
MainThreadLanguageFeatures
}
from
'
vs/workbench/api/common/extHostLanguageFeatures
'
;
import
{
EventService
}
from
'
vs/platform/event/common/eventService
'
;
import
{
IOptions
}
from
'
vs/workbench/common/options
'
;
...
...
@@ -338,7 +337,6 @@ export class WorkbenchShell {
this
.
threadServiceInstance
.
getRemotable
(
MainThreadEditors
);
this
.
threadServiceInstance
.
getRemotable
(
MainThreadStorage
);
this
.
threadServiceInstance
.
getRemotable
(
MainThreadLanguageFeatures
);
LanguageFeatures
.
createMainThreadInstances
(
this
.
threadServiceInstance
);
}
public
open
():
void
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录