Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
acb03913
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,发现更多精彩内容 >>
提交
acb03913
编写于
10月 11, 2018
作者:
O
Omkar Manjrekar
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
https://github.com/Microsoft/vscode
上级
748fab73
3e5bdc45
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
102 addition
and
107 deletion
+102
-107
src/tsconfig.strictNullChecks.json
src/tsconfig.strictNullChecks.json
+2
-0
src/vs/base/common/iterator.ts
src/vs/base/common/iterator.ts
+23
-15
src/vs/base/common/linkedList.ts
src/vs/base/common/linkedList.ts
+10
-16
src/vs/base/common/map.ts
src/vs/base/common/map.ts
+8
-9
src/vs/base/common/worker/simpleWorker.ts
src/vs/base/common/worker/simpleWorker.ts
+48
-55
src/vs/editor/common/services/editorSimpleWorker.ts
src/vs/editor/common/services/editorSimpleWorker.ts
+11
-12
未找到文件。
src/tsconfig.strictNullChecks.json
浏览文件 @
acb03913
...
...
@@ -21,6 +21,7 @@
"./vs/base/common/diff/diff.ts"
,
"./vs/base/common/diff/diffChange.ts"
,
"./vs/base/common/errors.ts"
,
//
"./vs/base/common/event.ts"
,
"./vs/base/common/functional.ts"
,
"./vs/base/common/idGenerator.ts"
,
"./vs/base/common/iterator.ts"
,
...
...
@@ -49,6 +50,7 @@
"./vs/base/common/urilpc.ts"
,
"./vs/base/common/uuid.ts"
,
"./vs/base/common/winjs.base.d.ts"
,
"./vs/base/common/worker/simpleWorker.ts"
,
"./vs/base/node/paths.ts"
,
"./vs/base/node/ports.ts"
,
"./vs/base/parts/contextmenu/common/contextmenu.ts"
,
...
...
src/vs/base/common/iterator.ts
浏览文件 @
acb03913
...
...
@@ -3,10 +3,16 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
export
interface
IteratorResult
<
T
>
{
readonly
done
:
boolean
;
readonly
value
:
T
|
undefined
;
export
interface
Iterator
Defined
Result
<
T
>
{
readonly
done
:
false
;
readonly
value
:
T
;
}
export
interface
IteratorUndefinedResult
{
readonly
done
:
true
;
readonly
value
:
undefined
;
}
export
const
FIN
:
IteratorUndefinedResult
=
{
done
:
true
,
value
:
undefined
};
export
type
IteratorResult
<
T
>
=
IteratorDefinedResult
<
T
>
|
IteratorUndefinedResult
;
export
interface
Iterator
<
T
>
{
next
():
IteratorResult
<
T
>
;
...
...
@@ -15,7 +21,7 @@ export interface Iterator<T> {
export
module
Iterator
{
const
_empty
:
Iterator
<
any
>
=
{
next
()
{
return
{
done
:
true
,
value
:
undefined
}
;
return
FIN
;
}
};
...
...
@@ -27,7 +33,7 @@ export module Iterator {
return
{
next
():
IteratorResult
<
T
>
{
if
(
index
>=
length
)
{
return
{
done
:
true
,
value
:
undefined
}
;
return
FIN
;
}
return
{
done
:
false
,
value
:
array
[
index
++
]
};
...
...
@@ -48,8 +54,12 @@ export module Iterator {
export
function
map
<
T
,
R
>
(
iterator
:
Iterator
<
T
>
,
fn
:
(
t
:
T
)
=>
R
):
Iterator
<
R
>
{
return
{
next
()
{
const
{
done
,
value
}
=
iterator
.
next
();
return
{
done
,
value
:
done
?
undefined
:
fn
(
value
!
)
};
const
element
=
iterator
.
next
();
if
(
element
.
done
)
{
return
FIN
;
}
else
{
return
{
done
:
false
,
value
:
fn
(
element
.
value
)
};
}
}
};
}
...
...
@@ -58,14 +68,12 @@ export module Iterator {
return
{
next
()
{
while
(
true
)
{
const
{
done
,
value
}
=
iterator
.
next
();
if
(
done
)
{
return
{
done
,
value
:
undefined
};
const
element
=
iterator
.
next
();
if
(
element
.
done
)
{
return
FIN
;
}
if
(
fn
(
value
!
))
{
return
{
done
,
value
};
if
(
fn
(
element
.
value
))
{
return
{
done
:
false
,
value
:
element
.
value
};
}
}
}
...
...
@@ -74,7 +82,7 @@ export module Iterator {
export
function
forEach
<
T
>
(
iterator
:
Iterator
<
T
>
,
fn
:
(
t
:
T
)
=>
void
):
void
{
for
(
let
next
=
iterator
.
next
();
!
next
.
done
;
next
=
iterator
.
next
())
{
fn
(
next
.
value
!
);
fn
(
next
.
value
);
}
}
...
...
src/vs/base/common/linkedList.ts
浏览文件 @
acb03913
...
...
@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
Iterator
}
from
'
vs/base/common/iterator
'
;
import
{
Iterator
,
IteratorResult
,
FIN
}
from
'
vs/base/common/iterator
'
;
class
Node
<
E
>
{
element
:
E
;
...
...
@@ -94,26 +94,20 @@ export class LinkedList<E> {
}
iterator
():
Iterator
<
E
>
{
let
element
:
{
done
:
boolean
;
value
:
E
|
undefined
};
let
element
:
{
done
:
false
;
value
:
E
;
};
let
node
=
this
.
_first
;
return
{
next
():
{
done
:
boolean
;
value
:
E
|
undefined
}
{
next
():
IteratorResult
<
E
>
{
if
(
!
node
)
{
if
(
!
element
)
{
element
=
{
done
:
true
,
value
:
undefined
};
}
else
{
element
.
done
=
true
;
element
.
value
=
undefined
;
}
return
FIN
;
}
if
(
!
element
)
{
element
=
{
done
:
false
,
value
:
node
.
element
};
}
else
{
if
(
!
element
)
{
element
=
{
done
:
false
,
value
:
node
.
element
};
}
else
{
element
.
done
=
false
;
element
.
value
=
node
.
element
;
}
node
=
node
.
next
;
element
.
value
=
node
.
element
;
}
node
=
node
.
next
;
return
element
;
}
};
...
...
src/vs/base/common/map.ts
浏览文件 @
acb03913
...
...
@@ -5,7 +5,7 @@
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
CharCode
}
from
'
vs/base/common/charCode
'
;
import
{
Iterator
}
from
'
./iterator
'
;
import
{
Iterator
,
IteratorResult
,
FIN
}
from
'
./iterator
'
;
export
function
values
<
V
=
any
>
(
set
:
Set
<
V
>
):
V
[];
export
function
values
<
K
=
any
,
V
=
any
>
(
map
:
Map
<
K
,
V
>
):
V
[];
...
...
@@ -332,13 +332,10 @@ export class TernarySearchTree<E> {
}
private
_nodeIterator
(
node
:
TernarySearchTreeNode
<
E
>
):
Iterator
<
E
>
{
let
res
=
{
done
:
false
,
value
:
undefined
};
let
res
:
{
done
:
false
;
value
:
E
;
};
let
idx
:
number
;
let
data
:
E
[];
let
next
=
()
=>
{
let
next
=
()
:
IteratorResult
<
E
>
=>
{
if
(
!
data
)
{
// lazy till first invocation
data
=
[];
...
...
@@ -346,10 +343,12 @@ export class TernarySearchTree<E> {
this
.
_forEach
(
node
,
value
=>
data
.
push
(
value
));
}
if
(
idx
>=
data
.
length
)
{
res
.
done
=
true
;
res
.
value
=
undefined
;
return
FIN
;
}
if
(
!
res
)
{
res
=
{
done
:
false
,
value
:
data
[
idx
++
]
};
}
else
{
res
.
done
=
false
;
res
.
value
=
data
[
idx
++
];
}
return
res
;
...
...
src/vs/base/common/worker/simpleWorker.ts
浏览文件 @
acb03913
...
...
@@ -84,24 +84,18 @@ class SimpleWorkerProtocol {
public
sendMessage
(
method
:
string
,
args
:
any
[]):
Promise
<
any
>
{
let
req
=
String
(
++
this
.
_lastSentReq
);
let
reply
:
IMessageReply
=
{
resolve
:
null
,
reject
:
null
};
let
result
=
new
Promise
<
any
>
((
resolve
,
reject
)
=>
{
reply
.
resolve
=
resolve
;
reply
.
reject
=
reject
;
});
this
.
_pendingReplies
[
req
]
=
reply
;
this
.
_send
({
vsWorker
:
this
.
_workerId
,
req
:
req
,
method
:
method
,
args
:
args
return
new
Promise
<
any
>
((
resolve
,
reject
)
=>
{
this
.
_pendingReplies
[
req
]
=
{
resolve
:
resolve
,
reject
:
reject
};
this
.
_send
({
vsWorker
:
this
.
_workerId
,
req
:
req
,
method
:
method
,
args
:
args
});
});
return
result
;
}
public
handleMessage
(
serializedMessage
:
string
):
void
{
...
...
@@ -110,6 +104,7 @@ class SimpleWorkerProtocol {
message
=
JSON
.
parse
(
serializedMessage
);
}
catch
(
e
)
{
// nothing
return
;
}
if
(
!
message
||
!
message
.
vsWorker
)
{
return
;
...
...
@@ -191,8 +186,7 @@ export class SimpleWorkerClient<T> extends Disposable {
constructor
(
workerFactory
:
IWorkerFactory
,
moduleId
:
string
)
{
super
();
let
lazyProxyResolve
:
(
v
:
T
)
=>
void
=
null
;
let
lazyProxyReject
:
(
err
:
any
)
=>
void
=
null
;
let
lazyProxyReject
:
((
err
:
any
)
=>
void
)
|
null
=
null
;
this
.
_worker
=
this
.
_register
(
workerFactory
.
create
(
'
vs/base/common/worker/simpleWorker
'
,
...
...
@@ -202,7 +196,9 @@ export class SimpleWorkerClient<T> extends Disposable {
(
err
:
any
)
=>
{
// in Firefox, web workers fail lazily :(
// we will reject the proxy
lazyProxyReject
(
err
);
if
(
lazyProxyReject
)
{
lazyProxyReject
(
err
);
}
}
));
...
...
@@ -227,26 +223,25 @@ export class SimpleWorkerClient<T> extends Disposable {
loaderConfiguration
=
(
<
any
>
self
).
requirejs
.
s
.
contexts
.
_
.
config
;
}
this
.
_lazyProxy
=
new
Promise
<
T
>
((
resolve
,
reject
)
=>
{
lazyProxyResolve
=
resolve
;
lazyProxyReject
=
reject
;
});
// Send initialize message
this
.
_onModuleLoaded
=
this
.
_protocol
.
sendMessage
(
INITIALIZE
,
[
this
.
_worker
.
getId
(),
moduleId
,
loaderConfiguration
]);
this
.
_onModuleLoaded
.
then
((
availableMethods
:
string
[])
=>
{
let
proxy
=
<
T
>
{};
for
(
let
i
=
0
;
i
<
availableMethods
.
length
;
i
++
)
{
(
proxy
as
any
)[
availableMethods
[
i
]]
=
createProxyMethod
(
availableMethods
[
i
],
proxyMethodRequest
);
}
lazyProxyResolve
(
proxy
);
},
(
e
)
=>
{
lazyProxyReject
(
e
);
this
.
_onError
(
'
Worker failed to load
'
+
moduleId
,
e
);
this
.
_lazyProxy
=
new
Promise
<
T
>
((
resolve
,
reject
)
=>
{
lazyProxyReject
=
reject
;
this
.
_onModuleLoaded
.
then
((
availableMethods
:
string
[])
=>
{
let
proxy
=
<
T
>
{};
for
(
let
i
=
0
;
i
<
availableMethods
.
length
;
i
++
)
{
(
proxy
as
any
)[
availableMethods
[
i
]]
=
createProxyMethod
(
availableMethods
[
i
],
proxyMethodRequest
);
}
resolve
(
proxy
);
},
(
e
)
=>
{
reject
(
e
);
this
.
_onError
(
'
Worker failed to load
'
+
moduleId
,
e
);
});
});
// Create proxy to loaded code
...
...
@@ -290,10 +285,10 @@ export interface IRequestHandler {
*/
export
class
SimpleWorkerServer
{
private
_requestHandler
:
IRequestHandler
;
private
_requestHandler
:
IRequestHandler
|
null
;
private
_protocol
:
SimpleWorkerProtocol
;
constructor
(
postSerializedMessage
:
(
msg
:
string
)
=>
void
,
requestHandler
:
IRequestHandler
)
{
constructor
(
postSerializedMessage
:
(
msg
:
string
)
=>
void
,
requestHandler
:
IRequestHandler
|
null
)
{
this
.
_requestHandler
=
requestHandler
;
this
.
_protocol
=
new
SimpleWorkerProtocol
({
sendMessage
:
(
msg
:
string
):
void
=>
{
...
...
@@ -353,29 +348,27 @@ export class SimpleWorkerServer {
(
<
any
>
self
).
require
.
config
(
loaderConfig
);
}
let
resolve
:
(
value
?:
string
[])
=>
void
;
let
reject
:
(
error
?:
any
)
=>
void
;
let
r
=
new
Promise
<
string
[]
>
((
_resolve
,
_reject
)
=>
{
resolve
=
_resolve
;
reject
=
_reject
;
});
// Use the global require to be sure to get the global config
(
<
any
>
self
).
require
([
moduleId
],
(...
result
:
any
[])
=>
{
let
handlerModule
=
result
[
0
];
this
.
_requestHandler
=
handlerModule
.
create
();
return
new
Promise
<
string
[]
>
((
resolve
,
reject
)
=>
{
// Use the global require to be sure to get the global config
(
<
any
>
self
).
require
([
moduleId
],
(...
result
:
any
[])
=>
{
let
handlerModule
=
result
[
0
];
this
.
_requestHandler
=
handlerModule
.
create
();
let
methods
:
string
[]
=
[];
for
(
let
prop
in
this
.
_requestHandler
)
{
if
(
typeof
this
.
_requestHandler
[
prop
]
===
'
function
'
)
{
methods
.
push
(
prop
);
if
(
!
this
.
_requestHandler
)
{
reject
(
new
Error
(
`No RequestHandler!`
));
return
;
}
}
resolve
(
methods
);
},
reject
);
let
methods
:
string
[]
=
[];
for
(
let
prop
in
this
.
_requestHandler
)
{
if
(
typeof
this
.
_requestHandler
[
prop
]
===
'
function
'
)
{
methods
.
push
(
prop
);
}
}
return
r
;
resolve
(
methods
);
},
reject
);
});
}
}
...
...
src/vs/editor/common/services/editorSimpleWorker.ts
浏览文件 @
acb03913
...
...
@@ -19,7 +19,7 @@ import { getWordAtText, ensureValidWordDefinition } from 'vs/editor/common/model
import
{
createMonacoBaseAPI
}
from
'
vs/editor/common/standalone/standaloneBase
'
;
import
{
IWordAtPosition
,
EndOfLineSequence
}
from
'
vs/editor/common/model
'
;
import
{
globals
}
from
'
vs/base/common/platform
'
;
import
{
Iterator
}
from
'
vs/base/common/iterator
'
;
import
{
Iterator
,
IteratorResult
,
FIN
}
from
'
vs/base/common/iterator
'
;
import
{
mergeSort
}
from
'
vs/base/common/arrays
'
;
export
interface
IMirrorModel
{
...
...
@@ -147,24 +147,25 @@ class MirrorModel extends BaseMirrorModel implements ICommonModel {
}
public
createWordIterator
(
wordDefinition
:
RegExp
):
Iterator
<
string
>
{
let
obj
=
{
done
:
false
,
value
:
''
};
let
obj
:
{
done
:
false
;
value
:
string
;
};
let
lineNumber
=
0
;
let
lineText
:
string
;
let
wordRangesIdx
=
0
;
let
wordRanges
:
IWordRange
[]
=
[];
let
next
=
():
{
done
:
boolean
;
value
:
string
}
=>
{
let
next
=
():
IteratorResult
<
string
>
=>
{
if
(
wordRangesIdx
<
wordRanges
.
length
)
{
obj
.
done
=
false
;
obj
.
value
=
lineText
.
substring
(
wordRanges
[
wordRangesIdx
].
start
,
wordRanges
[
wordRangesIdx
].
end
);
const
value
=
lineText
.
substring
(
wordRanges
[
wordRangesIdx
].
start
,
wordRanges
[
wordRangesIdx
].
end
);
wordRangesIdx
+=
1
;
if
(
!
obj
)
{
obj
=
{
done
:
false
,
value
:
value
};
}
else
{
obj
.
value
=
value
;
}
return
obj
;
}
else
if
(
lineNumber
>=
this
.
_lines
.
length
)
{
obj
.
done
=
true
;
obj
.
value
=
undefined
;
return
FIN
;
}
else
{
lineText
=
this
.
_lines
[
lineNumber
];
...
...
@@ -173,8 +174,6 @@ class MirrorModel extends BaseMirrorModel implements ICommonModel {
lineNumber
+=
1
;
return
next
();
}
return
obj
;
};
return
{
next
};
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录