Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
128ba86d
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,发现更多精彩内容 >>
提交
128ba86d
编写于
2月 18, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove model properties
上级
f0e70a6c
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
8 addition
and
116 deletion
+8
-116
src/vs/editor/common/editorCommon.ts
src/vs/editor/common/editorCommon.ts
+0
-32
src/vs/editor/common/model/mirrorModel.ts
src/vs/editor/common/model/mirrorModel.ts
+5
-24
src/vs/editor/common/model/model.ts
src/vs/editor/common/model/model.ts
+0
-43
src/vs/editor/common/services/modelServiceImpl.ts
src/vs/editor/common/services/modelServiceImpl.ts
+3
-11
src/vs/editor/common/viewModel/viewModel.ts
src/vs/editor/common/viewModel/viewModel.ts
+0
-4
src/vs/editor/test/common/model/editableTextModelTestUtils.ts
...vs/editor/test/common/model/editableTextModelTestUtils.ts
+0
-1
src/vs/editor/test/common/model/mirrorModel.test.ts
src/vs/editor/test/common/model/mirrorModel.test.ts
+0
-1
未找到文件。
src/vs/editor/common/editorCommon.ts
浏览文件 @
128ba86d
...
...
@@ -1756,25 +1756,6 @@ export interface IModel extends IEditableTextModel, ITextModelWithMarkers, IToke
*/
destroy
():
void
;
/**
* Set a property on the model. This property will be forwarded to the
* mirror model associated with this model. Please make sure that the
* value can be serialized. If a property by the same name exists,
* it will be overwritten.
*/
setProperty
(
name
:
string
,
value
:
any
):
void
;
/**
* Returns a property previously set on the model.
* If the property is not defined, returns null.
*/
getProperty
(
name
:
string
):
any
;
/**
* Returns all properties set on the model.
*/
getProperties
():
{[
name
:
string
]:
any
;};
/**
* Gets the resource associated with this editor model.
*/
...
...
@@ -1857,7 +1838,6 @@ export interface IMirrorModel extends IEventEmitter, ITokenizedModel {
getAllEmbedded
():
IMirrorModel
[];
getAssociatedResource
():
URI
;
getProperty
(
key
:
string
):
any
;
getOffsetFromPosition
(
position
:
IPosition
):
number
;
getPositionFromOffset
(
offset
:
number
):
IPosition
;
...
...
@@ -1999,17 +1979,6 @@ export interface IModelContentChangedLinesInsertedEvent extends IModelContentCha
*/
detail
:
string
;
}
/**
* An event describing that model properties have changed.
*/
export
interface
IModelPropertiesChangedEvent
{
/**
* A map with all the properties of the model.
*/
properties
:
{
[
key
:
string
]:
any
;
};
}
/**
* Decoration data associated with a model decorations changed event.
*/
...
...
@@ -3288,7 +3257,6 @@ export var EventType = {
EditorFocus
:
'
widgetFocus
'
,
EditorBlur
:
'
widgetBlur
'
,
ModelPropertiesChanged
:
'
propertiesChanged
'
,
ModelDecorationsChanged
:
'
decorationsChanged
'
,
CursorPositionChanged
:
'
positionChanged
'
,
...
...
src/vs/editor/common/model/mirrorModel.ts
浏览文件 @
128ba86d
...
...
@@ -17,25 +17,18 @@ import {disposeAll} from 'vs/base/common/lifecycle';
export
interface
IMirrorModelEvents
{
contentChanged
:
EditorCommon
.
IModelContentChangedEvent
[];
propertiesChanged
:
EditorCommon
.
IModelPropertiesChangedEvent
;
}
export
class
AbstractMirrorModel
extends
TextModelWithTokens
implements
EditorCommon
.
IMirrorModel
{
_lineStarts
:
PrefixSumComputer
;
_associatedResource
:
URI
;
_extraProperties
:{[
key
:
string
]:
any
;};
constructor
(
allowedEventTypes
:
string
[],
versionId
:
number
,
value
:
EditorCommon
.
IRawText
,
mode
:
IMode
|
TPromise
<
IMode
>
,
associatedResource
?:
URI
,
properties
?:{[
key
:
string
]:
any
;}
)
{
constructor
(
allowedEventTypes
:
string
[],
versionId
:
number
,
value
:
EditorCommon
.
IRawText
,
mode
:
IMode
|
TPromise
<
IMode
>
,
associatedResource
?:
URI
)
{
super
(
allowedEventTypes
.
concat
([
EditorCommon
.
EventType
.
ModelDispose
]),
value
,
false
,
mode
);
if
(
!
properties
)
{
properties
=
{};
}
this
.
_setVersionId
(
versionId
);
this
.
_associatedResource
=
associatedResource
;
this
.
_extraProperties
=
properties
;
}
public
getModeId
():
string
{
...
...
@@ -77,14 +70,6 @@ export class AbstractMirrorModel extends TextModelWithTokens implements EditorCo
return
this
.
_associatedResource
;
}
public
getProperty
(
name
:
string
):
any
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
AbstractMirrorModel.getProperty: Model is disposed
'
);
}
return
this
.
_extraProperties
.
hasOwnProperty
(
name
)
?
this
.
_extraProperties
[
name
]
:
null
;
}
private
_ensurePrefixSum
():
void
{
if
(
!
this
.
_lineStarts
)
{
var
lineStartValues
:
number
[]
=
[],
...
...
@@ -302,8 +287,8 @@ class EmbeddedModeRange {
}
}
export
function
createMirrorModelFromString
(
resourceService
:
IResourceService
,
versionId
:
number
,
value
:
string
,
mode
:
IMode
,
associatedResource
?:
URI
,
properties
?:{[
key
:
string
]:
any
;}
):
MirrorModel
{
return
new
MirrorModel
(
resourceService
,
versionId
,
TextModel
.
toRawText
(
value
),
mode
,
associatedResource
,
properties
);
export
function
createMirrorModelFromString
(
resourceService
:
IResourceService
,
versionId
:
number
,
value
:
string
,
mode
:
IMode
,
associatedResource
?:
URI
):
MirrorModel
{
return
new
MirrorModel
(
resourceService
,
versionId
,
TextModel
.
toRawText
(
value
),
mode
,
associatedResource
);
}
export
class
MirrorModel
extends
AbstractMirrorModel
implements
EditorCommon
.
IMirrorModel
{
...
...
@@ -311,8 +296,8 @@ export class MirrorModel extends AbstractMirrorModel implements EditorCommon.IMi
private
_resourceService
:
IResourceService
;
private
_embeddedModels
:
{[
modeId
:
string
]:
MirrorModelEmbedded
;};
constructor
(
resourceService
:
IResourceService
,
versionId
:
number
,
value
:
EditorCommon
.
IRawText
,
mode
:
IMode
|
TPromise
<
IMode
>
,
associatedResource
?:
URI
,
properties
?:{[
key
:
string
]:
any
;}
)
{
super
([
'
changed
'
],
versionId
,
value
,
mode
,
associatedResource
,
properties
);
constructor
(
resourceService
:
IResourceService
,
versionId
:
number
,
value
:
EditorCommon
.
IRawText
,
mode
:
IMode
|
TPromise
<
IMode
>
,
associatedResource
?:
URI
)
{
super
([
'
changed
'
],
versionId
,
value
,
mode
,
associatedResource
);
this
.
_resourceService
=
resourceService
;
this
.
_embeddedModels
=
{};
...
...
@@ -450,10 +435,6 @@ export class MirrorModel extends AbstractMirrorModel implements EditorCommon.IMi
throw
new
Error
(
'
MirrorModel.onEvents: Model is disposed
'
);
}
if
(
events
.
propertiesChanged
)
{
this
.
_extraProperties
=
events
.
propertiesChanged
.
properties
;
}
let
changed
=
false
;
for
(
let
i
=
0
,
len
=
events
.
contentChanged
.
length
;
i
<
len
;
i
++
)
{
let
contentChangedEvent
=
events
.
contentChanged
[
i
];
...
...
src/vs/editor/common/model/model.ts
浏览文件 @
128ba86d
...
...
@@ -10,15 +10,10 @@ import {TextModel} from 'vs/editor/common/model/textModel';
import
{
EditableTextModel
}
from
'
vs/editor/common/model/editableTextModel
'
;
import
EditorCommon
=
require
(
'
vs/editor/common/editorCommon
'
);
import
URI
from
'
vs/base/common/uri
'
;
import
Objects
=
require
(
'
vs/base/common/objects
'
);
// The hierarchy is:
// Model -> EditableTextModel -> TextModelWithDecorations -> TextModelWithTrackedRanges -> TextModelWithMarkers -> TextModelWithTokens -> TextModel
interface
IPropertiesMap
{
[
key
:
string
]:
any
;
}
var
MODEL_ID
=
0
;
var
aliveModels
:{[
modelId
:
string
]:
boolean
;}
=
{};
...
...
@@ -39,7 +34,6 @@ export class Model extends EditableTextModel implements EditorCommon.IModel {
public
id
:
string
;
private
_associatedResource
:
URI
;
private
_extraProperties
:
IPropertiesMap
;
private
_attachedEditorCount
:
number
;
/**
...
...
@@ -57,7 +51,6 @@ export class Model extends EditableTextModel implements EditorCommon.IModel {
*/
constructor
(
rawText
:
string
,
modeOrPromise
:
IMode
|
TPromise
<
IMode
>
,
associatedResource
:
URI
=
null
)
{
super
([
EditorCommon
.
EventType
.
ModelPropertiesChanged
,
EditorCommon
.
EventType
.
ModelDispose
],
TextModel
.
toRawText
(
rawText
),
modeOrPromise
);
...
...
@@ -76,7 +69,6 @@ export class Model extends EditableTextModel implements EditorCommon.IModel {
throw
new
Error
(
'
Cannot instantiate a second Model with the same URI!
'
);
}
this
.
_extraProperties
=
{};
this
.
_attachedEditorCount
=
0
;
aliveModels
[
String
(
this
.
_associatedResource
)]
=
true
;
...
...
@@ -132,39 +124,4 @@ export class Model extends EditableTextModel implements EditorCommon.IModel {
return
this
.
_associatedResource
;
}
public
setProperty
(
name
:
string
,
value
:
any
):
void
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
Model.setProperty: Model is disposed
'
);
}
this
.
_extraProperties
[
name
]
=
value
;
this
.
emitModelPropertiesChangedEvent
();
}
public
getProperty
(
name
:
string
):
any
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
Model.getProperty: Model is disposed
'
);
}
return
this
.
_extraProperties
.
hasOwnProperty
(
name
)
?
this
.
_extraProperties
[
name
]
:
null
;
}
public
getProperties
():
{[
name
:
string
]:
any
;}
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
Model.getProperties: Model is disposed
'
);
}
// TODO@Alex: avoid Objects.clone
return
Objects
.
clone
(
this
.
_extraProperties
);
}
private
emitModelPropertiesChangedEvent
():
void
{
var
e
:
EditorCommon
.
IModelPropertiesChangedEvent
=
{
properties
:
this
.
_extraProperties
};
if
(
!
this
.
_isDisposing
)
{
this
.
emit
(
EditorCommon
.
EventType
.
ModelPropertiesChanged
,
e
);
}
}
}
src/vs/editor/common/services/modelServiceImpl.ts
浏览文件 @
128ba86d
...
...
@@ -28,7 +28,6 @@ export interface IRawModelData {
url
:
URI
;
versionId
:
number
;
value
:
EditorCommon
.
IRawText
;
properties
:
any
;
modeId
:
string
;
}
...
...
@@ -325,14 +324,13 @@ export class ModelServiceImpl implements IModelService {
return
{
url
:
model
.
getAssociatedResource
(),
versionId
:
model
.
getVersionId
(),
properties
:
model
.
getProperties
(),
value
:
model
.
toRawText
(),
modeId
:
model
.
getMode
().
getId
()
};
}
private
_onModelEvents
(
modelData
:
ModelData
,
events
:
IEmitterEvent
[]):
void
{
let
eventsForWorkers
:
IMirrorModelEvents
=
{
contentChanged
:
[]
,
propertiesChanged
:
null
};
let
eventsForWorkers
:
IMirrorModelEvents
=
{
contentChanged
:
[]
};
for
(
let
i
=
0
,
len
=
events
.
length
;
i
<
len
;
i
++
)
{
let
e
=
events
[
i
];
...
...
@@ -350,12 +348,6 @@ export class ModelServiceImpl implements IModelService {
}
break
;
case
EditorCommon
.
EventType
.
ModelPropertiesChanged
:
if
(
modelData
.
isSyncedToWorkers
)
{
eventsForWorkers
.
propertiesChanged
=
<
EditorCommon
.
IModelPropertiesChangedEvent
>
data
;
}
break
;
case
EditorCommon
.
EventType
.
ModelModeChanged
:
let
modeChangedEvent
=
<
EditorCommon
.
IModelModeChangedEvent
>
data
;
if
(
modelData
.
isSyncedToWorkers
)
{
...
...
@@ -367,7 +359,7 @@ export class ModelServiceImpl implements IModelService {
}
}
if
(
eventsForWorkers
.
contentChanged
.
length
>
0
||
eventsForWorkers
.
propertiesChanged
)
{
if
(
eventsForWorkers
.
contentChanged
.
length
>
0
)
{
// Forward events to all the workers
this
.
_workerHelper
.
$_acceptModelEvents
(
modelData
.
getModelId
(),
eventsForWorkers
);
}
...
...
@@ -390,7 +382,7 @@ export class ModelServiceWorkerHelper {
public
$_acceptNewModel
(
data
:
IRawModelData
):
TPromise
<
void
>
{
// Create & insert the mirror model eagerly in the resource service
let
mirrorModel
=
new
MirrorModel
(
this
.
_resourceService
,
data
.
versionId
,
data
.
value
,
null
,
data
.
url
,
data
.
properties
);
let
mirrorModel
=
new
MirrorModel
(
this
.
_resourceService
,
data
.
versionId
,
data
.
value
,
null
,
data
.
url
);
this
.
_resourceService
.
insert
(
mirrorModel
.
getAssociatedResource
(),
mirrorModel
);
// Block worker execution until the mode is instantiated
...
...
src/vs/editor/common/viewModel/viewModel.ts
浏览文件 @
128ba86d
...
...
@@ -224,10 +224,6 @@ export class ViewModel extends EventEmitter implements EditorCommon.IViewModel {
// That's ok, no work to do
break
;
case
EditorCommon
.
EventType
.
ModelPropertiesChanged
:
// Ignore
break
;
case
EditorCommon
.
EventType
.
ModelContentChanged2
:
// Ignore
break
;
...
...
src/vs/editor/test/common/model/editableTextModelTestUtils.ts
浏览文件 @
128ba86d
...
...
@@ -58,7 +58,6 @@ export function assertSyncedModels(text:string, callback:(model:EditableTextMod
}
mirrorModel1PrevVersionId
=
versionId
;
let
mirrorModelEvents
:
IMirrorModelEvents
=
{
propertiesChanged
:
null
,
contentChanged
:
[
e
]
};
mirrorModel1
.
onEvents
(
mirrorModelEvents
);
...
...
src/vs/editor/test/common/model/mirrorModel.test.ts
浏览文件 @
128ba86d
...
...
@@ -67,7 +67,6 @@ function contentChangedLineChanged(lineNumber: number, detail: string): EditorCo
function
mirrorModelEvents
(
contentChanged
:
EditorCommon
.
IModelContentChangedEvent
[]):
MirrorModel
.
IMirrorModelEvents
{
return
{
propertiesChanged
:
null
,
contentChanged
:
contentChanged
};
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录