Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
94545eee
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,发现更多精彩内容 >>
提交
94545eee
编写于
4月 15, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Do not extend EventEmitter
上级
dd29eeb4
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
43 addition
and
41 deletion
+43
-41
src/vs/base/common/eventEmitter.ts
src/vs/base/common/eventEmitter.ts
+4
-4
src/vs/base/parts/tree/browser/treeModel.ts
src/vs/base/parts/tree/browser/treeModel.ts
+2
-2
src/vs/editor/common/model/editableTextModel.ts
src/vs/editor/common/model/editableTextModel.ts
+12
-12
src/vs/editor/common/model/model.ts
src/vs/editor/common/model/model.ts
+5
-10
src/vs/editor/common/model/textModel.ts
src/vs/editor/common/model/textModel.ts
+14
-7
src/vs/editor/common/model/textModelWithDecorations.ts
src/vs/editor/common/model/textModelWithDecorations.ts
+3
-3
src/vs/editor/common/model/textModelWithTokens.ts
src/vs/editor/common/model/textModelWithTokens.ts
+3
-3
未找到文件。
src/vs/base/common/eventEmitter.ts
浏览文件 @
94545eee
...
...
@@ -197,11 +197,11 @@ export class EventEmitter implements IEventEmitter {
}
}
p
rotected
_
beginDeferredEmit
():
void
{
p
ublic
beginDeferredEmit
():
void
{
this
.
_deferredCnt
=
this
.
_deferredCnt
+
1
;
}
p
rotected
_
endDeferredEmit
():
void
{
p
ublic
endDeferredEmit
():
void
{
this
.
_deferredCnt
=
this
.
_deferredCnt
-
1
;
if
(
this
.
_deferredCnt
===
0
)
{
...
...
@@ -210,11 +210,11 @@ export class EventEmitter implements IEventEmitter {
}
public
deferredEmit
<
T
>
(
callback
:
()
=>
T
):
T
{
this
.
_
beginDeferredEmit
();
this
.
beginDeferredEmit
();
let
result
:
T
=
safeInvokeNoArg
<
T
>
(
callback
);
this
.
_
endDeferredEmit
();
this
.
endDeferredEmit
();
return
result
;
}
...
...
src/vs/base/parts/tree/browser/treeModel.ts
浏览文件 @
94545eee
...
...
@@ -841,10 +841,10 @@ export class TreeModel extends Events.EventEmitter {
public
refreshAll
(
elements
:
any
[],
recursive
:
boolean
=
true
):
WinJS
.
Promise
{
try
{
this
.
_
beginDeferredEmit
();
this
.
beginDeferredEmit
();
return
this
.
_refreshAll
(
elements
,
recursive
);
}
finally
{
this
.
_
endDeferredEmit
();
this
.
endDeferredEmit
();
}
}
...
...
src/vs/editor/common/model/editableTextModel.ts
浏览文件 @
94545eee
...
...
@@ -38,10 +38,10 @@ export class EditableTextModel extends TextModelWithDecorations implements edito
}
public
onDidChangeRawContent
(
listener
:
(
e
:
editorCommon
.
IModelRawContentChangedEvent
)
=>
void
):
IDisposable
{
return
this
.
addListener
(
editorCommon
.
EventType
.
ModelRawContentChanged
,
listener
);
return
this
.
_eventEmitter
.
addListener
(
editorCommon
.
EventType
.
ModelRawContentChanged
,
listener
);
}
public
onDidChangeContent
(
listener
:
(
e
:
editorCommon
.
IModelContentChangedEvent
)
=>
void
):
IDisposable
{
return
this
.
addListener
(
editorCommon
.
EventType
.
ModelContentChanged
,
listener
);
return
this
.
_eventEmitter
.
addListener
(
editorCommon
.
EventType
.
ModelContentChanged
,
listener
);
}
private
_commandManager
:
EditStack
;
...
...
@@ -91,10 +91,10 @@ export class EditableTextModel extends TextModelWithDecorations implements edito
public
pushEditOperations
(
beforeCursorState
:
Selection
[],
editOperations
:
editorCommon
.
IIdentifiedSingleEditOperation
[],
cursorStateComputer
:
editorCommon
.
ICursorStateComputer
):
Selection
[]
{
try
{
this
.
_beginDeferredEmit
();
this
.
_
eventEmitter
.
beginDeferredEmit
();
return
this
.
_pushEditOperations
(
beforeCursorState
,
editOperations
,
cursorStateComputer
);
}
finally
{
this
.
_endDeferredEmit
();
this
.
_e
ventEmitter
.
e
ndDeferredEmit
();
}
}
...
...
@@ -273,12 +273,12 @@ export class EditableTextModel extends TextModelWithDecorations implements edito
public
applyEdits
(
rawOperations
:
editorCommon
.
IIdentifiedSingleEditOperation
[]):
editorCommon
.
IIdentifiedSingleEditOperation
[]
{
try
{
this
.
_beginDeferredEmit
();
this
.
_
eventEmitter
.
beginDeferredEmit
();
let
markersTracker
=
this
.
_acquireMarkersTracker
();
return
this
.
_applyEdits
(
markersTracker
,
rawOperations
);
}
finally
{
this
.
_releaseMarkersTracker
();
this
.
_endDeferredEmit
();
this
.
_e
ventEmitter
.
e
ndDeferredEmit
();
}
}
...
...
@@ -690,7 +690,7 @@ export class EditableTextModel extends TextModelWithDecorations implements edito
}
for
(
let
i
=
0
,
len
=
contentChangedEvents
.
length
;
i
<
len
;
i
++
)
{
this
.
emit
(
editorCommon
.
EventType
.
ModelRawContentChanged
,
contentChangedEvents
[
i
]);
this
.
_eventEmitter
.
emit
(
editorCommon
.
EventType
.
ModelRawContentChanged
,
contentChangedEvents
[
i
]);
}
const
e
:
editorCommon
.
IModelContentChangedEvent
=
{
changes
:
contentChanges
,
...
...
@@ -700,7 +700,7 @@ export class EditableTextModel extends TextModelWithDecorations implements edito
isRedoing
:
this
.
_isRedoing
,
isFlush
:
false
};
this
.
emit
(
editorCommon
.
EventType
.
ModelContentChanged
,
e
);
this
.
_eventEmitter
.
emit
(
editorCommon
.
EventType
.
ModelContentChanged
,
e
);
}
// this._assertLineNumbersOK();
...
...
@@ -752,12 +752,12 @@ export class EditableTextModel extends TextModelWithDecorations implements edito
public
undo
():
Selection
[]
{
try
{
this
.
_beginDeferredEmit
();
this
.
_
eventEmitter
.
beginDeferredEmit
();
this
.
_acquireMarkersTracker
();
return
this
.
_undo
();
}
finally
{
this
.
_releaseMarkersTracker
();
this
.
_endDeferredEmit
();
this
.
_e
ventEmitter
.
e
ndDeferredEmit
();
}
}
...
...
@@ -777,12 +777,12 @@ export class EditableTextModel extends TextModelWithDecorations implements edito
public
redo
():
Selection
[]
{
try
{
this
.
_beginDeferredEmit
();
this
.
_
eventEmitter
.
beginDeferredEmit
();
this
.
_acquireMarkersTracker
();
return
this
.
_redo
();
}
finally
{
this
.
_releaseMarkersTracker
();
this
.
_endDeferredEmit
();
this
.
_e
ventEmitter
.
e
ndDeferredEmit
();
}
}
...
...
src/vs/editor/common/model/model.ts
浏览文件 @
94545eee
...
...
@@ -12,7 +12,6 @@ import {
import
{
EditableTextModel
}
from
'
vs/editor/common/model/editableTextModel
'
;
import
{
TextModel
}
from
'
vs/editor/common/model/textModel
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
BulkListenerCallback
}
from
'
vs/base/common/eventEmitter
'
;
import
{
LanguageIdentifier
}
from
'
vs/editor/common/modes
'
;
import
{
IRawTextSource
,
RawTextSource
}
from
'
vs/editor/common/model/textSource
'
;
...
...
@@ -24,20 +23,16 @@ var MODEL_ID = 0;
export
class
Model
extends
EditableTextModel
implements
IModel
{
public
onDidChangeDecorations
(
listener
:
(
e
:
IModelDecorationsChangedEvent
)
=>
void
):
IDisposable
{
return
this
.
addListener
(
EventType
.
ModelDecorationsChanged
,
listener
);
return
this
.
_eventEmitter
.
addListener
(
EventType
.
ModelDecorationsChanged
,
listener
);
}
public
onDidChangeOptions
(
listener
:
(
e
:
IModelOptionsChangedEvent
)
=>
void
):
IDisposable
{
return
this
.
addListener
(
EventType
.
ModelOptionsChanged
,
listener
);
return
this
.
_eventEmitter
.
addListener
(
EventType
.
ModelOptionsChanged
,
listener
);
}
public
onWillDispose
(
listener
:
()
=>
void
):
IDisposable
{
return
this
.
addListener
(
EventType
.
ModelDispose
,
listener
);
return
this
.
_eventEmitter
.
addListener
(
EventType
.
ModelDispose
,
listener
);
}
public
onDidChangeLanguage
(
listener
:
(
e
:
IModelLanguageChangedEvent
)
=>
void
):
IDisposable
{
return
this
.
addListener
(
EventType
.
ModelLanguageChanged
,
listener
);
}
public
addBulkListener
(
listener
:
BulkListenerCallback
):
IDisposable
{
return
super
.
addBulkListener
(
listener
);
return
this
.
_eventEmitter
.
addListener
(
EventType
.
ModelLanguageChanged
,
listener
);
}
public
static
createFromString
(
text
:
string
,
options
:
ITextModelCreationOptions
=
TextModel
.
DEFAULT_CREATION_OPTIONS
,
languageIdentifier
:
LanguageIdentifier
=
null
,
uri
:
URI
=
null
):
Model
{
...
...
@@ -71,7 +66,7 @@ export class Model extends EditableTextModel implements IModel {
public
dispose
():
void
{
this
.
_isDisposing
=
true
;
this
.
emit
(
EventType
.
ModelDispose
);
this
.
_eventEmitter
.
emit
(
EventType
.
ModelDispose
);
super
.
dispose
();
this
.
_isDisposing
=
false
;
}
...
...
src/vs/editor/common/model/textModel.ts
浏览文件 @
94545eee
...
...
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
OrderGuaranteeEventEmitter
}
from
'
vs/base/common/eventEmitter
'
;
import
{
OrderGuaranteeEventEmitter
,
BulkListenerCallback
}
from
'
vs/base/common/eventEmitter
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
...
...
@@ -16,6 +16,7 @@ import { PrefixSumComputer } from 'vs/editor/common/viewModel/prefixSumComputer'
import
{
IndentRange
,
computeRanges
}
from
'
vs/editor/common/model/indentRanges
'
;
import
{
TextModelSearch
,
SearchParams
}
from
'
vs/editor/common/model/textModelSearch
'
;
import
{
TextSource
,
ITextSource
,
IRawTextSource
,
RawTextSource
}
from
'
vs/editor/common/model/textSource
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
const
LIMIT_FIND_COUNT
=
999
;
export
const
LONG_LINE_BOUNDARY
=
10000
;
...
...
@@ -25,7 +26,7 @@ export interface ITextModelCreationData {
readonly
options
:
editorCommon
.
TextModelResolvedOptions
;
}
export
class
TextModel
extends
OrderGuaranteeEventEmitter
implements
editorCommon
.
ITextModel
{
export
class
TextModel
implements
editorCommon
.
ITextModel
{
private
static
MODEL_SYNC_LIMIT
=
5
*
1024
*
1024
;
// 5 MB
private
static
MODEL_TOKENIZATION_LIMIT
=
20
*
1024
*
1024
;
// 20 MB
...
...
@@ -68,6 +69,12 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
};
}
public
addBulkListener
(
listener
:
BulkListenerCallback
):
IDisposable
{
return
this
.
_eventEmitter
.
addBulkListener
(
listener
);
}
protected
readonly
_eventEmitter
:
OrderGuaranteeEventEmitter
;
/*protected*/
_lines
:
ModelLine
[];
protected
_EOL
:
string
;
protected
_isDisposed
:
boolean
;
...
...
@@ -90,7 +97,7 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
constructor
(
allowedEventTypes
:
string
[],
rawTextSource
:
IRawTextSource
,
creationOptions
:
editorCommon
.
ITextModelCreationOptions
)
{
allowedEventTypes
.
push
(
editorCommon
.
EventType
.
ModelRawContentChanged
,
editorCommon
.
EventType
.
ModelOptionsChanged
,
editorCommon
.
EventType
.
ModelContentChanged
);
sup
er
(
allowedEventTypes
);
this
.
_eventEmitter
=
new
OrderGuaranteeEventEmitt
er
(
allowedEventTypes
);
const
textModelData
=
TextModel
.
resolveCreationData
(
rawTextSource
,
creationOptions
);
...
...
@@ -152,7 +159,7 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
}
}
this
.
emit
(
editorCommon
.
EventType
.
ModelOptionsChanged
,
e
);
this
.
_eventEmitter
.
emit
(
editorCommon
.
EventType
.
ModelOptionsChanged
,
e
);
}
public
detectIndentation
(
defaultInsertSpaces
:
boolean
,
defaultTabSize
:
number
):
void
{
...
...
@@ -295,7 +302,7 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
this
.
_EOL
=
null
;
this
.
_BOM
=
null
;
sup
er
.
dispose
();
this
.
_eventEmitt
er
.
dispose
();
}
private
_createContentChangedFlushEvent
():
editorCommon
.
IModelRawContentChangedFlushEvent
{
...
...
@@ -322,7 +329,7 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
isFlush
:
isFlush
};
if
(
!
this
.
_isDisposing
)
{
this
.
emit
(
editorCommon
.
EventType
.
ModelContentChanged
,
e
);
this
.
_eventEmitter
.
emit
(
editorCommon
.
EventType
.
ModelContentChanged
,
e
);
}
}
...
...
@@ -766,7 +773,7 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
protected
_emitModelContentChangedFlushEvent
(
e
:
editorCommon
.
IModelRawContentChangedFlushEvent
):
void
{
if
(
!
this
.
_isDisposing
)
{
this
.
emit
(
editorCommon
.
EventType
.
ModelRawContentChanged
,
e
);
this
.
_eventEmitter
.
emit
(
editorCommon
.
EventType
.
ModelRawContentChanged
,
e
);
}
}
...
...
src/vs/editor/common/model/textModelWithDecorations.ts
浏览文件 @
94545eee
...
...
@@ -199,12 +199,12 @@ export class TextModelWithDecorations extends TextModelWithMarkers implements ed
this
.
_assertNotDisposed
();
try
{
this
.
_beginDeferredEmit
();
this
.
_
eventEmitter
.
beginDeferredEmit
();
let
decorationsTracker
=
this
.
_acquireDecorationsTracker
();
return
this
.
_changeDecorations
(
decorationsTracker
,
ownerId
,
callback
);
}
finally
{
this
.
_releaseDecorationsTracker
();
this
.
_endDeferredEmit
();
this
.
_e
ventEmitter
.
e
ndDeferredEmit
();
}
}
...
...
@@ -541,7 +541,7 @@ export class TextModelWithDecorations extends TextModelWithMarkers implements ed
private
emitModelDecorationsChangedEvent
(
e
:
editorCommon
.
IModelDecorationsChangedEvent
):
void
{
if
(
!
this
.
_isDisposing
)
{
this
.
emit
(
editorCommon
.
EventType
.
ModelDecorationsChanged
,
e
);
this
.
_eventEmitter
.
emit
(
editorCommon
.
EventType
.
ModelDecorationsChanged
,
e
);
}
}
...
...
src/vs/editor/common/model/textModelWithTokens.ts
浏览文件 @
94545eee
...
...
@@ -160,7 +160,7 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
if
(
!
this
.
_isDisposing
)
{
let
e
=
eventBuilder
.
build
();
if
(
e
)
{
this
.
emit
(
editorCommon
.
EventType
.
ModelTokensChanged
,
e
);
this
.
_eventEmitter
.
emit
(
editorCommon
.
EventType
.
ModelTokensChanged
,
e
);
}
}
...
...
@@ -390,13 +390,13 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
private
emitModelTokensChangedEvent
(
e
:
editorCommon
.
IModelTokensChangedEvent
):
void
{
if
(
!
this
.
_isDisposing
)
{
this
.
emit
(
editorCommon
.
EventType
.
ModelTokensChanged
,
e
);
this
.
_eventEmitter
.
emit
(
editorCommon
.
EventType
.
ModelTokensChanged
,
e
);
}
}
private
_emitModelModeChangedEvent
(
e
:
editorCommon
.
IModelLanguageChangedEvent
):
void
{
if
(
!
this
.
_isDisposing
)
{
this
.
emit
(
editorCommon
.
EventType
.
ModelLanguageChanged
,
e
);
this
.
_eventEmitter
.
emit
(
editorCommon
.
EventType
.
ModelLanguageChanged
,
e
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录