Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
bf8fb5f8
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,发现更多精彩内容 >>
提交
bf8fb5f8
编写于
3月 13, 2020
作者:
M
Martin Aeschlimann
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
editor token inspect: resolve scopes like the sem highlight code
上级
39424388
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
24 addition
and
10 deletion
+24
-10
src/vs/workbench/contrib/codeEditor/browser/inspectEditorTokens/inspectEditorTokens.ts
...Editor/browser/inspectEditorTokens/inspectEditorTokens.ts
+7
-7
src/vs/workbench/services/themes/common/colorThemeData.ts
src/vs/workbench/services/themes/common/colorThemeData.ts
+17
-3
未找到文件。
src/vs/workbench/contrib/codeEditor/browser/inspectEditorTokens/inspectEditorTokens.ts
浏览文件 @
bf8fb5f8
...
...
@@ -26,7 +26,7 @@ import { findMatchingThemeRule } from 'vs/workbench/services/textMate/common/TMH
import
{
ITextMateService
,
IGrammar
,
IToken
,
StackElement
}
from
'
vs/workbench/services/textMate/common/textMateService
'
;
import
{
IWorkbenchThemeService
}
from
'
vs/workbench/services/themes/common/workbenchThemeService
'
;
import
{
CancellationTokenSource
}
from
'
vs/base/common/cancellation
'
;
import
{
ColorThemeData
,
TokenStyleDefinitions
,
TokenStyleDefinition
}
from
'
vs/workbench/services/themes/common/colorThemeData
'
;
import
{
ColorThemeData
,
TokenStyleDefinitions
,
TokenStyleDefinition
,
TextMateThemingRuleDefinitions
}
from
'
vs/workbench/services/themes/common/colorThemeData
'
;
import
{
TokenStylingRule
,
TokenStyleData
,
TokenStyle
}
from
'
vs/platform/theme/common/tokenClassificationRegistry
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
...
...
@@ -303,7 +303,7 @@ class InspectEditorTokensWidget extends Disposable implements IContentWidget {
const
allDefValues
=
[];
// remember the order
// first collect to detect when the same rule is used fro multiple properties
for
(
let
property
of
properties
)
{
if
(
semanticTokenInfo
.
metadata
[
property
])
{
if
(
semanticTokenInfo
.
metadata
[
property
]
!==
undefined
)
{
const
definition
=
semanticTokenInfo
.
definitions
[
property
];
const
defValue
=
this
.
_renderTokenStyleDefinition
(
definition
,
property
);
let
properties
=
propertiesByDefValue
[
defValue
];
...
...
@@ -532,11 +532,11 @@ class InspectEditorTokensWidget extends Disposable implements IContentWidget {
const
isTokenStylingRule
=
(
d
:
any
):
d
is
TokenStylingRule
=>
!!
d
.
value
;
if
(
Array
.
isArray
(
definition
))
{
for
(
const
d
of
definition
)
{
const
matchingRule
=
findMatchingThemeRule
(
theme
,
d
,
false
);
if
(
matchingRule
)
{
return
`
${
escape
(
d
.
join
(
'
'
))}
<br><code class="tiw-theme-selector">
${
matchingRule
.
rawSelector
}
\n
${
JSON
.
stringify
(
matchingRule
.
settings
,
null
,
'
\t
'
)}
</code>`
;
}
const
scopesDefinition
:
TextMateThemingRuleDefinitions
=
{};
theme
.
resolveScopes
(
definition
,
scopesDefinition
);
const
matchingRule
=
scopesDefinition
[
property
];
if
(
matchingRule
&&
scopesDefinition
.
scope
)
{
return
`
${
escape
(
scopesDefinition
.
scope
.
join
(
'
'
))}
<br><code class="tiw-theme-selector">
${
matchingRule
.
scope
}
\n
${
JSON
.
stringify
(
matchingRule
.
settings
,
null
,
'
\t
'
)}
</code>`
;
}
return
''
;
}
else
if
(
isTokenStylingRule
(
definition
))
{
...
...
src/vs/workbench/services/themes/common/colorThemeData.ts
浏览文件 @
bf8fb5f8
...
...
@@ -44,6 +44,8 @@ const tokenGroupToScopesMap = {
export
type
TokenStyleDefinition
=
TokenStylingRule
|
ProbeScope
[]
|
TokenStyleValue
;
export
type
TokenStyleDefinitions
=
{
[
P
in
keyof
TokenStyleData
]?:
TokenStyleDefinition
|
undefined
};
export
type
TextMateThemingRuleDefinitions
=
{
[
P
in
keyof
TokenStyleData
]?:
ITextMateThemingRule
|
undefined
;
}
&
{
scope
?:
ProbeScope
;
};
const
PERSISTED_THEME_STORAGE_KEY
=
'
colorThemeData
'
;
export
class
ColorThemeData
implements
IWorkbenchColorTheme
{
...
...
@@ -271,7 +273,8 @@ export class ColorThemeData implements IWorkbenchColorTheme {
return
colorRegistry
.
resolveDefaultColor
(
colorId
,
this
);
}
public
resolveScopes
(
scopes
:
ProbeScope
[]):
TokenStyle
|
undefined
{
public
resolveScopes
(
scopes
:
ProbeScope
[],
definitions
?:
TextMateThemingRuleDefinitions
):
TokenStyle
|
undefined
{
if
(
!
this
.
themeTokenScopeMatchers
)
{
this
.
themeTokenScopeMatchers
=
this
.
themeTokenColors
.
map
(
getScopeMatcher
);
...
...
@@ -285,19 +288,24 @@ export class ColorThemeData implements IWorkbenchColorTheme {
let
fontStyle
:
string
|
undefined
=
undefined
;
let
foregroundScore
=
-
1
;
let
fontStyleScore
=
-
1
;
let
fontStyleThemingRule
:
ITextMateThemingRule
|
undefined
=
undefined
;
let
foregroundThemingRule
:
ITextMateThemingRule
|
undefined
=
undefined
;
function
findTokenStyleForScopeInScopes
(
scopeMatchers
:
Matcher
<
ProbeScope
>
[],
t
okenColor
s
:
ITextMateThemingRule
[])
{
function
findTokenStyleForScopeInScopes
(
scopeMatchers
:
Matcher
<
ProbeScope
>
[],
t
hemingRule
s
:
ITextMateThemingRule
[])
{
for
(
let
i
=
0
;
i
<
scopeMatchers
.
length
;
i
++
)
{
const
score
=
scopeMatchers
[
i
](
scope
);
if
(
score
>=
0
)
{
const
settings
=
tokenColors
[
i
].
settings
;
const
themingRule
=
themingRules
[
i
];
const
settings
=
themingRules
[
i
].
settings
;
if
(
score
>=
foregroundScore
&&
settings
.
foreground
)
{
foreground
=
settings
.
foreground
;
foregroundScore
=
score
;
foregroundThemingRule
=
themingRule
;
}
if
(
score
>=
fontStyleScore
&&
types
.
isString
(
settings
.
fontStyle
))
{
fontStyle
=
settings
.
fontStyle
;
fontStyleScore
=
score
;
fontStyleThemingRule
=
themingRule
;
}
}
}
...
...
@@ -305,6 +313,12 @@ export class ColorThemeData implements IWorkbenchColorTheme {
findTokenStyleForScopeInScopes
(
this
.
themeTokenScopeMatchers
,
this
.
themeTokenColors
);
findTokenStyleForScopeInScopes
(
this
.
customTokenScopeMatchers
,
this
.
customTokenColors
);
if
(
foreground
!==
undefined
||
fontStyle
!==
undefined
)
{
if
(
definitions
)
{
definitions
.
foreground
=
foregroundThemingRule
;
definitions
.
bold
=
definitions
.
italic
=
definitions
.
underline
=
fontStyleThemingRule
;
definitions
.
scope
=
scope
;
}
return
TokenStyle
.
fromSettings
(
foreground
,
fontStyle
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录