Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
480b838e
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,发现更多精彩内容 >>
提交
480b838e
编写于
3月 05, 2019
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Strict null check apiCommands
上级
e3964c95
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
28 addition
and
27 deletion
+28
-27
src/tsconfig.strictNullChecks.json
src/tsconfig.strictNullChecks.json
+1
-0
src/vs/editor/common/core/editOperation.ts
src/vs/editor/common/core/editOperation.ts
+2
-2
src/vs/editor/common/model.ts
src/vs/editor/common/model.ts
+1
-1
src/vs/editor/contrib/format/formattingEdit.ts
src/vs/editor/contrib/format/formattingEdit.ts
+1
-1
src/vs/monaco.d.ts
src/vs/monaco.d.ts
+1
-1
src/vs/workbench/api/electron-browser/mainThreadSaveParticipant.ts
...rkbench/api/electron-browser/mainThreadSaveParticipant.ts
+6
-6
src/vs/workbench/api/node/extHostDocumentsAndEditors.ts
src/vs/workbench/api/node/extHostDocumentsAndEditors.ts
+7
-7
src/vs/workbench/api/node/extHostTextEditor.ts
src/vs/workbench/api/node/extHostTextEditor.ts
+9
-9
未找到文件。
src/tsconfig.strictNullChecks.json
浏览文件 @
480b838e
...
...
@@ -74,6 +74,7 @@
"./vs/workbench/api/electron-browser/mainThreadUrls.ts"
,
"./vs/workbench/api/electron-browser/mainThreadWindow.ts"
,
"./vs/workbench/api/electron-browser/mainThreadWorkspace.ts"
,
"./vs/workbench/api/node/apiCommands.ts"
,
"./vs/workbench/api/node/extHost.protocol.ts"
,
"./vs/workbench/api/node/extHostClipboard.ts"
,
"./vs/workbench/api/node/extHostConfiguration.ts"
,
...
...
src/vs/editor/common/core/editOperation.ts
浏览文件 @
480b838e
...
...
@@ -24,14 +24,14 @@ export class EditOperation {
};
}
public
static
replace
(
range
:
Range
,
text
:
string
):
IIdentifiedSingleEditOperation
{
public
static
replace
(
range
:
Range
,
text
:
string
|
null
):
IIdentifiedSingleEditOperation
{
return
{
range
:
range
,
text
:
text
};
}
public
static
replaceMove
(
range
:
Range
,
text
:
string
):
IIdentifiedSingleEditOperation
{
public
static
replaceMove
(
range
:
Range
,
text
:
string
|
null
):
IIdentifiedSingleEditOperation
{
return
{
range
:
range
,
text
:
text
,
...
...
src/vs/editor/common/model.ts
浏览文件 @
480b838e
...
...
@@ -289,7 +289,7 @@ export interface ISingleEditOperation {
/**
* The text to replace with. This can be null to emulate a simple delete.
*/
text
:
string
;
text
:
string
|
null
;
/**
* This indicates that this operation has "insert" semantics.
* i.e. forceMoveMarkers = true => if `range` is collapsed, all markers at the position will be moved.
...
...
src/vs/editor/contrib/format/formattingEdit.ts
浏览文件 @
480b838e
...
...
@@ -45,7 +45,7 @@ export class FormattingEdit {
static
execute
(
editor
:
ICodeEditor
,
_edits
:
TextEdit
[])
{
editor
.
pushUndoStop
();
le
t
edits
=
FormattingEdit
.
_handleEolEdits
(
editor
,
_edits
);
cons
t
edits
=
FormattingEdit
.
_handleEolEdits
(
editor
,
_edits
);
if
(
edits
.
length
===
1
&&
FormattingEdit
.
_isFullModelReplaceEdit
(
editor
,
edits
[
0
]))
{
// We use replace semantics and hope that markers stay put...
editor
.
executeEdits
(
'
formatEditsCommand
'
,
edits
.
map
(
edit
=>
EditOperation
.
replace
(
Range
.
lift
(
edit
.
range
),
edit
.
text
)));
...
...
src/vs/monaco.d.ts
浏览文件 @
480b838e
...
...
@@ -1387,7 +1387,7 @@ declare namespace monaco.editor {
/**
* The text to replace with. This can be null to emulate a simple delete.
*/
text
:
string
;
text
:
string
|
null
;
/**
* This indicates that this operation has "insert" semantics.
* i.e. forceMoveMarkers = true => if `range` is collapsed, all markers at the position will be moved.
...
...
src/vs/workbench/api/electron-browser/mainThreadSaveParticipant.ts
浏览文件 @
480b838e
...
...
@@ -16,8 +16,8 @@ import { EditOperation } from 'vs/editor/common/core/editOperation';
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
import
{
IIdentifiedSingleEditOperation
,
I
SingleEditOperation
,
I
TextModel
}
from
'
vs/editor/common/model
'
;
import
{
CodeAction
}
from
'
vs/editor/common/modes
'
;
import
{
IIdentifiedSingleEditOperation
,
ITextModel
}
from
'
vs/editor/common/model
'
;
import
{
CodeAction
,
TextEdit
}
from
'
vs/editor/common/modes
'
;
import
{
IEditorWorkerService
}
from
'
vs/editor/common/services/editorWorkerService
'
;
import
{
shouldSynchronizeModel
}
from
'
vs/editor/common/services/modelService
'
;
import
{
getCodeActions
}
from
'
vs/editor/contrib/codeAction/codeAction
'
;
...
...
@@ -234,7 +234,7 @@ class FormatOnSaveParticipant implements ISaveParticipantParticipant {
const
timeout
=
this
.
_configurationService
.
getValue
<
number
>
(
'
editor.formatOnSaveTimeout
'
,
{
overrideIdentifier
:
model
.
getLanguageIdentifier
().
language
,
resource
:
editorModel
.
getResource
()
});
return
new
Promise
<
ISingleEditOperation
[]
|
null
|
undefined
>
((
resolve
,
reject
)
=>
{
return
new
Promise
<
TextEdit
[]
|
null
|
undefined
>
((
resolve
,
reject
)
=>
{
let
source
=
new
CancellationTokenSource
();
let
request
=
getDocumentFormattingEdits
(
this
.
_telemetryService
,
this
.
_editorWorkerService
,
model
,
model
.
getFormattingOptions
(),
FormatMode
.
Auto
,
source
.
token
);
...
...
@@ -257,11 +257,11 @@ class FormatOnSaveParticipant implements ISaveParticipantParticipant {
});
}
private
_editsWithEditor
(
editor
:
ICodeEditor
,
edits
:
ISingleEditOperation
[]):
void
{
private
_editsWithEditor
(
editor
:
ICodeEditor
,
edits
:
TextEdit
[]):
void
{
FormattingEdit
.
execute
(
editor
,
edits
);
}
private
_editWithModel
(
model
:
ITextModel
,
edits
:
ISingleEditOperation
[]):
void
{
private
_editWithModel
(
model
:
ITextModel
,
edits
:
TextEdit
[]):
void
{
const
[{
range
}]
=
edits
;
const
initialSelection
=
new
Selection
(
range
.
startLineNumber
,
range
.
startColumn
,
range
.
endLineNumber
,
range
.
endColumn
);
...
...
@@ -276,7 +276,7 @@ class FormatOnSaveParticipant implements ISaveParticipantParticipant {
});
}
private
static
_asIdentEdit
({
text
,
range
}:
ISingleEditOperation
):
IIdentifiedSingleEditOperation
{
private
static
_asIdentEdit
({
text
,
range
}:
TextEdit
):
IIdentifiedSingleEditOperation
{
return
{
text
,
range
:
Range
.
lift
(
range
),
...
...
src/vs/workbench/api/node/extHostDocumentsAndEditors.ts
浏览文件 @
480b838e
...
...
@@ -17,7 +17,7 @@ export class ExtHostDocumentsAndEditors implements ExtHostDocumentsAndEditorsSha
private
_disposables
:
Disposable
[]
=
[];
private
_activeEditorId
:
string
;
private
_activeEditorId
:
string
|
null
;
private
readonly
_editors
=
new
Map
<
string
,
ExtHostTextEditor
>
();
private
readonly
_documents
=
new
Map
<
string
,
ExtHostDocumentData
>
();
...
...
@@ -25,12 +25,12 @@ export class ExtHostDocumentsAndEditors implements ExtHostDocumentsAndEditorsSha
private
readonly
_onDidAddDocuments
=
new
Emitter
<
ExtHostDocumentData
[]
>
();
private
readonly
_onDidRemoveDocuments
=
new
Emitter
<
ExtHostDocumentData
[]
>
();
private
readonly
_onDidChangeVisibleTextEditors
=
new
Emitter
<
ExtHostTextEditor
[]
>
();
private
readonly
_onDidChangeActiveTextEditor
=
new
Emitter
<
ExtHostTextEditor
>
();
private
readonly
_onDidChangeActiveTextEditor
=
new
Emitter
<
ExtHostTextEditor
|
undefined
>
();
readonly
onDidAddDocuments
:
Event
<
ExtHostDocumentData
[]
>
=
this
.
_onDidAddDocuments
.
event
;
readonly
onDidRemoveDocuments
:
Event
<
ExtHostDocumentData
[]
>
=
this
.
_onDidRemoveDocuments
.
event
;
readonly
onDidChangeVisibleTextEditors
:
Event
<
ExtHostTextEditor
[]
>
=
this
.
_onDidChangeVisibleTextEditors
.
event
;
readonly
onDidChangeActiveTextEditor
:
Event
<
ExtHostTextEditor
>
=
this
.
_onDidChangeActiveTextEditor
.
event
;
readonly
onDidChangeActiveTextEditor
:
Event
<
ExtHostTextEditor
|
undefined
>
=
this
.
_onDidChangeActiveTextEditor
.
event
;
constructor
(
private
readonly
_mainContext
:
IMainContext
,
...
...
@@ -93,14 +93,14 @@ export class ExtHostDocumentsAndEditors implements ExtHostDocumentsAndEditorsSha
assert
.
ok
(
this
.
_documents
.
has
(
resource
.
toString
()),
`document '
${
resource
}
' does not exist`
);
assert
.
ok
(
!
this
.
_editors
.
has
(
data
.
id
),
`editor '
${
data
.
id
}
' already exists!`
);
const
documentData
=
this
.
_documents
.
get
(
resource
.
toString
());
const
documentData
=
this
.
_documents
.
get
(
resource
.
toString
())
!
;
const
editor
=
new
ExtHostTextEditor
(
this
.
_mainContext
.
getProxy
(
MainContext
.
MainThreadTextEditors
),
data
.
id
,
documentData
,
data
.
selections
.
map
(
typeConverters
.
Selection
.
to
),
data
.
options
,
data
.
visibleRanges
.
map
(
typeConverters
.
Range
.
to
),
data
.
visibleRanges
.
map
(
range
=>
typeConverters
.
Range
.
to
(
range
)
),
typeof
data
.
editorPosition
===
'
number
'
?
typeConverters
.
ViewColumn
.
to
(
data
.
editorPosition
)
:
undefined
);
this
.
_editors
.
set
(
data
.
id
,
editor
);
...
...
@@ -131,7 +131,7 @@ export class ExtHostDocumentsAndEditors implements ExtHostDocumentsAndEditorsSha
}
}
getDocument
(
uri
:
URI
):
ExtHostDocumentData
{
getDocument
(
uri
:
URI
):
ExtHostDocumentData
|
undefined
{
return
this
.
_documents
.
get
(
uri
.
toString
());
}
...
...
@@ -141,7 +141,7 @@ export class ExtHostDocumentsAndEditors implements ExtHostDocumentsAndEditorsSha
return
result
;
}
getEditor
(
id
:
string
):
ExtHostTextEditor
{
getEditor
(
id
:
string
):
ExtHostTextEditor
|
undefined
{
return
this
.
_editors
.
get
(
id
);
}
...
...
src/vs/workbench/api/node/extHostTextEditor.ts
浏览文件 @
480b838e
...
...
@@ -35,7 +35,7 @@ export class TextEditorDecorationType implements vscode.TextEditorDecorationType
export
interface
ITextEditOperation
{
range
:
vscode
.
Range
;
text
:
string
;
text
:
string
|
null
;
forceMoveMarkers
:
boolean
;
}
...
...
@@ -105,7 +105,7 @@ export class TextEditorEdit {
this
.
_pushEdit
(
range
,
null
,
true
);
}
private
_pushEdit
(
range
:
Range
,
text
:
string
,
forceMoveMarkers
:
boolean
):
void
{
private
_pushEdit
(
range
:
Range
,
text
:
string
|
null
,
forceMoveMarkers
:
boolean
):
void
{
let
validRange
=
this
.
_document
.
validateRange
(
range
);
this
.
_collectedEdits
.
push
({
range
:
validRange
,
...
...
@@ -373,7 +373,7 @@ export class ExtHostTextEditor implements vscode.TextEditor {
private
_selections
:
Selection
[];
private
_options
:
ExtHostTextEditorOptions
;
private
_visibleRanges
:
Range
[];
private
_viewColumn
:
vscode
.
ViewColumn
;
private
_viewColumn
:
vscode
.
ViewColumn
|
undefined
;
private
_disposed
:
boolean
=
false
;
private
_hasDecorationsForKey
:
{
[
key
:
string
]:
boolean
;
};
...
...
@@ -382,7 +382,7 @@ export class ExtHostTextEditor implements vscode.TextEditor {
constructor
(
proxy
:
MainThreadTextEditorsShape
,
id
:
string
,
document
:
ExtHostDocumentData
,
selections
:
Selection
[],
options
:
IResolvedTextEditorConfiguration
,
visibleRanges
:
Range
[],
viewColumn
:
vscode
.
ViewColumn
visibleRanges
:
Range
[],
viewColumn
:
vscode
.
ViewColumn
|
undefined
)
{
this
.
_proxy
=
proxy
;
this
.
_id
=
id
;
...
...
@@ -451,7 +451,7 @@ export class ExtHostTextEditor implements vscode.TextEditor {
// ---- view column
get
viewColumn
():
vscode
.
ViewColumn
{
get
viewColumn
():
vscode
.
ViewColumn
|
undefined
{
return
this
.
_viewColumn
;
}
...
...
@@ -538,7 +538,7 @@ export class ExtHostTextEditor implements vscode.TextEditor {
);
}
private
_trySetSelection
():
Promise
<
vscode
.
TextEditor
>
{
private
_trySetSelection
():
Promise
<
vscode
.
TextEditor
|
null
|
undefined
>
{
let
selection
=
this
.
_selections
.
map
(
TypeConverters
.
Selection
.
from
);
return
this
.
_runOnProxy
(()
=>
this
.
_proxy
.
$trySetSelections
(
this
.
_id
,
selection
));
}
...
...
@@ -598,7 +598,7 @@ export class ExtHostTextEditor implements vscode.TextEditor {
}
// prepare data for serialization
let
edits
:
ISingleEditOperation
[]
=
editData
.
edits
.
map
((
edit
)
=>
{
const
edits
=
editData
.
edits
.
map
((
edit
):
ISingleEditOperation
=>
{
return
{
range
:
TypeConverters
.
Range
.
from
(
edit
.
range
),
text
:
edit
.
text
,
...
...
@@ -620,7 +620,7 @@ export class ExtHostTextEditor implements vscode.TextEditor {
let
ranges
:
IRange
[];
if
(
!
where
||
(
Array
.
isArray
(
where
)
&&
where
.
length
===
0
))
{
ranges
=
this
.
_selections
.
map
(
TypeConverters
.
Range
.
from
);
ranges
=
this
.
_selections
.
map
(
range
=>
TypeConverters
.
Range
.
from
(
range
)
);
}
else
if
(
where
instanceof
Position
)
{
const
{
lineNumber
,
column
}
=
TypeConverters
.
Position
.
from
(
where
);
...
...
@@ -645,7 +645,7 @@ export class ExtHostTextEditor implements vscode.TextEditor {
// ---- util
private
_runOnProxy
(
callback
:
()
=>
Promise
<
any
>
):
Promise
<
ExtHostTextEditor
>
{
private
_runOnProxy
(
callback
:
()
=>
Promise
<
any
>
):
Promise
<
ExtHostTextEditor
|
undefined
|
null
>
{
if
(
this
.
_disposed
)
{
console
.
warn
(
'
TextEditor is closed/disposed
'
);
return
Promise
.
resolve
(
undefined
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录