Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
8d6645c2
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,发现更多精彩内容 >>
提交
8d6645c2
编写于
6月 21, 2017
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Initial work on making ts extension multiroot aware
上级
dd07cadd
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
57 addition
and
22 deletion
+57
-22
extensions/typescript/src/features/bufferSyncSupport.ts
extensions/typescript/src/features/bufferSyncSupport.ts
+5
-2
extensions/typescript/src/typescriptMain.ts
extensions/typescript/src/typescriptMain.ts
+2
-2
extensions/typescript/src/typescriptService.ts
extensions/typescript/src/typescriptService.ts
+1
-0
extensions/typescript/src/typescriptServiceClient.ts
extensions/typescript/src/typescriptServiceClient.ts
+39
-10
extensions/typescript/src/utils/projectStatus.ts
extensions/typescript/src/utils/projectStatus.ts
+6
-1
extensions/typescript/src/utils/tsconfig.ts
extensions/typescript/src/utils/tsconfig.ts
+3
-6
extensions/typescript/src/utils/tsconfigProvider.ts
extensions/typescript/src/utils/tsconfigProvider.ts
+1
-1
未找到文件。
extensions/typescript/src/features/bufferSyncSupport.ts
浏览文件 @
8d6645c2
...
...
@@ -50,8 +50,11 @@ class SyncedBuffer {
}
}
if
(
workspace
.
rootPath
&&
this
.
client
.
apiVersion
.
has230Features
())
{
args
.
projectRootPath
=
workspace
.
rootPath
;
if
(
this
.
client
.
apiVersion
.
has230Features
())
{
const
root
=
this
.
client
.
getWorkspaceRootForResource
(
this
.
document
.
uri
);
if
(
root
)
{
args
.
projectRootPath
=
root
;
}
}
this
.
client
.
execute
(
'
open
'
,
args
,
false
);
...
...
extensions/typescript/src/typescriptMain.ts
浏览文件 @
8d6645c2
...
...
@@ -541,7 +541,7 @@ class TypeScriptServiceClientHost implements ITypescriptServiceClientHost {
isTypeScriptProject
:
boolean
,
resource
:
Uri
):
Thenable
<
TextEditor
|
undefined
>
|
undefined
{
const
rootPath
=
workspace
.
rootPath
;
const
rootPath
=
this
.
client
.
getWorkspaceRootForResource
(
resource
)
;
if
(
!
rootPath
)
{
window
.
showInformationMessage
(
localize
(
...
...
@@ -588,7 +588,7 @@ class TypeScriptServiceClientHost implements ITypescriptServiceClientHost {
}).
then
(
selected
=>
{
switch
(
selected
&&
selected
.
id
)
{
case
ProjectConfigAction
.
CreateConfig
:
return
openOrCreateConfigFile
(
isTypeScriptProject
);
return
openOrCreateConfigFile
(
isTypeScriptProject
,
rootPath
);
case
ProjectConfigAction
.
LearnMore
:
if
(
isTypeScriptProject
)
{
...
...
extensions/typescript/src/typescriptService.ts
浏览文件 @
8d6645c2
...
...
@@ -76,6 +76,7 @@ export class API {
export
interface
ITypescriptServiceClient
{
normalizePath
(
resource
:
Uri
):
string
|
null
;
asUrl
(
filepath
:
string
):
Uri
;
getWorkspaceRootForResource
(
resource
:
Uri
):
string
|
undefined
;
warn
(
message
:
string
,
data
?:
any
):
void
;
...
...
extensions/typescript/src/typescriptServiceClient.ts
浏览文件 @
8d6645c2
...
...
@@ -394,7 +394,8 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
}
private
get
localTypeScriptPath
():
string
|
null
{
if
(
!
workspace
.
rootPath
)
{
const
rootPath
=
this
.
mainWorkspaceRootPath
;
if
(
!
rootPath
)
{
return
null
;
}
...
...
@@ -403,10 +404,10 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
if
((
<
any
>
path
).
isAbsolute
(
this
.
configuration
.
localTsdk
))
{
return
path
.
join
(
this
.
configuration
.
localTsdk
,
'
tsserver.js
'
);
}
return
path
.
join
(
workspace
.
rootPath
,
this
.
configuration
.
localTsdk
,
'
tsserver.js
'
);
return
path
.
join
(
rootPath
,
this
.
configuration
.
localTsdk
,
'
tsserver.js
'
);
}
const
localModulePath
=
path
.
join
(
workspace
.
rootPath
,
'
node_modules
'
,
'
typescript
'
,
'
lib
'
,
'
tsserver.js
'
);
const
localModulePath
=
path
.
join
(
rootPath
,
'
node_modules
'
,
'
typescript
'
,
'
lib
'
,
'
tsserver.js
'
);
if
(
fs
.
existsSync
(
localModulePath
)
&&
this
.
getTypeScriptVersion
(
localModulePath
))
{
return
localModulePath
;
}
...
...
@@ -418,8 +419,8 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
this
.
_checkGlobalTSCVersion
=
false
;
if
((
<
any
>
path
).
isAbsolute
(
this
.
configuration
.
globalTsdk
))
{
return
path
.
join
(
this
.
configuration
.
globalTsdk
,
'
tsserver.js
'
);
}
else
if
(
workspace
.
r
ootPath
)
{
return
path
.
join
(
workspace
.
r
ootPath
,
this
.
configuration
.
globalTsdk
,
'
tsserver.js
'
);
}
else
if
(
this
.
mainWorkspaceR
ootPath
)
{
return
path
.
join
(
this
.
mainWorkspaceR
ootPath
,
this
.
configuration
.
globalTsdk
,
'
tsserver.js
'
);
}
}
...
...
@@ -435,14 +436,14 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
if
(
!
this
.
workspaceState
.
get
<
boolean
>
(
TypeScriptServiceClient
.
tsdkMigratedStorageKey
,
false
))
{
this
.
workspaceState
.
update
(
TypeScriptServiceClient
.
tsdkMigratedStorageKey
,
true
);
if
(
workspace
.
r
ootPath
&&
this
.
hasWorkspaceTsdkSetting
())
{
if
(
this
.
mainWorkspaceR
ootPath
&&
this
.
hasWorkspaceTsdkSetting
())
{
modulePath
=
this
.
showVersionPicker
(
true
);
}
}
return
modulePath
.
then
(
modulePath
=>
{
if
(
this
.
workspaceState
.
get
<
boolean
>
(
TypeScriptServiceClient
.
useWorkspaceTsdkStorageKey
,
false
))
{
if
(
workspace
.
r
ootPath
)
{
if
(
this
.
mainWorkspaceR
ootPath
)
{
// TODO: check if we need better error handling
return
this
.
localTypeScriptPath
||
modulePath
;
}
...
...
@@ -485,8 +486,8 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
const
options
:
electron
.
IForkOptions
=
{
execArgv
:
[]
// [`--debug-brk=5859`]
};
if
(
workspace
.
r
ootPath
)
{
options
.
cwd
=
workspace
.
r
ootPath
;
if
(
this
.
mainWorkspaceR
ootPath
)
{
options
.
cwd
=
this
.
mainWorkspaceR
ootPath
;
}
if
(
debugPort
&&
!
isNaN
(
debugPort
))
{
...
...
@@ -622,7 +623,7 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
private
showVersionPicker
(
firstRun
:
boolean
):
Thenable
<
string
>
{
const
modulePath
=
this
.
modulePath
||
this
.
globalTypescriptPath
;
if
(
!
workspace
.
r
ootPath
||
!
modulePath
)
{
if
(
!
this
.
mainWorkspaceR
ootPath
||
!
modulePath
)
{
return
Promise
.
resolve
(
modulePath
);
}
...
...
@@ -883,6 +884,34 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
return
Uri
.
file
(
filepath
);
}
private
get
mainWorkspaceRootPath
():
string
|
undefined
{
if
(
workspace
.
rootPath
)
{
return
workspace
.
rootPath
;
}
if
(
workspace
.
workspaceFolders
&&
workspace
.
workspaceFolders
.
length
)
{
return
workspace
.
workspaceFolders
[
0
].
fsPath
;
}
return
undefined
;
}
public
getWorkspaceRootForResource
(
resource
:
Uri
):
string
|
undefined
{
if
(
workspace
.
rootPath
)
{
return
workspace
.
rootPath
;
}
if
(
workspace
.
workspaceFolders
&&
workspace
.
workspaceFolders
.
length
)
{
if
(
resource
.
scheme
===
'
file
'
)
{
const
found
=
workspace
.
workspaceFolders
.
find
(
root
=>
resource
.
fsPath
.
startsWith
(
root
.
fsPath
));
return
found
?
found
.
fsPath
:
found
;
}
return
workspace
.
workspaceFolders
[
0
].
fsPath
;
}
return
undefined
;
}
public
execute
(
command
:
string
,
args
:
any
,
expectsResultOrToken
?:
boolean
|
CancellationToken
):
Promise
<
any
>
{
let
token
:
CancellationToken
|
undefined
=
undefined
;
let
expectsResult
=
true
;
...
...
extensions/typescript/src/utils/projectStatus.ts
浏览文件 @
8d6645c2
...
...
@@ -145,7 +145,12 @@ function createLargeProjectMonitorFromTypeScript(item: ExcludeHintItem, client:
vscode
.
workspace
.
openTextDocument
(
configFileName
)
.
then
(
vscode
.
window
.
showTextDocument
);
}
else
{
openOrCreateConfigFile
(
configFileName
.
match
(
/tsconfig
\.?
.*
\.
json/
)
!==
null
);
const
root
=
client
.
getWorkspaceRootForResource
(
vscode
.
Uri
.
file
(
configFileName
));
if
(
root
)
{
openOrCreateConfigFile
(
configFileName
.
match
(
/tsconfig
\.?
.*
\.
json/
)
!==
null
,
root
);
}
}
});
}
...
...
extensions/typescript/src/utils/tsconfig.ts
浏览文件 @
8d6645c2
...
...
@@ -11,13 +11,10 @@ export function isImplicitProjectConfigFile(configFileName: string) {
}
export
function
openOrCreateConfigFile
(
isTypeScriptProject
:
boolean
isTypeScriptProject
:
boolean
,
rootPath
:
string
):
Thenable
<
vscode
.
TextEditor
|
null
>
{
if
(
!
vscode
.
workspace
.
rootPath
)
{
return
Promise
.
resolve
(
null
);
}
const
configFile
=
vscode
.
Uri
.
file
(
path
.
join
(
vscode
.
workspace
.
rootPath
,
isTypeScriptProject
?
'
tsconfig.json
'
:
'
jsconfig.json
'
));
const
configFile
=
vscode
.
Uri
.
file
(
path
.
join
(
rootPath
,
isTypeScriptProject
?
'
tsconfig.json
'
:
'
jsconfig.json
'
));
const
col
=
vscode
.
window
.
activeTextEditor
?
vscode
.
window
.
activeTextEditor
.
viewColumn
:
undefined
;
return
vscode
.
workspace
.
openTextDocument
(
configFile
)
.
then
(
doc
=>
{
...
...
extensions/typescript/src/utils/tsconfigProvider.ts
浏览文件 @
8d6645c2
...
...
@@ -19,7 +19,7 @@ export default class TsConfigProvider extends vscode.Disposable {
}
public
async
getConfigsForWorkspace
():
Promise
<
Iterable
<
string
>>
{
if
(
!
vscode
.
workspace
.
rootPath
)
{
if
(
!
vscode
.
workspace
.
rootPath
&&
!
vscode
.
workspace
.
workspaceFolders
)
{
return
[];
}
await
this
.
ensureActivated
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录