Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
d433dfd6
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,发现更多精彩内容 >>
提交
d433dfd6
编写于
11月 27, 2015
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add utility method for the 80% case, add doc highlights command
上级
6497432d
变更
10
显示空白变更内容
内联
并排
Showing
10 changed file
with
70 addition
and
68 deletion
+70
-68
src/vs/editor/common/core/position.ts
src/vs/editor/common/core/position.ts
+1
-1
src/vs/editor/common/editorCommonExtensions.ts
src/vs/editor/common/editorCommonExtensions.ts
+37
-2
src/vs/editor/contrib/goToDeclaration/common/goToDeclaration.ts
.../editor/contrib/goToDeclaration/common/goToDeclaration.ts
+3
-17
src/vs/editor/contrib/hover/common/hover.ts
src/vs/editor/contrib/hover/common/hover.ts
+3
-17
src/vs/editor/contrib/wordHighlighter/common/wordHighlighter.ts
.../editor/contrib/wordHighlighter/common/wordHighlighter.ts
+4
-1
src/vs/platform/keybinding/common/commandsUtils.ts
src/vs/platform/keybinding/common/commandsUtils.ts
+0
-26
src/vs/workbench/api/common/extHostLanguageFeatureCommands.ts
...vs/workbench/api/common/extHostLanguageFeatureCommands.ts
+14
-1
src/vs/workbench/api/common/pluginHostTypeConverters.ts
src/vs/workbench/api/common/pluginHostTypeConverters.ts
+5
-0
src/vs/workbench/parts/search/common/search.ts
src/vs/workbench/parts/search/common/search.ts
+2
-2
src/vs/workbench/test/common/api/testThreadService.ts
src/vs/workbench/test/common/api/testThreadService.ts
+1
-1
未找到文件。
src/vs/editor/common/core/position.ts
浏览文件 @
d433dfd6
...
...
@@ -54,7 +54,7 @@ export class Position implements EditorCommon.IEditorPosition {
return
new
Position
(
pos
.
lineNumber
,
pos
.
column
);
}
public
static
isIPosition
(
obj
:
any
):
boolea
n
{
public
static
isIPosition
(
obj
:
any
):
obj
is
EditorCommon
.
IPositio
n
{
return
(
obj
&&
(
typeof
obj
.
lineNumber
===
'
number
'
)
...
...
src/vs/editor/common/editorCommonExtensions.ts
浏览文件 @
d433dfd6
...
...
@@ -5,10 +5,13 @@
'
use strict
'
;
import
EditorCommon
=
require
(
'
vs/editor/common/editorCommon
'
);
import
{
onUnexpectedError
,
illegalArgument
}
from
'
vs/base/common/errors
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
{
Registry
}
from
'
vs/platform/platform
'
;
import
Errors
=
require
(
'
vs/base/common/errors
'
);
import
{
KeybindingsRegistry
,
ICommandDescriptor
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
config
=
require
(
'
vs/editor/common/config/config
'
);
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
...
...
@@ -84,6 +87,38 @@ export module CommonEditorRegistry {
KeybindingsRegistry
.
registerCommandDesc
(
commandDesc
);
}
export
function
registerLanguageCommand
(
id
:
string
,
handler
:
(
accessor
:
ServicesAccessor
,
args
:
{
[
n
:
string
]:
any
})
=>
any
)
{
KeybindingsRegistry
.
registerCommandDesc
({
id
,
handler
(
accessor
,
args
:
any
[])
{
if
(
args
&&
args
.
length
>
1
||
typeof
args
[
0
]
!==
'
object
'
)
{
throw
illegalArgument
();
}
return
handler
(
accessor
,
args
&&
args
[
0
]);
},
weight
:
KeybindingsRegistry
.
WEIGHT
.
editorContrib
(),
primary
:
undefined
,
context
:
undefined
,
});
}
export
function
registerDefaultLanguageCommand
(
id
:
string
,
handler
:
(
model
:
EditorCommon
.
IModel
,
position
:
EditorCommon
.
IPosition
)
=>
any
)
{
registerLanguageCommand
(
id
,
function
(
accessor
,
args
)
{
const
{
resource
,
position
}
=
args
;
if
(
!
URI
.
isURI
(
resource
)
||
!
Position
.
isIPosition
(
position
))
{
throw
illegalArgument
();
}
const
model
=
accessor
.
get
(
IModelService
).
getModel
(
resource
);
if
(
!
model
)
{
throw
illegalArgument
();
}
return
handler
(
model
,
position
);
});
}
}
class
SimpleEditorContributionDescriptor
implements
EditorCommon
.
ICommonEditorContributionDescriptor
{
...
...
@@ -193,7 +228,7 @@ function triggerEditorActionGlobal(actionId: string, accessor: ServicesAccessor,
var
action
=
activeEditor
.
getAction
(
actionId
);
if
(
action
)
{
accessor
.
get
(
ITelemetryService
).
publicLog
(
'
editorActionInvoked
'
,
{
name
:
action
.
label
}
);
action
.
run
().
done
(
null
,
Errors
.
onUnexpectedError
);
action
.
run
().
done
(
null
,
onUnexpectedError
);
}
return
;
}
...
...
src/vs/editor/contrib/goToDeclaration/common/goToDeclaration.ts
浏览文件 @
d433dfd6
...
...
@@ -7,13 +7,12 @@
import
URI
from
'
vs/base/common/uri
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
onUnexpectedError
,
illegalArgument
}
from
'
vs/base/common/errors
'
;
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
{
IModel
,
IPosition
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IDeclarationSupport
}
from
'
vs/editor/common/modes
'
;
import
LanguageFeatureRegistry
from
'
vs/editor/common/modes/languageFeatureRegistry
'
;
import
{
IReference
}
from
'
vs/editor/common/modes
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
{
registerCommand
}
from
'
vs/platform/keybinding/common/commandsUtils
'
;
import
{
CommonEditorRegistry
}
from
'
vs/editor/common/editorCommonExtensions
'
;
export
const
DeclarationRegistry
=
new
LanguageFeatureRegistry
<
IDeclarationSupport
>
(
'
declarationSupport
'
);
...
...
@@ -44,17 +43,4 @@ export function getDeclarationsAtPosition(model: IModel, position: IPosition): T
});
}
registerCommand
(
'
_executeDefinitionProvider
'
,
function
(
accessor
,
args
)
{
let
{
resource
,
position
}
=
args
;
if
(
!
URI
.
isURI
(
resource
))
{
throw
illegalArgument
();
}
let
model
=
accessor
.
get
(
IModelService
).
getModel
(
resource
);
if
(
!
model
)
{
throw
illegalArgument
(
resource
+
'
not found
'
);
}
return
getDeclarationsAtPosition
(
model
,
position
);
});
\ No newline at end of file
CommonEditorRegistry
.
registerDefaultLanguageCommand
(
'
_executeDefinitionProvider
'
,
getDeclarationsAtPosition
)
\ No newline at end of file
src/vs/editor/contrib/hover/common/hover.ts
浏览文件 @
d433dfd6
...
...
@@ -5,15 +5,13 @@
'
use strict
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
IExtraInfoSupport
,
IComputeExtraInfoResult
}
from
'
vs/editor/common/modes
'
;
import
LanguageFeatureRegistry
from
'
vs/editor/common/modes/languageFeatureRegistry
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
coalesce
}
from
'
vs/base/common/arrays
'
;
import
{
onUnexpectedError
,
illegalArgument
}
from
'
vs/base/common/errors
'
;
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
{
IPosition
,
IModel
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
{
registerCommand
}
from
'
vs/platform/keybinding/common/commandsUtils
'
;
import
{
CommonEditorRegistry
}
from
'
vs/editor/common/editorCommonExtensions
'
;
export
const
ExtraInfoRegistry
=
new
LanguageFeatureRegistry
<
IExtraInfoSupport
>
(
'
extraInfoSupport
'
);
...
...
@@ -41,16 +39,4 @@ export function getExtraInfoAtPosition(model: IModel, position: IPosition): TPro
return
TPromise
.
join
(
promises
).
then
(()
=>
coalesce
(
values
));
}
registerCommand
(
'
_executeHoverProvider
'
,
function
(
accessor
,
args
)
{
let
{
resource
,
position
}
=
args
;
if
(
!
URI
.
isURI
(
resource
))
{
throw
illegalArgument
();
}
let
model
=
accessor
.
get
(
IModelService
).
getModel
(
resource
);
if
(
!
model
)
{
throw
illegalArgument
(
resource
+
'
not found
'
);
}
return
getExtraInfoAtPosition
(
model
,
position
);
});
\ No newline at end of file
CommonEditorRegistry
.
registerDefaultLanguageCommand
(
'
_executeHoverProvider
'
,
getExtraInfoAtPosition
);
\ No newline at end of file
src/vs/editor/contrib/wordHighlighter/common/wordHighlighter.ts
浏览文件 @
d433dfd6
...
...
@@ -10,9 +10,10 @@ import * as EditorCommon from 'vs/editor/common/editorCommon';
import
{
IOccurrencesSupport
,
IOccurence
}
from
'
vs/editor/common/modes
'
;
import
{
CommonEditorRegistry
}
from
'
vs/editor/common/editorCommonExtensions
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
{
onUnexpectedError
,
illegalArgument
}
from
'
vs/base/common/errors
'
;
import
{
INullService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
sequence
}
from
'
vs/base/common/async
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
LanguageFeatureRegistry
from
'
vs/editor/common/modes/languageFeatureRegistry
'
;
export
const
OccurrencesRegistry
=
new
LanguageFeatureRegistry
<
IOccurrencesSupport
>
(
'
occurrencesSupport
'
);
...
...
@@ -44,6 +45,8 @@ export function getOccurrencesAtPosition(model: EditorCommon.IModel, position: E
});
}
CommonEditorRegistry
.
registerDefaultLanguageCommand
(
'
_executeDocumentHighlights
'
,
getOccurrencesAtPosition
);
class
WordHighlighter
{
private
editor
:
EditorCommon
.
ICommonCodeEditor
;
...
...
src/vs/platform/keybinding/common/commandsUtils.ts
已删除
100644 → 0
浏览文件 @
6497432d
/*---------------------------------------------------------------------------------------------
* 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
{
illegalArgument
}
from
'
vs/base/common/errors
'
;
import
{
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
KeybindingsRegistry
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
export
function
registerCommand
(
id
:
string
,
handler
:
(
accessor
:
ServicesAccessor
,
args
:
{
[
n
:
string
]:
any
})
=>
any
)
{
KeybindingsRegistry
.
registerCommandDesc
({
id
,
handler
(
accessor
,
args
:
any
[])
{
if
(
args
&&
args
.
length
>
1
||
typeof
args
[
0
]
!==
'
object
'
)
{
throw
illegalArgument
();
}
return
handler
(
accessor
,
args
&&
args
[
0
]);
},
weight
:
KeybindingsRegistry
.
WEIGHT
.
editorContrib
(),
primary
:
undefined
,
context
:
undefined
,
});
}
\ No newline at end of file
src/vs/workbench/api/common/extHostLanguageFeatureCommands.ts
浏览文件 @
d433dfd6
...
...
@@ -41,8 +41,8 @@ import {SuggestRegistry} from 'vs/editor/contrib/suggest/common/suggest';
// vscode.executeWorkspaceSymbolProvider
// vscode.executeDefinitionProvider
// vscode.executeHoverProvider
// vscode.executeDocumentHighlights
// vscode.executeReferenceProvider
// vscode.executeCodeActionProvider
// vscode.executeCodeLensProvider
...
...
@@ -65,6 +65,7 @@ export class ExtHostLanguageFeatureCommands {
this
.
_register
(
'
vscode.executeWorkspaceSymbolProvider
'
,
this
.
_executeWorkspaceSymbolProvider
);
this
.
_register
(
'
vscode.executeDefinitionProvider
'
,
this
.
_executeDefinitionProvider
);
this
.
_register
(
'
vscode.executeHoverProvider
'
,
this
.
_executeHoverProvider
);
this
.
_register
(
'
vscode.executeDocumentHighlights
'
,
this
.
_executeDocumentHighlights
);
}
private
_register
(
id
:
string
,
callback
:
(...
args
:
any
[])
=>
any
):
void
{
...
...
@@ -104,4 +105,16 @@ export class ExtHostLanguageFeatureCommands {
}
});
}
private
_executeDocumentHighlights
(
resource
:
URI
,
position
:
types
.
Position
):
Thenable
<
types
.
DocumentHighlight
[]
>
{
const
args
=
{
resource
,
position
:
position
&&
typeConverters
.
fromPosition
(
position
)
};
return
this
.
_commands
.
executeCommand
<
modes
.
IOccurence
[]
>
(
'
_executeDocumentHighlights
'
,
args
).
then
(
value
=>
{
if
(
Array
.
isArray
(
value
))
{
return
value
.
map
(
typeConverters
.
toDocumentHighlight
)
}
});
}
}
\ No newline at end of file
src/vs/workbench/api/common/pluginHostTypeConverters.ts
浏览文件 @
d433dfd6
...
...
@@ -246,3 +246,8 @@ export function fromHover(hover: vscode.Hover): modes.IComputeExtraInfoResult {
export
function
toHover
(
info
:
modes
.
IComputeExtraInfoResult
):
types
.
Hover
{
return
new
types
.
Hover
(
info
.
htmlContent
.
map
(
toFormattedString
),
toRange
(
info
.
range
));
}
export
function
toDocumentHighlight
(
occurrence
:
modes
.
IOccurence
):
types
.
DocumentHighlight
{
return
new
types
.
DocumentHighlight
(
toRange
(
occurrence
.
range
),
types
.
DocumentHighlightKind
[
occurrence
.
kind
.
charAt
(
0
).
toUpperCase
()
+
occurrence
.
kind
.
substr
(
1
)]);
}
\ No newline at end of file
src/vs/workbench/parts/search/common/search.ts
浏览文件 @
d433dfd6
...
...
@@ -9,9 +9,9 @@ import {TPromise} from 'vs/base/common/winjs.base';
import
{
onUnexpectedError
,
illegalArgument
}
from
'
vs/base/common/errors
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
LanguageFeatureRegistry
from
'
vs/editor/common/modes/languageFeatureRegistry
'
;
import
{
CommonEditorRegistry
}
from
'
vs/editor/common/editorCommonExtensions
'
;
import
{
IRange
}
from
'
vs/editor/common/editorCommon
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
registerCommand
}
from
'
vs/platform/keybinding/common/commandsUtils
'
;
/**
* Interface used to navigate to types by value.
...
...
@@ -75,7 +75,7 @@ export function getNavigateToItems(query: string): TPromise<ITypeBearing[]> {
});
}
register
Command
(
'
_executeWorkspaceSymbolProvider
'
,
function
(
accessor
,
args
:
{
query
:
string
;})
{
CommonEditorRegistry
.
registerLanguage
Command
(
'
_executeWorkspaceSymbolProvider
'
,
function
(
accessor
,
args
:
{
query
:
string
;})
{
let
{
query
}
=
args
;
if
(
typeof
query
!==
'
string
'
)
{
throw
illegalArgument
();
...
...
src/vs/workbench/test/common/api/testThreadService.ts
浏览文件 @
d433dfd6
...
...
@@ -24,7 +24,7 @@ export class TestThreadService extends NullThreadService {
private
set
_callCount
(
value
:
number
)
{
this
.
_callCountValue
=
value
;
if
(
this
.
_callCountValue
===
0
)
{
this
.
_completeIdle
();
this
.
_completeIdle
&&
this
.
_completeIdle
();
this
.
_idle
=
undefined
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录