Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
4f8dbd45
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,发现更多精彩内容 >>
提交
4f8dbd45
编写于
3月 12, 2019
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
use a parent pointer instead of 2d array, #67872
上级
a86ff6a4
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
51 addition
and
24 deletion
+51
-24
extensions/css-language-features/client/src/cssMain.ts
extensions/css-language-features/client/src/cssMain.ts
+5
-4
extensions/html-language-features/client/src/htmlMain.ts
extensions/html-language-features/client/src/htmlMain.ts
+4
-3
extensions/json-language-features/client/src/jsonMain.ts
extensions/json-language-features/client/src/jsonMain.ts
+4
-3
src/vs/editor/contrib/smartSelect/smartSelect.ts
src/vs/editor/contrib/smartSelect/smartSelect.ts
+2
-1
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+3
-2
src/vs/workbench/api/node/extHostLanguageFeatures.ts
src/vs/workbench/api/node/extHostLanguageFeatures.ts
+7
-2
src/vs/workbench/api/node/extHostTypes.ts
src/vs/workbench/api/node/extHostTypes.ts
+3
-1
src/vs/workbench/test/electron-browser/api/extHostApiCommands.test.ts
...ench/test/electron-browser/api/extHostApiCommands.test.ts
+3
-4
src/vs/workbench/test/electron-browser/api/extHostLanguageFeatures.test.ts
...test/electron-browser/api/extHostLanguageFeatures.test.ts
+20
-4
未找到文件。
extensions/css-language-features/client/src/cssMain.ts
浏览文件 @
4f8dbd45
...
@@ -81,16 +81,17 @@ export function activate(context: ExtensionContext) {
...
@@ -81,16 +81,17 @@ export function activate(context: ExtensionContext) {
documentSelector
.
forEach
(
selector
=>
{
documentSelector
.
forEach
(
selector
=>
{
context
.
subscriptions
.
push
(
languages
.
registerSelectionRangeProvider
(
selector
,
{
context
.
subscriptions
.
push
(
languages
.
registerSelectionRangeProvider
(
selector
,
{
async
provideSelectionRanges
(
document
:
TextDocument
,
positions
:
Position
[]):
Promise
<
SelectionRange
[]
[]
>
{
async
provideSelectionRanges
(
document
:
TextDocument
,
positions
:
Position
[]):
Promise
<
SelectionRange
[]
>
{
const
textDocument
=
client
.
code2ProtocolConverter
.
asTextDocumentIdentifier
(
document
);
const
textDocument
=
client
.
code2ProtocolConverter
.
asTextDocumentIdentifier
(
document
);
const
rawResult
=
await
client
.
sendRequest
<
SelectionRange
[][]
>
(
'
$/textDocument/selectionRanges
'
,
{
textDocument
,
positions
:
positions
.
map
(
client
.
code2ProtocolConverter
.
asPosition
)
});
const
rawResult
=
await
client
.
sendRequest
<
SelectionRange
[][]
>
(
'
$/textDocument/selectionRanges
'
,
{
textDocument
,
positions
:
positions
.
map
(
client
.
code2ProtocolConverter
.
asPosition
)
});
if
(
Array
.
isArray
(
rawResult
))
{
if
(
Array
.
isArray
(
rawResult
))
{
return
rawResult
.
map
(
rawSelectionRanges
=>
{
return
rawResult
.
map
(
rawSelectionRanges
=>
{
return
rawSelectionRanges
.
map
(
selectionRange
=>
{
return
rawSelectionRanges
.
reduceRight
((
parent
:
SelectionRange
|
undefined
,
selectionRange
:
SelectionRange
)
=>
{
return
{
return
{
range
:
client
.
protocol2CodeConverter
.
asRange
(
selectionRange
.
range
)
range
:
client
.
protocol2CodeConverter
.
asRange
(
selectionRange
.
range
),
parent
};
};
}
)
;
}
,
undefined
)
!
;
});
});
}
}
return
[];
return
[];
...
...
extensions/html-language-features/client/src/htmlMain.ts
浏览文件 @
4f8dbd45
...
@@ -90,16 +90,17 @@ export function activate(context: ExtensionContext) {
...
@@ -90,16 +90,17 @@ export function activate(context: ExtensionContext) {
documentSelector
.
forEach
(
selector
=>
{
documentSelector
.
forEach
(
selector
=>
{
context
.
subscriptions
.
push
(
languages
.
registerSelectionRangeProvider
(
selector
,
{
context
.
subscriptions
.
push
(
languages
.
registerSelectionRangeProvider
(
selector
,
{
async
provideSelectionRanges
(
document
:
TextDocument
,
positions
:
Position
[]):
Promise
<
SelectionRange
[]
[]
>
{
async
provideSelectionRanges
(
document
:
TextDocument
,
positions
:
Position
[]):
Promise
<
SelectionRange
[]
>
{
const
textDocument
=
client
.
code2ProtocolConverter
.
asTextDocumentIdentifier
(
document
);
const
textDocument
=
client
.
code2ProtocolConverter
.
asTextDocumentIdentifier
(
document
);
const
rawResult
=
await
client
.
sendRequest
<
SelectionRange
[][]
>
(
'
$/textDocument/selectionRanges
'
,
{
textDocument
,
positions
:
positions
.
map
(
client
.
code2ProtocolConverter
.
asPosition
)
});
const
rawResult
=
await
client
.
sendRequest
<
SelectionRange
[][]
>
(
'
$/textDocument/selectionRanges
'
,
{
textDocument
,
positions
:
positions
.
map
(
client
.
code2ProtocolConverter
.
asPosition
)
});
if
(
Array
.
isArray
(
rawResult
))
{
if
(
Array
.
isArray
(
rawResult
))
{
return
rawResult
.
map
(
rawSelectionRanges
=>
{
return
rawResult
.
map
(
rawSelectionRanges
=>
{
return
rawSelectionRanges
.
map
(
selectionRange
=>
{
return
rawSelectionRanges
.
reduceRight
((
parent
:
SelectionRange
|
undefined
,
selectionRange
:
SelectionRange
)
=>
{
return
{
return
{
range
:
client
.
protocol2CodeConverter
.
asRange
(
selectionRange
.
range
),
range
:
client
.
protocol2CodeConverter
.
asRange
(
selectionRange
.
range
),
parent
};
};
}
)
;
}
,
undefined
)
!
;
});
});
}
}
return
[];
return
[];
...
...
extensions/json-language-features/client/src/jsonMain.ts
浏览文件 @
4f8dbd45
...
@@ -214,16 +214,17 @@ export function activate(context: ExtensionContext) {
...
@@ -214,16 +214,17 @@ export function activate(context: ExtensionContext) {
documentSelector
.
forEach
(
selector
=>
{
documentSelector
.
forEach
(
selector
=>
{
toDispose
.
push
(
languages
.
registerSelectionRangeProvider
(
selector
,
{
toDispose
.
push
(
languages
.
registerSelectionRangeProvider
(
selector
,
{
async
provideSelectionRanges
(
document
:
TextDocument
,
positions
:
Position
[]):
Promise
<
SelectionRange
[]
[]
>
{
async
provideSelectionRanges
(
document
:
TextDocument
,
positions
:
Position
[]):
Promise
<
SelectionRange
[]
>
{
const
textDocument
=
client
.
code2ProtocolConverter
.
asTextDocumentIdentifier
(
document
);
const
textDocument
=
client
.
code2ProtocolConverter
.
asTextDocumentIdentifier
(
document
);
const
rawResult
=
await
client
.
sendRequest
<
SelectionRange
[][]
>
(
'
$/textDocument/selectionRanges
'
,
{
textDocument
,
positions
:
positions
.
map
(
client
.
code2ProtocolConverter
.
asPosition
)
});
const
rawResult
=
await
client
.
sendRequest
<
SelectionRange
[][]
>
(
'
$/textDocument/selectionRanges
'
,
{
textDocument
,
positions
:
positions
.
map
(
client
.
code2ProtocolConverter
.
asPosition
)
});
if
(
Array
.
isArray
(
rawResult
))
{
if
(
Array
.
isArray
(
rawResult
))
{
return
rawResult
.
map
(
rawSelectionRanges
=>
{
return
rawResult
.
map
(
rawSelectionRanges
=>
{
return
rawSelectionRanges
.
map
(
selectionRange
=>
{
return
rawSelectionRanges
.
reduceRight
((
parent
:
SelectionRange
|
undefined
,
selectionRange
:
SelectionRange
)
=>
{
return
{
return
{
range
:
client
.
protocol2CodeConverter
.
asRange
(
selectionRange
.
range
),
range
:
client
.
protocol2CodeConverter
.
asRange
(
selectionRange
.
range
),
parent
,
};
};
}
)
;
}
,
undefined
)
!
;
});
});
}
}
return
[];
return
[];
...
...
src/vs/editor/contrib/smartSelect/smartSelect.ts
浏览文件 @
4f8dbd45
...
@@ -22,6 +22,7 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle';
...
@@ -22,6 +22,7 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import
{
WordSelectionRangeProvider
}
from
'
vs/editor/contrib/smartSelect/wordSelections
'
;
import
{
WordSelectionRangeProvider
}
from
'
vs/editor/contrib/smartSelect/wordSelections
'
;
import
{
BracketSelectionRangeProvider
}
from
'
vs/editor/contrib/smartSelect/bracketSelections
'
;
import
{
BracketSelectionRangeProvider
}
from
'
vs/editor/contrib/smartSelect/bracketSelections
'
;
import
{
CommandsRegistry
}
from
'
vs/platform/commands/common/commands
'
;
import
{
CommandsRegistry
}
from
'
vs/platform/commands/common/commands
'
;
import
{
onUnexpectedExternalError
}
from
'
vs/base/common/errors
'
;
class
SelectionRanges
{
class
SelectionRanges
{
...
@@ -237,7 +238,7 @@ export function provideSelectionRanges(model: ITextModel, positions: Position[],
...
@@ -237,7 +238,7 @@ export function provideSelectionRanges(model: ITextModel, positions: Position[],
}
}
}
}
}
}
}));
}
,
onUnexpectedExternalError
));
}
}
return
Promise
.
all
(
work
).
then
(()
=>
{
return
Promise
.
all
(
work
).
then
(()
=>
{
...
...
src/vs/vscode.proposed.d.ts
浏览文件 @
4f8dbd45
...
@@ -86,7 +86,8 @@ declare module 'vscode' {
...
@@ -86,7 +86,8 @@ declare module 'vscode' {
export
class
SelectionRange
{
export
class
SelectionRange
{
range
:
Range
;
range
:
Range
;
constructor
(
range
:
Range
);
parent
?:
SelectionRange
;
constructor
(
range
:
Range
,
parent
?:
SelectionRange
);
}
}
export
interface
SelectionRangeProvider
{
export
interface
SelectionRangeProvider
{
...
@@ -97,7 +98,7 @@ declare module 'vscode' {
...
@@ -97,7 +98,7 @@ declare module 'vscode' {
*
*
* todo@joh
* todo@joh
*/
*/
provideSelectionRanges
(
document
:
TextDocument
,
positions
:
Position
[],
token
:
CancellationToken
):
ProviderResult
<
SelectionRange
[]
[]
>
;
provideSelectionRanges
(
document
:
TextDocument
,
positions
:
Position
[],
token
:
CancellationToken
):
ProviderResult
<
SelectionRange
[]
>
;
}
}
export
namespace
languages
{
export
namespace
languages
{
...
...
src/vs/workbench/api/node/extHostLanguageFeatures.ts
浏览文件 @
4f8dbd45
...
@@ -944,14 +944,19 @@ class SelectionRangeAdapter {
...
@@ -944,14 +944,19 @@ class SelectionRangeAdapter {
const
oneResult
:
modes
.
SelectionRange
[]
=
[];
const
oneResult
:
modes
.
SelectionRange
[]
=
[];
allResults
.
push
(
oneResult
);
allResults
.
push
(
oneResult
);
const
oneProviderRanges
=
allProviderRanges
[
i
];
let
last
:
vscode
.
Position
|
vscode
.
Range
=
positions
[
i
];
let
last
:
vscode
.
Position
|
vscode
.
Range
=
positions
[
i
];
for
(
const
selectionRange
of
oneProviderRanges
)
{
let
selectionRange
=
allProviderRanges
[
i
];
while
(
true
)
{
if
(
!
selectionRange
.
range
.
contains
(
last
))
{
if
(
!
selectionRange
.
range
.
contains
(
last
))
{
throw
new
Error
(
'
INVALID selection range, must contain the previous range
'
);
throw
new
Error
(
'
INVALID selection range, must contain the previous range
'
);
}
}
oneResult
.
push
(
typeConvert
.
SelectionRange
.
from
(
selectionRange
));
oneResult
.
push
(
typeConvert
.
SelectionRange
.
from
(
selectionRange
));
if
(
!
selectionRange
.
parent
)
{
break
;
}
last
=
selectionRange
.
range
;
last
=
selectionRange
.
range
;
selectionRange
=
selectionRange
.
parent
;
}
}
}
}
return
allResults
;
return
allResults
;
...
...
src/vs/workbench/api/node/extHostTypes.ts
浏览文件 @
4f8dbd45
...
@@ -1098,9 +1098,11 @@ CodeActionKind.SourceFixAll = CodeActionKind.Source.append('fixAll');
...
@@ -1098,9 +1098,11 @@ CodeActionKind.SourceFixAll = CodeActionKind.Source.append('fixAll');
export
class
SelectionRange
{
export
class
SelectionRange
{
range
:
Range
;
range
:
Range
;
parent
?:
SelectionRange
;
constructor
(
range
:
Range
)
{
constructor
(
range
:
Range
,
parent
?:
SelectionRange
)
{
this
.
range
=
range
;
this
.
range
=
range
;
this
.
parent
=
parent
;
}
}
}
}
...
...
src/vs/workbench/test/electron-browser/api/extHostApiCommands.test.ts
浏览文件 @
4f8dbd45
...
@@ -799,10 +799,9 @@ suite('ExtHostLanguageFeatureCommands', function () {
...
@@ -799,10 +799,9 @@ suite('ExtHostLanguageFeatureCommands', function () {
disposables
.
push
(
extHost
.
registerSelectionRangeProvider
(
nullExtensionDescription
,
defaultSelector
,
<
vscode
.
SelectionRangeProvider
>
{
disposables
.
push
(
extHost
.
registerSelectionRangeProvider
(
nullExtensionDescription
,
defaultSelector
,
<
vscode
.
SelectionRangeProvider
>
{
provideSelectionRanges
()
{
provideSelectionRanges
()
{
return
[[
return
[
new
types
.
SelectionRange
(
new
types
.
Range
(
0
,
10
,
0
,
18
)),
new
types
.
SelectionRange
(
new
types
.
Range
(
0
,
10
,
0
,
18
),
new
types
.
SelectionRange
(
new
types
.
Range
(
0
,
2
,
0
,
20
))),
new
types
.
SelectionRange
(
new
types
.
Range
(
0
,
2
,
0
,
20
))
];
]];
}
}
}));
}));
...
...
src/vs/workbench/test/electron-browser/api/extHostLanguageFeatures.test.ts
浏览文件 @
4f8dbd45
...
@@ -1104,10 +1104,9 @@ suite('ExtHostLanguageFeatures', function () {
...
@@ -1104,10 +1104,9 @@ suite('ExtHostLanguageFeatures', function () {
test
(
'
Selection Ranges, data conversion
'
,
async
()
=>
{
test
(
'
Selection Ranges, data conversion
'
,
async
()
=>
{
disposables
.
push
(
extHost
.
registerSelectionRangeProvider
(
defaultExtension
,
defaultSelector
,
new
class
implements
vscode
.
SelectionRangeProvider
{
disposables
.
push
(
extHost
.
registerSelectionRangeProvider
(
defaultExtension
,
defaultSelector
,
new
class
implements
vscode
.
SelectionRangeProvider
{
provideSelectionRanges
()
{
provideSelectionRanges
()
{
return
[[
return
[
new
types
.
SelectionRange
(
new
types
.
Range
(
0
,
10
,
0
,
18
)),
new
types
.
SelectionRange
(
new
types
.
Range
(
0
,
10
,
0
,
18
),
new
types
.
SelectionRange
(
new
types
.
Range
(
0
,
2
,
0
,
20
))),
new
types
.
SelectionRange
(
new
types
.
Range
(
0
,
2
,
0
,
20
))
];
]];
}
}
}));
}));
...
@@ -1118,4 +1117,21 @@ suite('ExtHostLanguageFeatures', function () {
...
@@ -1118,4 +1117,21 @@ suite('ExtHostLanguageFeatures', function () {
assert
.
ok
(
ranges
[
0
].
length
>=
2
);
assert
.
ok
(
ranges
[
0
].
length
>=
2
);
});
});
});
});
test
(
'
Selection Ranges, bad data
'
,
async
()
=>
{
disposables
.
push
(
extHost
.
registerSelectionRangeProvider
(
defaultExtension
,
defaultSelector
,
new
class
implements
vscode
.
SelectionRangeProvider
{
provideSelectionRanges
()
{
return
[
new
types
.
SelectionRange
(
new
types
.
Range
(
0
,
10
,
0
,
18
),
new
types
.
SelectionRange
(
new
types
.
Range
(
0
,
11
,
0
,
18
))),
];
}
}));
await
rpcProtocol
.
sync
();
provideSelectionRanges
(
model
,
[
new
Position
(
1
,
17
)],
CancellationToken
.
None
).
then
(
ranges
=>
{
assert
.
equal
(
ranges
.
length
,
0
);
});
});
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录