Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
7c13230a
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,体验更适合开发者的 AI 搜索 >>
提交
7c13230a
编写于
11月 30, 2017
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Setup basic typescript.isManagedFile context
上级
04c4491a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
62 addition
and
8 deletion
+62
-8
extensions/typescript/package.json
extensions/typescript/package.json
+7
-7
extensions/typescript/src/extension.ts
extensions/typescript/src/extension.ts
+3
-0
extensions/typescript/src/features/taskProvider.ts
extensions/typescript/src/features/taskProvider.ts
+1
-1
extensions/typescript/src/utils/managedFileContext.ts
extensions/typescript/src/utils/managedFileContext.ts
+51
-0
未找到文件。
extensions/typescript/package.json
浏览文件 @
7c13230a
...
...
@@ -483,23 +483,23 @@
"commandPalette"
:
[
{
"command"
:
"typescript.reloadProjects"
,
"when"
:
"editorLangId ==
'typescript'
"
"when"
:
"editorLangId ==
typescript && typescript.isManagedFile
"
},
{
"command"
:
"typescript.reloadProjects"
,
"when"
:
"editorLangId == typescriptreact"
"when"
:
"editorLangId == typescriptreact
&& typescript.isManagedFile
"
},
{
"command"
:
"javascript.reloadProjects"
,
"when"
:
"editorLangId ==
'javascript'
"
"when"
:
"editorLangId ==
javascript && typescript.isManagedFile
"
},
{
"command"
:
"javascript.reloadProjects"
,
"when"
:
"editorLangId == javascriptreact"
"when"
:
"editorLangId == javascriptreact
&& typescript.isManagedFile
"
},
{
"command"
:
"typescript.goToProjectConfig"
,
"when"
:
"editorLangId ==
'typescript'
"
"when"
:
"editorLangId ==
typescript && typescript.isManagedFile
"
},
{
"command"
:
"typescript.goToProjectConfig"
,
...
...
@@ -507,11 +507,11 @@
},
{
"command"
:
"javascript.goToProjectConfig"
,
"when"
:
"editorLangId ==
'javascript'
"
"when"
:
"editorLangId ==
javascript && typescript.isManagedFile
"
},
{
"command"
:
"javascript.goToProjectConfig"
,
"when"
:
"editorLangId == javascriptreact"
"when"
:
"editorLangId == javascriptreact
&& typescript.isManagedFile
"
}
]
},
...
...
extensions/typescript/src/extension.ts
浏览文件 @
7c13230a
...
...
@@ -14,6 +14,7 @@ import * as ProjectStatus from './utils/projectStatus';
import
*
as
languageModeIds
from
'
./utils/languageModeIds
'
;
import
*
as
languageConfigurations
from
'
./utils/languageConfigurations
'
;
import
{
standardLanguageDescriptions
}
from
'
./utils/languageDescription
'
;
import
ManagedFileContextManager
from
'
./utils/managedFileContext
'
;
export
function
activate
(
context
:
vscode
.
ExtensionContext
...
...
@@ -25,10 +26,12 @@ export function activate(
const
lazyClientHost
=
createLazyClientHost
(
context
,
plugins
,
commandManager
);
context
.
subscriptions
.
push
(
new
ManagedFileContextManager
(
resource
=>
lazyClientHost
().
serviceClient
.
normalizePath
(
resource
)));
registerCommands
(
commandManager
,
lazyClientHost
);
context
.
subscriptions
.
push
(
new
TypeScriptTaskProviderManager
(()
=>
lazyClientHost
().
serviceClient
));
context
.
subscriptions
.
push
(
vscode
.
languages
.
setLanguageConfiguration
(
languageModeIds
.
jsxTags
,
languageConfigurations
.
jsxTags
));
const
supportedLanguage
=
[].
concat
.
apply
([],
standardLanguageDescriptions
.
map
(
x
=>
x
.
modeIds
).
concat
(
plugins
.
map
(
x
=>
x
.
languages
)));
function
didOpenTextDocument
(
textDocument
:
vscode
.
TextDocument
):
boolean
{
if
(
supportedLanguage
.
indexOf
(
textDocument
.
languageId
)
>=
0
)
{
...
...
extensions/typescript/src/features/taskProvider.ts
浏览文件 @
7c13230a
...
...
@@ -235,7 +235,7 @@ class TscTaskProvider implements vscode.TaskProvider {
}
/**
* Manages registrations of TypeScript task provide
s with VSc
ode.
* Manages registrations of TypeScript task provide
rs with VS C
ode.
*/
export
default
class
TypeScriptTaskProviderManager
{
private
taskProviderSub
:
vscode
.
Disposable
|
undefined
=
undefined
;
...
...
extensions/typescript/src/utils/managedFileContext.ts
0 → 100644
浏览文件 @
7c13230a
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
*
as
vscode
from
'
vscode
'
;
import
*
as
languageModeIds
from
'
./languageModeIds
'
;
/**
* When clause context set when the current file is managed by vscode's built-in typescript extension.
*/
const
isManagedFile_contextName
=
'
typescript.isManagedFile
'
;
export
default
class
ManagedFileContextManager
{
private
isInManagedFileContext
:
boolean
=
false
;
private
readonly
onDidChangeActiveTextEditorSub
:
vscode
.
Disposable
;
public
constructor
(
private
readonly
normalizePath
:
(
resource
:
vscode
.
Uri
)
=>
string
|
null
)
{
this
.
onDidChangeActiveTextEditorSub
=
vscode
.
window
.
onDidChangeActiveTextEditor
(
this
.
onDidChangeActiveTextEditor
,
this
);
if
(
vscode
.
window
.
activeTextEditor
)
{
this
.
onDidChangeActiveTextEditor
(
vscode
.
window
.
activeTextEditor
);
}
}
public
dispose
()
{
this
.
onDidChangeActiveTextEditorSub
.
dispose
();
}
private
onDidChangeActiveTextEditor
(
editor
:
vscode
.
TextEditor
):
any
{
const
isManagedFile
=
isSupportedLanguageMode
(
editor
.
document
)
&&
this
.
normalizePath
(
editor
.
document
.
uri
)
!==
null
;
this
.
updateContext
(
isManagedFile
);
}
private
updateContext
(
newValue
:
boolean
)
{
if
(
newValue
===
this
.
isInManagedFileContext
)
{
return
;
}
vscode
.
commands
.
executeCommand
(
'
setContext
'
,
isManagedFile_contextName
,
newValue
);
this
.
isInManagedFileContext
=
newValue
;
}
}
function
isSupportedLanguageMode
(
doc
:
vscode
.
TextDocument
)
{
return
vscode
.
languages
.
match
([
languageModeIds
.
typescript
,
languageModeIds
.
typescriptreact
,
languageModeIds
.
javascript
,
languageModeIds
.
javascript
],
doc
)
>
0
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录