Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
a3143da0
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
a3143da0
编写于
1月 29, 2020
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make ITheme.getTokenStyleMetadata return an object to be able to express "inherit" (#89600)
上级
bf15553f
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
71 addition
and
56 deletion
+71
-56
src/vs/editor/common/services/modelServiceImpl.ts
src/vs/editor/common/services/modelServiceImpl.ts
+16
-4
src/vs/editor/standalone/browser/standaloneThemeServiceImpl.ts
...s/editor/standalone/browser/standaloneThemeServiceImpl.ts
+2
-2
src/vs/editor/standalone/test/browser/standaloneLanguages.test.ts
...ditor/standalone/test/browser/standaloneLanguages.test.ts
+2
-2
src/vs/platform/theme/common/themeService.ts
src/vs/platform/theme/common/themeService.ts
+8
-1
src/vs/platform/theme/test/common/testThemeService.ts
src/vs/platform/theme/test/common/testThemeService.ts
+2
-2
src/vs/workbench/contrib/codeEditor/browser/inspectEditorTokens/inspectEditorTokens.ts
...Editor/browser/inspectEditorTokens/inspectEditorTokens.ts
+24
-3
src/vs/workbench/services/themes/common/colorThemeData.ts
src/vs/workbench/services/themes/common/colorThemeData.ts
+11
-33
src/vs/workbench/services/themes/test/electron-browser/tokenStyleResolving.test.ts
.../themes/test/electron-browser/tokenStyleResolving.test.ts
+6
-9
未找到文件。
src/vs/editor/common/services/modelServiceImpl.ts
浏览文件 @
a3143da0
...
@@ -14,7 +14,7 @@ import { Range } from 'vs/editor/common/core/range';
...
@@ -14,7 +14,7 @@ import { Range } from 'vs/editor/common/core/range';
import
{
DefaultEndOfLine
,
EndOfLinePreference
,
EndOfLineSequence
,
IIdentifiedSingleEditOperation
,
ITextBuffer
,
ITextBufferFactory
,
ITextModel
,
ITextModelCreationOptions
}
from
'
vs/editor/common/model
'
;
import
{
DefaultEndOfLine
,
EndOfLinePreference
,
EndOfLineSequence
,
IIdentifiedSingleEditOperation
,
ITextBuffer
,
ITextBufferFactory
,
ITextModel
,
ITextModelCreationOptions
}
from
'
vs/editor/common/model
'
;
import
{
TextModel
,
createTextBuffer
}
from
'
vs/editor/common/model/textModel
'
;
import
{
TextModel
,
createTextBuffer
}
from
'
vs/editor/common/model/textModel
'
;
import
{
IModelLanguageChangedEvent
,
IModelContentChangedEvent
}
from
'
vs/editor/common/model/textModelEvents
'
;
import
{
IModelLanguageChangedEvent
,
IModelContentChangedEvent
}
from
'
vs/editor/common/model/textModelEvents
'
;
import
{
LanguageIdentifier
,
DocumentSemanticTokensProviderRegistry
,
DocumentSemanticTokensProvider
,
SemanticTokensLegend
,
SemanticTokens
,
SemanticTokensEdits
,
TokenMetadata
}
from
'
vs/editor/common/modes
'
;
import
{
LanguageIdentifier
,
DocumentSemanticTokensProviderRegistry
,
DocumentSemanticTokensProvider
,
SemanticTokensLegend
,
SemanticTokens
,
SemanticTokensEdits
,
TokenMetadata
,
FontStyle
,
MetadataConsts
}
from
'
vs/editor/common/modes
'
;
import
{
PLAINTEXT_LANGUAGE_IDENTIFIER
}
from
'
vs/editor/common/modes/modesRegistry
'
;
import
{
PLAINTEXT_LANGUAGE_IDENTIFIER
}
from
'
vs/editor/common/modes/modesRegistry
'
;
import
{
ILanguageSelection
}
from
'
vs/editor/common/services/modeService
'
;
import
{
ILanguageSelection
}
from
'
vs/editor/common/services/modeService
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
...
@@ -629,7 +629,7 @@ class SemanticColoringProviderStyling {
...
@@ -629,7 +629,7 @@ class SemanticColoringProviderStyling {
public
getMetadata
(
tokenTypeIndex
:
number
,
tokenModifierSet
:
number
):
number
{
public
getMetadata
(
tokenTypeIndex
:
number
,
tokenModifierSet
:
number
):
number
{
const
entry
=
this
.
_hashTable
.
get
(
tokenTypeIndex
,
tokenModifierSet
);
const
entry
=
this
.
_hashTable
.
get
(
tokenTypeIndex
,
tokenModifierSet
);
let
metadata
:
number
|
undefined
;
let
metadata
:
number
;
if
(
entry
)
{
if
(
entry
)
{
metadata
=
entry
.
metadata
;
metadata
=
entry
.
metadata
;
}
else
{
}
else
{
...
@@ -643,9 +643,21 @@ class SemanticColoringProviderStyling {
...
@@ -643,9 +643,21 @@ class SemanticColoringProviderStyling {
modifierSet
=
modifierSet
>>
1
;
modifierSet
=
modifierSet
>>
1
;
}
}
metadata
=
this
.
_themeService
.
getTheme
().
getTokenStyleMetadata
(
tokenType
,
tokenModifiers
);
const
tokenStyle
=
this
.
_themeService
.
getTheme
().
getTokenStyleMetadata
(
tokenType
,
tokenModifiers
);
if
(
typeof
metadata
===
'
undefined
'
)
{
if
(
typeof
tokenStyle
===
'
undefined
'
)
{
metadata
=
Constants
.
NO_STYLING
;
metadata
=
Constants
.
NO_STYLING
;
}
else
{
const
fontStyle
=
(
(
tokenStyle
.
italic
?
FontStyle
.
Italic
:
0
)
|
(
tokenStyle
.
bold
?
FontStyle
.
Bold
:
0
)
|
(
tokenStyle
.
underline
?
FontStyle
.
Underline
:
0
)
);
const
foreground
=
tokenStyle
.
foreground
||
0
;
metadata
=
(
foreground
<<
MetadataConsts
.
FOREGROUND_OFFSET
|
fontStyle
<<
MetadataConsts
.
FONT_STYLE_OFFSET
)
>>>
0
;
}
}
this
.
_hashTable
.
add
(
tokenTypeIndex
,
tokenModifierSet
,
metadata
);
this
.
_hashTable
.
add
(
tokenTypeIndex
,
tokenModifierSet
,
metadata
);
}
}
...
...
src/vs/editor/standalone/browser/standaloneThemeServiceImpl.ts
浏览文件 @
a3143da0
...
@@ -13,7 +13,7 @@ import { hc_black, vs, vs_dark } from 'vs/editor/standalone/common/themes';
...
@@ -13,7 +13,7 @@ import { hc_black, vs, vs_dark } from 'vs/editor/standalone/common/themes';
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
ColorIdentifier
,
Extensions
,
IColorRegistry
}
from
'
vs/platform/theme/common/colorRegistry
'
;
import
{
ColorIdentifier
,
Extensions
,
IColorRegistry
}
from
'
vs/platform/theme/common/colorRegistry
'
;
import
{
Extensions
as
ThemingExtensions
,
ICssStyleCollector
,
IIconTheme
,
IThemingRegistry
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
Extensions
as
ThemingExtensions
,
ICssStyleCollector
,
IIconTheme
,
IThemingRegistry
,
ITokenStyle
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
IDisposable
,
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
,
Disposable
}
from
'
vs/base/common/lifecycle
'
;
const
VS_THEME_NAME
=
'
vs
'
;
const
VS_THEME_NAME
=
'
vs
'
;
...
@@ -131,7 +131,7 @@ class StandaloneTheme implements IStandaloneTheme {
...
@@ -131,7 +131,7 @@ class StandaloneTheme implements IStandaloneTheme {
return
this
.
_tokenTheme
;
return
this
.
_tokenTheme
;
}
}
public
getTokenStyleMetadata
(
type
:
string
,
modifiers
:
string
[]):
number
|
undefined
{
public
getTokenStyleMetadata
(
type
:
string
,
modifiers
:
string
[]):
ITokenStyle
|
undefined
{
return
undefined
;
return
undefined
;
}
}
...
...
src/vs/editor/standalone/test/browser/standaloneLanguages.test.ts
浏览文件 @
a3143da0
...
@@ -12,7 +12,7 @@ import { TokenTheme } from 'vs/editor/common/modes/supports/tokenization';
...
@@ -12,7 +12,7 @@ import { TokenTheme } from 'vs/editor/common/modes/supports/tokenization';
import
{
ILineTokens
,
IToken
,
TokenizationSupport2Adapter
,
TokensProvider
}
from
'
vs/editor/standalone/browser/standaloneLanguages
'
;
import
{
ILineTokens
,
IToken
,
TokenizationSupport2Adapter
,
TokensProvider
}
from
'
vs/editor/standalone/browser/standaloneLanguages
'
;
import
{
IStandaloneTheme
,
IStandaloneThemeData
,
IStandaloneThemeService
}
from
'
vs/editor/standalone/common/standaloneThemeService
'
;
import
{
IStandaloneTheme
,
IStandaloneThemeData
,
IStandaloneThemeService
}
from
'
vs/editor/standalone/common/standaloneThemeService
'
;
import
{
ColorIdentifier
}
from
'
vs/platform/theme/common/colorRegistry
'
;
import
{
ColorIdentifier
}
from
'
vs/platform/theme/common/colorRegistry
'
;
import
{
IIconTheme
,
ITheme
,
LIGHT
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
IIconTheme
,
ITheme
,
LIGHT
,
ITokenStyle
}
from
'
vs/platform/theme/common/themeService
'
;
suite
(
'
TokenizationSupport2Adapter
'
,
()
=>
{
suite
(
'
TokenizationSupport2Adapter
'
,
()
=>
{
...
@@ -56,7 +56,7 @@ suite('TokenizationSupport2Adapter', () => {
...
@@ -56,7 +56,7 @@ suite('TokenizationSupport2Adapter', () => {
throw
new
Error
(
'
Not implemented
'
);
throw
new
Error
(
'
Not implemented
'
);
},
},
getTokenStyleMetadata
:
(
type
:
string
,
modifiers
:
string
[]):
number
|
undefined
=>
{
getTokenStyleMetadata
:
(
type
:
string
,
modifiers
:
string
[]):
ITokenStyle
|
undefined
=>
{
return
undefined
;
return
undefined
;
},
},
...
...
src/vs/platform/theme/common/themeService.ts
浏览文件 @
a3143da0
...
@@ -79,6 +79,13 @@ export function getThemeTypeSelector(type: ThemeType): string {
...
@@ -79,6 +79,13 @@ export function getThemeTypeSelector(type: ThemeType): string {
}
}
}
}
export
interface
ITokenStyle
{
readonly
foreground
?:
number
;
readonly
bold
?:
boolean
;
readonly
underline
?:
boolean
;
readonly
italic
?:
boolean
;
}
export
interface
ITheme
{
export
interface
ITheme
{
readonly
type
:
ThemeType
;
readonly
type
:
ThemeType
;
...
@@ -99,7 +106,7 @@ export interface ITheme {
...
@@ -99,7 +106,7 @@ export interface ITheme {
/**
/**
* Returns the token style for a given classification. The result uses the <code>MetadataConsts</code> format
* Returns the token style for a given classification. The result uses the <code>MetadataConsts</code> format
*/
*/
getTokenStyleMetadata
(
type
:
string
,
modifiers
:
string
[]):
number
|
undefined
;
getTokenStyleMetadata
(
type
:
string
,
modifiers
:
string
[]):
ITokenStyle
|
undefined
;
/**
/**
* List of all colors used with tokens. <code>getTokenStyleMetadata</code> references the colors by index into this list.
* List of all colors used with tokens. <code>getTokenStyleMetadata</code> references the colors by index into this list.
...
...
src/vs/platform/theme/test/common/testThemeService.ts
浏览文件 @
a3143da0
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
*--------------------------------------------------------------------------------------------*/
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
{
IThemeService
,
ITheme
,
DARK
,
IIconTheme
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
IThemeService
,
ITheme
,
DARK
,
IIconTheme
,
ITokenStyle
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
Color
}
from
'
vs/base/common/color
'
;
import
{
Color
}
from
'
vs/base/common/color
'
;
export
class
TestTheme
implements
ITheme
{
export
class
TestTheme
implements
ITheme
{
...
@@ -24,7 +24,7 @@ export class TestTheme implements ITheme {
...
@@ -24,7 +24,7 @@ export class TestTheme implements ITheme {
throw
new
Error
(
'
Method not implemented.
'
);
throw
new
Error
(
'
Method not implemented.
'
);
}
}
getTokenStyleMetadata
(
type
:
string
,
modifiers
:
string
[]):
number
|
undefined
{
getTokenStyleMetadata
(
type
:
string
,
modifiers
:
string
[]):
ITokenStyle
|
undefined
{
return
undefined
;
return
undefined
;
}
}
...
...
src/vs/workbench/contrib/codeEditor/browser/inspectEditorTokens/inspectEditorTokens.ts
浏览文件 @
a3143da0
...
@@ -17,7 +17,7 @@ import { Position } from 'vs/editor/common/core/position';
...
@@ -17,7 +17,7 @@ import { Position } from 'vs/editor/common/core/position';
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
IEditorContribution
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IEditorContribution
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ITextModel
}
from
'
vs/editor/common/model
'
;
import
{
ITextModel
}
from
'
vs/editor/common/model
'
;
import
{
FontStyle
,
LanguageIdentifier
,
StandardTokenType
,
TokenMetadata
,
DocumentSemanticTokensProviderRegistry
,
SemanticTokensLegend
,
SemanticTokens
}
from
'
vs/editor/common/modes
'
;
import
{
FontStyle
,
LanguageIdentifier
,
StandardTokenType
,
TokenMetadata
,
DocumentSemanticTokensProviderRegistry
,
SemanticTokensLegend
,
SemanticTokens
,
LanguageId
}
from
'
vs/editor/common/modes
'
;
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
INotificationService
}
from
'
vs/platform/notification/common/notification
'
;
import
{
INotificationService
}
from
'
vs/platform/notification/common/notification
'
;
import
{
editorHoverBackground
,
editorHoverBorder
}
from
'
vs/platform/theme/common/colorRegistry
'
;
import
{
editorHoverBackground
,
editorHoverBorder
}
from
'
vs/platform/theme/common/colorRegistry
'
;
...
@@ -474,9 +474,30 @@ class InspectEditorTokensWidget extends Disposable implements IContentWidget {
...
@@ -474,9 +474,30 @@ class InspectEditorTokensWidget extends Disposable implements IContentWidget {
const
modifiers
=
semanticTokens
.
legend
.
tokenModifiers
.
filter
((
_
,
k
)
=>
modSet
&
1
<<
k
);
const
modifiers
=
semanticTokens
.
legend
.
tokenModifiers
.
filter
((
_
,
k
)
=>
modSet
&
1
<<
k
);
const
range
=
new
Range
(
line
+
1
,
character
+
1
,
line
+
1
,
character
+
1
+
len
);
const
range
=
new
Range
(
line
+
1
,
character
+
1
,
line
+
1
,
character
+
1
+
len
);
const
definitions
=
{};
const
definitions
=
{};
const
colorMap
=
this
.
_themeService
.
getColorTheme
().
tokenColorMap
;
const
theme
=
this
.
_themeService
.
getTheme
()
as
ColorThemeData
;
const
theme
=
this
.
_themeService
.
getTheme
()
as
ColorThemeData
;
const
m
=
theme
.
getTokenStyleMetadata
(
type
,
modifiers
,
true
,
definitions
);
const
tokenStyle
=
theme
.
getTokenStyleMetadata
(
type
,
modifiers
,
true
,
definitions
);
const
metadata
=
this
.
_decodeMetadata
(
m
||
0
);
let
fontStyle
=
FontStyle
.
None
;
let
foreground
:
string
|
undefined
=
undefined
;
if
(
tokenStyle
)
{
fontStyle
=
(
(
tokenStyle
.
italic
?
FontStyle
.
Italic
:
0
)
|
(
tokenStyle
.
bold
?
FontStyle
.
Bold
:
0
)
|
(
tokenStyle
.
underline
?
FontStyle
.
Underline
:
0
)
);
if
(
tokenStyle
.
foreground
)
{
foreground
=
colorMap
[
tokenStyle
.
foreground
];
}
}
const
metadata
:
IDecodedMetadata
=
{
languageIdentifier
:
this
.
_modeService
.
getLanguageIdentifier
(
LanguageId
.
Null
)
!
,
tokenType
:
StandardTokenType
.
Other
,
fontStyle
:
this
.
_fontStyleToString
(
fontStyle
),
foreground
:
foreground
,
};
return
{
type
,
modifiers
,
range
,
metadata
,
definitions
};
return
{
type
,
modifiers
,
range
,
metadata
,
definitions
};
}
}
lastLine
=
line
;
lastLine
=
line
;
...
...
src/vs/workbench/services/themes/common/colorThemeData.ts
浏览文件 @
a3143da0
...
@@ -13,7 +13,7 @@ import * as types from 'vs/base/common/types';
...
@@ -13,7 +13,7 @@ import * as types from 'vs/base/common/types';
import
*
as
objects
from
'
vs/base/common/objects
'
;
import
*
as
objects
from
'
vs/base/common/objects
'
;
import
*
as
resources
from
'
vs/base/common/resources
'
;
import
*
as
resources
from
'
vs/base/common/resources
'
;
import
{
Extensions
as
ColorRegistryExtensions
,
IColorRegistry
,
ColorIdentifier
,
editorBackground
,
editorForeground
}
from
'
vs/platform/theme/common/colorRegistry
'
;
import
{
Extensions
as
ColorRegistryExtensions
,
IColorRegistry
,
ColorIdentifier
,
editorBackground
,
editorForeground
}
from
'
vs/platform/theme/common/colorRegistry
'
;
import
{
ThemeType
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
ThemeType
,
ITokenStyle
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
getParseErrorMessage
}
from
'
vs/base/common/jsonErrorMessages
'
;
import
{
getParseErrorMessage
}
from
'
vs/base/common/jsonErrorMessages
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
...
@@ -22,7 +22,6 @@ import { startsWith } from 'vs/base/common/strings';
...
@@ -22,7 +22,6 @@ import { startsWith } from 'vs/base/common/strings';
import
{
TokenStyle
,
TokenClassification
,
ProbeScope
,
TokenStylingRule
,
getTokenClassificationRegistry
,
TokenStyleValue
,
TokenStyleData
}
from
'
vs/platform/theme/common/tokenClassificationRegistry
'
;
import
{
TokenStyle
,
TokenClassification
,
ProbeScope
,
TokenStylingRule
,
getTokenClassificationRegistry
,
TokenStyleValue
,
TokenStyleData
}
from
'
vs/platform/theme/common/tokenClassificationRegistry
'
;
import
{
MatcherWithPriority
,
Matcher
,
createMatchers
}
from
'
vs/workbench/services/themes/common/textMateScopeMatcher
'
;
import
{
MatcherWithPriority
,
Matcher
,
createMatchers
}
from
'
vs/workbench/services/themes/common/textMateScopeMatcher
'
;
import
{
IExtensionResourceLoaderService
}
from
'
vs/workbench/services/extensionResourceLoader/common/extensionResourceLoader
'
;
import
{
IExtensionResourceLoaderService
}
from
'
vs/workbench/services/extensionResourceLoader/common/extensionResourceLoader
'
;
import
{
FontStyle
,
ColorId
,
MetadataConsts
}
from
'
vs/editor/common/modes
'
;
import
{
CharCode
}
from
'
vs/base/common/charCode
'
;
import
{
CharCode
}
from
'
vs/base/common/charCode
'
;
let
colorRegistry
=
Registry
.
as
<
IColorRegistry
>
(
ColorRegistryExtensions
.
ColorContribution
);
let
colorRegistry
=
Registry
.
as
<
IColorRegistry
>
(
ColorRegistryExtensions
.
ColorContribution
);
...
@@ -243,27 +242,22 @@ export class ColorThemeData implements IColorTheme {
...
@@ -243,27 +242,22 @@ export class ColorThemeData implements IColorTheme {
return
this
.
getTokenColorIndex
().
asArray
();
return
this
.
getTokenColorIndex
().
asArray
();
}
}
public
getTokenStyleMetadata
(
type
:
string
,
modifiers
:
string
[],
useDefault
=
true
,
definitions
:
TokenStyleDefinitions
=
{}):
number
|
undefined
{
public
getTokenStyleMetadata
(
type
:
string
,
modifiers
:
string
[],
useDefault
=
true
,
definitions
:
TokenStyleDefinitions
=
{}):
ITokenStyle
|
undefined
{
const
classification
=
tokenClassificationRegistry
.
getTokenClassification
(
type
,
modifiers
);
const
classification
=
tokenClassificationRegistry
.
getTokenClassification
(
type
,
modifiers
);
if
(
!
classification
)
{
if
(
!
classification
)
{
return
undefined
;
return
undefined
;
}
}
const
style
=
this
.
getTokenStyle
(
classification
,
useDefault
,
definitions
);
const
style
=
this
.
getTokenStyle
(
classification
,
useDefault
,
definitions
);
let
fontStyle
=
FontStyle
.
None
;
if
(
!
style
)
{
let
foreground
=
0
;
return
undefined
;
if
(
style
)
{
if
(
style
.
bold
)
{
fontStyle
|=
FontStyle
.
Bold
;
}
if
(
style
.
underline
)
{
fontStyle
|=
FontStyle
.
Underline
;
}
if
(
style
.
italic
)
{
fontStyle
|=
FontStyle
.
Italic
;
}
foreground
=
this
.
getTokenColorIndex
().
get
(
style
.
foreground
);
}
}
return
toMetadata
(
fontStyle
,
foreground
,
0
);
return
{
foreground
:
this
.
getTokenColorIndex
().
get
(
style
.
foreground
),
bold
:
style
.
bold
,
underline
:
style
.
underline
,
italic
:
style
.
italic
};
}
}
public
getTokenStylingRuleScope
(
rule
:
TokenStylingRule
):
'
setting
'
|
'
theme
'
|
undefined
{
public
getTokenStylingRuleScope
(
rule
:
TokenStylingRule
):
'
setting
'
|
'
theme
'
|
undefined
{
...
@@ -819,19 +813,3 @@ function hexUpper(charCode: CharCode): number {
...
@@ -819,19 +813,3 @@ function hexUpper(charCode: CharCode): number {
}
}
return
0
;
return
0
;
}
}
function
toMetadata
(
fontStyle
:
FontStyle
,
foreground
:
ColorId
|
number
,
background
:
ColorId
|
number
)
{
const
fontStyleBits
=
fontStyle
<<
MetadataConsts
.
FONT_STYLE_OFFSET
;
const
foregroundBits
=
foreground
<<
MetadataConsts
.
FOREGROUND_OFFSET
;
const
backgroundBits
=
background
<<
MetadataConsts
.
BACKGROUND_OFFSET
;
if
((
fontStyleBits
&
MetadataConsts
.
FONT_STYLE_MASK
)
!==
fontStyleBits
)
{
console
.
log
(
`Can not express fontStyle
${
fontStyle
}
in metadata`
);
}
if
((
backgroundBits
&
MetadataConsts
.
BACKGROUND_MASK
)
!==
backgroundBits
)
{
console
.
log
(
`Can not express background
${
background
}
in metadata`
);
}
if
((
foregroundBits
&
MetadataConsts
.
FOREGROUND_MASK
)
!==
foregroundBits
)
{
console
.
log
(
`Can not express foreground
${
foreground
}
in metadata`
);
}
return
(
fontStyleBits
|
foregroundBits
|
backgroundBits
)
>>>
0
;
}
src/vs/workbench/services/themes/test/electron-browser/tokenStyleResolving.test.ts
浏览文件 @
a3143da0
...
@@ -16,7 +16,7 @@ import { Schemas } from 'vs/base/common/network';
...
@@ -16,7 +16,7 @@ import { Schemas } from 'vs/base/common/network';
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
getPathFromAmdModule
}
from
'
vs/base/common/amd
'
;
import
{
getPathFromAmdModule
}
from
'
vs/base/common/amd
'
;
import
{
ExtensionResourceLoaderService
}
from
'
vs/workbench/services/extensionResourceLoader/electron-browser/extensionResourceLoaderService
'
;
import
{
ExtensionResourceLoaderService
}
from
'
vs/workbench/services/extensionResourceLoader/electron-browser/extensionResourceLoaderService
'
;
import
{
TokenMetadata
,
FontStyle
}
from
'
vs/editor/common/modes
'
;
import
{
ITokenStyle
}
from
'
vs/platform/theme/common/themeService
'
;
let
tokenClassificationRegistry
=
getTokenClassificationRegistry
();
let
tokenClassificationRegistry
=
getTokenClassificationRegistry
();
...
@@ -49,24 +49,21 @@ function assertTokenStyle(actual: TokenStyle | undefined | null, expected: Token
...
@@ -49,24 +49,21 @@ function assertTokenStyle(actual: TokenStyle | undefined | null, expected: Token
assert
.
equal
(
tokenStyleAsString
(
actual
),
tokenStyleAsString
(
expected
),
message
);
assert
.
equal
(
tokenStyleAsString
(
actual
),
tokenStyleAsString
(
expected
),
message
);
}
}
function
assertTokenStyleMetaData
(
colorIndex
:
string
[],
actual
:
number
|
undefined
,
expected
:
TokenStyle
|
undefined
|
null
,
message
?:
string
)
{
function
assertTokenStyleMetaData
(
colorIndex
:
string
[],
actual
:
ITokenStyle
|
undefined
,
expected
:
TokenStyle
|
undefined
|
null
,
message
?:
string
)
{
if
(
expected
===
undefined
||
expected
===
null
||
actual
===
undefined
)
{
if
(
expected
===
undefined
||
expected
===
null
||
actual
===
undefined
)
{
assert
.
equal
(
actual
,
expected
,
message
);
assert
.
equal
(
actual
,
expected
,
message
);
return
;
return
;
}
}
const
actualFontStyle
=
TokenMetadata
.
getFontStyle
(
actual
);
assert
.
strictEqual
(
actual
.
bold
,
expected
.
bold
,
'
bold
'
);
assert
.
equal
((
actualFontStyle
&
FontStyle
.
Bold
)
===
FontStyle
.
Bold
,
expected
.
bold
===
true
,
'
bold
'
);
assert
.
strictEqual
(
actual
.
italic
,
expected
.
italic
,
'
italic
'
);
assert
.
equal
((
actualFontStyle
&
FontStyle
.
Italic
)
===
FontStyle
.
Italic
,
expected
.
italic
===
true
,
'
italic
'
);
assert
.
strictEqual
(
actual
.
underline
,
expected
.
underline
,
'
underline
'
);
assert
.
equal
((
actualFontStyle
&
FontStyle
.
Underline
)
===
FontStyle
.
Underline
,
expected
.
underline
===
true
,
'
underline
'
);
const
actualForegroundIndex
=
TokenMetadata
.
getForeground
(
actual
)
;
const
actualForegroundIndex
=
actual
.
foreground
;
if
(
expected
.
foreground
)
{
if
(
expected
.
foreground
)
{
assert
.
equal
(
actualForegroundIndex
,
colorIndex
.
indexOf
(
Color
.
Format
.
CSS
.
formatHexA
(
expected
.
foreground
,
true
).
toUpperCase
()),
'
foreground
'
);
assert
.
equal
(
actualForegroundIndex
,
colorIndex
.
indexOf
(
Color
.
Format
.
CSS
.
formatHexA
(
expected
.
foreground
,
true
).
toUpperCase
()),
'
foreground
'
);
}
else
{
}
else
{
assert
.
equal
(
actualForegroundIndex
,
0
,
'
foreground
'
);
assert
.
equal
(
actualForegroundIndex
,
0
,
'
foreground
'
);
}
}
const
actualBackgroundIndex
=
TokenMetadata
.
getBackground
(
actual
);
assert
.
equal
(
actualBackgroundIndex
,
0
,
'
background
'
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录