Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
f1043f2b
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,发现更多精彩内容 >>
提交
f1043f2b
编写于
9月 19, 2017
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Continue moving vs loc to ts loc location into single set of functions
上级
703e7408
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
56 addition
and
60 deletion
+56
-60
extensions/typescript/src/features/baseCodeLensProvider.ts
extensions/typescript/src/features/baseCodeLensProvider.ts
+2
-2
extensions/typescript/src/features/codeActionProvider.ts
extensions/typescript/src/features/codeActionProvider.ts
+3
-3
extensions/typescript/src/features/completionItemProvider.ts
extensions/typescript/src/features/completionItemProvider.ts
+5
-7
extensions/typescript/src/features/definitionProviderBase.ts
extensions/typescript/src/features/definitionProviderBase.ts
+3
-3
extensions/typescript/src/features/documentHighlightProvider.ts
...ions/typescript/src/features/documentHighlightProvider.ts
+3
-3
extensions/typescript/src/features/documentSymbolProvider.ts
extensions/typescript/src/features/documentSymbolProvider.ts
+3
-3
extensions/typescript/src/features/formattingProvider.ts
extensions/typescript/src/features/formattingProvider.ts
+2
-2
extensions/typescript/src/features/hoverProvider.ts
extensions/typescript/src/features/hoverProvider.ts
+3
-3
extensions/typescript/src/features/implementationsCodeLensProvider.ts
...ypescript/src/features/implementationsCodeLensProvider.ts
+3
-3
extensions/typescript/src/features/jsDocCompletionProvider.ts
...nsions/typescript/src/features/jsDocCompletionProvider.ts
+2
-2
extensions/typescript/src/features/refactorProvider.ts
extensions/typescript/src/features/refactorProvider.ts
+6
-7
extensions/typescript/src/features/referenceProvider.ts
extensions/typescript/src/features/referenceProvider.ts
+3
-3
extensions/typescript/src/features/referencesCodeLensProvider.ts
...ons/typescript/src/features/referencesCodeLensProvider.ts
+3
-3
extensions/typescript/src/features/renameProvider.ts
extensions/typescript/src/features/renameProvider.ts
+3
-5
extensions/typescript/src/features/signatureHelpProvider.ts
extensions/typescript/src/features/signatureHelpProvider.ts
+2
-5
extensions/typescript/src/features/workspaceSymbolProvider.ts
...nsions/typescript/src/features/workspaceSymbolProvider.ts
+2
-2
extensions/typescript/src/typescriptMain.ts
extensions/typescript/src/typescriptMain.ts
+2
-1
extensions/typescript/src/utils/convert.ts
extensions/typescript/src/utils/convert.ts
+6
-3
未找到文件。
extensions/typescript/src/features/baseCodeLensProvider.ts
浏览文件 @
f1043f2b
...
...
@@ -7,7 +7,7 @@ import { CodeLensProvider, CodeLens, CancellationToken, TextDocument, Range, Uri
import
*
as
Proto
from
'
../protocol
'
;
import
{
ITypescriptServiceClient
}
from
'
../typescriptService
'
;
import
{
t
extSpanTo
Range
}
from
'
../utils/convert
'
;
import
{
t
sTextSpanToVs
Range
}
from
'
../utils/convert
'
;
export
class
ReferencesCodeLens
extends
CodeLens
{
constructor
(
...
...
@@ -100,7 +100,7 @@ export abstract class TypeScriptBaseCodeLensProvider implements CodeLensProvider
return
null
;
}
const
range
=
t
extSpanTo
Range
(
span
);
const
range
=
t
sTextSpanToVs
Range
(
span
);
const
text
=
document
.
getText
(
range
);
const
identifierMatch
=
new
RegExp
(
`^(.*?(\\b|\\W))
${(
item
.
text
||
''
).
replace
(
/
[
-[
\]
{}()*+?.,
\\
^$|#
\s]
/g
,
'
\\
$&
'
)}
(\\b|\\W)`
,
'
gm
'
);
...
...
extensions/typescript/src/features/codeActionProvider.ts
浏览文件 @
f1043f2b
...
...
@@ -7,7 +7,7 @@ import { CodeActionProvider, TextDocument, Range, CancellationToken, CodeActionC
import
*
as
Proto
from
'
../protocol
'
;
import
{
ITypescriptServiceClient
}
from
'
../typescriptService
'
;
import
{
t
extSpanToRange
,
rangeTo
FileRange
}
from
'
../utils/convert
'
;
import
{
t
sTextSpanToVsRange
,
vsRangeToTs
FileRange
}
from
'
../utils/convert
'
;
interface
NumberSet
{
[
key
:
number
]:
boolean
;
...
...
@@ -68,7 +68,7 @@ export default class TypeScriptCodeActionProvider implements CodeActionProvider
formattingOptions
:
formattingOptions
};
const
args
:
Proto
.
CodeFixRequestArgs
=
{
...
rangeTo
FileRange
(
file
,
range
),
...
vsRangeToTs
FileRange
(
file
,
range
),
errorCodes
:
Array
.
from
(
supportedActions
)
};
const
response
=
await
this
.
client
.
execute
(
'
getCodeFixes
'
,
args
,
token
);
...
...
@@ -109,7 +109,7 @@ export default class TypeScriptCodeActionProvider implements CodeActionProvider
for
(
const
change
of
action
.
changes
)
{
for
(
const
textChange
of
change
.
textChanges
)
{
workspaceEdit
.
replace
(
this
.
client
.
asUrl
(
change
.
fileName
),
t
extSpanTo
Range
(
textChange
),
t
sTextSpanToVs
Range
(
textChange
),
textChange
.
newText
);
}
}
...
...
extensions/typescript/src/features/completionItemProvider.ts
浏览文件 @
f1043f2b
...
...
@@ -11,7 +11,7 @@ import TypingsStatus from '../utils/typingsStatus';
import
*
as
PConst
from
'
../protocol.const
'
;
import
{
CompletionEntry
,
CompletionsRequestArgs
,
CompletionDetailsRequestArgs
,
CompletionEntryDetails
}
from
'
../protocol
'
;
import
*
as
Previewer
from
'
./previewer
'
;
import
{
t
extSpanToRange
,
positionTo
FileLocation
}
from
'
../utils/convert
'
;
import
{
t
sTextSpanToVsRange
,
vsPositionToTs
FileLocation
}
from
'
../utils/convert
'
;
import
*
as
nls
from
'
vscode-nls
'
;
let
localize
=
nls
.
loadMessageBundle
();
...
...
@@ -33,7 +33,7 @@ class MyCompletionItem extends CompletionItem {
let
span
:
protocol
.
TextSpan
=
entry
.
replacementSpan
;
// The indexing for the range returned by the server uses 1-based indexing.
// We convert to 0-based indexing.
this
.
textEdit
=
TextEdit
.
replace
(
t
extSpanTo
Range
(
span
),
entry
.
name
);
this
.
textEdit
=
TextEdit
.
replace
(
t
sTextSpanToVs
Range
(
span
),
entry
.
name
);
}
else
{
// Try getting longer, prefix based range for completions that span words
const
wordRange
=
document
.
getWordRangeAtPosition
(
position
);
...
...
@@ -175,7 +175,7 @@ export default class TypeScriptCompletionItemProvider implements CompletionItemP
if
(
!
file
)
{
return
Promise
.
resolve
<
CompletionItem
[]
>
([]);
}
const
args
:
CompletionsRequestArgs
=
positionTo
FileLocation
(
file
,
position
);
const
args
:
CompletionsRequestArgs
=
vsPositionToTs
FileLocation
(
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;
...
...
@@ -234,9 +234,7 @@ export default class TypeScriptCompletionItemProvider implements CompletionItemP
return
null
;
}
const
args
:
CompletionDetailsRequestArgs
=
{
file
:
filepath
,
line
:
item
.
position
.
line
+
1
,
offset
:
item
.
position
.
character
+
1
,
...
vsPositionToTsFileLocation
(
filepath
,
item
.
position
),
entryNames
:
[
item
.
label
]
};
return
this
.
client
.
execute
(
'
completionEntryDetails
'
,
args
,
token
).
then
((
response
)
=>
{
...
...
@@ -265,7 +263,7 @@ export default class TypeScriptCompletionItemProvider implements CompletionItemP
}
private
isValidFunctionCompletionContext
(
filepath
:
string
,
position
:
Position
):
Promise
<
boolean
>
{
const
args
=
positionTo
FileLocation
(
filepath
,
position
);
const
args
=
vsPositionToTs
FileLocation
(
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
浏览文件 @
f1043f2b
...
...
@@ -7,7 +7,7 @@ import { TextDocument, Position, CancellationToken, Location } from 'vscode';
import
*
as
Proto
from
'
../protocol
'
;
import
{
ITypescriptServiceClient
}
from
'
../typescriptService
'
;
import
{
t
extSpanToRange
,
positionTo
FileLocation
}
from
'
../utils/convert
'
;
import
{
t
sTextSpanToVsRange
,
vsPositionToTs
FileLocation
}
from
'
../utils/convert
'
;
export
default
class
TypeScriptDefinitionProviderBase
{
constructor
(
...
...
@@ -23,7 +23,7 @@ export default class TypeScriptDefinitionProviderBase {
if
(
!
filepath
)
{
return
Promise
.
resolve
(
null
);
}
const
args
=
positionTo
FileLocation
(
filepath
,
position
);
const
args
=
vsPositionToTs
FileLocation
(
filepath
,
position
);
return
this
.
client
.
execute
(
definitionType
,
args
,
token
).
then
(
response
=>
{
const
locations
:
Proto
.
FileSpan
[]
=
(
response
&&
response
.
body
)
||
[];
if
(
!
locations
||
locations
.
length
===
0
)
{
...
...
@@ -34,7 +34,7 @@ export default class TypeScriptDefinitionProviderBase {
if
(
resource
===
null
)
{
return
null
;
}
else
{
return
new
Location
(
resource
,
t
extSpanTo
Range
(
location
));
return
new
Location
(
resource
,
t
sTextSpanToVs
Range
(
location
));
}
}).
filter
(
x
=>
x
!==
null
)
as
Location
[];
},
()
=>
{
...
...
extensions/typescript/src/features/documentHighlightProvider.ts
浏览文件 @
f1043f2b
...
...
@@ -6,7 +6,7 @@
import
{
DocumentHighlightProvider
,
DocumentHighlight
,
DocumentHighlightKind
,
TextDocument
,
Position
,
Range
,
CancellationToken
}
from
'
vscode
'
;
import
{
ITypescriptServiceClient
}
from
'
../typescriptService
'
;
import
{
t
extSpanToRange
,
positionTo
FileLocation
}
from
'
../utils/convert
'
;
import
{
t
sTextSpanToVsRange
,
vsPositionToTs
FileLocation
}
from
'
../utils/convert
'
;
export
default
class
TypeScriptDocumentHighlightProvider
implements
DocumentHighlightProvider
{
...
...
@@ -18,7 +18,7 @@ export default class TypeScriptDocumentHighlightProvider implements DocumentHigh
if
(
!
filepath
)
{
return
Promise
.
resolve
<
DocumentHighlight
[]
>
([]);
}
const
args
=
positionTo
FileLocation
(
filepath
,
position
);
const
args
=
vsPositionToTs
FileLocation
(
filepath
,
position
);
return
this
.
client
.
execute
(
'
occurrences
'
,
args
,
token
).
then
((
response
):
DocumentHighlight
[]
=>
{
let
data
=
response
.
body
;
if
(
data
&&
data
.
length
)
{
...
...
@@ -35,7 +35,7 @@ export default class TypeScriptDocumentHighlightProvider implements DocumentHigh
}
return
data
.
map
(
item
=>
new
DocumentHighlight
(
t
extSpanTo
Range
(
item
),
t
sTextSpanToVs
Range
(
item
),
item
.
isWriteAccess
?
DocumentHighlightKind
.
Write
:
DocumentHighlightKind
.
Read
));
}
return
[];
...
...
extensions/typescript/src/features/documentSymbolProvider.ts
浏览文件 @
f1043f2b
...
...
@@ -8,7 +8,7 @@ import { DocumentSymbolProvider, SymbolInformation, SymbolKind, TextDocument, Lo
import
*
as
Proto
from
'
../protocol
'
;
import
*
as
PConst
from
'
../protocol.const
'
;
import
{
ITypescriptServiceClient
}
from
'
../typescriptService
'
;
import
{
t
extSpanTo
Range
}
from
'
../utils/convert
'
;
import
{
t
sTextSpanToVs
Range
}
from
'
../utils/convert
'
;
const
outlineTypeTable
:
{
[
kind
:
string
]:
SymbolKind
}
=
Object
.
create
(
null
);
outlineTypeTable
[
PConst
.
Kind
.
module
]
=
SymbolKind
.
Module
;
...
...
@@ -71,7 +71,7 @@ export default class TypeScriptDocumentSymbolProvider implements DocumentSymbolP
let
result
=
new
SymbolInformation
(
item
.
text
,
outlineTypeTable
[
item
.
kind
as
string
]
||
SymbolKind
.
Variable
,
containerLabel
?
containerLabel
:
''
,
new
Location
(
resource
,
t
extSpanTo
Range
(
item
.
spans
[
0
])));
new
Location
(
resource
,
t
sTextSpanToVs
Range
(
item
.
spans
[
0
])));
foldingMap
[
key
]
=
result
;
bucket
.
push
(
result
);
}
...
...
@@ -86,7 +86,7 @@ export default class TypeScriptDocumentSymbolProvider implements DocumentSymbolP
const
result
=
new
SymbolInformation
(
item
.
text
,
outlineTypeTable
[
item
.
kind
as
string
]
||
SymbolKind
.
Variable
,
containerLabel
?
containerLabel
:
''
,
new
Location
(
resource
,
t
extSpanTo
Range
(
item
.
spans
[
0
]))
new
Location
(
resource
,
t
sTextSpanToVs
Range
(
item
.
spans
[
0
]))
);
if
(
item
.
childItems
&&
item
.
childItems
.
length
>
0
)
{
for
(
const
child
of
item
.
childItems
)
{
...
...
extensions/typescript/src/features/formattingProvider.ts
浏览文件 @
f1043f2b
...
...
@@ -7,7 +7,7 @@ import { workspace as Workspace, DocumentRangeFormattingEditProvider, OnTypeForm
import
*
as
Proto
from
'
../protocol
'
;
import
{
ITypescriptServiceClient
}
from
'
../typescriptService
'
;
import
{
t
extSpanTo
Range
}
from
'
../utils/convert
'
;
import
{
t
sTextSpanToVs
Range
}
from
'
../utils/convert
'
;
interface
Configuration
{
enable
:
boolean
;
...
...
@@ -206,7 +206,7 @@ export class TypeScriptFormattingProvider implements DocumentRangeFormattingEdit
}
private
codeEdit2SingleEditOperation
(
edit
:
Proto
.
CodeEdit
):
TextEdit
{
return
new
TextEdit
(
t
extSpanTo
Range
(
edit
),
edit
.
newText
);
return
new
TextEdit
(
t
sTextSpanToVs
Range
(
edit
),
edit
.
newText
);
}
private
getFormatOptions
(
options
:
FormattingOptions
):
Proto
.
FormatCodeSettings
{
...
...
extensions/typescript/src/features/hoverProvider.ts
浏览文件 @
f1043f2b
...
...
@@ -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
{
t
extSpanToRange
,
positionTo
FileLocation
}
from
'
../utils/convert
'
;
import
{
t
sTextSpanToVsRange
,
vsPositionToTs
FileLocation
}
from
'
../utils/convert
'
;
export
default
class
TypeScriptHoverProvider
implements
HoverProvider
{
...
...
@@ -20,14 +20,14 @@ export default class TypeScriptHoverProvider implements HoverProvider {
if
(
!
filepath
)
{
return
undefined
;
}
const
args
=
positionTo
FileLocation
(
filepath
,
position
);
const
args
=
vsPositionToTs
FileLocation
(
filepath
,
position
);
try
{
const
response
=
await
this
.
client
.
execute
(
'
quickinfo
'
,
args
,
token
);
if
(
response
&&
response
.
body
)
{
const
data
=
response
.
body
;
return
new
Hover
(
TypeScriptHoverProvider
.
getContents
(
data
),
t
extSpanTo
Range
(
data
));
t
sTextSpanToVs
Range
(
data
));
}
}
catch
(
e
)
{
// noop
...
...
extensions/typescript/src/features/implementationsCodeLensProvider.ts
浏览文件 @
f1043f2b
...
...
@@ -9,7 +9,7 @@ import * as PConst from '../protocol.const';
import
{
TypeScriptBaseCodeLensProvider
,
ReferencesCodeLens
}
from
'
./baseCodeLensProvider
'
;
import
{
ITypescriptServiceClient
}
from
'
../typescriptService
'
;
import
{
t
extSpanToRange
,
positionTo
FileLocation
}
from
'
../utils/convert
'
;
import
{
t
sTextSpanToVsRange
,
vsPositionToTs
FileLocation
}
from
'
../utils/convert
'
;
import
*
as
nls
from
'
vscode-nls
'
;
const
localize
=
nls
.
loadMessageBundle
();
...
...
@@ -36,7 +36,7 @@ export default class TypeScriptImplementationsCodeLensProvider extends TypeScrip
resolveCodeLens
(
inputCodeLens
:
CodeLens
,
token
:
CancellationToken
):
Promise
<
CodeLens
>
{
const
codeLens
=
inputCodeLens
as
ReferencesCodeLens
;
const
args
=
positionTo
FileLocation
(
codeLens
.
file
,
codeLens
.
range
.
start
);
const
args
=
vsPositionToTs
FileLocation
(
codeLens
.
file
,
codeLens
.
range
.
start
);
return
this
.
client
.
execute
(
'
implementation
'
,
args
,
token
).
then
(
response
=>
{
if
(
!
response
||
!
response
.
body
)
{
throw
codeLens
;
...
...
@@ -47,7 +47,7 @@ export default class TypeScriptImplementationsCodeLensProvider extends TypeScrip
// Only take first line on implementation: https://github.com/Microsoft/vscode/issues/23924
new
Location
(
this
.
client
.
asUrl
(
reference
.
file
),
reference
.
start
.
line
===
reference
.
end
.
line
?
t
extSpanTo
Range
(
reference
)
?
t
sTextSpanToVs
Range
(
reference
)
:
new
Range
(
reference
.
start
.
line
-
1
,
reference
.
start
.
offset
-
1
,
reference
.
start
.
line
,
0
)))
...
...
extensions/typescript/src/features/jsDocCompletionProvider.ts
浏览文件 @
f1043f2b
...
...
@@ -9,7 +9,7 @@ import { ITypescriptServiceClient } from '../typescriptService';
import
{
DocCommandTemplateResponse
}
from
'
../protocol
'
;
import
*
as
nls
from
'
vscode-nls
'
;
import
{
positionTo
FileLocation
}
from
'
../utils/convert
'
;
import
{
vsPositionToTs
FileLocation
}
from
'
../utils/convert
'
;
const
localize
=
nls
.
loadMessageBundle
();
const
configurationNamespace
=
'
jsDocCompletion
'
;
...
...
@@ -119,7 +119,7 @@ export class TryCompleteJsDocCommand {
}
private
tryInsertJsDocFromTemplate
(
editor
:
TextEditor
,
file
:
string
,
position
:
Position
):
Promise
<
boolean
>
{
const
args
=
positionTo
FileLocation
(
file
,
position
);
const
args
=
vsPositionToTs
FileLocation
(
file
,
position
);
return
Promise
.
race
([
this
.
lazyClient
().
execute
(
'
docCommentTemplate
'
,
args
),
new
Promise
((
_
,
reject
)
=>
setTimeout
(
reject
,
250
))
...
...
extensions/typescript/src/features/refactorProvider.ts
浏览文件 @
f1043f2b
...
...
@@ -5,11 +5,11 @@
'
use strict
'
;
import
{
CodeActionProvider
,
TextDocument
,
Range
,
CancellationToken
,
CodeActionContext
,
Command
,
commands
,
workspace
,
WorkspaceEdit
,
window
,
QuickPickItem
,
Selection
,
Position
}
from
'
vscode
'
;
import
{
CodeActionProvider
,
TextDocument
,
Range
,
CancellationToken
,
CodeActionContext
,
Command
,
commands
,
workspace
,
WorkspaceEdit
,
window
,
QuickPickItem
,
Selection
}
from
'
vscode
'
;
import
*
as
Proto
from
'
../protocol
'
;
import
{
ITypescriptServiceClient
}
from
'
../typescriptService
'
;
import
{
t
extSpanToRange
,
rangeToFileRange
}
from
'
../utils/convert
'
;
import
{
t
sTextSpanToVsRange
,
vsRangeToTsFileRange
,
tsLocationToVsPosition
}
from
'
../utils/convert
'
;
export
default
class
TypeScriptRefactorProvider
implements
CodeActionProvider
{
...
...
@@ -25,7 +25,6 @@ export default class TypeScriptRefactorProvider implements CodeActionProvider {
commands
.
registerCommand
(
this
.
doRefactorCommandId
,
this
.
doRefactoring
,
this
);
commands
.
registerCommand
(
this
.
selectRefactorCommandId
,
this
.
selectRefactoring
,
this
);
}
public
async
provideCodeActions
(
...
...
@@ -43,7 +42,7 @@ export default class TypeScriptRefactorProvider implements CodeActionProvider {
return
[];
}
const
args
:
Proto
.
GetApplicableRefactorsRequestArgs
=
rangeTo
FileRange
(
file
,
range
);
const
args
:
Proto
.
GetApplicableRefactorsRequestArgs
=
vsRangeToTs
FileRange
(
file
,
range
);
try
{
const
response
=
await
this
.
client
.
execute
(
'
getApplicableRefactors
'
,
args
,
token
);
if
(
!
response
||
!
response
.
body
)
{
...
...
@@ -79,7 +78,7 @@ export default class TypeScriptRefactorProvider implements CodeActionProvider {
for
(
const
edit
of
edits
)
{
for
(
const
textChange
of
edit
.
textChanges
)
{
workspaceEdit
.
replace
(
this
.
client
.
asUrl
(
edit
.
fileName
),
t
extSpanTo
Range
(
textChange
),
t
sTextSpanToVs
Range
(
textChange
),
textChange
.
newText
);
}
}
...
...
@@ -100,7 +99,7 @@ export default class TypeScriptRefactorProvider implements CodeActionProvider {
private
async
doRefactoring
(
file
:
string
,
refactor
:
string
,
action
:
string
,
range
:
Range
):
Promise
<
boolean
>
{
const
args
:
Proto
.
GetEditsForRefactorRequestArgs
=
{
...
rangeTo
FileRange
(
file
,
range
),
...
vsRangeToTs
FileRange
(
file
,
range
),
refactor
,
action
};
...
...
@@ -118,7 +117,7 @@ export default class TypeScriptRefactorProvider implements CodeActionProvider {
const
renameLocation
=
response
.
body
.
renameLocation
;
if
(
renameLocation
)
{
if
(
window
.
activeTextEditor
&&
window
.
activeTextEditor
.
document
.
uri
.
fsPath
===
file
)
{
const
pos
=
new
Position
(
renameLocation
.
line
-
1
,
renameLocation
.
offset
-
1
);
const
pos
=
tsLocationToVsPosition
(
renameLocation
);
window
.
activeTextEditor
.
selection
=
new
Selection
(
pos
,
pos
);
await
commands
.
executeCommand
(
'
editor.action.rename
'
);
}
...
...
extensions/typescript/src/features/referenceProvider.ts
浏览文件 @
f1043f2b
...
...
@@ -6,7 +6,7 @@
import
{
ReferenceProvider
,
Location
,
TextDocument
,
Position
,
CancellationToken
}
from
'
vscode
'
;
import
{
ITypescriptServiceClient
}
from
'
../typescriptService
'
;
import
{
t
extSpanToRange
,
positionTo
FileLocation
}
from
'
../utils/convert
'
;
import
{
t
sTextSpanToVsRange
,
vsPositionToTs
FileLocation
}
from
'
../utils/convert
'
;
export
default
class
TypeScriptReferenceSupport
implements
ReferenceProvider
{
public
constructor
(
...
...
@@ -17,7 +17,7 @@ export default class TypeScriptReferenceSupport implements ReferenceProvider {
if
(
!
filepath
)
{
return
Promise
.
resolve
<
Location
[]
>
([]);
}
const
args
=
positionTo
FileLocation
(
filepath
,
position
);
const
args
=
vsPositionToTs
FileLocation
(
filepath
,
position
);
const
apiVersion
=
this
.
client
.
apiVersion
;
return
this
.
client
.
execute
(
'
references
'
,
args
,
token
).
then
((
msg
)
=>
{
const
result
:
Location
[]
=
[];
...
...
@@ -31,7 +31,7 @@ export default class TypeScriptReferenceSupport implements ReferenceProvider {
continue
;
}
const
url
=
this
.
client
.
asUrl
(
ref
.
file
);
const
location
=
new
Location
(
url
,
t
extSpanTo
Range
(
ref
));
const
location
=
new
Location
(
url
,
t
sTextSpanToVs
Range
(
ref
));
result
.
push
(
location
);
}
return
result
;
...
...
extensions/typescript/src/features/referencesCodeLensProvider.ts
浏览文件 @
f1043f2b
...
...
@@ -9,7 +9,7 @@ import * as PConst from '../protocol.const';
import
{
TypeScriptBaseCodeLensProvider
,
ReferencesCodeLens
}
from
'
./baseCodeLensProvider
'
;
import
{
ITypescriptServiceClient
}
from
'
../typescriptService
'
;
import
{
t
extSpanToRange
,
positionTo
FileLocation
}
from
'
../utils/convert
'
;
import
{
t
sTextSpanToVsRange
,
vsPositionToTs
FileLocation
}
from
'
../utils/convert
'
;
import
*
as
nls
from
'
vscode-nls
'
;
const
localize
=
nls
.
loadMessageBundle
();
...
...
@@ -36,7 +36,7 @@ export default class TypeScriptReferencesCodeLensProvider extends TypeScriptBase
resolveCodeLens
(
inputCodeLens
:
CodeLens
,
token
:
CancellationToken
):
Promise
<
CodeLens
>
{
const
codeLens
=
inputCodeLens
as
ReferencesCodeLens
;
const
args
=
positionTo
FileLocation
(
codeLens
.
file
,
codeLens
.
range
.
start
);
const
args
=
vsPositionToTs
FileLocation
(
codeLens
.
file
,
codeLens
.
range
.
start
);
return
this
.
client
.
execute
(
'
references
'
,
args
,
token
).
then
(
response
=>
{
if
(
!
response
||
!
response
.
body
)
{
throw
codeLens
;
...
...
@@ -44,7 +44,7 @@ export default class TypeScriptReferencesCodeLensProvider extends TypeScriptBase
const
locations
=
response
.
body
.
refs
.
map
(
reference
=>
new
Location
(
this
.
client
.
asUrl
(
reference
.
file
),
t
extSpanTo
Range
(
reference
)))
new
Location
(
this
.
client
.
asUrl
(
reference
.
file
),
t
sTextSpanToVs
Range
(
reference
)))
.
filter
(
location
=>
// Exclude original definition from references
!
(
location
.
uri
.
fsPath
===
codeLens
.
document
.
fsPath
&&
...
...
extensions/typescript/src/features/renameProvider.ts
浏览文件 @
f1043f2b
...
...
@@ -7,7 +7,7 @@ import { RenameProvider, WorkspaceEdit, TextDocument, Position, CancellationToke
import
*
as
Proto
from
'
../protocol
'
;
import
{
ITypescriptServiceClient
}
from
'
../typescriptService
'
;
import
{
t
extSpanToRange
}
from
'
../utils/convert
'
;
import
{
t
sTextSpanToVsRange
,
vsPositionToTsFileLocation
}
from
'
../utils/convert
'
;
export
default
class
TypeScriptRenameProvider
implements
RenameProvider
{
public
constructor
(
...
...
@@ -25,9 +25,7 @@ export default class TypeScriptRenameProvider implements RenameProvider {
}
const
args
:
Proto
.
RenameRequestArgs
=
{
file
:
filepath
,
line
:
position
.
line
+
1
,
offset
:
position
.
character
+
1
,
...
vsPositionToTsFileLocation
(
filepath
,
position
),
findInStrings
:
false
,
findInComments
:
false
};
...
...
@@ -50,7 +48,7 @@ export default class TypeScriptRenameProvider implements RenameProvider {
continue
;
}
for
(
const
textSpan
of
spanGroup
.
locs
)
{
result
.
replace
(
resource
,
t
extSpanTo
Range
(
textSpan
),
newName
);
result
.
replace
(
resource
,
t
sTextSpanToVs
Range
(
textSpan
),
newName
);
}
}
return
result
;
...
...
extensions/typescript/src/features/signatureHelpProvider.ts
浏览文件 @
f1043f2b
...
...
@@ -8,6 +8,7 @@ import { SignatureHelpProvider, SignatureHelp, SignatureInformation, ParameterIn
import
*
as
Previewer
from
'
./previewer
'
;
import
*
as
Proto
from
'
../protocol
'
;
import
{
ITypescriptServiceClient
}
from
'
../typescriptService
'
;
import
{
vsPositionToTsFileLocation
}
from
'
../utils/convert
'
;
export
default
class
TypeScriptSignatureHelpProvider
implements
SignatureHelpProvider
{
...
...
@@ -19,11 +20,7 @@ export default class TypeScriptSignatureHelpProvider implements SignatureHelpPro
if
(
!
filepath
)
{
return
Promise
.
resolve
(
null
);
}
const
args
:
Proto
.
SignatureHelpRequestArgs
=
{
file
:
filepath
,
line
:
position
.
line
+
1
,
offset
:
position
.
character
+
1
};
const
args
:
Proto
.
SignatureHelpRequestArgs
=
vsPositionToTsFileLocation
(
filepath
,
position
);
return
this
.
client
.
execute
(
'
signatureHelp
'
,
args
,
token
).
then
((
response
)
=>
{
const
info
=
response
.
body
;
if
(
!
info
)
{
...
...
extensions/typescript/src/features/workspaceSymbolProvider.ts
浏览文件 @
f1043f2b
...
...
@@ -7,7 +7,7 @@ import { workspace, window, Uri, WorkspaceSymbolProvider, SymbolInformation, Sym
import
*
as
Proto
from
'
../protocol
'
;
import
{
ITypescriptServiceClient
}
from
'
../typescriptService
'
;
import
{
t
extSpanTo
Range
}
from
'
../utils/convert
'
;
import
{
t
sTextSpanToVs
Range
}
from
'
../utils/convert
'
;
function
getSymbolKind
(
item
:
Proto
.
NavtoItem
):
SymbolKind
{
switch
(
item
.
kind
)
{
...
...
@@ -68,7 +68,7 @@ export default class TypeScriptWorkspaceSymbolProvider implements WorkspaceSymbo
if
(
!
item
.
containerName
&&
item
.
kind
===
'
alias
'
)
{
continue
;
}
const
range
=
t
extSpanTo
Range
(
item
);
const
range
=
t
sTextSpanToVs
Range
(
item
);
let
label
=
item
.
name
;
if
(
item
.
kind
===
'
method
'
||
item
.
kind
===
'
function
'
)
{
label
+=
'
()
'
;
...
...
extensions/typescript/src/typescriptMain.ts
浏览文件 @
f1043f2b
...
...
@@ -33,6 +33,7 @@ import TypingsStatus, { AtaProgressReporter } from './utils/typingsStatus';
import
VersionStatus
from
'
./utils/versionStatus
'
;
import
{
getContributedTypeScriptServerPlugins
,
TypeScriptServerPlugin
}
from
'
./utils/plugins
'
;
import
{
openOrCreateConfigFile
,
isImplicitProjectConfigFile
}
from
'
./utils/tsconfig
'
;
import
{
tsLocationToVsPosition
}
from
'
./utils/convert
'
;
interface
LanguageDescription
{
id
:
string
;
...
...
@@ -681,7 +682,7 @@ class TypeScriptServiceClientHost implements ITypescriptServiceClientHost {
const
result
:
Diagnostic
[]
=
[];
for
(
let
diagnostic
of
diagnostics
)
{
const
{
start
,
end
,
text
}
=
diagnostic
;
const
range
=
new
Range
(
start
.
line
-
1
,
start
.
offset
-
1
,
end
.
line
-
1
,
end
.
offset
-
1
);
const
range
=
new
Range
(
tsLocationToVsPosition
(
start
),
tsLocationToVsPosition
(
end
)
);
const
converted
=
new
Diagnostic
(
range
,
text
);
converted
.
severity
=
this
.
getDiagnosticSeverity
(
diagnostic
);
converted
.
source
=
diagnostic
.
source
||
source
;
...
...
extensions/typescript/src/utils/convert.ts
浏览文件 @
f1043f2b
...
...
@@ -7,18 +7,21 @@ import * as vscode from 'vscode';
import
*
as
Proto
from
'
../protocol
'
;
export
const
t
extSpanTo
Range
=
(
span
:
Proto
.
TextSpan
)
=>
export
const
t
sTextSpanToVs
Range
=
(
span
:
Proto
.
TextSpan
)
=>
new
vscode
.
Range
(
span
.
start
.
line
-
1
,
span
.
start
.
offset
-
1
,
span
.
end
.
line
-
1
,
span
.
end
.
offset
-
1
);
export
const
positionToFileLocation
=
(
file
:
string
,
position
:
vscode
.
Position
):
Proto
.
FileLocationRequestArgs
=>
({
export
const
tsLocationToVsPosition
=
(
tslocation
:
Proto
.
Location
)
=>
new
vscode
.
Position
(
tslocation
.
line
-
1
,
tslocation
.
offset
-
1
);
export
const
vsPositionToTsFileLocation
=
(
file
:
string
,
position
:
vscode
.
Position
):
Proto
.
FileLocationRequestArgs
=>
({
file
,
line
:
position
.
line
+
1
,
offset
:
position
.
character
+
1
});
export
const
rangeTo
FileRange
=
(
file
:
string
,
range
:
vscode
.
Range
):
Proto
.
FileRangeRequestArgs
=>
({
export
const
vsRangeToTs
FileRange
=
(
file
:
string
,
range
:
vscode
.
Range
):
Proto
.
FileRangeRequestArgs
=>
({
file
,
startLine
:
range
.
start
.
line
+
1
,
startOffset
:
range
.
start
.
character
+
1
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录