Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
703e7408
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,发现更多精彩内容 >>
提交
703e7408
编写于
9月 19, 2017
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Continue moving range/position conversion to single location
上级
474a29ee
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
42 addition
and
83 deletion
+42
-83
extensions/typescript/src/features/codeActionProvider.ts
extensions/typescript/src/features/codeActionProvider.ts
+2
-6
extensions/typescript/src/features/completionItemProvider.ts
extensions/typescript/src/features/completionItemProvider.ts
+4
-13
extensions/typescript/src/features/definitionProviderBase.ts
extensions/typescript/src/features/definitionProviderBase.ts
+2
-6
extensions/typescript/src/features/documentHighlightProvider.ts
...ions/typescript/src/features/documentHighlightProvider.ts
+2
-7
extensions/typescript/src/features/hoverProvider.ts
extensions/typescript/src/features/hoverProvider.ts
+2
-7
extensions/typescript/src/features/implementationsCodeLensProvider.ts
...ypescript/src/features/implementationsCodeLensProvider.ts
+2
-6
extensions/typescript/src/features/jsDocCompletionProvider.ts
...nsions/typescript/src/features/jsDocCompletionProvider.ts
+3
-6
extensions/typescript/src/features/refactorProvider.ts
extensions/typescript/src/features/refactorProvider.ts
+4
-15
extensions/typescript/src/features/referenceProvider.ts
extensions/typescript/src/features/referenceProvider.ts
+2
-7
extensions/typescript/src/features/referencesCodeLensProvider.ts
...ons/typescript/src/features/referencesCodeLensProvider.ts
+2
-6
extensions/typescript/src/utils/convert.ts
extensions/typescript/src/utils/convert.ts
+17
-4
未找到文件。
extensions/typescript/src/features/codeActionProvider.ts
浏览文件 @
703e7408
...
...
@@ -7,7 +7,7 @@ import { CodeActionProvider, TextDocument, Range, CancellationToken, CodeActionC
import
*
as
Proto
from
'
../protocol
'
;
import
{
ITypescriptServiceClient
}
from
'
../typescriptService
'
;
import
{
textSpanToRange
}
from
'
../utils/convert
'
;
import
{
textSpanToRange
,
rangeToFileRange
}
from
'
../utils/convert
'
;
interface
NumberSet
{
[
key
:
number
]:
boolean
;
...
...
@@ -68,11 +68,7 @@ export default class TypeScriptCodeActionProvider implements CodeActionProvider
formattingOptions
:
formattingOptions
};
const
args
:
Proto
.
CodeFixRequestArgs
=
{
file
:
file
,
startLine
:
range
.
start
.
line
+
1
,
endLine
:
range
.
end
.
line
+
1
,
startOffset
:
range
.
start
.
character
+
1
,
endOffset
:
range
.
end
.
character
+
1
,
...
rangeToFileRange
(
file
,
range
),
errorCodes
:
Array
.
from
(
supportedActions
)
};
const
response
=
await
this
.
client
.
execute
(
'
getCodeFixes
'
,
args
,
token
);
...
...
extensions/typescript/src/features/completionItemProvider.ts
浏览文件 @
703e7408
...
...
@@ -9,9 +9,9 @@ import { ITypescriptServiceClient } from '../typescriptService';
import
TypingsStatus
from
'
../utils/typingsStatus
'
;
import
*
as
PConst
from
'
../protocol.const
'
;
import
{
CompletionEntry
,
CompletionsRequestArgs
,
CompletionDetailsRequestArgs
,
CompletionEntryDetails
,
FileLocationRequestArgs
}
from
'
../protocol
'
;
import
{
CompletionEntry
,
CompletionsRequestArgs
,
CompletionDetailsRequestArgs
,
CompletionEntryDetails
}
from
'
../protocol
'
;
import
*
as
Previewer
from
'
./previewer
'
;
import
{
textSpanToRange
}
from
'
../utils/convert
'
;
import
{
textSpanToRange
,
positionToFileLocation
}
from
'
../utils/convert
'
;
import
*
as
nls
from
'
vscode-nls
'
;
let
localize
=
nls
.
loadMessageBundle
();
...
...
@@ -175,12 +175,7 @@ export default class TypeScriptCompletionItemProvider implements CompletionItemP
if
(
!
file
)
{
return
Promise
.
resolve
<
CompletionItem
[]
>
([]);
}
const
args
:
CompletionsRequestArgs
=
{
file
:
file
,
line
:
position
.
line
+
1
,
offset
:
position
.
character
+
1
};
const
args
:
CompletionsRequestArgs
=
positionToFileLocation
(
file
,
position
);
return
this
.
client
.
execute
(
'
completions
'
,
args
,
token
).
then
((
msg
)
=>
{
// This info has to come from the tsserver. See https://github.com/Microsoft/TypeScript/issues/2831
// let isMemberCompletion = false;
...
...
@@ -270,11 +265,7 @@ export default class TypeScriptCompletionItemProvider implements CompletionItemP
}
private
isValidFunctionCompletionContext
(
filepath
:
string
,
position
:
Position
):
Promise
<
boolean
>
{
const
args
:
FileLocationRequestArgs
=
{
file
:
filepath
,
line
:
position
.
line
+
1
,
offset
:
position
.
character
+
1
};
const
args
=
positionToFileLocation
(
filepath
,
position
);
// Workaround for https://github.com/Microsoft/TypeScript/issues/12677
// Don't complete function calls inside of destructive assigments or imports
return
this
.
client
.
execute
(
'
quickinfo
'
,
args
).
then
(
infoResponse
=>
{
...
...
extensions/typescript/src/features/definitionProviderBase.ts
浏览文件 @
703e7408
...
...
@@ -7,7 +7,7 @@ import { TextDocument, Position, CancellationToken, Location } from 'vscode';
import
*
as
Proto
from
'
../protocol
'
;
import
{
ITypescriptServiceClient
}
from
'
../typescriptService
'
;
import
{
textSpanToRange
}
from
'
../utils/convert
'
;
import
{
textSpanToRange
,
positionToFileLocation
}
from
'
../utils/convert
'
;
export
default
class
TypeScriptDefinitionProviderBase
{
constructor
(
...
...
@@ -23,11 +23,7 @@ export default class TypeScriptDefinitionProviderBase {
if
(
!
filepath
)
{
return
Promise
.
resolve
(
null
);
}
const
args
:
Proto
.
FileLocationRequestArgs
=
{
file
:
filepath
,
line
:
position
.
line
+
1
,
offset
:
position
.
character
+
1
};
const
args
=
positionToFileLocation
(
filepath
,
position
);
return
this
.
client
.
execute
(
definitionType
,
args
,
token
).
then
(
response
=>
{
const
locations
:
Proto
.
FileSpan
[]
=
(
response
&&
response
.
body
)
||
[];
if
(
!
locations
||
locations
.
length
===
0
)
{
...
...
extensions/typescript/src/features/documentHighlightProvider.ts
浏览文件 @
703e7408
...
...
@@ -5,9 +5,8 @@
import
{
DocumentHighlightProvider
,
DocumentHighlight
,
DocumentHighlightKind
,
TextDocument
,
Position
,
Range
,
CancellationToken
}
from
'
vscode
'
;
import
*
as
Proto
from
'
../protocol
'
;
import
{
ITypescriptServiceClient
}
from
'
../typescriptService
'
;
import
{
textSpanToRange
}
from
'
../utils/convert
'
;
import
{
textSpanToRange
,
positionToFileLocation
}
from
'
../utils/convert
'
;
export
default
class
TypeScriptDocumentHighlightProvider
implements
DocumentHighlightProvider
{
...
...
@@ -19,11 +18,7 @@ export default class TypeScriptDocumentHighlightProvider implements DocumentHigh
if
(
!
filepath
)
{
return
Promise
.
resolve
<
DocumentHighlight
[]
>
([]);
}
const
args
:
Proto
.
FileLocationRequestArgs
=
{
file
:
filepath
,
line
:
position
.
line
+
1
,
offset
:
position
.
character
+
1
};
const
args
=
positionToFileLocation
(
filepath
,
position
);
return
this
.
client
.
execute
(
'
occurrences
'
,
args
,
token
).
then
((
response
):
DocumentHighlight
[]
=>
{
let
data
=
response
.
body
;
if
(
data
&&
data
.
length
)
{
...
...
extensions/typescript/src/features/hoverProvider.ts
浏览文件 @
703e7408
...
...
@@ -8,7 +8,7 @@ import { HoverProvider, Hover, TextDocument, Position, CancellationToken } from
import
*
as
Proto
from
'
../protocol
'
;
import
{
ITypescriptServiceClient
}
from
'
../typescriptService
'
;
import
{
tagsMarkdownPreview
}
from
'
./previewer
'
;
import
{
textSpanToRange
}
from
'
../utils/convert
'
;
import
{
textSpanToRange
,
positionToFileLocation
}
from
'
../utils/convert
'
;
export
default
class
TypeScriptHoverProvider
implements
HoverProvider
{
...
...
@@ -20,12 +20,7 @@ export default class TypeScriptHoverProvider implements HoverProvider {
if
(
!
filepath
)
{
return
undefined
;
}
const
args
:
Proto
.
FileLocationRequestArgs
=
{
file
:
filepath
,
line
:
position
.
line
+
1
,
offset
:
position
.
character
+
1
};
const
args
=
positionToFileLocation
(
filepath
,
position
);
try
{
const
response
=
await
this
.
client
.
execute
(
'
quickinfo
'
,
args
,
token
);
if
(
response
&&
response
.
body
)
{
...
...
extensions/typescript/src/features/implementationsCodeLensProvider.ts
浏览文件 @
703e7408
...
...
@@ -9,7 +9,7 @@ import * as PConst from '../protocol.const';
import
{
TypeScriptBaseCodeLensProvider
,
ReferencesCodeLens
}
from
'
./baseCodeLensProvider
'
;
import
{
ITypescriptServiceClient
}
from
'
../typescriptService
'
;
import
{
textSpanToRange
}
from
'
../utils/convert
'
;
import
{
textSpanToRange
,
positionToFileLocation
}
from
'
../utils/convert
'
;
import
*
as
nls
from
'
vscode-nls
'
;
const
localize
=
nls
.
loadMessageBundle
();
...
...
@@ -36,11 +36,7 @@ export default class TypeScriptImplementationsCodeLensProvider extends TypeScrip
resolveCodeLens
(
inputCodeLens
:
CodeLens
,
token
:
CancellationToken
):
Promise
<
CodeLens
>
{
const
codeLens
=
inputCodeLens
as
ReferencesCodeLens
;
const
args
:
Proto
.
FileLocationRequestArgs
=
{
file
:
codeLens
.
file
,
line
:
codeLens
.
range
.
start
.
line
+
1
,
offset
:
codeLens
.
range
.
start
.
character
+
1
};
const
args
=
positionToFileLocation
(
codeLens
.
file
,
codeLens
.
range
.
start
);
return
this
.
client
.
execute
(
'
implementation
'
,
args
,
token
).
then
(
response
=>
{
if
(
!
response
||
!
response
.
body
)
{
throw
codeLens
;
...
...
extensions/typescript/src/features/jsDocCompletionProvider.ts
浏览文件 @
703e7408
...
...
@@ -6,9 +6,10 @@
import
{
Position
,
Range
,
CompletionItemProvider
,
CompletionItemKind
,
TextDocument
,
CancellationToken
,
CompletionItem
,
window
,
Uri
,
ProviderResult
,
TextEditor
,
SnippetString
,
workspace
}
from
'
vscode
'
;
import
{
ITypescriptServiceClient
}
from
'
../typescriptService
'
;
import
{
FileLocationRequestArgs
,
DocCommandTemplateResponse
}
from
'
../protocol
'
;
import
{
DocCommandTemplateResponse
}
from
'
../protocol
'
;
import
*
as
nls
from
'
vscode-nls
'
;
import
{
positionToFileLocation
}
from
'
../utils/convert
'
;
const
localize
=
nls
.
loadMessageBundle
();
const
configurationNamespace
=
'
jsDocCompletion
'
;
...
...
@@ -118,11 +119,7 @@ export class TryCompleteJsDocCommand {
}
private
tryInsertJsDocFromTemplate
(
editor
:
TextEditor
,
file
:
string
,
position
:
Position
):
Promise
<
boolean
>
{
const
args
:
FileLocationRequestArgs
=
{
file
:
file
,
line
:
position
.
line
+
1
,
offset
:
position
.
character
+
1
};
const
args
=
positionToFileLocation
(
file
,
position
);
return
Promise
.
race
([
this
.
lazyClient
().
execute
(
'
docCommentTemplate
'
,
args
),
new
Promise
((
_
,
reject
)
=>
setTimeout
(
reject
,
250
))
...
...
extensions/typescript/src/features/refactorProvider.ts
浏览文件 @
703e7408
...
...
@@ -9,7 +9,7 @@ import { CodeActionProvider, TextDocument, Range, CancellationToken, CodeActionC
import
*
as
Proto
from
'
../protocol
'
;
import
{
ITypescriptServiceClient
}
from
'
../typescriptService
'
;
import
{
textSpanToRange
}
from
'
../utils/convert
'
;
import
{
textSpanToRange
,
rangeToFileRange
}
from
'
../utils/convert
'
;
export
default
class
TypeScriptRefactorProvider
implements
CodeActionProvider
{
...
...
@@ -43,14 +43,7 @@ export default class TypeScriptRefactorProvider implements CodeActionProvider {
return
[];
}
const
args
:
Proto
.
GetApplicableRefactorsRequestArgs
=
{
file
:
file
,
startLine
:
range
.
start
.
line
+
1
,
startOffset
:
range
.
start
.
character
+
1
,
endLine
:
range
.
end
.
line
+
1
,
endOffset
:
range
.
end
.
character
+
1
};
const
args
:
Proto
.
GetApplicableRefactorsRequestArgs
=
rangeToFileRange
(
file
,
range
);
try
{
const
response
=
await
this
.
client
.
execute
(
'
getApplicableRefactors
'
,
args
,
token
);
if
(
!
response
||
!
response
.
body
)
{
...
...
@@ -107,13 +100,9 @@ export default class TypeScriptRefactorProvider implements CodeActionProvider {
private
async
doRefactoring
(
file
:
string
,
refactor
:
string
,
action
:
string
,
range
:
Range
):
Promise
<
boolean
>
{
const
args
:
Proto
.
GetEditsForRefactorRequestArgs
=
{
file
,
...
rangeToFileRange
(
file
,
range
)
,
refactor
,
action
,
startLine
:
range
.
start
.
line
+
1
,
startOffset
:
range
.
start
.
character
+
1
,
endLine
:
range
.
end
.
line
+
1
,
endOffset
:
range
.
end
.
character
+
1
action
};
const
response
=
await
this
.
client
.
execute
(
'
getEditsForRefactor
'
,
args
);
...
...
extensions/typescript/src/features/referenceProvider.ts
浏览文件 @
703e7408
...
...
@@ -5,9 +5,8 @@
import
{
ReferenceProvider
,
Location
,
TextDocument
,
Position
,
CancellationToken
}
from
'
vscode
'
;
import
*
as
Proto
from
'
../protocol
'
;
import
{
ITypescriptServiceClient
}
from
'
../typescriptService
'
;
import
{
textSpanToRange
}
from
'
../utils/convert
'
;
import
{
textSpanToRange
,
positionToFileLocation
}
from
'
../utils/convert
'
;
export
default
class
TypeScriptReferenceSupport
implements
ReferenceProvider
{
public
constructor
(
...
...
@@ -18,11 +17,7 @@ export default class TypeScriptReferenceSupport implements ReferenceProvider {
if
(
!
filepath
)
{
return
Promise
.
resolve
<
Location
[]
>
([]);
}
const
args
:
Proto
.
FileLocationRequestArgs
=
{
file
:
filepath
,
line
:
position
.
line
+
1
,
offset
:
position
.
character
+
1
};
const
args
=
positionToFileLocation
(
filepath
,
position
);
const
apiVersion
=
this
.
client
.
apiVersion
;
return
this
.
client
.
execute
(
'
references
'
,
args
,
token
).
then
((
msg
)
=>
{
const
result
:
Location
[]
=
[];
...
...
extensions/typescript/src/features/referencesCodeLensProvider.ts
浏览文件 @
703e7408
...
...
@@ -9,7 +9,7 @@ import * as PConst from '../protocol.const';
import
{
TypeScriptBaseCodeLensProvider
,
ReferencesCodeLens
}
from
'
./baseCodeLensProvider
'
;
import
{
ITypescriptServiceClient
}
from
'
../typescriptService
'
;
import
{
textSpanToRange
}
from
'
../utils/convert
'
;
import
{
textSpanToRange
,
positionToFileLocation
}
from
'
../utils/convert
'
;
import
*
as
nls
from
'
vscode-nls
'
;
const
localize
=
nls
.
loadMessageBundle
();
...
...
@@ -36,11 +36,7 @@ export default class TypeScriptReferencesCodeLensProvider extends TypeScriptBase
resolveCodeLens
(
inputCodeLens
:
CodeLens
,
token
:
CancellationToken
):
Promise
<
CodeLens
>
{
const
codeLens
=
inputCodeLens
as
ReferencesCodeLens
;
const
args
:
Proto
.
FileLocationRequestArgs
=
{
file
:
codeLens
.
file
,
line
:
codeLens
.
range
.
start
.
line
+
1
,
offset
:
codeLens
.
range
.
start
.
character
+
1
};
const
args
=
positionToFileLocation
(
codeLens
.
file
,
codeLens
.
range
.
start
);
return
this
.
client
.
execute
(
'
references
'
,
args
,
token
).
then
(
response
=>
{
if
(
!
response
||
!
response
.
body
)
{
throw
codeLens
;
...
...
extensions/typescript/src/utils/convert.ts
浏览文件 @
703e7408
...
...
@@ -3,12 +3,25 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
Range
}
from
'
vscode
'
;
import
*
as
vscode
from
'
vscode
'
;
import
*
as
Proto
from
'
../protocol
'
;
export
const
textSpanToRange
=
(
span
:
Proto
.
TextSpan
)
=>
new
Range
(
new
vscode
.
Range
(
span
.
start
.
line
-
1
,
span
.
start
.
offset
-
1
,
span
.
end
.
line
-
1
,
span
.
end
.
offset
-
1
);
\ No newline at end of file
span
.
end
.
line
-
1
,
span
.
end
.
offset
-
1
);
export
const
positionToFileLocation
=
(
file
:
string
,
position
:
vscode
.
Position
):
Proto
.
FileLocationRequestArgs
=>
({
file
,
line
:
position
.
line
+
1
,
offset
:
position
.
character
+
1
});
export
const
rangeToFileRange
=
(
file
:
string
,
range
:
vscode
.
Range
):
Proto
.
FileRangeRequestArgs
=>
({
file
,
startLine
:
range
.
start
.
line
+
1
,
startOffset
:
range
.
start
.
character
+
1
,
endLine
:
range
.
end
.
line
+
1
,
endOffset
:
range
.
end
.
character
+
1
});
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录