Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
8d244787
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,发现更多精彩内容 >>
提交
8d244787
编写于
12月 18, 2017
作者:
S
SteVen Batten
提交者:
Matt Bierner
12月 18, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
updating the typescript extension codelens to cache requests for the navtree (#40402)
Fixes #28214
上级
f929c1bf
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
37 addition
and
10 deletion
+37
-10
extensions/typescript/src/features/baseCodeLensProvider.ts
extensions/typescript/src/features/baseCodeLensProvider.ts
+24
-2
extensions/typescript/src/features/implementationsCodeLensProvider.ts
...ypescript/src/features/implementationsCodeLensProvider.ts
+4
-3
extensions/typescript/src/features/referencesCodeLensProvider.ts
...ons/typescript/src/features/referencesCodeLensProvider.ts
+4
-3
extensions/typescript/src/typescriptMain.ts
extensions/typescript/src/typescriptMain.ts
+5
-2
未找到文件。
extensions/typescript/src/features/baseCodeLensProvider.ts
浏览文件 @
8d244787
...
@@ -19,12 +19,29 @@ export class ReferencesCodeLens extends CodeLens {
...
@@ -19,12 +19,29 @@ export class ReferencesCodeLens extends CodeLens {
}
}
}
}
export
class
CachedNavTreeResponse
{
response
?:
Promise
<
Proto
.
NavTreeResponse
>
;
version
:
number
=
-
1
;
document
:
string
=
''
;
matches
(
document
:
TextDocument
):
boolean
{
return
this
.
version
===
document
.
version
&&
this
.
document
===
document
.
uri
.
toString
();
}
update
(
document
:
TextDocument
,
response
:
Promise
<
Proto
.
NavTreeResponse
>
)
{
this
.
response
=
response
;
this
.
version
=
document
.
version
;
this
.
document
=
document
.
uri
.
toString
();
}
}
export
abstract
class
TypeScriptBaseCodeLensProvider
implements
CodeLensProvider
{
export
abstract
class
TypeScriptBaseCodeLensProvider
implements
CodeLensProvider
{
private
enabled
:
boolean
=
true
;
private
enabled
:
boolean
=
true
;
private
onDidChangeCodeLensesEmitter
=
new
EventEmitter
<
void
>
();
private
onDidChangeCodeLensesEmitter
=
new
EventEmitter
<
void
>
();
public
constructor
(
public
constructor
(
protected
client
:
ITypeScriptServiceClient
protected
client
:
ITypeScriptServiceClient
,
private
cachedResponse
:
CachedNavTreeResponse
)
{
}
)
{
}
public
get
onDidChangeCodeLenses
():
Event
<
void
>
{
public
get
onDidChangeCodeLenses
():
Event
<
void
>
{
...
@@ -48,10 +65,15 @@ export abstract class TypeScriptBaseCodeLensProvider implements CodeLensProvider
...
@@ -48,10 +65,15 @@ export abstract class TypeScriptBaseCodeLensProvider implements CodeLensProvider
return
[];
return
[];
}
}
try
{
try
{
const
response
=
await
this
.
client
.
execute
(
'
navtree
'
,
{
file
:
filepath
},
token
);
if
(
!
this
.
cachedResponse
.
matches
(
document
))
{
this
.
cachedResponse
.
update
(
document
,
this
.
client
.
execute
(
'
navtree
'
,
{
file
:
filepath
},
token
));
}
const
response
=
await
this
.
cachedResponse
.
response
;
if
(
!
response
)
{
if
(
!
response
)
{
return
[];
return
[];
}
}
const
tree
=
response
.
body
;
const
tree
=
response
.
body
;
const
referenceableSpans
:
Range
[]
=
[];
const
referenceableSpans
:
Range
[]
=
[];
if
(
tree
&&
tree
.
childItems
)
{
if
(
tree
&&
tree
.
childItems
)
{
...
...
extensions/typescript/src/features/implementationsCodeLensProvider.ts
浏览文件 @
8d244787
...
@@ -7,7 +7,7 @@ import { CodeLens, CancellationToken, TextDocument, Range, Location, workspace }
...
@@ -7,7 +7,7 @@ import { CodeLens, CancellationToken, TextDocument, Range, Location, workspace }
import
*
as
Proto
from
'
../protocol
'
;
import
*
as
Proto
from
'
../protocol
'
;
import
*
as
PConst
from
'
../protocol.const
'
;
import
*
as
PConst
from
'
../protocol.const
'
;
import
{
TypeScriptBaseCodeLensProvider
,
ReferencesCodeLens
}
from
'
./baseCodeLensProvider
'
;
import
{
TypeScriptBaseCodeLensProvider
,
ReferencesCodeLens
,
CachedNavTreeResponse
}
from
'
./baseCodeLensProvider
'
;
import
{
ITypeScriptServiceClient
}
from
'
../typescriptService
'
;
import
{
ITypeScriptServiceClient
}
from
'
../typescriptService
'
;
import
{
tsTextSpanToVsRange
,
vsPositionToTsFileLocation
}
from
'
../utils/convert
'
;
import
{
tsTextSpanToVsRange
,
vsPositionToTsFileLocation
}
from
'
../utils/convert
'
;
...
@@ -17,9 +17,10 @@ const localize = nls.loadMessageBundle();
...
@@ -17,9 +17,10 @@ const localize = nls.loadMessageBundle();
export
default
class
TypeScriptImplementationsCodeLensProvider
extends
TypeScriptBaseCodeLensProvider
{
export
default
class
TypeScriptImplementationsCodeLensProvider
extends
TypeScriptBaseCodeLensProvider
{
public
constructor
(
public
constructor
(
client
:
ITypeScriptServiceClient
,
client
:
ITypeScriptServiceClient
,
private
readonly
language
:
string
private
readonly
language
:
string
,
cachedResponse
:
CachedNavTreeResponse
)
{
)
{
super
(
client
);
super
(
client
,
cachedResponse
);
}
}
public
updateConfiguration
():
void
{
public
updateConfiguration
():
void
{
...
...
extensions/typescript/src/features/referencesCodeLensProvider.ts
浏览文件 @
8d244787
...
@@ -7,7 +7,7 @@ import { CodeLens, CancellationToken, TextDocument, Range, Location, workspace }
...
@@ -7,7 +7,7 @@ import { CodeLens, CancellationToken, TextDocument, Range, Location, workspace }
import
*
as
Proto
from
'
../protocol
'
;
import
*
as
Proto
from
'
../protocol
'
;
import
*
as
PConst
from
'
../protocol.const
'
;
import
*
as
PConst
from
'
../protocol.const
'
;
import
{
TypeScriptBaseCodeLensProvider
,
ReferencesCodeLens
}
from
'
./baseCodeLensProvider
'
;
import
{
TypeScriptBaseCodeLensProvider
,
ReferencesCodeLens
,
CachedNavTreeResponse
}
from
'
./baseCodeLensProvider
'
;
import
{
ITypeScriptServiceClient
}
from
'
../typescriptService
'
;
import
{
ITypeScriptServiceClient
}
from
'
../typescriptService
'
;
import
{
tsTextSpanToVsRange
,
vsPositionToTsFileLocation
}
from
'
../utils/convert
'
;
import
{
tsTextSpanToVsRange
,
vsPositionToTsFileLocation
}
from
'
../utils/convert
'
;
...
@@ -17,9 +17,10 @@ const localize = nls.loadMessageBundle();
...
@@ -17,9 +17,10 @@ const localize = nls.loadMessageBundle();
export
default
class
TypeScriptReferencesCodeLensProvider
extends
TypeScriptBaseCodeLensProvider
{
export
default
class
TypeScriptReferencesCodeLensProvider
extends
TypeScriptBaseCodeLensProvider
{
public
constructor
(
public
constructor
(
client
:
ITypeScriptServiceClient
,
client
:
ITypeScriptServiceClient
,
private
readonly
language
:
string
private
readonly
language
:
string
,
cachedResponse
:
CachedNavTreeResponse
)
{
)
{
super
(
client
);
super
(
client
,
cachedResponse
);
}
}
public
updateConfiguration
():
void
{
public
updateConfiguration
():
void
{
...
...
extensions/typescript/src/typescriptMain.ts
浏览文件 @
8d244787
...
@@ -37,6 +37,7 @@ import { CommandManager } from './utils/commandManager';
...
@@ -37,6 +37,7 @@ import { CommandManager } from './utils/commandManager';
import
DiagnosticsManager
from
'
./features/diagnostics
'
;
import
DiagnosticsManager
from
'
./features/diagnostics
'
;
import
{
LanguageDescription
}
from
'
./utils/languageDescription
'
;
import
{
LanguageDescription
}
from
'
./utils/languageDescription
'
;
import
*
as
fileSchemes
from
'
./utils/fileSchemes
'
;
import
*
as
fileSchemes
from
'
./utils/fileSchemes
'
;
import
{
CachedNavTreeResponse
}
from
'
./features/baseCodeLensProvider
'
;
const
validateSetting
=
'
validate.enable
'
;
const
validateSetting
=
'
validate.enable
'
;
...
@@ -148,12 +149,14 @@ class LanguageProvider {
...
@@ -148,12 +149,14 @@ class LanguageProvider {
this
.
disposables
.
push
(
languages
.
registerCodeActionsProvider
(
selector
,
new
(
await
import
(
'
./features/refactorProvider
'
)).
default
(
client
,
this
.
formattingOptionsManager
,
commandManager
)));
this
.
disposables
.
push
(
languages
.
registerCodeActionsProvider
(
selector
,
new
(
await
import
(
'
./features/refactorProvider
'
)).
default
(
client
,
this
.
formattingOptionsManager
,
commandManager
)));
this
.
registerVersionDependentProviders
();
this
.
registerVersionDependentProviders
();
const
referenceCodeLensProvider
=
new
(
await
import
(
'
./features/referencesCodeLensProvider
'
)).
default
(
client
,
this
.
description
.
id
);
const
cachedResponse
=
new
CachedNavTreeResponse
();
const
referenceCodeLensProvider
=
new
(
await
import
(
'
./features/referencesCodeLensProvider
'
)).
default
(
client
,
this
.
description
.
id
,
cachedResponse
);
referenceCodeLensProvider
.
updateConfiguration
();
referenceCodeLensProvider
.
updateConfiguration
();
this
.
toUpdateOnConfigurationChanged
.
push
(
referenceCodeLensProvider
);
this
.
toUpdateOnConfigurationChanged
.
push
(
referenceCodeLensProvider
);
this
.
disposables
.
push
(
languages
.
registerCodeLensProvider
(
selector
,
referenceCodeLensProvider
));
this
.
disposables
.
push
(
languages
.
registerCodeLensProvider
(
selector
,
referenceCodeLensProvider
));
const
implementationCodeLensProvider
=
new
(
await
import
(
'
./features/implementationsCodeLensProvider
'
)).
default
(
client
,
this
.
description
.
id
);
const
implementationCodeLensProvider
=
new
(
await
import
(
'
./features/implementationsCodeLensProvider
'
)).
default
(
client
,
this
.
description
.
id
,
cachedResponse
);
implementationCodeLensProvider
.
updateConfiguration
();
implementationCodeLensProvider
.
updateConfiguration
();
this
.
toUpdateOnConfigurationChanged
.
push
(
implementationCodeLensProvider
);
this
.
toUpdateOnConfigurationChanged
.
push
(
implementationCodeLensProvider
);
this
.
disposables
.
push
(
languages
.
registerCodeLensProvider
(
selector
,
implementationCodeLensProvider
));
this
.
disposables
.
push
(
languages
.
registerCodeLensProvider
(
selector
,
implementationCodeLensProvider
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录