Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
徽霖
Vscode
提交
d4193f15
V
Vscode
项目概览
徽霖
/
Vscode
通知
9
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,发现更多精彩内容 >>
提交
d4193f15
编写于
8月 25, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
config - add lookup method
上级
57e3c8f8
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
191 addition
and
11 deletion
+191
-11
src/vs/editor/browser/standalone/simpleServices.ts
src/vs/editor/browser/standalone/simpleServices.ts
+9
-1
src/vs/editor/contrib/referenceSearch/browser/referencesController.ts
...r/contrib/referenceSearch/browser/referencesController.ts
+2
-2
src/vs/platform/configuration/common/configuration.ts
src/vs/platform/configuration/common/configuration.ts
+12
-0
src/vs/platform/configuration/node/configurationService.ts
src/vs/platform/configuration/node/configurationService.ts
+9
-1
src/vs/platform/configuration/test/node/configurationService.test.ts
...form/configuration/test/node/configurationService.test.ts
+49
-0
src/vs/platform/telemetry/test/node/telemetryService.test.ts
src/vs/platform/telemetry/test/node/telemetryService.test.ts
+8
-0
src/vs/test/utils/servicesTestUtils.ts
src/vs/test/utils/servicesTestUtils.ts
+9
-1
src/vs/workbench/parts/lib/test/node/configVariables.test.ts
src/vs/workbench/parts/lib/test/node/configVariables.test.ts
+3
-2
src/vs/workbench/parts/terminal/test/terminalConfigHelper.test.ts
...orkbench/parts/terminal/test/terminalConfigHelper.test.ts
+2
-1
src/vs/workbench/services/configuration/common/configuration.ts
.../workbench/services/configuration/common/configuration.ts
+10
-1
src/vs/workbench/services/configuration/node/configurationService.ts
...bench/services/configuration/node/configurationService.ts
+13
-2
src/vs/workbench/services/configuration/test/node/configurationService.test.ts
...ices/configuration/test/node/configurationService.test.ts
+65
-0
未找到文件。
src/vs/editor/browser/standalone/simpleServices.ts
浏览文件 @
d4193f15
...
...
@@ -9,7 +9,7 @@ import {EventEmitter} from 'vs/base/common/eventEmitter';
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
Severity
from
'
vs/base/common/severity
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IConfigurationService
,
IConfigurationServiceEvent
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IConfigurationService
,
IConfigurationServiceEvent
,
IConfigurationValue
,
getConfigurationValue
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IEditor
,
IEditorInput
,
IEditorOptions
,
IEditorService
,
IResourceInput
,
ITextEditorModel
,
Position
}
from
'
vs/platform/editor/common/editor
'
;
import
{
AbstractExtensionService
,
ActivatedExtension
}
from
'
vs/platform/extensions/common/abstractExtensionService
'
;
import
{
IExtensionDescription
}
from
'
vs/platform/extensions/common/extensions
'
;
...
...
@@ -296,4 +296,12 @@ export class SimpleConfigurationService implements IConfigurationService {
public
reloadConfiguration
<
T
>
(
section
?:
string
):
TPromise
<
T
>
{
return
TPromise
.
as
(
this
.
getConfiguration
(
section
));
}
public
lookup
<
C
>
(
key
:
string
):
IConfigurationValue
<
C
>
{
return
{
value
:
getConfigurationValue
<
C
>
(
this
.
getConfiguration
(),
key
),
default
:
getConfigurationValue
<
C
>
(
this
.
getConfiguration
(),
key
),
user
:
getConfigurationValue
<
C
>
(
this
.
getConfiguration
(),
key
)
};
}
}
src/vs/editor/contrib/referenceSearch/browser/referencesController.ts
浏览文件 @
d4193f15
...
...
@@ -14,7 +14,7 @@ import {IInstantiationService, optional} from 'vs/platform/instantiation/common/
import
{
IContextKey
,
IContextKeyService
,
RawContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IMessageService
}
from
'
vs/platform/message/common/message
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
IConfigurationService
,
getConfigurationValue
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
IStorageService
}
from
'
vs/platform/storage/common/storage
'
;
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
...
...
@@ -116,7 +116,7 @@ export class ReferencesController implements editorCommon.IEditorContribution {
switch
(
kind
)
{
case
'
open
'
:
if
(
event
.
source
===
'
editor
'
&&
getConfigurationValue
(
this
.
_configurationService
.
getConfiguration
(),
'
editor.stablePeek
'
,
false
)
)
{
&&
this
.
_configurationService
.
lookup
(
'
editor.stablePeek
'
).
value
)
{
// when stable peek is configured we don't close
// the peek window on selecting the editor
...
...
src/vs/platform/configuration/common/configuration.ts
浏览文件 @
d4193f15
...
...
@@ -18,6 +18,12 @@ export interface IConfigurationService {
*/
getConfiguration
<
T
>
(
section
?:
string
):
T
;
/**
* Resolves a configuration key to its values in the different scopes
* the setting is defined.
*/
lookup
<
T
>
(
key
:
string
):
IConfigurationValue
<
T
>
;
/**
* Similar to #getConfiguration() but ensures that the latest configuration
* from disk is fetched.
...
...
@@ -34,6 +40,12 @@ export interface IConfigurationServiceEvent {
config
:
any
;
}
export
interface
IConfigurationValue
<
T
>
{
value
:
T
;
default
:
T
;
user
:
T
;
}
/**
* A helper function to get the configuration value with a specific settings path (e.g. config.some.setting)
*/
...
...
src/vs/platform/configuration/node/configurationService.ts
浏览文件 @
d4193f15
...
...
@@ -11,7 +11,7 @@ import {ConfigWatcher} from 'vs/base/node/config';
import
{
Registry
}
from
'
vs/platform/platform
'
;
import
{
IConfigurationRegistry
,
Extensions
}
from
'
vs/platform/configuration/common/configurationRegistry
'
;
import
{
IDisposable
,
dispose
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IConfigurationService
,
IConfigurationServiceEvent
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IConfigurationService
,
IConfigurationServiceEvent
,
IConfigurationValue
,
getConfigurationValue
}
from
'
vs/platform/configuration/common/configuration
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
...
...
@@ -72,6 +72,14 @@ export class ConfigurationService<T> implements IConfigurationService, IDisposab
return
section
?
consolidatedConfig
[
section
]
:
consolidatedConfig
;
}
public
lookup
<
C
>
(
key
:
string
):
IConfigurationValue
<
C
>
{
return
{
default
:
getConfigurationValue
<
C
>
(
getDefaultValues
(),
key
),
user
:
getConfigurationValue
<
C
>
(
flatten
(
this
.
rawConfig
.
getConfig
()),
key
),
value
:
getConfigurationValue
<
C
>
(
this
.
getConfiguration
(),
key
)
};
}
private
getConsolidatedConfig
():
T
{
const
defaults
=
getDefaultValues
();
// defaults coming from contributions to registries
const
user
=
flatten
(
this
.
rawConfig
.
getConfig
());
// user configured settings
...
...
src/vs/platform/configuration/test/node/configurationService.test.ts
浏览文件 @
d4193f15
...
...
@@ -209,4 +209,53 @@ suite('ConfigurationService - Node', () => {
});
});
});
test
(
'
lookup
'
,
(
done
:
()
=>
void
)
=>
{
interface
ILookupTestSetting
{
lookup
:
{
service
:
{
testSetting
:
string
;
}
};
}
const
configurationRegistry
=
<
IConfigurationRegistry
>
Registry
.
as
(
ConfigurationExtensions
.
Configuration
);
configurationRegistry
.
registerConfiguration
({
'
id
'
:
'
_test
'
,
'
type
'
:
'
object
'
,
'
properties
'
:
{
'
lookup.service.testSetting
'
:
{
'
type
'
:
'
string
'
,
'
default
'
:
'
isSet
'
}
}
});
testFile
((
testFile
,
cleanUp
)
=>
{
const
service
=
new
ConfigurationService
(
new
SettingsTestEnvironmentService
(
parseArgs
(
process
.
argv
),
process
.
execPath
,
testFile
));
let
res
=
service
.
lookup
(
'
something.missing
'
);
assert
.
ok
(
!
res
.
value
);
assert
.
ok
(
!
res
.
default
);
assert
.
ok
(
!
res
.
user
);
res
=
service
.
lookup
(
'
lookup.service.testSetting
'
);
assert
.
equal
(
res
.
default
,
'
isSet
'
);
assert
.
equal
(
res
.
value
,
'
isSet
'
);
assert
.
ok
(
!
res
.
user
);
fs
.
writeFileSync
(
testFile
,
'
{ "lookup.service.testSetting": "bar" }
'
);
return
service
.
reloadConfiguration
().
then
(()
=>
{
res
=
service
.
lookup
(
'
lookup.service.testSetting
'
);
assert
.
equal
(
res
.
default
,
'
isSet
'
);
assert
.
equal
(
res
.
user
,
'
bar
'
);
assert
.
equal
(
res
.
value
,
'
bar
'
);
service
.
dispose
();
cleanUp
(
done
);
});
});
});
});
\ No newline at end of file
src/vs/platform/telemetry/test/node/telemetryService.test.ts
浏览文件 @
d4193f15
...
...
@@ -13,6 +13,7 @@ import Telemetry = require('vs/platform/telemetry/common/telemetry');
import
Errors
=
require
(
'
vs/base/common/errors
'
);
import
Timer
=
require
(
'
vs/base/common/timer
'
);
import
*
as
sinon
from
'
sinon
'
;
import
{
getConfigurationValue
}
from
'
vs/platform/configuration/common/configuration
'
;
const
optInStatusEventName
:
string
=
'
optInStatus
'
;
...
...
@@ -654,6 +655,13 @@ suite('TelemetryService', () => {
reloadConfiguration
()
{
return
TPromise
.
as
(
this
.
getConfiguration
());
},
lookup
(
key
:
string
)
{
return
{
value
:
getConfigurationValue
(
this
.
getConfiguration
(),
key
),
default
:
getConfigurationValue
(
this
.
getConfiguration
(),
key
),
user
:
getConfigurationValue
(
this
.
getConfiguration
(),
key
)
};
},
onDidUpdateConfiguration
:
emitter
.
event
});
...
...
src/vs/test/utils/servicesTestUtils.ts
浏览文件 @
d4193f15
...
...
@@ -15,7 +15,7 @@ import Storage = require('vs/workbench/common/storage');
import
{
EditorInputEvent
,
IEditorGroup
}
from
'
vs/workbench/common/editor
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
Severity
from
'
vs/base/common/severity
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IConfigurationService
,
getConfigurationValue
,
IConfigurationValue
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IStorageService
,
StorageScope
}
from
'
vs/platform/storage/common/storage
'
;
import
WorkbenchEditorService
=
require
(
'
vs/workbench/services/editor/common/editorService
'
);
import
QuickOpenService
=
require
(
'
vs/workbench/services/quickopen/common/quickOpenService
'
);
...
...
@@ -557,6 +557,14 @@ export class TestConfigurationService extends EventEmitter.EventEmitter implemen
public
onDidUpdateConfiguration
()
{
return
{
dispose
()
{
}
};
}
public
lookup
<
C
>
(
key
:
string
):
IConfigurationValue
<
C
>
{
return
{
value
:
getConfigurationValue
<
C
>
(
this
.
getConfiguration
(),
key
),
default
:
getConfigurationValue
<
C
>
(
this
.
getConfiguration
(),
key
),
user
:
getConfigurationValue
<
C
>
(
this
.
getConfiguration
(),
key
)
};
}
}
export
class
TestLifecycleService
implements
ILifecycleService
{
...
...
src/vs/workbench/parts/lib/test/node/configVariables.test.ts
浏览文件 @
d4193f15
...
...
@@ -7,8 +7,8 @@
import
*
as
assert
from
'
assert
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
*
as
Platform
from
'
vs/base/common/platform
'
;
import
{
ConfigVariables
}
from
'
vs/workbench/parts/lib/node/configVariables
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
ConfigVariables
}
from
'
vs/workbench/parts/lib/node/configVariables
'
;
import
{
IConfigurationService
,
getConfigurationValue
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
TestEnvironmentService
}
from
'
vs/test/utils/servicesTestUtils
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
...
...
@@ -126,6 +126,7 @@ class MockConfigurationService implements IConfigurationService {
public
serviceId
=
IConfigurationService
;
public
constructor
(
private
configuration
:
any
=
{})
{
}
public
reloadConfiguration
<
T
>
(
section
?:
string
):
TPromise
<
T
>
{
return
TPromise
.
as
(
this
.
getConfiguration
());
}
public
lookup
(
key
:
string
)
{
return
{
value
:
getConfigurationValue
(
this
.
getConfiguration
(),
key
),
default
:
getConfigurationValue
(
this
.
getConfiguration
(),
key
),
user
:
getConfigurationValue
(
this
.
getConfiguration
(),
key
)
};
}
public
getConfiguration
():
any
{
return
this
.
configuration
;
}
public
onDidUpdateConfiguration
()
{
return
{
dispose
()
{
}
};
}
}
\ No newline at end of file
src/vs/workbench/parts/terminal/test/terminalConfigHelper.test.ts
浏览文件 @
d4193f15
...
...
@@ -7,7 +7,7 @@
import
*
as
assert
from
'
assert
'
;
import
{
Builder
}
from
'
vs/base/browser/builder
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IConfigurationService
,
getConfigurationValue
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
Platform
}
from
'
vs/base/common/platform
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
TerminalConfigHelper
}
from
'
vs/workbench/parts/terminal/electron-browser/terminalConfigHelper
'
;
...
...
@@ -18,6 +18,7 @@ class MockConfigurationService implements IConfigurationService {
public
_serviceBrand
:
any
;
public
constructor
(
private
configuration
:
any
=
{})
{}
public
reloadConfiguration
<
T
>
(
section
?:
string
):
TPromise
<
T
>
{
return
TPromise
.
as
(
this
.
getConfiguration
());
}
public
lookup
(
key
:
string
)
{
return
{
value
:
getConfigurationValue
(
this
.
getConfiguration
(),
key
),
default
:
getConfigurationValue
(
this
.
getConfiguration
(),
key
),
user
:
getConfigurationValue
(
this
.
getConfiguration
(),
key
)
};
}
public
getConfiguration
():
any
{
return
this
.
configuration
;
}
public
onDidUpdateConfiguration
()
{
return
{
dispose
()
{
}
};
}
}
...
...
src/vs/workbench/services/configuration/common/configuration.ts
浏览文件 @
d4193f15
...
...
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import
{
JSONPath
}
from
'
vs/base/common/json
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IConfigurationService
,
IConfigurationValue
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
export
const
IWorkbenchConfigurationService
=
createDecorator
<
IWorkbenchConfigurationService
>
(
'
configurationService
'
);
...
...
@@ -16,9 +16,18 @@ export interface IWorkbenchConfigurationService extends IConfigurationService {
*/
hasWorkspaceConfiguration
():
boolean
;
/**
* Override for the IConfigurationService#lookup() method that adds information about workspace settings.
*/
lookup
<
T
>
(
key
:
string
):
IWorkbenchConfigurationValue
<
T
>
;
/**
* Sets a user configuration. An the setting does not yet exist in the settings, it will be
* added.
*/
setUserConfiguration
(
key
:
string
|
JSONPath
,
value
:
any
):
Thenable
<
void
>
;
}
export
interface
IWorkbenchConfigurationValue
<
T
>
extends
IConfigurationValue
<
T
>
{
workspace
:
T
;
}
\ No newline at end of file
src/vs/workbench/services/configuration/node/configurationService.ts
浏览文件 @
d4193f15
...
...
@@ -22,9 +22,9 @@ import {applyEdits} from 'vs/base/common/jsonFormatter';
import
{
setProperty
}
from
'
vs/base/common/jsonEdit
'
;
import
errors
=
require
(
'
vs/base/common/errors
'
);
import
{
IConfigFile
,
consolidate
,
CONFIG_DEFAULT_NAME
,
newConfigFile
}
from
'
vs/workbench/services/configuration/common/model
'
;
import
{
IConfigurationServiceEvent
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IConfigurationServiceEvent
,
getConfigurationValue
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
ConfigurationService
as
BaseConfigurationService
}
from
'
vs/platform/configuration/node/configurationService
'
;
import
{
IWorkbenchConfigurationService
}
from
'
vs/workbench/services/configuration/common/configuration
'
;
import
{
IWorkbenchConfigurationService
,
IWorkbenchConfigurationValue
}
from
'
vs/workbench/services/configuration/common/configuration
'
;
import
{
EventType
as
FileEventType
,
FileChangeType
,
FileChangesEvent
}
from
'
vs/platform/files/common/files
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
...
...
@@ -116,6 +116,17 @@ export class WorkspaceConfigurationService implements IWorkbenchConfigurationSer
return
section
?
this
.
cachedConfig
[
section
]
:
this
.
cachedConfig
;
}
public
lookup
<
C
>
(
key
:
string
):
IWorkbenchConfigurationValue
<
C
>
{
const
configurationValue
=
this
.
baseConfigurationService
.
lookup
<
C
>
(
key
);
return
{
default
:
configurationValue
.
default
,
user
:
configurationValue
.
user
,
workspace
:
getConfigurationValue
<
C
>
(
this
.
cachedWorkspaceConfig
,
key
),
value
:
getConfigurationValue
<
C
>
(
this
.
getConfiguration
(),
key
)
};
}
public
reloadConfiguration
(
section
?:
string
):
TPromise
<
any
>
{
// Reset caches to ensure we are hitting the disk
...
...
src/vs/workbench/services/configuration/test/node/configurationService.test.ts
浏览文件 @
d4193f15
...
...
@@ -229,4 +229,69 @@ suite('WorkspaceConfigurationService - Node', () => {
});
});
});
test
(
'
lookup
'
,
(
done
:
()
=>
void
)
=>
{
interface
ILookupTestSetting
{
workspaceLookup
:
{
service
:
{
testSetting
:
string
;
}
};
}
const
configurationRegistry
=
<
IConfigurationRegistry
>
Registry
.
as
(
ConfigurationExtensions
.
Configuration
);
configurationRegistry
.
registerConfiguration
({
'
id
'
:
'
_test
'
,
'
type
'
:
'
object
'
,
'
properties
'
:
{
'
workspaceLookup.service.testSetting
'
:
{
'
type
'
:
'
string
'
,
'
default
'
:
'
isSet
'
}
}
});
createWorkspace
((
workspaceDir
,
globalSettingsFile
,
cleanUp
)
=>
{
return
createService
(
workspaceDir
,
globalSettingsFile
).
then
(
service
=>
{
let
res
=
service
.
lookup
(
'
something.missing
'
);
assert
.
ok
(
!
res
.
default
);
assert
.
ok
(
!
res
.
user
);
assert
.
ok
(
!
res
.
workspace
);
assert
.
ok
(
!
res
.
value
);
res
=
service
.
lookup
(
'
workspaceLookup.service.testSetting
'
);
assert
.
equal
(
res
.
default
,
'
isSet
'
);
assert
.
equal
(
res
.
value
,
'
isSet
'
);
assert
.
ok
(
!
res
.
user
);
assert
.
ok
(
!
res
.
workspace
);
fs
.
writeFileSync
(
globalSettingsFile
,
'
{ "workspaceLookup.service.testSetting": true }
'
);
return
service
.
reloadConfiguration
().
then
(()
=>
{
res
=
service
.
lookup
(
'
workspaceLookup.service.testSetting
'
);
assert
.
equal
(
res
.
default
,
'
isSet
'
);
assert
.
equal
(
res
.
user
,
true
);
assert
.
equal
(
res
.
value
,
true
);
assert
.
ok
(
!
res
.
workspace
);
const
settingsFile
=
path
.
join
(
workspaceDir
,
'
.vscode
'
,
'
settings.json
'
);
fs
.
writeFileSync
(
settingsFile
,
'
{ "workspaceLookup.service.testSetting": 55 }
'
);
return
service
.
reloadConfiguration
().
then
(()
=>
{
res
=
service
.
lookup
(
'
workspaceLookup.service.testSetting
'
);
assert
.
equal
(
res
.
default
,
'
isSet
'
);
assert
.
equal
(
res
.
user
,
true
);
assert
.
equal
(
res
.
workspace
,
55
);
assert
.
equal
(
res
.
value
,
55
);
service
.
dispose
();
cleanUp
(
done
);
});
});
});
});
});
});
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录