Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
df829157
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,发现更多精彩内容 >>
提交
df829157
编写于
3月 30, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove isDisposed checks in model
上级
f050eaae
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
15 addition
and
351 deletion
+15
-351
src/vs/editor/common/core/position.ts
src/vs/editor/common/core/position.ts
+2
-2
src/vs/editor/common/editorCommon.ts
src/vs/editor/common/editorCommon.ts
+2
-2
src/vs/editor/common/model/editableTextModel.ts
src/vs/editor/common/model/editableTextModel.ts
+0
-28
src/vs/editor/common/model/mirrorModel.ts
src/vs/editor/common/model/mirrorModel.ts
+0
-51
src/vs/editor/common/model/model.ts
src/vs/editor/common/model/model.ts
+0
-12
src/vs/editor/common/model/textModel.ts
src/vs/editor/common/model/textModel.ts
+0
-103
src/vs/editor/common/model/textModelWithDecorations.ts
src/vs/editor/common/model/textModelWithDecorations.ts
+0
-35
src/vs/editor/common/model/textModelWithMarkers.ts
src/vs/editor/common/model/textModelWithMarkers.ts
+0
-27
src/vs/editor/common/model/textModelWithTokens.ts
src/vs/editor/common/model/textModelWithTokens.ts
+0
-65
src/vs/editor/common/model/textModelWithTrackedRanges.ts
src/vs/editor/common/model/textModelWithTrackedRanges.ts
+0
-24
src/vs/editor/common/modes/TMState.ts
src/vs/editor/common/modes/TMState.ts
+11
-2
未找到文件。
src/vs/editor/common/core/position.ts
浏览文件 @
df829157
...
...
@@ -12,8 +12,8 @@ export class Position implements IEditorPosition {
public
column
:
number
;
constructor
(
lineNumber
:
number
,
column
:
number
)
{
this
.
lineNumber
=
lineNumber
;
this
.
column
=
column
;
this
.
lineNumber
=
lineNumber
|
0
;
this
.
column
=
column
|
0
;
}
public
equals
(
other
:
IPosition
):
boolean
{
...
...
src/vs/editor/common/editorCommon.ts
浏览文件 @
df829157
...
...
@@ -3528,8 +3528,8 @@ export class HorizontalRange {
public
width
:
number
;
constructor
(
left
:
number
,
width
:
number
)
{
this
.
left
=
left
;
this
.
width
=
width
;
this
.
left
=
left
|
0
;
this
.
width
=
width
|
0
;
}
}
...
...
src/vs/editor/common/model/editableTextModel.ts
浏览文件 @
df829157
...
...
@@ -66,18 +66,10 @@ export class EditableTextModel extends TextModelWithDecorations implements edito
}
public
pushStackElement
():
void
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
EditableTextModel.pushStackElement: Model is disposed
'
);
}
this
.
_commandManager
.
pushStackElement
();
}
public
pushEditOperations
(
beforeCursorState
:
editorCommon
.
IEditorSelection
[],
editOperations
:
editorCommon
.
IIdentifiedSingleEditOperation
[],
cursorStateComputer
:
editorCommon
.
ICursorStateComputer
):
editorCommon
.
IEditorSelection
[]
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
EditableTextModel.pushEditOperations: Model is disposed
'
);
}
return
this
.
deferredEmit
(()
=>
{
return
this
.
_commandManager
.
pushEditOperation
(
beforeCursorState
,
editOperations
,
cursorStateComputer
);
});
...
...
@@ -532,10 +524,6 @@ export class EditableTextModel extends TextModelWithDecorations implements edito
}
public
undo
():
editorCommon
.
IEditorSelection
[]
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
EditableTextModel.undo: Model is disposed
'
);
}
return
this
.
_withDeferredEvents
(()
=>
{
this
.
_isUndoing
=
true
;
let
r
=
this
.
_commandManager
.
undo
();
...
...
@@ -552,10 +540,6 @@ export class EditableTextModel extends TextModelWithDecorations implements edito
}
public
redo
():
editorCommon
.
IEditorSelection
[]
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
EditableTextModel.redo: Model is disposed
'
);
}
return
this
.
_withDeferredEvents
(()
=>
{
this
.
_isRedoing
=
true
;
let
r
=
this
.
_commandManager
.
redo
();
...
...
@@ -572,10 +556,6 @@ export class EditableTextModel extends TextModelWithDecorations implements edito
}
public
setEditableRange
(
range
:
editorCommon
.
IRange
):
void
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
EditableTextModel.setEditableRange: Model is disposed
'
);
}
this
.
_commandManager
.
clear
();
if
(
this
.
_hasEditableRange
)
{
this
.
removeTrackedRange
(
this
.
_editableRangeId
);
...
...
@@ -590,18 +570,10 @@ export class EditableTextModel extends TextModelWithDecorations implements edito
}
public
hasEditableRange
():
boolean
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
EditableTextModel.hasEditableRange: Model is disposed
'
);
}
return
this
.
_hasEditableRange
;
}
public
getEditableRange
():
editorCommon
.
IEditorRange
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
EditableTextModel.getEditableRange: Model is disposed
'
);
}
if
(
this
.
_hasEditableRange
)
{
return
this
.
getTrackedRange
(
this
.
_editableRangeId
);
}
else
{
...
...
src/vs/editor/common/model/mirrorModel.ts
浏览文件 @
df829157
...
...
@@ -32,10 +32,6 @@ export class AbstractMirrorModel extends TextModelWithTokens implements editorCo
}
public
getModeId
():
string
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
AbstractMirrorModel.getModeId: Model is disposed
'
);
}
return
this
.
getMode
().
getId
();
}
...
...
@@ -63,10 +59,6 @@ export class AbstractMirrorModel extends TextModelWithTokens implements editorCo
}
public
getAssociatedResource
():
URI
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
AbstractMirrorModel.getAssociatedResource: Model is disposed
'
);
}
return
this
.
_associatedResource
;
}
...
...
@@ -82,10 +74,6 @@ export class AbstractMirrorModel extends TextModelWithTokens implements editorCo
}
public
getRangeFromOffsetAndLength
(
offset
:
number
,
length
:
number
):
editorCommon
.
IRange
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
AbstractMirrorModel.getRangeFromOffsetAndLength: Model is disposed
'
);
}
var
startPosition
=
this
.
getPositionFromOffset
(
offset
),
endPosition
=
this
.
getPositionFromOffset
(
offset
+
length
);
return
{
...
...
@@ -97,10 +85,6 @@ export class AbstractMirrorModel extends TextModelWithTokens implements editorCo
}
public
getOffsetAndLengthFromRange
(
range
:
editorCommon
.
IRange
):{
offset
:
number
;
length
:
number
;}
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
AbstractMirrorModel.getOffsetAndLengthFromRange: Model is disposed
'
);
}
var
startOffset
=
this
.
getOffsetFromPosition
({
lineNumber
:
range
.
startLineNumber
,
column
:
range
.
startColumn
}),
endOffset
=
this
.
getOffsetFromPosition
({
lineNumber
:
range
.
endLineNumber
,
column
:
range
.
endColumn
});
return
{
...
...
@@ -110,10 +94,6 @@ export class AbstractMirrorModel extends TextModelWithTokens implements editorCo
}
public
getPositionFromOffset
(
offset
:
number
):
editorCommon
.
IPosition
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
AbstractMirrorModel.getPositionFromOffset: Model is disposed
'
);
}
this
.
_ensurePrefixSum
();
let
r
=
this
.
_lineStarts
.
getIndexOf
(
offset
);
...
...
@@ -124,18 +104,10 @@ export class AbstractMirrorModel extends TextModelWithTokens implements editorCo
}
public
getOffsetFromPosition
(
position
:
editorCommon
.
IPosition
):
number
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
AbstractMirrorModel.getOffsetFromPosition: Model is disposed
'
);
}
return
this
.
getLineStart
(
position
.
lineNumber
)
+
position
.
column
-
1
/* column isn't zero-index based */
;
}
public
getLineStart
(
lineNumber
:
number
):
number
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
AbstractMirrorModel.getLineStart: Model is disposed
'
);
}
this
.
_ensurePrefixSum
();
var
lineIndex
=
Math
.
min
(
lineNumber
,
this
.
_lines
.
length
)
-
1
;
...
...
@@ -143,9 +115,6 @@ export class AbstractMirrorModel extends TextModelWithTokens implements editorCo
}
public
getAllWordsWithRange
():
editorCommon
.
IRangeWithText
[]
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
AbstractMirrorModel.getAllWordsWithRange: Model is disposed
'
);
}
if
(
this
.
_lines
.
length
>
10000
)
{
// This is a very heavy method, unavailable for very heavy models
return
[];
...
...
@@ -169,10 +138,6 @@ export class AbstractMirrorModel extends TextModelWithTokens implements editorCo
}
public
getAllWords
():
string
[]
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
AbstractMirrorModel.getAllWords: Model is disposed
'
);
}
var
result
:
string
[]
=
[];
this
.
_lines
.
forEach
((
line
)
=>
{
this
.
wordenize
(
line
.
text
).
forEach
((
info
)
=>
{
...
...
@@ -183,10 +148,6 @@ export class AbstractMirrorModel extends TextModelWithTokens implements editorCo
}
public
getAllUniqueWords
(
skipWordOnce
?:
string
)
:
string
[]
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
AbstractMirrorModel.getAllUniqueWords: Model is disposed
'
);
}
var
foundSkipWord
=
false
;
var
uniqueWords
=
{};
return
this
.
getAllWords
().
filter
((
word
)
=>
{
...
...
@@ -308,10 +269,6 @@ export class MirrorModel extends AbstractMirrorModel implements editorCommon.IMi
}
public
getEmbeddedAtPosition
(
position
:
editorCommon
.
IPosition
):
editorCommon
.
IMirrorModel
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
MirrorModel.getEmbeddedAtPosition: Model is disposed
'
);
}
var
modeAtPosition
=
this
.
getModeAtPosition
(
position
.
lineNumber
,
position
.
column
);
if
(
this
.
_embeddedModels
.
hasOwnProperty
(
modeAtPosition
.
getId
()))
{
return
this
.
_embeddedModels
[
modeAtPosition
.
getId
()];
...
...
@@ -320,10 +277,6 @@ export class MirrorModel extends AbstractMirrorModel implements editorCommon.IMi
}
public
getAllEmbedded
():
editorCommon
.
IMirrorModel
[]
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
MirrorModel.getAllEmbedded: Model is disposed
'
);
}
return
Object
.
keys
(
this
.
_embeddedModels
).
map
((
embeddedModeId
)
=>
this
.
_embeddedModels
[
embeddedModeId
]);
}
...
...
@@ -434,10 +387,6 @@ export class MirrorModel extends AbstractMirrorModel implements editorCommon.IMi
}
public
onEvents
(
events
:
IMirrorModelEvents
)
:
boolean
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
MirrorModel.onEvents: Model is disposed
'
);
}
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
浏览文件 @
df829157
...
...
@@ -95,10 +95,6 @@ export class Model extends EditableTextModel implements IModel {
}
public
onBeforeAttached
():
void
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
Model.onBeforeAttached: Model is disposed
'
);
}
this
.
_attachedEditorCount
++
;
// Warm up tokens for the editor
...
...
@@ -106,10 +102,6 @@ export class Model extends EditableTextModel implements IModel {
}
public
onBeforeDetached
():
void
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
Model.onBeforeDetached: Model is disposed
'
);
}
this
.
_attachedEditorCount
--
;
// Intentional empty (for now)
...
...
@@ -120,10 +112,6 @@ export class Model extends EditableTextModel implements IModel {
}
public
getAssociatedResource
():
URI
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
Model.getAssociatedResource: Model is disposed
'
);
}
return
this
.
_associatedResource
;
}
}
src/vs/editor/common/model/textModel.ts
浏览文件 @
df829157
...
...
@@ -49,10 +49,6 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
}
public
getOptions
():
editorCommon
.
ITextModelResolvedOptions
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModel.getOptions: Model is disposed
'
);
}
return
this
.
_options
;
}
...
...
@@ -145,18 +141,10 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
}
public
getVersionId
():
number
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModel.getVersionId: Model is disposed
'
);
}
return
this
.
_versionId
;
}
public
getAlternativeVersionId
():
number
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModel.getAlternativeVersionId: Model is disposed
'
);
}
return
this
.
_alternativeVersionId
;
}
...
...
@@ -178,10 +166,6 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
}
public
dispose
():
void
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModel.dispose: Model is disposed
'
);
}
this
.
_isDisposed
=
true
;
// Null out members, such that any use of a disposed model will throw exceptions sooner rather than later
this
.
_lines
=
null
;
...
...
@@ -255,9 +239,6 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
}
public
setValue
(
value
:
string
):
void
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModel.setValue: Model is disposed
'
);
}
let
rawText
:
editorCommon
.
IRawText
=
null
;
if
(
value
!==
null
)
{
rawText
=
TextModel
.
toRawText
(
value
,
{
...
...
@@ -271,10 +252,6 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
}
public
setValueFromRawText
(
newValue
:
editorCommon
.
IRawText
):
void
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModel.setValueFromRawText: Model is disposed
'
);
}
if
(
newValue
===
null
)
{
// There's nothing to do
return
;
...
...
@@ -291,10 +268,6 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
}
public
getValue
(
eol
?:
editorCommon
.
EndOfLinePreference
,
preserveBOM
:
boolean
=
false
):
string
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModel.getValue: Model is disposed
'
);
}
var
fullModelRange
=
this
.
getFullModelRange
();
var
fullModelValue
=
this
.
getValueInRange
(
fullModelRange
,
eol
);
...
...
@@ -306,10 +279,6 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
}
public
getValueLength
(
eol
?:
editorCommon
.
EndOfLinePreference
,
preserveBOM
:
boolean
=
false
):
number
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModel.getValueLength: Model is disposed
'
);
}
var
fullModelRange
=
this
.
getFullModelRange
();
var
fullModelValue
=
this
.
getValueLengthInRange
(
fullModelRange
,
eol
);
...
...
@@ -321,10 +290,6 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
}
public
getEmptiedValueInRange
(
rawRange
:
editorCommon
.
IRange
,
fillCharacter
:
string
=
''
,
eol
:
editorCommon
.
EndOfLinePreference
=
editorCommon
.
EndOfLinePreference
.
TextDefined
):
string
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModel.getEmptiedValueInRange: Model is disposed
'
);
}
var
range
=
this
.
validateRange
(
rawRange
);
if
(
range
.
isEmpty
())
{
...
...
@@ -358,10 +323,6 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
}
public
getValueInRange
(
rawRange
:
editorCommon
.
IRange
,
eol
:
editorCommon
.
EndOfLinePreference
=
editorCommon
.
EndOfLinePreference
.
TextDefined
):
string
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModel.getValueInRange: Model is disposed
'
);
}
var
range
=
this
.
validateRange
(
rawRange
);
if
(
range
.
isEmpty
())
{
...
...
@@ -387,10 +348,6 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
}
public
getValueLengthInRange
(
rawRange
:
editorCommon
.
IRange
,
eol
:
editorCommon
.
EndOfLinePreference
=
editorCommon
.
EndOfLinePreference
.
TextDefined
):
number
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModel.getValueInRange: Model is disposed
'
);
}
var
range
=
this
.
validateRange
(
rawRange
);
if
(
range
.
isEmpty
())
{
...
...
@@ -416,10 +373,6 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
}
public
isDominatedByLongLines
(
longLineBoundary
:
number
):
boolean
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModel.isDominatedByLongLines: Model is disposed
'
);
}
var
smallLineCharCount
=
0
,
longLineCharCount
=
0
,
i
:
number
,
...
...
@@ -440,17 +393,10 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
}
public
getLineCount
():
number
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModel.getLineCount: Model is disposed
'
);
}
return
this
.
_lines
.
length
;
}
public
getLineContent
(
lineNumber
:
number
):
string
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModel.getLineContent: Model is disposed
'
);
}
if
(
lineNumber
<
1
||
lineNumber
>
this
.
getLineCount
())
{
throw
new
Error
(
'
Illegal value
'
+
lineNumber
+
'
for `lineNumber`
'
);
}
...
...
@@ -459,10 +405,6 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
}
public
getLinesContent
():
string
[]
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModel.getLineContent: Model is disposed
'
);
}
var
r
:
string
[]
=
[];
for
(
var
i
=
0
,
len
=
this
.
_lines
.
length
;
i
<
len
;
i
++
)
{
r
[
i
]
=
this
.
_lines
[
i
].
text
;
...
...
@@ -471,10 +413,6 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
}
public
getEOL
():
string
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModel.getEOL: Model is disposed
'
);
}
return
this
.
_EOL
;
}
...
...
@@ -506,9 +444,6 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
}
public
getLineMaxColumn
(
lineNumber
:
number
):
number
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModel.getLineMaxColumn: Model is disposed
'
);
}
if
(
lineNumber
<
1
||
lineNumber
>
this
.
getLineCount
())
{
throw
new
Error
(
'
Illegal value
'
+
lineNumber
+
'
for `lineNumber`
'
);
}
...
...
@@ -517,9 +452,6 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
}
public
getLineFirstNonWhitespaceColumn
(
lineNumber
:
number
):
number
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModel.getLineFirstNonWhitespaceColumn: Model is disposed
'
);
}
if
(
lineNumber
<
1
||
lineNumber
>
this
.
getLineCount
())
{
throw
new
Error
(
'
Illegal value
'
+
lineNumber
+
'
for `lineNumber`
'
);
}
...
...
@@ -532,9 +464,6 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
}
public
getLineLastNonWhitespaceColumn
(
lineNumber
:
number
):
number
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModel.getLineLastNonWhitespaceColumn: Model is disposed
'
);
}
if
(
lineNumber
<
1
||
lineNumber
>
this
.
getLineCount
())
{
throw
new
Error
(
'
Illegal value
'
+
lineNumber
+
'
for `lineNumber`
'
);
}
...
...
@@ -547,10 +476,6 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
}
public
validateLineNumber
(
lineNumber
:
number
):
number
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModel.validateLineNumber: Model is disposed
'
);
}
if
(
lineNumber
<
1
)
{
lineNumber
=
1
;
}
...
...
@@ -561,10 +486,6 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
}
public
validatePosition
(
position
:
editorCommon
.
IPosition
):
editorCommon
.
IEditorPosition
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModel.validatePosition: Model is disposed
'
);
}
var
lineNumber
=
position
.
lineNumber
?
position
.
lineNumber
:
1
;
var
column
=
position
.
column
?
position
.
column
:
1
;
...
...
@@ -587,20 +508,12 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
}
public
validateRange
(
range
:
editorCommon
.
IRange
):
editorCommon
.
IEditorRange
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModel.validateRange: Model is disposed
'
);
}
var
start
=
this
.
validatePosition
(
new
Position
(
range
.
startLineNumber
,
range
.
startColumn
));
var
end
=
this
.
validatePosition
(
new
Position
(
range
.
endLineNumber
,
range
.
endColumn
));
return
new
Range
(
start
.
lineNumber
,
start
.
column
,
end
.
lineNumber
,
end
.
column
);
}
public
modifyPosition
(
rawPosition
:
editorCommon
.
IPosition
,
offset
:
number
)
:
editorCommon
.
IEditorPosition
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModel.modifyPosition: Model is disposed
'
);
}
var
position
=
this
.
validatePosition
(
rawPosition
);
// Handle positive offsets, one line at a time
...
...
@@ -664,10 +577,6 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
}
public
getFullModelRange
():
editorCommon
.
IEditorRange
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModel.getFullModelRange: Model is disposed
'
);
}
var
lineCount
=
this
.
getLineCount
();
return
new
Range
(
1
,
1
,
lineCount
,
this
.
getLineMaxColumn
(
lineCount
));
}
...
...
@@ -761,10 +670,6 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
}
public
findMatches
(
searchString
:
string
,
rawSearchScope
:
any
,
isRegex
:
boolean
,
matchCase
:
boolean
,
wholeWord
:
boolean
,
limitResultCount
:
number
=
LIMIT_FIND_COUNT
):
editorCommon
.
IEditorRange
[]
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
Model.findMatches: Model is disposed
'
);
}
var
regex
=
strings
.
createSafeRegExp
(
searchString
,
isRegex
,
matchCase
,
wholeWord
);
if
(
!
regex
)
{
return
[];
...
...
@@ -781,10 +686,6 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
}
public
findNextMatch
(
searchString
:
string
,
rawSearchStart
:
editorCommon
.
IPosition
,
isRegex
:
boolean
,
matchCase
:
boolean
,
wholeWord
:
boolean
):
editorCommon
.
IEditorRange
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
Model.findNextMatch: Model is disposed
'
);
}
var
regex
=
strings
.
createSafeRegExp
(
searchString
,
isRegex
,
matchCase
,
wholeWord
);
if
(
!
regex
)
{
return
null
;
...
...
@@ -816,10 +717,6 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
}
public
findPreviousMatch
(
searchString
:
string
,
rawSearchStart
:
editorCommon
.
IPosition
,
isRegex
:
boolean
,
matchCase
:
boolean
,
wholeWord
:
boolean
):
editorCommon
.
IEditorRange
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
Model.findPreviousMatch: Model is disposed
'
);
}
var
regex
=
strings
.
createSafeRegExp
(
searchString
,
isRegex
,
matchCase
,
wholeWord
);
if
(
!
regex
)
{
return
null
;
...
...
src/vs/editor/common/model/textModelWithDecorations.ts
浏览文件 @
df829157
...
...
@@ -122,10 +122,6 @@ export class TextModelWithDecorations extends TextModelWithTrackedRanges impleme
}
public
changeDecorations
(
callback
:
(
changeAccessor
:
editorCommon
.
IModelDecorationsChangeAccessor
)
=>
any
,
ownerId
:
number
=
0
):
any
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModelWithDecorations.changeDecorations: Model is disposed
'
);
}
return
this
.
_withDeferredEvents
((
deferredEventsBuilder
:
DeferredEventsBuilder
)
=>
{
var
changeAccessor
:
editorCommon
.
IModelDecorationsChangeAccessor
=
{
addDecoration
:
(
range
:
editorCommon
.
IRange
,
options
:
editorCommon
.
IModelDecorationOptions
):
string
=>
{
...
...
@@ -160,10 +156,6 @@ export class TextModelWithDecorations extends TextModelWithTrackedRanges impleme
}
public
deltaDecorations
(
oldDecorations
:
string
[],
newDecorations
:
editorCommon
.
IModelDeltaDecoration
[],
ownerId
:
number
=
0
):
string
[]
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModelWithDecorations.deltaDecorations: Model is disposed
'
);
}
if
(
!
oldDecorations
)
{
oldDecorations
=
[];
}
...
...
@@ -173,10 +165,6 @@ export class TextModelWithDecorations extends TextModelWithTrackedRanges impleme
}
public
removeAllDecorationsWithOwnerId
(
ownerId
:
number
):
void
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModelWithDecorations.removeAllDecorationsWithOwnerId: Model is disposed
'
);
}
let
toRemove
:
string
[]
=
[];
let
keys
=
Object
.
keys
(
this
.
decorations
);
...
...
@@ -193,10 +181,6 @@ export class TextModelWithDecorations extends TextModelWithTrackedRanges impleme
}
public
getDecorationOptions
(
decorationId
:
string
):
editorCommon
.
IModelDecorationOptions
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModelWithDecorations.getDecorationOptions: Model is disposed
'
);
}
if
(
this
.
decorations
.
hasOwnProperty
(
decorationId
))
{
return
this
.
decorations
[
decorationId
].
options
;
}
...
...
@@ -204,10 +188,6 @@ export class TextModelWithDecorations extends TextModelWithTrackedRanges impleme
}
public
getDecorationRange
(
decorationId
:
string
):
editorCommon
.
IEditorRange
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModelWithDecorations.getDecorationRange: Model is disposed
'
);
}
if
(
this
.
decorations
.
hasOwnProperty
(
decorationId
))
{
var
decoration
=
this
.
decorations
[
decorationId
];
return
this
.
getTrackedRange
(
decoration
.
rangeId
);
...
...
@@ -216,9 +196,6 @@ export class TextModelWithDecorations extends TextModelWithTrackedRanges impleme
}
public
getLineDecorations
(
lineNumber
:
number
,
ownerId
:
number
=
0
,
filterOutValidation
:
boolean
=
false
):
editorCommon
.
IModelDecoration
[]
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModelWithDecorations.getLineDecorations: Model is disposed
'
);
}
if
(
lineNumber
<
1
||
lineNumber
>
this
.
getLineCount
())
{
return
[];
}
...
...
@@ -272,10 +249,6 @@ export class TextModelWithDecorations extends TextModelWithTrackedRanges impleme
}
public
getLinesDecorations
(
startLineNumber
:
number
,
endLineNumber
:
number
,
ownerId
:
number
=
0
,
filterOutValidation
:
boolean
=
false
):
editorCommon
.
IModelDecoration
[]
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModelWithDecorations.getLinesDecorations: Model is disposed
'
);
}
var
lineCount
=
this
.
getLineCount
();
startLineNumber
=
Math
.
min
(
lineCount
,
Math
.
max
(
1
,
startLineNumber
));
endLineNumber
=
Math
.
min
(
lineCount
,
Math
.
max
(
1
,
endLineNumber
));
...
...
@@ -283,19 +256,11 @@ export class TextModelWithDecorations extends TextModelWithTrackedRanges impleme
}
public
getDecorationsInRange
(
range
:
editorCommon
.
IRange
,
ownerId
?:
number
,
filterOutValidation
?:
boolean
):
editorCommon
.
IModelDecoration
[]
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModelWithDecorations.getDecorationsInRange: Model is disposed
'
);
}
var
validatedRange
=
this
.
validateRange
(
range
);
return
this
.
_getDecorationsInRange
(
validatedRange
.
startLineNumber
,
validatedRange
.
startColumn
,
validatedRange
.
endLineNumber
,
validatedRange
.
endColumn
,
ownerId
,
filterOutValidation
);
}
public
getAllDecorations
(
ownerId
:
number
=
0
,
filterOutValidation
:
boolean
=
false
):
editorCommon
.
IModelDecoration
[]
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModelWithDecorations.getAllDecorations: Model is disposed
'
);
}
let
result
:
editorCommon
.
IModelDecoration
[]
=
[];
let
keys
=
Object
.
keys
(
this
.
decorations
);
...
...
src/vs/editor/common/model/textModelWithMarkers.ts
浏览文件 @
df829157
...
...
@@ -70,10 +70,6 @@ export class TextModelWithMarkers extends TextModelWithTokens implements ITextMo
}
_addMarker
(
lineNumber
:
number
,
column
:
number
,
stickToPreviousCharacter
:
boolean
):
string
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModelWithMarkers._addMarker: Model is disposed
'
);
}
var
pos
=
this
.
validatePosition
(
new
Position
(
lineNumber
,
column
));
var
marker
=
new
LineMarker
(
this
.
_markerIdGenerator
.
generate
(),
pos
.
column
,
stickToPreviousCharacter
);
...
...
@@ -114,10 +110,6 @@ export class TextModelWithMarkers extends TextModelWithTokens implements ITextMo
}
_changeMarker
(
id
:
string
,
lineNumber
:
number
,
column
:
number
):
void
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModelWithMarkers._changeMarker: Model is disposed
'
);
}
if
(
this
.
_markerIdToMarker
.
hasOwnProperty
(
id
))
{
var
marker
=
this
.
_markerIdToMarker
[
id
];
var
newPos
=
this
.
validatePosition
(
new
Position
(
lineNumber
,
column
));
...
...
@@ -134,10 +126,6 @@ export class TextModelWithMarkers extends TextModelWithTokens implements ITextMo
}
_changeMarkerStickiness
(
id
:
string
,
newStickToPreviousCharacter
:
boolean
):
void
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModelWithMarkers._changeMarkerStickiness: Model is disposed
'
);
}
if
(
this
.
_markerIdToMarker
.
hasOwnProperty
(
id
))
{
var
marker
=
this
.
_markerIdToMarker
[
id
];
...
...
@@ -148,10 +136,6 @@ export class TextModelWithMarkers extends TextModelWithTokens implements ITextMo
}
_getMarker
(
id
:
string
):
IEditorPosition
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModelWithMarkers._getMarker: Model is disposed
'
);
}
if
(
this
.
_markerIdToMarker
.
hasOwnProperty
(
id
))
{
var
marker
=
this
.
_markerIdToMarker
[
id
];
return
new
Position
(
marker
.
line
.
lineNumber
,
marker
.
column
);
...
...
@@ -164,9 +148,6 @@ export class TextModelWithMarkers extends TextModelWithTokens implements ITextMo
}
_getLineMarkers
(
lineNumber
:
number
):
IReadOnlyLineMarker
[]
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModelWithMarkers._getLineMarkers: Model is disposed
'
);
}
if
(
lineNumber
<
1
||
lineNumber
>
this
.
getLineCount
())
{
throw
new
Error
(
'
Illegal value
'
+
lineNumber
+
'
for `lineNumber`
'
);
}
...
...
@@ -175,10 +156,6 @@ export class TextModelWithMarkers extends TextModelWithTokens implements ITextMo
}
_removeMarker
(
id
:
string
):
void
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModelWithMarkers._removeMarker: Model is disposed
'
);
}
if
(
this
.
_markerIdToMarker
.
hasOwnProperty
(
id
))
{
var
marker
=
this
.
_markerIdToMarker
[
id
];
marker
.
line
.
removeMarker
(
marker
);
...
...
@@ -219,10 +196,6 @@ export class TextModelWithMarkers extends TextModelWithTokens implements ITextMo
}
_getMarkersInMap
(
markersMap
:{[
markerId
:
string
]:
boolean
;}):
ILineMarker
[]
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModelWithMarkers._getMarkersInMap: Model is disposed
'
);
}
let
result
:
ILineMarker
[]
=
[];
let
keys
=
Object
.
keys
(
markersMap
);
for
(
let
i
=
0
,
len
=
keys
.
length
;
i
<
len
;
i
++
)
{
...
...
src/vs/editor/common/model/textModelWithTokens.ts
浏览文件 @
df829157
...
...
@@ -426,17 +426,10 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
}
public
setStopLineTokenizationAfter
(
stopLineTokenizationAfter
:
number
):
void
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModelWithTokens.setStopLineTokenizationAfter: Model is disposed
'
);
}
this
.
_stopLineTokenizationAfter
=
stopLineTokenizationAfter
;
}
public
getLineTokens
(
lineNumber
:
number
,
inaccurateTokensAcceptable
:
boolean
=
false
):
editorCommon
.
ILineTokens
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModelWithTokens.getLineTokens: Model is disposed
'
);
}
if
(
lineNumber
<
1
||
lineNumber
>
this
.
getLineCount
())
{
throw
new
Error
(
'
Illegal value
'
+
lineNumber
+
'
for `lineNumber`
'
);
}
...
...
@@ -448,9 +441,6 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
}
public
getLineContext
(
lineNumber
:
number
):
ILineContext
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModelWithTokens.getLineContext: Model is disposed
'
);
}
if
(
lineNumber
<
1
||
lineNumber
>
this
.
getLineCount
())
{
throw
new
Error
(
'
Illegal value
'
+
lineNumber
+
'
for `lineNumber`
'
);
}
...
...
@@ -468,9 +458,6 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
public
setValue
(
value
:
string
,
newMode
?:
IMode
):
void
;
public
setValue
(
value
:
string
,
newModePromise
?:
TPromise
<
IMode
>
):
void
;
public
setValue
(
value
:
string
,
newModeOrPromise
:
any
=
null
):
void
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModelWithTokens.setValue: Model is disposed
'
);
}
let
rawText
:
editorCommon
.
IRawText
=
null
;
if
(
value
!==
null
)
{
rawText
=
TextModel
.
toRawText
(
value
,
{
...
...
@@ -486,10 +473,6 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
public
setValueFromRawText
(
value
:
editorCommon
.
IRawText
,
newMode
?:
IMode
):
void
;
public
setValueFromRawText
(
value
:
editorCommon
.
IRawText
,
newModePromise
?:
TPromise
<
IMode
>
):
void
;
public
setValueFromRawText
(
value
:
editorCommon
.
IRawText
,
newModeOrPromise
:
any
=
null
):
void
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModelWithTokens.setValueFromRawText: Model is disposed
'
);
}
if
(
value
!==
null
)
{
super
.
setValueFromRawText
(
value
);
}
...
...
@@ -516,20 +499,12 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
}
public
getMode
():
IMode
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModelWithTokens.getMode: Model is disposed
'
);
}
return
this
.
_mode
;
}
public
setMode
(
newMode
:
IMode
):
void
;
public
setMode
(
newModePromise
:
TPromise
<
IMode
>
):
void
;
public
setMode
(
newModeOrPromise
:
any
):
void
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModelWithTokens.setMode: Model is disposed
'
);
}
if
(
!
newModeOrPromise
)
{
// There's nothing to do
return
;
...
...
@@ -538,10 +513,6 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
}
public
getModeAtPosition
(
_lineNumber
:
number
,
_column
:
number
):
IMode
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModelWithTokens.getModeAtPosition: Model is disposed
'
);
}
var
validPosition
=
this
.
validatePosition
({
lineNumber
:
_lineNumber
,
column
:
_column
...
...
@@ -586,10 +557,6 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
}
_warmUpTokens
():
void
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModelWithTokens._warmUpTokens: Model is disposed
'
);
}
// Warm up first 100 lines (if it takes less than 50ms)
var
maxLineNumber
=
Math
.
min
(
100
,
this
.
getLineCount
());
var
toLineNumber
=
maxLineNumber
;
...
...
@@ -679,9 +646,6 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
}
_getLineModeTransitions
(
lineNumber
:
number
):
IModeTransition
[]
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModelWithTokens._getLineModeTransitions: Model is disposed
'
);
}
if
(
lineNumber
<
1
||
lineNumber
>
this
.
getLineCount
())
{
throw
new
Error
(
'
Illegal value
'
+
lineNumber
+
'
for `lineNumber`
'
);
}
...
...
@@ -829,18 +793,10 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
}
public
getWordAtPosition
(
position
:
editorCommon
.
IPosition
):
editorCommon
.
IWordAtPosition
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModelWithTokens.getWordAtPosition: Model is disposed
'
);
}
return
WordHelper
.
getWordAtPosition
(
this
,
this
.
validatePosition
(
position
));
}
public
getWordUntilPosition
(
position
:
editorCommon
.
IPosition
):
editorCommon
.
IWordAtPosition
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModelWithTokens.getWordUntilPosition: Model is disposed
'
);
}
var
wordAtPosition
=
this
.
getWordAtPosition
(
position
);
if
(
!
wordAtPosition
)
{
return
{
...
...
@@ -857,9 +813,6 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
}
public
getWords
(
lineNumber
:
number
):
editorCommon
.
IWordRange
[]
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModelWithTokens.getWords: Model is disposed
'
);
}
if
(
lineNumber
<
1
||
lineNumber
>
this
.
getLineCount
())
{
throw
new
Error
(
'
Illegal value
'
+
lineNumber
+
'
for `lineNumber`
'
);
}
...
...
@@ -868,10 +821,6 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
}
public
tokenIterator
(
position
:
editorCommon
.
IPosition
,
callback
:(
it
:
TokenIterator
)
=>
any
):
any
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModelWithTokens.tokenIterator: Model is disposed
'
);
}
var
iter
=
new
TokenIterator
(
this
,
this
.
validatePosition
(
position
));
var
result
=
callback
(
iter
);
iter
.
_invalidate
();
...
...
@@ -879,10 +828,6 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
}
public
findMatchingBracketUp
(
bracket
:
string
,
_position
:
editorCommon
.
IPosition
):
editorCommon
.
IEditorRange
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModelWithTokens.findMatchingBracketUp: Model is disposed
'
);
}
let
position
=
this
.
validatePosition
(
_position
);
let
modeTransitions
=
this
.
_lines
[
position
.
lineNumber
-
1
].
getModeTransitions
().
toArray
(
this
.
_mode
);
let
currentModeIndex
=
Arrays
.
findIndexInSegmentsArray
(
modeTransitions
,
position
.
column
-
1
);
...
...
@@ -903,10 +848,6 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
}
public
matchBracket
(
position
:
editorCommon
.
IPosition
,
inaccurateResultAcceptable
:
boolean
=
false
):
editorCommon
.
IMatchBracketResult
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModelWithTokens.matchBracket: Model is disposed
'
);
}
return
this
.
_matchBracket
(
this
.
validatePosition
(
position
));
}
...
...
@@ -1165,9 +1106,6 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
}
public
findPrevBracket
(
_position
:
editorCommon
.
IPosition
):
editorCommon
.
IFoundBracket
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModelWithTokens.findPrevBracket: Model is disposed
'
);
}
let
position
=
this
.
validatePosition
(
_position
);
let
tokensMap
=
this
.
_tokensInflatorMap
;
...
...
@@ -1205,9 +1143,6 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
}
public
findNextBracket
(
_position
:
editorCommon
.
IPosition
):
editorCommon
.
IFoundBracket
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModelWithTokens.findNextBracket: Model is disposed
'
);
}
let
position
=
this
.
validatePosition
(
_position
);
let
tokensMap
=
this
.
_tokensInflatorMap
;
...
...
src/vs/editor/common/model/textModelWithTrackedRanges.ts
浏览文件 @
df829157
...
...
@@ -132,10 +132,6 @@ export class TextModelWithTrackedRanges extends TextModelWithMarkers implements
}
public
addTrackedRange
(
textRange
:
editorCommon
.
IRange
,
stickiness
:
editorCommon
.
TrackedRangeStickiness
):
string
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModelWithTrackedRanges.addTrackedRange: Model is disposed
'
);
}
textRange
=
this
.
validateRange
(
textRange
);
var
startMarkerSticksToPreviousCharacter
=
this
.
_shouldStartMarkerSticksToPreviousCharacter
(
stickiness
);
...
...
@@ -194,10 +190,6 @@ export class TextModelWithTrackedRanges extends TextModelWithMarkers implements
}
public
changeTrackedRange
(
rangeId
:
string
,
newTextRange
:
editorCommon
.
IRange
):
void
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModelWithTrackedRanges.changeTrackedRange: Model is disposed
'
);
}
if
(
this
.
_ranges
.
hasOwnProperty
(
rangeId
))
{
newTextRange
=
this
.
validateRange
(
newTextRange
);
...
...
@@ -210,10 +202,6 @@ export class TextModelWithTrackedRanges extends TextModelWithMarkers implements
}
public
changeTrackedRangeStickiness
(
rangeId
:
string
,
newStickiness
:
editorCommon
.
TrackedRangeStickiness
):
void
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModelWithTrackedRanges.changeTrackedRangeStickiness: Model is disposed
'
);
}
if
(
this
.
_ranges
.
hasOwnProperty
(
rangeId
))
{
var
range
=
this
.
_ranges
[
rangeId
];
this
.
_changeMarkerStickiness
(
range
.
startMarkerId
,
this
.
_shouldStartMarkerSticksToPreviousCharacter
(
newStickiness
));
...
...
@@ -229,10 +217,6 @@ export class TextModelWithTrackedRanges extends TextModelWithMarkers implements
}
public
removeTrackedRange
(
rangeId
:
string
):
void
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModelWithTrackedRanges.removeTrackedRange: Model is disposed
'
);
}
if
(
this
.
_ranges
.
hasOwnProperty
(
rangeId
))
{
var
range
=
this
.
_ranges
[
rangeId
];
...
...
@@ -284,10 +268,6 @@ export class TextModelWithTrackedRanges extends TextModelWithMarkers implements
}
public
getTrackedRange
(
rangeId
:
string
):
editorCommon
.
IEditorRange
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModelWithTrackedRanges.getTrackedRange: Model is disposed
'
);
}
var
range
=
this
.
_ranges
[
rangeId
];
var
startMarker
=
this
.
_getMarker
(
range
.
startMarkerId
);
var
endMarker
=
this
.
_getMarker
(
range
.
endMarkerId
);
...
...
@@ -326,10 +306,6 @@ export class TextModelWithTrackedRanges extends TextModelWithMarkers implements
}
public
getLinesTrackedRanges
(
startLineNumber
:
number
,
endLineNumber
:
number
):
editorCommon
.
IModelTrackedRange
[]
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
TextModelWithTrackedRanges.getLinesTrackedRanges: Model is disposed
'
);
}
var
result
=
this
.
_getMultiLineTrackedRanges
(
startLineNumber
,
endLineNumber
),
resultMap
:
{
[
rangeId
:
string
]:
boolean
;
}
=
{},
lineMarkers
:
editorCommon
.
IReadOnlyLineMarker
[],
...
...
src/vs/editor/common/modes/TMState.ts
浏览文件 @
df829157
...
...
@@ -33,12 +33,21 @@ export class TMState implements IState {
constructor
(
mode
:
IMode
,
parentEmbedderState
:
IState
,
ruleStack
:
StackElement
[])
{
this
.
_mode
=
mode
;
this
.
_parentEmbedderState
=
parentEmbedderState
;
this
.
_ruleStack
=
ruleStack
;
this
.
_ruleStack
=
ruleStack
||
null
;
}
public
clone
():
TMState
{
let
parentEmbedderStateClone
=
AbstractState
.
safeClone
(
this
.
_parentEmbedderState
);
let
ruleStackClone
=
this
.
_ruleStack
?
this
.
_ruleStack
.
map
(
el
=>
el
.
clone
())
:
null
;
let
ruleStackClone
:
StackElement
[]
=
null
;
if
(
this
.
_ruleStack
)
{
ruleStackClone
=
[];
for
(
let
i
=
0
,
len
=
this
.
_ruleStack
.
length
;
i
<
len
;
i
++
)
{
let
rule
=
this
.
_ruleStack
[
i
];
ruleStackClone
.
push
(
rule
.
clone
());
}
}
return
new
TMState
(
this
.
_mode
,
parentEmbedderStateClone
,
ruleStackClone
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录