Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
2fa4edea
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,发现更多精彩内容 >>
提交
2fa4edea
编写于
12月 20, 2017
作者:
M
Martin Aeschlimann
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[html] Follow Link in Multi Root Workspace. Fixes #38469
上级
099e2842
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
87 addition
and
50 deletion
+87
-50
extensions/html/server/package.json
extensions/html/server/package.json
+2
-2
extensions/html/server/src/htmlServerMain.ts
extensions/html/server/src/htmlServerMain.ts
+17
-42
extensions/html/server/src/test/documentContext.test.ts
extensions/html/server/src/test/documentContext.test.ts
+22
-0
extensions/html/server/src/utils/documentContext.ts
extensions/html/server/src/utils/documentContext.ts
+40
-0
extensions/html/server/yarn.lock
extensions/html/server/yarn.lock
+6
-6
未找到文件。
extensions/html/server/package.json
浏览文件 @
2fa4edea
...
@@ -8,8 +8,8 @@
...
@@ -8,8 +8,8 @@
"node"
:
"*"
"node"
:
"*"
},
},
"dependencies"
:
{
"dependencies"
:
{
"vscode-css-languageservice"
:
"^3.0.
2
"
,
"vscode-css-languageservice"
:
"^3.0.
3
"
,
"vscode-html-languageservice"
:
"^2.0.1
3
"
,
"vscode-html-languageservice"
:
"^2.0.1
4
"
,
"vscode-languageserver"
:
"^3.5.0"
,
"vscode-languageserver"
:
"^3.5.0"
,
"vscode-nls"
:
"^2.0.2"
,
"vscode-nls"
:
"^2.0.2"
,
"vscode-uri"
:
"^1.0.1"
"vscode-uri"
:
"^1.0.1"
...
...
extensions/html/server/src/htmlServerMain.ts
浏览文件 @
2fa4edea
...
@@ -5,7 +5,6 @@
...
@@ -5,7 +5,6 @@
'
use strict
'
;
'
use strict
'
;
import
{
createConnection
,
IConnection
,
TextDocuments
,
InitializeParams
,
InitializeResult
,
RequestType
,
DocumentRangeFormattingRequest
,
Disposable
,
DocumentSelector
,
TextDocumentPositionParams
,
ServerCapabilities
,
Position
}
from
'
vscode-languageserver
'
;
import
{
createConnection
,
IConnection
,
TextDocuments
,
InitializeParams
,
InitializeResult
,
RequestType
,
DocumentRangeFormattingRequest
,
Disposable
,
DocumentSelector
,
TextDocumentPositionParams
,
ServerCapabilities
,
Position
}
from
'
vscode-languageserver
'
;
import
{
DocumentContext
}
from
'
vscode-html-languageservice
'
;
import
{
TextDocument
,
Diagnostic
,
DocumentLink
,
SymbolInformation
}
from
'
vscode-languageserver-types
'
;
import
{
TextDocument
,
Diagnostic
,
DocumentLink
,
SymbolInformation
}
from
'
vscode-languageserver-types
'
;
import
{
getLanguageModes
,
LanguageModes
,
Settings
}
from
'
./modes/languageModes
'
;
import
{
getLanguageModes
,
LanguageModes
,
Settings
}
from
'
./modes/languageModes
'
;
...
@@ -15,13 +14,11 @@ import { DidChangeWorkspaceFoldersNotification, WorkspaceFolder } from 'vscode-l
...
@@ -15,13 +14,11 @@ import { DidChangeWorkspaceFoldersNotification, WorkspaceFolder } from 'vscode-l
import
{
format
}
from
'
./modes/formatting
'
;
import
{
format
}
from
'
./modes/formatting
'
;
import
{
pushAll
}
from
'
./utils/arrays
'
;
import
{
pushAll
}
from
'
./utils/arrays
'
;
import
{
endsWith
,
startsWith
}
from
'
./utils/strings
'
;
import
{
getDocumentContext
}
from
'
./utils/documentContext
'
;
import
*
as
url
from
'
url
'
;
import
*
as
path
from
'
path
'
;
import
uri
from
'
vscode-uri
'
;
import
uri
from
'
vscode-uri
'
;
import
*
as
nls
from
'
vscode-nls
'
;
import
*
as
nls
from
'
vscode-nls
'
;
nls
.
config
(
process
.
env
[
'
VSCODE_NLS_CONFIG
'
]);
nls
.
config
(
process
.
env
[
'
VSCODE_NLS_CONFIG
'
]);
namespace
TagCloseRequest
{
namespace
TagCloseRequest
{
...
@@ -41,7 +38,6 @@ let documents: TextDocuments = new TextDocuments();
...
@@ -41,7 +38,6 @@ let documents: TextDocuments = new TextDocuments();
// for open, change and close text document events
// for open, change and close text document events
documents
.
listen
(
connection
);
documents
.
listen
(
connection
);
let
workspacePath
:
string
|
undefined
|
null
;
let
workspaceFolders
:
WorkspaceFolder
[]
|
undefined
;
let
workspaceFolders
:
WorkspaceFolder
[]
|
undefined
;
var
languageModes
:
LanguageModes
;
var
languageModes
:
LanguageModes
;
...
@@ -77,8 +73,13 @@ function getDocumentSettings(textDocument: TextDocument, needsDocumentSettings:
...
@@ -77,8 +73,13 @@ function getDocumentSettings(textDocument: TextDocument, needsDocumentSettings:
connection
.
onInitialize
((
params
:
InitializeParams
):
InitializeResult
=>
{
connection
.
onInitialize
((
params
:
InitializeParams
):
InitializeResult
=>
{
let
initializationOptions
=
params
.
initializationOptions
;
let
initializationOptions
=
params
.
initializationOptions
;
workspacePath
=
params
.
rootPath
;
workspaceFolders
=
(
<
any
>
params
).
workspaceFolders
;
workspaceFolders
=
(
<
any
>
params
).
workspaceFolders
;
if
(
!
Array
.
isArray
(
workspaceFolders
))
{
workspaceFolders
=
[];
if
(
params
.
rootPath
)
{
workspaceFolders
.
push
({
name
:
''
,
uri
:
uri
.
file
(
params
.
rootPath
).
toString
()
});
}
}
languageModes
=
getLanguageModes
(
initializationOptions
?
initializationOptions
.
embeddedLanguages
:
{
css
:
true
,
javascript
:
true
});
languageModes
=
getLanguageModes
(
initializationOptions
?
initializationOptions
.
embeddedLanguages
:
{
css
:
true
,
javascript
:
true
});
documents
.
onDidClose
(
e
=>
{
documents
.
onDidClose
(
e
=>
{
...
@@ -305,45 +306,19 @@ connection.onDocumentRangeFormatting(async formatParams => {
...
@@ -305,45 +306,19 @@ connection.onDocumentRangeFormatting(async formatParams => {
connection
.
onDocumentLinks
(
documentLinkParam
=>
{
connection
.
onDocumentLinks
(
documentLinkParam
=>
{
let
document
=
documents
.
get
(
documentLinkParam
.
textDocument
.
uri
);
let
document
=
documents
.
get
(
documentLinkParam
.
textDocument
.
uri
);
let
documentContext
:
DocumentContext
=
{
resolveReference
:
(
ref
,
base
)
=>
{
if
(
base
)
{
ref
=
url
.
resolve
(
base
,
ref
);
}
if
(
ref
[
0
]
===
'
/
'
)
{
let
root
=
getRootFolder
(
document
.
uri
);
if
(
root
)
{
return
uri
.
file
(
path
.
join
(
root
,
ref
)).
toString
();
}
}
return
url
.
resolve
(
document
.
uri
,
ref
);
},
};
let
links
:
DocumentLink
[]
=
[];
let
links
:
DocumentLink
[]
=
[];
languageModes
.
getAllModesInDocument
(
document
).
forEach
(
m
=>
{
if
(
document
)
{
if
(
m
.
findDocumentLinks
)
{
let
documentContext
=
getDocumentContext
(
document
.
uri
,
workspaceFolders
);
pushAll
(
links
,
m
.
findDocumentLinks
(
document
,
documentContext
));
languageModes
.
getAllModesInDocument
(
document
).
forEach
(
m
=>
{
}
if
(
m
.
findDocumentLinks
)
{
});
pushAll
(
links
,
m
.
findDocumentLinks
(
document
,
documentContext
));
}
});
}
return
links
;
return
links
;
});
});
function
getRootFolder
(
docUri
:
string
):
string
|
undefined
{
if
(
workspaceFolders
)
{
for
(
let
folder
of
workspaceFolders
)
{
let
folderURI
=
folder
.
uri
;
if
(
!
endsWith
(
folderURI
,
'
/
'
))
{
folderURI
=
folderURI
+
'
/
'
;
}
if
(
startsWith
(
docUri
,
folderURI
))
{
return
uri
.
parse
(
folderURI
).
fsPath
;
}
}
return
void
0
;
}
return
workspacePath
;
}
connection
.
onDocumentSymbol
(
documentSymbolParms
=>
{
connection
.
onDocumentSymbol
(
documentSymbolParms
=>
{
let
document
=
documents
.
get
(
documentSymbolParms
.
textDocument
.
uri
);
let
document
=
documents
.
get
(
documentSymbolParms
.
textDocument
.
uri
);
...
...
extensions/html/server/src/test/documentContext.test.ts
0 → 100644
浏览文件 @
2fa4edea
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
*
as
assert
from
'
assert
'
;
import
{
getDocumentContext
}
from
'
../utils/documentContext
'
;
suite
(
'
Document Context
'
,
()
=>
{
test
(
'
Context
'
,
function
():
any
{
const
docURI
=
'
file:///users/test/folder/test.html
'
;
const
rootFolders
=
[{
name
:
''
,
uri
:
'
file:///users/test/
'
}];
let
context
=
getDocumentContext
(
docURI
,
rootFolders
);
assert
.
equal
(
context
.
resolveReference
(
'
/
'
,
docURI
),
'
file:///users/test/
'
);
assert
.
equal
(
context
.
resolveReference
(
'
/message.html
'
,
docURI
),
'
file:///users/test/message.html
'
);
assert
.
equal
(
context
.
resolveReference
(
'
message.html
'
,
docURI
),
'
file:///users/test/folder/message.html
'
);
assert
.
equal
(
context
.
resolveReference
(
'
message.html
'
,
'
file:///users/test/
'
),
'
file:///users/test/message.html
'
);
});
});
\ No newline at end of file
extensions/html/server/src/utils/documentContext.ts
0 → 100644
浏览文件 @
2fa4edea
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
DocumentContext
}
from
'
vscode-html-languageservice
'
;
import
{
endsWith
,
startsWith
}
from
'
../utils/strings
'
;
import
*
as
url
from
'
url
'
;
import
{
WorkspaceFolder
}
from
'
vscode-languageserver-protocol/lib/protocol.workspaceFolders.proposed
'
;
export
function
getDocumentContext
(
documentUri
:
string
,
workspaceFolders
:
WorkspaceFolder
[]):
DocumentContext
{
function
getRootFolder
():
string
|
undefined
{
for
(
let
folder
of
workspaceFolders
)
{
let
folderURI
=
folder
.
uri
;
if
(
!
endsWith
(
folderURI
,
'
/
'
))
{
folderURI
=
folderURI
+
'
/
'
;
}
if
(
startsWith
(
documentUri
,
folderURI
))
{
return
folderURI
;
}
}
return
void
0
;
}
return
{
resolveReference
:
(
ref
,
base
=
documentUri
)
=>
{
if
(
ref
[
0
]
===
'
/
'
)
{
// resolve absolute path against the current workspace folder
if
(
startsWith
(
base
,
'
file://
'
))
{
let
folderUri
=
getRootFolder
();
if
(
folderUri
)
{
return
folderUri
+
ref
.
substr
(
1
);
}
}
}
return
url
.
resolve
(
base
,
ref
);
},
};
}
extensions/html/server/yarn.lock
浏览文件 @
2fa4edea
...
@@ -10,16 +10,16 @@
...
@@ -10,16 +10,16 @@
version "7.0.43"
version "7.0.43"
resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.43.tgz#a187e08495a075f200ca946079c914e1a5fe962c"
resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.43.tgz#a187e08495a075f200ca946079c914e1a5fe962c"
vscode-css-languageservice@^3.0.
2
:
vscode-css-languageservice@^3.0.
3
:
version "3.0.
2
"
version "3.0.
3
"
resolved "https://registry.yarnpkg.com/vscode-css-languageservice/-/vscode-css-languageservice-3.0.
2.tgz#ae0c43836318455aa290c777556394d6127b8f6c
"
resolved "https://registry.yarnpkg.com/vscode-css-languageservice/-/vscode-css-languageservice-3.0.
3.tgz#02cc4efa5335f5104e0a2f3b6920faaf59db4f7a
"
dependencies:
dependencies:
vscode-languageserver-types "3.5.0"
vscode-languageserver-types "3.5.0"
vscode-nls "^2.0.1"
vscode-nls "^2.0.1"
vscode-html-languageservice@^2.0.1
3
:
vscode-html-languageservice@^2.0.1
4
:
version "2.0.1
3
"
version "2.0.1
4
"
resolved "https://registry.yarnpkg.com/vscode-html-languageservice/-/vscode-html-languageservice-2.0.1
3.tgz#09c4437cffb0800b865d71552f4dfd8240c796d8
"
resolved "https://registry.yarnpkg.com/vscode-html-languageservice/-/vscode-html-languageservice-2.0.1
4.tgz#15491c11bb7e196f6fd03b6c6c768901935862eb
"
dependencies:
dependencies:
vscode-languageserver-types "3.5.0"
vscode-languageserver-types "3.5.0"
vscode-nls "^2.0.2"
vscode-nls "^2.0.2"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录