mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 19:42:56 +01:00
run import, minor edits
This commit is contained in:
parent
fede24ed75
commit
151b807fee
5 changed files with 155 additions and 52 deletions
|
|
@ -101,25 +101,19 @@ export = ts;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
function importLibs() {
|
function importLibs() {
|
||||||
function getFileName(name) {
|
|
||||||
return name
|
|
||||||
}
|
|
||||||
function getVariableName(name) {
|
|
||||||
return name.replace(/\./g, '_') + "_dts"
|
|
||||||
}
|
|
||||||
function readLibFile(name) {
|
function readLibFile(name) {
|
||||||
var srcPath = path.join(TYPESCRIPT_LIB_SOURCE, name);
|
var srcPath = path.join(TYPESCRIPT_LIB_SOURCE, name);
|
||||||
return fs.readFileSync(srcPath).toString();
|
return fs.readFileSync(srcPath).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
var dtsFiles = fs.readdirSync(TYPESCRIPT_LIB_SOURCE).filter(f => f.includes("lib."))
|
var dtsFiles = fs.readdirSync(TYPESCRIPT_LIB_SOURCE).filter(f => f.includes("lib."));
|
||||||
|
|
||||||
var result = [];
|
var result = [];
|
||||||
while (dtsFiles.length > 0) {
|
while (dtsFiles.length > 0) {
|
||||||
var name = dtsFiles.shift();
|
var name = dtsFiles.shift();
|
||||||
var output = readLibFile(name);
|
var output = readLibFile(name);
|
||||||
result.push({
|
result.push({
|
||||||
name: getVariableName(name),
|
name: name.replace(/\./g, '_') + "_dts",
|
||||||
filepath: name,
|
filepath: name,
|
||||||
deps: [],
|
deps: [],
|
||||||
output: '"' + escapeText(output) + '"'
|
output: '"' + escapeText(output) + '"'
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
import { LanguageServiceDefaultsImpl } from './monaco.contribution';
|
import { LanguageServiceDefaultsImpl } from './monaco.contribution';
|
||||||
import * as ts from './lib/typescriptServices';
|
import * as ts from './lib/typescriptServices';
|
||||||
import { TypeScriptWorker } from './tsWorker';
|
import { TypeScriptWorker } from './tsWorker';
|
||||||
import {libFileMap} from "./lib/lib"
|
import { libFileMap } from "./lib/lib"
|
||||||
|
|
||||||
import Uri = monaco.Uri;
|
import Uri = monaco.Uri;
|
||||||
import Position = monaco.Position;
|
import Position = monaco.Position;
|
||||||
|
|
@ -23,7 +23,7 @@ enum IndentStyle {
|
||||||
Smart = 2
|
Smart = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
function getOrCreateLibFile(uri: Uri) {
|
function getOrCreateLibFile(uri: Uri): monaco.editor.ITextModel | null {
|
||||||
let model = monaco.editor.getModel(uri)
|
let model = monaco.editor.getModel(uri)
|
||||||
if (!model) {
|
if (!model) {
|
||||||
if (uri.path.indexOf("/lib.") === 0) {
|
if (uri.path.indexOf("/lib.") === 0) {
|
||||||
|
|
@ -33,7 +33,6 @@ function getOrCreateLibFile(uri: Uri) {
|
||||||
return model
|
return model
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export function flattenDiagnosticMessageText(diag: string | ts.DiagnosticMessageChain | undefined, newLine: string, indent = 0): string {
|
export function flattenDiagnosticMessageText(diag: string | ts.DiagnosticMessageChain | undefined, newLine: string, indent = 0): string {
|
||||||
if (typeof diag === "string") {
|
if (typeof diag === "string") {
|
||||||
return diag;
|
return diag;
|
||||||
|
|
|
||||||
183
src/lib/lib.ts
183
src/lib/lib.ts
File diff suppressed because one or more lines are too long
|
|
@ -130,7 +130,9 @@ export class TypeScriptWorker implements ts.LanguageServiceHost, monaco.language
|
||||||
// Note: This also looks in _extraLibs, If you want
|
// Note: This also looks in _extraLibs, If you want
|
||||||
// to add support for additional target options, you will need to
|
// to add support for additional target options, you will need to
|
||||||
// add the extra dts files to _extraLibs via the API.
|
// add the extra dts files to _extraLibs via the API.
|
||||||
if (eslib in libFileMap || eslib in this._extraLibs) return eslib
|
if (eslib in libFileMap || eslib in this._extraLibs) {
|
||||||
|
return eslib;
|
||||||
|
}
|
||||||
|
|
||||||
return "lib.es6.d.ts"; // We don't use lib.es2015.full.d.ts due to breaking change.
|
return "lib.es6.d.ts"; // We don't use lib.es2015.full.d.ts due to breaking change.
|
||||||
case 1:
|
case 1:
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
import { LanguageServiceDefaultsImpl } from './monaco.contribution';
|
import { LanguageServiceDefaultsImpl } from './monaco.contribution';
|
||||||
import { TypeScriptWorker } from './tsWorker';
|
import { TypeScriptWorker } from './tsWorker';
|
||||||
import { libFileMap } from './lib/lib'
|
|
||||||
|
|
||||||
import IDisposable = monaco.IDisposable;
|
import IDisposable = monaco.IDisposable;
|
||||||
import Uri = monaco.Uri;
|
import Uri = monaco.Uri;
|
||||||
|
|
@ -65,13 +64,15 @@ export class WorkerManager {
|
||||||
|
|
||||||
// module that exports the create() method and returns a `TypeScriptWorker` instance
|
// module that exports the create() method and returns a `TypeScriptWorker` instance
|
||||||
moduleId: 'vs/language/typescript/tsWorker',
|
moduleId: 'vs/language/typescript/tsWorker',
|
||||||
|
|
||||||
label: this._modeId,
|
label: this._modeId,
|
||||||
|
|
||||||
keepIdleModels: true,
|
keepIdleModels: true,
|
||||||
|
|
||||||
// passed in to the create() method
|
// passed in to the create() method
|
||||||
createData: {
|
createData: {
|
||||||
compilerOptions: this._defaults.getCompilerOptions(),
|
compilerOptions: this._defaults.getCompilerOptions(),
|
||||||
extraLibs: this._defaults.getExtraLibs(),
|
extraLibs: this._defaults.getExtraLibs()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue