Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
ec75457f
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,发现更多精彩内容 >>
提交
ec75457f
编写于
12月 14, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Don't rely on custom marshalling for $setLanguageConfiguration (#40169)
上级
1ab3fd8f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
147 addition
and
9 deletion
+147
-9
src/vs/workbench/api/electron-browser/mainThreadLanguageFeatures.ts
...kbench/api/electron-browser/mainThreadLanguageFeatures.ts
+49
-6
src/vs/workbench/api/node/extHost.protocol.ts
src/vs/workbench/api/node/extHost.protocol.ts
+41
-1
src/vs/workbench/api/node/extHostLanguageFeatures.ts
src/vs/workbench/api/node/extHostLanguageFeatures.ts
+57
-2
未找到文件。
src/vs/workbench/api/electron-browser/mainThreadLanguageFeatures.ts
浏览文件 @
ec75457f
...
...
@@ -15,9 +15,9 @@ import { wireCancellationToken } from 'vs/base/common/async';
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
import
{
Position
as
EditorPosition
}
from
'
vs/editor/common/core/position
'
;
import
{
Range
as
EditorRange
}
from
'
vs/editor/common/core/range
'
;
import
{
ExtHostContext
,
MainThreadLanguageFeaturesShape
,
ExtHostLanguageFeaturesShape
,
MainContext
,
IExtHostContext
}
from
'
../node/extHost.protocol
'
;
import
{
ExtHostContext
,
MainThreadLanguageFeaturesShape
,
ExtHostLanguageFeaturesShape
,
MainContext
,
IExtHostContext
,
ISerializedLanguageConfiguration
,
ISerializedRegExp
,
ISerializedIndentationRule
,
ISerializedOnEnterRule
}
from
'
../node/extHost.protocol
'
;
import
{
LanguageConfigurationRegistry
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
LanguageConfiguration
}
from
'
vs/editor/common/modes/languageConfiguration
'
;
import
{
LanguageConfiguration
,
IndentationRule
,
OnEnterRule
}
from
'
vs/editor/common/modes/languageConfiguration
'
;
import
{
IHeapService
}
from
'
./mainThreadHeapService
'
;
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
extHostNamedCustomer
}
from
'
vs/workbench/api/electron-browser/extHostCustomers
'
;
...
...
@@ -328,14 +328,57 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
// --- configuration
$setLanguageConfiguration
(
handle
:
number
,
languageId
:
string
,
_configuration
:
vscode
.
LanguageConfiguration
):
TPromise
<
any
>
{
private
static
_reviveRegExp
(
regExp
:
ISerializedRegExp
):
RegExp
{
if
(
typeof
regExp
===
'
undefined
'
)
{
return
undefined
;
}
if
(
regExp
===
null
)
{
return
null
;
}
return
new
RegExp
(
regExp
.
pattern
,
regExp
.
flags
);
}
private
static
_reviveIndentationRule
(
indentationRule
:
ISerializedIndentationRule
):
IndentationRule
{
if
(
typeof
indentationRule
===
'
undefined
'
)
{
return
undefined
;
}
if
(
indentationRule
===
null
)
{
return
null
;
}
return
{
decreaseIndentPattern
:
MainThreadLanguageFeatures
.
_reviveRegExp
(
indentationRule
.
decreaseIndentPattern
),
increaseIndentPattern
:
MainThreadLanguageFeatures
.
_reviveRegExp
(
indentationRule
.
increaseIndentPattern
),
indentNextLinePattern
:
MainThreadLanguageFeatures
.
_reviveRegExp
(
indentationRule
.
indentNextLinePattern
),
unIndentedLinePattern
:
MainThreadLanguageFeatures
.
_reviveRegExp
(
indentationRule
.
unIndentedLinePattern
),
};
}
private
static
_reviveOnEnterRule
(
onEnterRule
:
ISerializedOnEnterRule
):
OnEnterRule
{
return
{
beforeText
:
MainThreadLanguageFeatures
.
_reviveRegExp
(
onEnterRule
.
beforeText
),
afterText
:
MainThreadLanguageFeatures
.
_reviveRegExp
(
onEnterRule
.
afterText
),
action
:
onEnterRule
.
action
};
}
private
static
_reviveOnEnterRules
(
onEnterRules
:
ISerializedOnEnterRule
[]):
OnEnterRule
[]
{
if
(
typeof
onEnterRules
===
'
undefined
'
)
{
return
undefined
;
}
if
(
onEnterRules
===
null
)
{
return
null
;
}
return
onEnterRules
.
map
(
MainThreadLanguageFeatures
.
_reviveOnEnterRule
);
}
$setLanguageConfiguration
(
handle
:
number
,
languageId
:
string
,
_configuration
:
ISerializedLanguageConfiguration
):
TPromise
<
any
>
{
let
configuration
:
LanguageConfiguration
=
{
comments
:
_configuration
.
comments
,
brackets
:
_configuration
.
brackets
,
wordPattern
:
_configuration
.
wordPattern
,
indentationRules
:
_configuration
.
indentationRules
,
onEnterRules
:
_configuration
.
onEnterRules
,
wordPattern
:
MainThreadLanguageFeatures
.
_reviveRegExp
(
_configuration
.
wordPattern
)
,
indentationRules
:
MainThreadLanguageFeatures
.
_reviveIndentationRule
(
_configuration
.
indentationRules
)
,
onEnterRules
:
MainThreadLanguageFeatures
.
_reviveOnEnterRules
(
_configuration
.
onEnterRules
)
,
autoClosingPairs
:
null
,
surroundingPairs
:
null
,
...
...
src/vs/workbench/api/node/extHost.protocol.ts
浏览文件 @
ec75457f
...
...
@@ -51,6 +51,7 @@ import { SerializedError } from 'vs/base/common/errors';
import
{
IStat
,
IFileChange
}
from
'
vs/platform/files/common/files
'
;
import
{
ConfigurationScope
}
from
'
vs/platform/configuration/common/configurationRegistry
'
;
import
{
ParsedArgs
}
from
'
vs/platform/environment/common/environment
'
;
import
{
CommentRule
,
CharacterPair
,
EnterAction
}
from
'
vs/editor/common/modes/languageConfiguration
'
;
export
interface
IEnvironment
{
isExtensionDevelopmentDebug
:
boolean
;
...
...
@@ -234,6 +235,45 @@ export interface MainThreadErrorsShape extends IDisposable {
$onUnexpectedError
(
err
:
any
|
SerializedError
):
void
;
}
export
interface
ISerializedRegExp
{
pattern
:
string
;
flags
?:
string
;
}
export
interface
ISerializedIndentationRule
{
decreaseIndentPattern
:
ISerializedRegExp
;
increaseIndentPattern
:
ISerializedRegExp
;
indentNextLinePattern
?:
ISerializedRegExp
;
unIndentedLinePattern
?:
ISerializedRegExp
;
}
export
interface
ISerializedOnEnterRule
{
beforeText
:
ISerializedRegExp
;
afterText
?:
ISerializedRegExp
;
action
:
EnterAction
;
}
export
interface
ISerializedLanguageConfiguration
{
comments
?:
CommentRule
;
brackets
?:
CharacterPair
[];
wordPattern
?:
ISerializedRegExp
;
indentationRules
?:
ISerializedIndentationRule
;
onEnterRules
?:
ISerializedOnEnterRule
[];
__electricCharacterSupport
?:
{
brackets
?:
any
;
docComment
?:
{
scope
:
string
;
open
:
string
;
lineStart
:
string
;
close
?:
string
;
};
};
__characterPairSupport
?:
{
autoClosingPairs
:
{
open
:
string
;
close
:
string
;
notIn
?:
string
[];
}[];
};
}
export
interface
MainThreadLanguageFeaturesShape
extends
IDisposable
{
$unregister
(
handle
:
number
):
TPromise
<
any
>
;
$registerOutlineSupport
(
handle
:
number
,
selector
:
vscode
.
DocumentSelector
):
TPromise
<
any
>
;
...
...
@@ -255,7 +295,7 @@ export interface MainThreadLanguageFeaturesShape extends IDisposable {
$registerSignatureHelpProvider
(
handle
:
number
,
selector
:
vscode
.
DocumentSelector
,
triggerCharacter
:
string
[]):
TPromise
<
any
>
;
$registerDocumentLinkProvider
(
handle
:
number
,
selector
:
vscode
.
DocumentSelector
):
TPromise
<
any
>
;
$registerDocumentColorProvider
(
handle
:
number
,
selector
:
vscode
.
DocumentSelector
):
TPromise
<
any
>
;
$setLanguageConfiguration
(
handle
:
number
,
languageId
:
string
,
configuration
:
vscode
.
LanguageConfiguration
):
TPromise
<
any
>
;
$setLanguageConfiguration
(
handle
:
number
,
languageId
:
string
,
configuration
:
ISerialized
LanguageConfiguration
):
TPromise
<
any
>
;
}
export
interface
MainThreadLanguagesShape
extends
IDisposable
{
...
...
src/vs/workbench/api/node/extHostLanguageFeatures.ts
浏览文件 @
ec75457f
...
...
@@ -17,7 +17,7 @@ import { ExtHostDocuments } from 'vs/workbench/api/node/extHostDocuments';
import
{
ExtHostCommands
,
CommandsConverter
}
from
'
vs/workbench/api/node/extHostCommands
'
;
import
{
ExtHostDiagnostics
,
DiagnosticCollection
}
from
'
vs/workbench/api/node/extHostDiagnostics
'
;
import
{
asWinJsPromise
}
from
'
vs/base/common/async
'
;
import
{
MainContext
,
MainThreadLanguageFeaturesShape
,
ExtHostLanguageFeaturesShape
,
ObjectIdentifier
,
IRawColorInfo
,
IMainContext
,
IExtHostSuggestResult
,
IExtHostSuggestion
,
IWorkspaceSymbols
,
IWorkspaceSymbol
,
IdObject
}
from
'
./extHost.protocol
'
;
import
{
MainContext
,
MainThreadLanguageFeaturesShape
,
ExtHostLanguageFeaturesShape
,
ObjectIdentifier
,
IRawColorInfo
,
IMainContext
,
IExtHostSuggestResult
,
IExtHostSuggestion
,
IWorkspaceSymbols
,
IWorkspaceSymbol
,
IdObject
,
ISerializedRegExp
,
ISerializedIndentationRule
,
ISerializedOnEnterRule
,
ISerializedLanguageConfiguration
}
from
'
./extHost.protocol
'
;
import
{
regExpLeadsToEndlessLoop
}
from
'
vs/base/common/strings
'
;
import
{
IPosition
}
from
'
vs/editor/common/core/position
'
;
import
{
IRange
}
from
'
vs/editor/common/core/range
'
;
...
...
@@ -1089,6 +1089,52 @@ export class ExtHostLanguageFeatures implements ExtHostLanguageFeaturesShape {
// --- configuration
private
static
_serializeRegExp
(
regExp
:
RegExp
):
ISerializedRegExp
{
if
(
typeof
regExp
===
'
undefined
'
)
{
return
undefined
;
}
if
(
regExp
===
null
)
{
return
null
;
}
return
{
pattern
:
regExp
.
source
,
flags
:
(
regExp
.
global
?
'
g
'
:
''
)
+
(
regExp
.
ignoreCase
?
'
i
'
:
''
)
+
(
regExp
.
multiline
?
'
m
'
:
''
),
};
}
private
static
_serializeIndentationRule
(
indentationRule
:
vscode
.
IndentationRule
):
ISerializedIndentationRule
{
if
(
typeof
indentationRule
===
'
undefined
'
)
{
return
undefined
;
}
if
(
indentationRule
===
null
)
{
return
null
;
}
return
{
decreaseIndentPattern
:
ExtHostLanguageFeatures
.
_serializeRegExp
(
indentationRule
.
decreaseIndentPattern
),
increaseIndentPattern
:
ExtHostLanguageFeatures
.
_serializeRegExp
(
indentationRule
.
increaseIndentPattern
),
indentNextLinePattern
:
ExtHostLanguageFeatures
.
_serializeRegExp
(
indentationRule
.
indentNextLinePattern
),
unIndentedLinePattern
:
ExtHostLanguageFeatures
.
_serializeRegExp
(
indentationRule
.
unIndentedLinePattern
),
};
}
private
static
_serializeOnEnterRule
(
onEnterRule
:
vscode
.
OnEnterRule
):
ISerializedOnEnterRule
{
return
{
beforeText
:
ExtHostLanguageFeatures
.
_serializeRegExp
(
onEnterRule
.
beforeText
),
afterText
:
ExtHostLanguageFeatures
.
_serializeRegExp
(
onEnterRule
.
afterText
),
action
:
onEnterRule
.
action
};
}
private
static
_serializeOnEnterRules
(
onEnterRules
:
vscode
.
OnEnterRule
[]):
ISerializedOnEnterRule
[]
{
if
(
typeof
onEnterRules
===
'
undefined
'
)
{
return
undefined
;
}
if
(
onEnterRules
===
null
)
{
return
null
;
}
return
onEnterRules
.
map
(
ExtHostLanguageFeatures
.
_serializeOnEnterRule
);
}
setLanguageConfiguration
(
languageId
:
string
,
configuration
:
vscode
.
LanguageConfiguration
):
vscode
.
Disposable
{
let
{
wordPattern
}
=
configuration
;
...
...
@@ -1105,7 +1151,16 @@ export class ExtHostLanguageFeatures implements ExtHostLanguageFeaturesShape {
}
const
handle
=
this
.
_nextHandle
();
this
.
_proxy
.
$setLanguageConfiguration
(
handle
,
languageId
,
configuration
);
const
serializedConfiguration
:
ISerializedLanguageConfiguration
=
{
comments
:
configuration
.
comments
,
brackets
:
configuration
.
brackets
,
wordPattern
:
ExtHostLanguageFeatures
.
_serializeRegExp
(
configuration
.
wordPattern
),
indentationRules
:
ExtHostLanguageFeatures
.
_serializeIndentationRule
(
configuration
.
indentationRules
),
onEnterRules
:
ExtHostLanguageFeatures
.
_serializeOnEnterRules
(
configuration
.
onEnterRules
),
__electricCharacterSupport
:
configuration
.
__electricCharacterSupport
,
__characterPairSupport
:
configuration
.
__characterPairSupport
,
};
this
.
_proxy
.
$setLanguageConfiguration
(
handle
,
languageId
,
serializedConfiguration
);
return
this
.
_createDisposable
(
handle
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录