Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
4b8f9288
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,发现更多精彩内容 >>
提交
4b8f9288
编写于
10月 17, 2018
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Faster monaco.d.ts generation
上级
613aa464
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
214 addition
and
16 deletion
+214
-16
build/lib/compilation.js
build/lib/compilation.js
+0
-1
build/lib/compilation.ts
build/lib/compilation.ts
+0
-1
build/monaco/api.js
build/monaco/api.js
+102
-6
build/monaco/api.ts
build/monaco/api.ts
+111
-7
build/monaco/monaco.d.ts.recipe
build/monaco/monaco.d.ts.recipe
+1
-1
未找到文件。
build/lib/compilation.js
浏览文件 @
4b8f9288
...
...
@@ -89,7 +89,6 @@ function compileTask(src, out, build) {
.
pipe
(
generator
.
stream
)
.
pipe
(
compile
())
.
pipe
(
gulp
.
dest
(
out
));
// .pipe(src !== 'src' ? es.through() : monacodtsTask(out, false));
};
}
exports
.
compileTask
=
compileTask
;
...
...
build/lib/compilation.ts
浏览文件 @
4b8f9288
...
...
@@ -106,7 +106,6 @@ export function compileTask(src: string, out: string, build: boolean): () => Nod
.
pipe
(
generator
.
stream
)
.
pipe
(
compile
())
.
pipe
(
gulp
.
dest
(
out
));
// .pipe(src !== 'src' ? es.through() : monacodtsTask(out, false));
};
}
...
...
build/monaco/api.js
浏览文件 @
4b8f9288
...
...
@@ -162,13 +162,109 @@ function getMassagedTopLevelDeclarationText(sourceFile, declaration, importName,
result
=
result
.
replace
(
/export declare/g
,
'
export
'
);
return
result
;
}
function
format
(
text
)
{
function
format
(
text
,
endl
)
{
const
REALLY_FORMAT
=
false
;
text
=
preformat
(
text
,
endl
);
if
(
!
REALLY_FORMAT
)
{
return
text
;
}
// Parse the source text
let
sourceFile
=
ts
.
createSourceFile
(
'
file.ts
'
,
text
,
ts
.
ScriptTarget
.
Latest
,
/*setParentPointers*/
true
);
// Get the formatting edits on the input sources
let
edits
=
ts
.
formatting
.
formatDocument
(
sourceFile
,
getRuleProvider
(
tsfmt
),
tsfmt
);
// Apply the edits on the input code
return
applyEdits
(
text
,
edits
);
function
countParensCurly
(
text
)
{
let
cnt
=
0
;
for
(
let
i
=
0
;
i
<
text
.
length
;
i
++
)
{
if
(
text
.
charAt
(
i
)
===
'
(
'
||
text
.
charAt
(
i
)
===
'
{
'
)
{
cnt
++
;
}
if
(
text
.
charAt
(
i
)
===
'
)
'
||
text
.
charAt
(
i
)
===
'
}
'
)
{
cnt
--
;
}
}
return
cnt
;
}
function
repeatStr
(
s
,
cnt
)
{
let
r
=
''
;
for
(
let
i
=
0
;
i
<
cnt
;
i
++
)
{
r
+=
s
;
}
return
r
;
}
function
preformat
(
text
,
endl
)
{
let
lines
=
text
.
split
(
endl
);
let
inComment
=
false
;
let
inCommentDeltaIndent
=
0
;
let
indent
=
0
;
for
(
let
i
=
0
;
i
<
lines
.
length
;
i
++
)
{
let
line
=
lines
[
i
].
replace
(
/
\s
$/
,
''
);
let
repeat
=
false
;
let
lineIndent
=
0
;
do
{
repeat
=
false
;
if
(
line
.
substring
(
0
,
4
)
===
'
'
)
{
line
=
line
.
substring
(
4
);
lineIndent
++
;
repeat
=
true
;
}
if
(
line
.
charAt
(
0
)
===
'
\t
'
)
{
line
=
line
.
substring
(
1
);
lineIndent
++
;
repeat
=
true
;
}
}
while
(
repeat
);
if
(
line
.
length
===
0
)
{
continue
;
}
if
(
inComment
)
{
if
(
/
\*\/
/
.
test
(
line
))
{
inComment
=
false
;
}
lines
[
i
]
=
repeatStr
(
'
\t
'
,
lineIndent
+
inCommentDeltaIndent
)
+
line
;
continue
;
}
if
(
/
\/\*
/
.
test
(
line
))
{
inComment
=
true
;
inCommentDeltaIndent
=
indent
-
lineIndent
;
lines
[
i
]
=
repeatStr
(
'
\t
'
,
indent
)
+
line
;
continue
;
}
const
cnt
=
countParensCurly
(
line
);
let
shouldUnindentAfter
=
false
;
let
shouldUnindentBefore
=
false
;
if
(
cnt
<
0
)
{
if
(
/
[
({
]
/
.
test
(
line
))
{
shouldUnindentAfter
=
true
;
}
else
{
shouldUnindentBefore
=
true
;
}
}
else
if
(
cnt
===
0
)
{
shouldUnindentBefore
=
/^
\}
/
.
test
(
line
);
}
let
shouldIndentAfter
=
false
;
if
(
cnt
>
0
)
{
shouldIndentAfter
=
true
;
}
else
if
(
cnt
===
0
)
{
shouldIndentAfter
=
/{$/
.
test
(
line
);
}
if
(
shouldUnindentBefore
)
{
indent
--
;
}
lines
[
i
]
=
repeatStr
(
'
\t
'
,
indent
)
+
line
;
if
(
shouldUnindentAfter
)
{
indent
--
;
}
if
(
shouldIndentAfter
)
{
indent
++
;
}
}
return
lines
.
join
(
endl
);
}
function
getRuleProvider
(
options
)
{
// Share this between multiple formatters using the same options.
// This represents the bulk of the space the formatter uses.
...
...
@@ -293,7 +389,7 @@ function generateDeclarationFile(recipe, sourceFileGetter) {
let
resultTxt
=
result
.
join
(
endl
);
resultTxt
=
resultTxt
.
replace
(
/
\b
URI
\b
/g
,
'
Uri
'
);
resultTxt
=
resultTxt
.
replace
(
/
\b
Event</g
,
'
IEvent<
'
);
resultTxt
=
format
(
resultTxt
);
resultTxt
=
format
(
resultTxt
,
endl
);
return
[
resultTxt
,
`
${
usageImports
.
join
(
'
\n
'
)}
\n\n
${
usage
.
join
(
'
\n
'
)}
`
...
...
@@ -326,13 +422,13 @@ function getFilesToWatch(out) {
exports
.
getFilesToWatch
=
getFilesToWatch
;
function
_run
(
sourceFileGetter
)
{
log
(
'
Starting monaco.d.ts generation
'
);
let
recipe
=
fs
.
readFileSync
(
exports
.
RECIPE_PATH
).
toString
();
let
[
result
,
usageContent
]
=
generateDeclarationFile
(
recipe
,
sourceFileGetter
);
let
currentContent
=
fs
.
readFileSync
(
DECLARATION_PATH
).
toString
();
log
(
'
Finished monaco.d.ts generation
'
);
const
recipe
=
fs
.
readFileSync
(
exports
.
RECIPE_PATH
).
toString
();
const
[
result
,
usageContent
]
=
generateDeclarationFile
(
recipe
,
sourceFileGetter
);
const
currentContent
=
fs
.
readFileSync
(
DECLARATION_PATH
).
toString
();
const
one
=
currentContent
.
replace
(
/
\r\n
/gm
,
'
\n
'
);
const
other
=
result
.
replace
(
/
\r\n
/gm
,
'
\n
'
);
const
isTheSame
=
(
one
===
other
);
log
(
'
Finished monaco.d.ts generation
'
);
return
{
content
:
result
,
usageContent
:
usageContent
,
...
...
build/monaco/api.ts
浏览文件 @
4b8f9288
...
...
@@ -197,7 +197,13 @@ function getMassagedTopLevelDeclarationText(sourceFile: ts.SourceFile, declarati
return
result
;
}
function
format
(
text
:
string
):
string
{
function
format
(
text
:
string
,
endl
:
string
):
string
{
const
REALLY_FORMAT
=
false
;
text
=
preformat
(
text
,
endl
);
if
(
!
REALLY_FORMAT
)
{
return
text
;
}
// Parse the source text
let
sourceFile
=
ts
.
createSourceFile
(
'
file.ts
'
,
text
,
ts
.
ScriptTarget
.
Latest
,
/*setParentPointers*/
true
);
...
...
@@ -208,6 +214,104 @@ function format(text: string): string {
// Apply the edits on the input code
return
applyEdits
(
text
,
edits
);
function
countParensCurly
(
text
:
string
):
number
{
let
cnt
=
0
;
for
(
let
i
=
0
;
i
<
text
.
length
;
i
++
)
{
if
(
text
.
charAt
(
i
)
===
'
(
'
||
text
.
charAt
(
i
)
===
'
{
'
)
{
cnt
++
;
}
if
(
text
.
charAt
(
i
)
===
'
)
'
||
text
.
charAt
(
i
)
===
'
}
'
)
{
cnt
--
;
}
}
return
cnt
;
}
function
repeatStr
(
s
:
string
,
cnt
:
number
):
string
{
let
r
=
''
;
for
(
let
i
=
0
;
i
<
cnt
;
i
++
)
{
r
+=
s
;
}
return
r
;
}
function
preformat
(
text
:
string
,
endl
:
string
):
string
{
let
lines
=
text
.
split
(
endl
);
let
inComment
=
false
;
let
inCommentDeltaIndent
=
0
;
let
indent
=
0
;
for
(
let
i
=
0
;
i
<
lines
.
length
;
i
++
)
{
let
line
=
lines
[
i
].
replace
(
/
\s
$/
,
''
);
let
repeat
=
false
;
let
lineIndent
=
0
;
do
{
repeat
=
false
;
if
(
line
.
substring
(
0
,
4
)
===
'
'
)
{
line
=
line
.
substring
(
4
);
lineIndent
++
;
repeat
=
true
;
}
if
(
line
.
charAt
(
0
)
===
'
\t
'
)
{
line
=
line
.
substring
(
1
);
lineIndent
++
;
repeat
=
true
;
}
}
while
(
repeat
);
if
(
line
.
length
===
0
)
{
continue
;
}
if
(
inComment
)
{
if
(
/
\*\/
/
.
test
(
line
))
{
inComment
=
false
;
}
lines
[
i
]
=
repeatStr
(
'
\t
'
,
lineIndent
+
inCommentDeltaIndent
)
+
line
;
continue
;
}
if
(
/
\/\*
/
.
test
(
line
))
{
inComment
=
true
;
inCommentDeltaIndent
=
indent
-
lineIndent
;
lines
[
i
]
=
repeatStr
(
'
\t
'
,
indent
)
+
line
;
continue
;
}
const
cnt
=
countParensCurly
(
line
);
let
shouldUnindentAfter
=
false
;
let
shouldUnindentBefore
=
false
;
if
(
cnt
<
0
)
{
if
(
/
[
({
]
/
.
test
(
line
))
{
shouldUnindentAfter
=
true
;
}
else
{
shouldUnindentBefore
=
true
;
}
}
else
if
(
cnt
===
0
)
{
shouldUnindentBefore
=
/^
\}
/
.
test
(
line
);
}
let
shouldIndentAfter
=
false
;
if
(
cnt
>
0
)
{
shouldIndentAfter
=
true
;
}
else
if
(
cnt
===
0
)
{
shouldIndentAfter
=
/{$/
.
test
(
line
);
}
if
(
shouldUnindentBefore
)
{
indent
--
;
}
lines
[
i
]
=
repeatStr
(
'
\t
'
,
indent
)
+
line
;
if
(
shouldUnindentAfter
)
{
indent
--
;
}
if
(
shouldIndentAfter
)
{
indent
++
;
}
}
return
lines
.
join
(
endl
);
}
function
getRuleProvider
(
options
:
ts
.
FormatCodeSettings
)
{
// Share this between multiple formatters using the same options.
// This represents the bulk of the space the formatter uses.
...
...
@@ -353,7 +457,7 @@ function generateDeclarationFile(recipe: string, sourceFileGetter: SourceFileGet
resultTxt
=
resultTxt
.
replace
(
/
\b
URI
\b
/g
,
'
Uri
'
);
resultTxt
=
resultTxt
.
replace
(
/
\b
Event</g
,
'
IEvent<
'
);
resultTxt
=
format
(
resultTxt
);
resultTxt
=
format
(
resultTxt
,
endl
);
return
[
resultTxt
,
...
...
@@ -400,16 +504,16 @@ export interface IMonacoDeclarationResult {
function
_run
(
sourceFileGetter
:
SourceFileGetter
):
IMonacoDeclarationResult
{
log
(
'
Starting monaco.d.ts generation
'
);
let
recipe
=
fs
.
readFileSync
(
RECIPE_PATH
).
toString
();
let
[
result
,
usageContent
]
=
generateDeclarationFile
(
recipe
,
sourceFileGetter
);
let
currentContent
=
fs
.
readFileSync
(
DECLARATION_PATH
).
toString
();
log
(
'
Finished monaco.d.ts generation
'
);
const
recipe
=
fs
.
readFileSync
(
RECIPE_PATH
).
toString
();
const
[
result
,
usageContent
]
=
generateDeclarationFile
(
recipe
,
sourceFileGetter
);
const
currentContent
=
fs
.
readFileSync
(
DECLARATION_PATH
).
toString
();
const
one
=
currentContent
.
replace
(
/
\r\n
/gm
,
'
\n
'
);
const
other
=
result
.
replace
(
/
\r\n
/gm
,
'
\n
'
);
const
isTheSame
=
(
one
===
other
);
log
(
'
Finished monaco.d.ts generation
'
);
return
{
content
:
result
,
usageContent
:
usageContent
,
...
...
build/monaco/monaco.d.ts.recipe
浏览文件 @
4b8f9288
...
...
@@ -58,7 +58,7 @@ declare namespace monaco.editor {
#include(vs/editor/common/services/webWorker): MonacoWebWorker, IWebWorkerOptions
#include(vs/editor/standalone/browser/standaloneCodeEditor): IActionDescriptor, IEditorConstructionOptions, IDiffEditorConstructionOptions, IStandaloneCodeEditor, IStandaloneDiffEditor
export interface ICommandHandler {
(...args:any[]): void;
(...args:
any[]): void;
}
#include(vs/platform/contextkey/common/contextkey): IContextKey
#include(vs/editor/standalone/browser/standaloneServices): IEditorOverrideServices
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录