Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
229ab747
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 搜索 >>
提交
229ab747
编写于
11月 30, 2017
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move TS extension activate to own file
上级
dec4686c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
97 addition
and
87 deletion
+97
-87
extensions/typescript/package.json
extensions/typescript/package.json
+1
-1
extensions/typescript/src/extension.ts
extensions/typescript/src/extension.ts
+84
-0
extensions/typescript/src/typescriptMain.ts
extensions/typescript/src/typescriptMain.ts
+12
-86
未找到文件。
extensions/typescript/package.json
浏览文件 @
229ab747
...
...
@@ -38,7 +38,7 @@
"onCommand:typescript.openTsServerLog"
,
"onCommand:workbench.action.tasks.runTask"
],
"main"
:
"./out/
typescriptMai
n"
,
"main"
:
"./out/
extensio
n"
,
"contributes"
:
{
"languages"
:
[
{
...
...
extensions/typescript/src/extension.ts
0 → 100644
浏览文件 @
229ab747
/*---------------------------------------------------------------------------------------------
* 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
{
CommandManager
}
from
'
./utils/commandManager
'
;
import
{
ReloadTypeScriptProjectsCommand
,
SelectTypeScriptVersionCommand
,
ReloadJavaScriptProjectsCommand
,
RestartTsServerCommand
,
OpenTsServerLogCommand
,
TypeScriptGoToProjectConfigCommand
,
JavaScriptGoToProjectConfigCommand
,
LanguageDescription
,
TypeScriptServiceClientHost
}
from
'
./typescriptMain
'
;
import
TypeScriptTaskProviderManager
from
'
./features/taskProvider
'
;
import
{
getContributedTypeScriptServerPlugins
}
from
'
./utils/plugins
'
;
import
*
as
ProjectStatus
from
'
./utils/projectStatus
'
;
import
*
as
languageModeIds
from
'
./utils/languageModeIds
'
;
import
*
as
languageConfigurations
from
'
./utils/languageConfigurations
'
;
export
const
standardLanguageDescriptions
:
LanguageDescription
[]
=
[
{
id
:
'
typescript
'
,
diagnosticSource
:
'
ts
'
,
modeIds
:
[
languageModeIds
.
typescript
,
languageModeIds
.
typescriptreact
],
configFile
:
'
tsconfig.json
'
},
{
id
:
'
javascript
'
,
diagnosticSource
:
'
js
'
,
modeIds
:
[
languageModeIds
.
javascript
,
languageModeIds
.
javascriptreact
],
configFile
:
'
jsconfig.json
'
}
];
export
function
activate
(
context
:
vscode
.
ExtensionContext
):
void
{
const
plugins
=
getContributedTypeScriptServerPlugins
();
const
commandManager
=
new
CommandManager
();
context
.
subscriptions
.
push
(
commandManager
);
const
lazyClientHost
=
(()
=>
{
let
clientHost
:
TypeScriptServiceClientHost
|
undefined
;
return
()
=>
{
if
(
!
clientHost
)
{
clientHost
=
new
TypeScriptServiceClientHost
(
standardLanguageDescriptions
,
context
.
workspaceState
,
plugins
,
commandManager
);
context
.
subscriptions
.
push
(
clientHost
);
const
host
=
clientHost
;
clientHost
.
serviceClient
.
onReady
().
then
(()
=>
{
context
.
subscriptions
.
push
(
ProjectStatus
.
create
(
host
.
serviceClient
,
host
.
serviceClient
.
telemetryReporter
,
path
=>
new
Promise
<
boolean
>
(
resolve
=>
setTimeout
(()
=>
resolve
(
host
.
handles
(
path
)),
750
)),
context
.
workspaceState
));
},
()
=>
{
// Nothing to do here. The client did show a message;
});
}
return
clientHost
;
};
})();
commandManager
.
register
(
new
ReloadTypeScriptProjectsCommand
(
lazyClientHost
));
commandManager
.
register
(
new
ReloadJavaScriptProjectsCommand
(
lazyClientHost
));
commandManager
.
register
(
new
SelectTypeScriptVersionCommand
(
lazyClientHost
));
commandManager
.
register
(
new
OpenTsServerLogCommand
(
lazyClientHost
));
commandManager
.
register
(
new
RestartTsServerCommand
(
lazyClientHost
));
commandManager
.
register
(
new
TypeScriptGoToProjectConfigCommand
(
lazyClientHost
));
commandManager
.
register
(
new
JavaScriptGoToProjectConfigCommand
(
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
)
{
openListener
.
dispose
();
// Force activation
void
lazyClientHost
();
return
true
;
}
return
false
;
}
const
openListener
=
vscode
.
workspace
.
onDidOpenTextDocument
(
didOpenTextDocument
);
for
(
let
textDocument
of
vscode
.
workspace
.
textDocuments
)
{
if
(
didOpenTextDocument
(
textDocument
))
{
break
;
}
}
}
\ No newline at end of file
extensions/typescript/src/typescriptMain.ts
浏览文件 @
229ab747
...
...
@@ -8,7 +8,7 @@
* https://github.com/Microsoft/TypeScript-Sublime-Plugin/blob/master/TypeScript%20Indent.tmPreferences
* ------------------------------------------------------------------------------------------ */
import
{
env
,
languages
,
commands
,
workspace
,
window
,
ExtensionContext
,
Memento
,
Diagnostic
,
Range
,
Disposable
,
Uri
,
MessageItem
,
DiagnosticSeverity
,
TextDocument
}
from
'
vscode
'
;
import
{
env
,
languages
,
commands
,
workspace
,
window
,
Memento
,
Diagnostic
,
Range
,
Disposable
,
Uri
,
MessageItem
,
DiagnosticSeverity
,
TextDocument
}
from
'
vscode
'
;
// This must be the first statement otherwise modules might got loaded with
// the wrong locale.
...
...
@@ -25,21 +25,18 @@ import TypeScriptServiceClient from './typescriptServiceClient';
import
{
ITypeScriptServiceClientHost
}
from
'
./typescriptService
'
;
import
BufferSyncSupport
from
'
./features/bufferSyncSupport
'
;
import
TypeScriptTaskProviderManager
from
'
./features/taskProvider
'
;
import
*
as
ProjectStatus
from
'
./utils/projectStatus
'
;
import
TypingsStatus
,
{
AtaProgressReporter
}
from
'
./utils/typingsStatus
'
;
import
VersionStatus
from
'
./utils/versionStatus
'
;
import
{
getContributedTypeScriptServerPlugins
,
TypeScriptServerPlugin
}
from
'
./utils/plugins
'
;
import
{
TypeScriptServerPlugin
}
from
'
./utils/plugins
'
;
import
{
openOrCreateConfigFile
,
isImplicitProjectConfigFile
}
from
'
./utils/tsconfig
'
;
import
{
tsLocationToVsPosition
}
from
'
./utils/convert
'
;
import
FormattingConfigurationManager
from
'
./features/formattingConfigurationManager
'
;
import
*
as
languageModeIds
from
'
./utils/languageModeIds
'
;
import
*
as
languageConfigurations
from
'
./utils/languageConfigurations
'
;
import
{
CommandManager
,
Command
}
from
'
./utils/commandManager
'
;
import
DiagnosticsManager
from
'
./features/diagnostics
'
;
interface
LanguageDescription
{
export
interface
LanguageDescription
{
id
:
string
;
diagnosticSource
:
string
;
modeIds
:
string
[];
...
...
@@ -47,21 +44,7 @@ interface LanguageDescription {
isExternal
?:
boolean
;
}
const
standardLanguageDescriptions
:
LanguageDescription
[]
=
[
{
id
:
'
typescript
'
,
diagnosticSource
:
'
ts
'
,
modeIds
:
[
languageModeIds
.
typescript
,
languageModeIds
.
typescriptreact
],
configFile
:
'
tsconfig.json
'
},
{
id
:
'
javascript
'
,
diagnosticSource
:
'
js
'
,
modeIds
:
[
languageModeIds
.
javascript
,
languageModeIds
.
javascriptreact
],
configFile
:
'
jsconfig.json
'
}
];
class
ReloadTypeScriptProjectsCommand
implements
Command
{
export
class
ReloadTypeScriptProjectsCommand
implements
Command
{
public
readonly
id
=
'
typescript.reloadProjects
'
;
public
constructor
(
...
...
@@ -73,7 +56,7 @@ class ReloadTypeScriptProjectsCommand implements Command {
}
}
class
ReloadJavaScriptProjectsCommand
implements
Command
{
export
class
ReloadJavaScriptProjectsCommand
implements
Command
{
public
readonly
id
=
'
javascript.reloadProjects
'
;
public
constructor
(
...
...
@@ -85,7 +68,7 @@ class ReloadJavaScriptProjectsCommand implements Command {
}
}
class
SelectTypeScriptVersionCommand
implements
Command
{
export
class
SelectTypeScriptVersionCommand
implements
Command
{
public
readonly
id
=
'
typescript.selectTypeScriptVersion
'
;
public
constructor
(
...
...
@@ -97,7 +80,7 @@ class SelectTypeScriptVersionCommand implements Command {
}
}
class
OpenTsServerLogCommand
implements
Command
{
export
class
OpenTsServerLogCommand
implements
Command
{
public
readonly
id
=
'
typescript.openTsServerLog
'
;
public
constructor
(
...
...
@@ -109,7 +92,7 @@ class OpenTsServerLogCommand implements Command {
}
}
class
RestartTsServerCommand
implements
Command
{
export
class
RestartTsServerCommand
implements
Command
{
public
readonly
id
=
'
typescript.restartTsServer
'
;
public
constructor
(
...
...
@@ -121,7 +104,7 @@ class RestartTsServerCommand implements Command {
}
}
class
TypeScriptGoToProjectConfigCommand
implements
Command
{
export
class
TypeScriptGoToProjectConfigCommand
implements
Command
{
public
readonly
id
=
'
typescript.goToProjectConfig
'
;
public
constructor
(
...
...
@@ -136,7 +119,7 @@ class TypeScriptGoToProjectConfigCommand implements Command {
}
}
class
JavaScriptGoToProjectConfigCommand
implements
Command
{
export
class
JavaScriptGoToProjectConfigCommand
implements
Command
{
public
readonly
id
=
'
javascript.goToProjectConfig
'
;
public
constructor
(
...
...
@@ -151,63 +134,6 @@ class JavaScriptGoToProjectConfigCommand implements Command {
}
}
export
function
activate
(
context
:
ExtensionContext
):
void
{
const
plugins
=
getContributedTypeScriptServerPlugins
();
const
commandManager
=
new
CommandManager
();
context
.
subscriptions
.
push
(
commandManager
);
const
lazyClientHost
=
(()
=>
{
let
clientHost
:
TypeScriptServiceClientHost
|
undefined
;
return
()
=>
{
if
(
!
clientHost
)
{
clientHost
=
new
TypeScriptServiceClientHost
(
standardLanguageDescriptions
,
context
.
workspaceState
,
plugins
,
commandManager
);
context
.
subscriptions
.
push
(
clientHost
);
const
host
=
clientHost
;
clientHost
.
serviceClient
.
onReady
().
then
(()
=>
{
context
.
subscriptions
.
push
(
ProjectStatus
.
create
(
host
.
serviceClient
,
host
.
serviceClient
.
telemetryReporter
,
path
=>
new
Promise
<
boolean
>
(
resolve
=>
setTimeout
(()
=>
resolve
(
host
.
handles
(
path
)),
750
)),
context
.
workspaceState
));
},
()
=>
{
// Nothing to do here. The client did show a message;
});
}
return
clientHost
;
};
})();
commandManager
.
register
(
new
ReloadTypeScriptProjectsCommand
(
lazyClientHost
));
commandManager
.
register
(
new
ReloadJavaScriptProjectsCommand
(
lazyClientHost
));
commandManager
.
register
(
new
SelectTypeScriptVersionCommand
(
lazyClientHost
));
commandManager
.
register
(
new
OpenTsServerLogCommand
(
lazyClientHost
));
commandManager
.
register
(
new
RestartTsServerCommand
(
lazyClientHost
));
commandManager
.
register
(
new
TypeScriptGoToProjectConfigCommand
(
lazyClientHost
));
commandManager
.
register
(
new
JavaScriptGoToProjectConfigCommand
(
lazyClientHost
));
context
.
subscriptions
.
push
(
new
TypeScriptTaskProviderManager
(()
=>
lazyClientHost
().
serviceClient
));
context
.
subscriptions
.
push
(
languages
.
setLanguageConfiguration
(
languageModeIds
.
jsxTags
,
languageConfigurations
.
jsxTags
));
const
supportedLanguage
=
[].
concat
.
apply
([],
standardLanguageDescriptions
.
map
(
x
=>
x
.
modeIds
).
concat
(
plugins
.
map
(
x
=>
x
.
languages
)));
function
didOpenTextDocument
(
textDocument
:
TextDocument
):
boolean
{
if
(
supportedLanguage
.
indexOf
(
textDocument
.
languageId
)
>=
0
)
{
openListener
.
dispose
();
// Force activation
void
lazyClientHost
();
return
true
;
}
return
false
;
}
const
openListener
=
workspace
.
onDidOpenTextDocument
(
didOpenTextDocument
);
for
(
let
textDocument
of
workspace
.
textDocuments
)
{
if
(
didOpenTextDocument
(
textDocument
))
{
break
;
}
}
}
const
validateSetting
=
'
validate.enable
'
;
class
LanguageProvider
{
...
...
@@ -422,7 +348,7 @@ const styleCheckDiagnostics = [
7030
// not all code paths return a value
];
class
TypeScriptServiceClientHost
implements
ITypeScriptServiceClientHost
{
export
class
TypeScriptServiceClientHost
implements
ITypeScriptServiceClientHost
{
private
readonly
ataProgressReporter
:
AtaProgressReporter
;
private
readonly
typingsStatus
:
TypingsStatus
;
private
readonly
client
:
TypeScriptServiceClient
;
...
...
@@ -453,7 +379,7 @@ class TypeScriptServiceClientHost implements ITypeScriptServiceClientHost {
configFileWatcher
.
onDidDelete
(
handleProjectCreateOrDelete
,
this
,
this
.
disposables
);
configFileWatcher
.
onDidChange
(
handleProjectChange
,
this
,
this
.
disposables
);
this
.
versionStatus
=
new
VersionStatus
(
resource
=>
this
.
client
.
normalizePath
(
resource
)
);
this
.
versionStatus
=
new
VersionStatus
(
resource
=>
this
.
client
?
this
.
client
.
normalizePath
(
resource
)
:
null
);
this
.
disposables
.
push
(
this
.
versionStatus
);
this
.
client
=
new
TypeScriptServiceClient
(
this
,
workspaceState
,
this
.
versionStatus
,
plugins
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录