mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 11:35:40 +01:00
Adopt monaco-editor-core@0.5.1
This commit is contained in:
parent
a30bf9ceac
commit
876a2de2af
4 changed files with 16 additions and 14 deletions
|
|
@ -21,16 +21,14 @@ This npm module is bundled and distributed in the [monaco-editor](https://www.np
|
|||
* run `$/src/monaco-typescript> npm run watch`
|
||||
* clone https://github.com/Microsoft/monaco-editor in `$/src/monaco-editor`
|
||||
* run `$/src/monaco-editor> npm run simpleserver`
|
||||
* edit `$/src/monaco-editor/test/index.html` and set `RUN_PLUGINS_FROM_SOURCE['monaco-typescript'] = true;`
|
||||
* open http://localhost:8080/monaco-editor/test/
|
||||
* open http://localhost:8080/monaco-editor/test/?monaco-typescript=dev
|
||||
|
||||
### [Optional] Running monaco-editor-core from source
|
||||
|
||||
* this is only needed when you want to make changes also in `monaco-editor-core`.
|
||||
* clone https://github.com/Microsoft/vscode in `$/src/vscode/`
|
||||
* run `$/src/vscode> gulp watch`
|
||||
* edit `$/src/monaco-editor/test/index.html` and set `var RUN_EDITOR_FROM_SOURCE = true;`
|
||||
* open http://localhost:8080/monaco-editor/test/
|
||||
* open http://localhost:8080/monaco-editor/test/?monaco-typescript=dev&editor=dev
|
||||
|
||||
## License
|
||||
[MIT](https://github.com/Microsoft/monaco-typescript/blob/master/LICENSE.md)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "monaco-typescript",
|
||||
"version": "0.2.1",
|
||||
"version": "0.4.0",
|
||||
"description": "TypeScript and JavaScript language support for Monaco Editor",
|
||||
"scripts": {
|
||||
"test": "node_modules/.bin/mocha",
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
"gulp-uglify": "^1.5.3",
|
||||
"merge-stream": "^1.0.0",
|
||||
"mocha": "^2.5.3",
|
||||
"monaco-editor-core": "^0.4.0",
|
||||
"monaco-editor-core": "0.5.1",
|
||||
"object-assign": "^4.1.0",
|
||||
"rimraf": "^2.5.2",
|
||||
"typescript": "1.8.10",
|
||||
|
|
|
|||
|
|
@ -288,9 +288,10 @@ export class QuickInfoAdapter extends Adapter implements monaco.languages.HoverP
|
|||
if (!info) {
|
||||
return;
|
||||
}
|
||||
return <monaco.languages.Hover>{
|
||||
let contents = ts.displayPartsToString(info.displayParts);
|
||||
return {
|
||||
range: this._textSpanToRange(resource, info.textSpan),
|
||||
htmlContent: [{ text: ts.displayPartsToString(info.displayParts) }]
|
||||
contents: [contents]
|
||||
};
|
||||
}));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import {contents as libdts} from '../lib/lib-ts';
|
|||
import {contents as libes6ts} from '../lib/lib-es6-ts';
|
||||
|
||||
import Promise = monaco.Promise;
|
||||
import IWorkerContext = monaco.worker.IWorkerContext;
|
||||
|
||||
const DEFAULT_LIB = {
|
||||
NAME: 'defaultLib:lib.d.ts',
|
||||
|
|
@ -24,11 +25,13 @@ export class TypeScriptWorker implements ts.LanguageServiceHost {
|
|||
|
||||
// --- model sync -----------------------
|
||||
|
||||
private _ctx:IWorkerContext;
|
||||
private _extraLibs: { [fileName: string]: string } = Object.create(null);
|
||||
private _languageService = ts.createLanguageService(this);
|
||||
private _compilerOptions: ts.CompilerOptions;
|
||||
|
||||
constructor(createData:ICreateData) {
|
||||
constructor(ctx:IWorkerContext, createData:ICreateData) {
|
||||
this._ctx = ctx;
|
||||
this._compilerOptions = createData.compilerOptions;
|
||||
this._extraLibs = createData.extraLibs;
|
||||
}
|
||||
|
|
@ -40,12 +43,12 @@ export class TypeScriptWorker implements ts.LanguageServiceHost {
|
|||
}
|
||||
|
||||
getScriptFileNames(): string[] {
|
||||
let models = monaco.worker.getMirrorModels().map(model => model.uri.toString());
|
||||
let models = this._ctx.getMirrorModels().map(model => model.uri.toString());
|
||||
return models.concat(Object.keys(this._extraLibs));
|
||||
}
|
||||
|
||||
private _getModel(fileName:string): monaco.worker.IMirrorModel {
|
||||
let models = monaco.worker.getMirrorModels();
|
||||
let models = this._ctx.getMirrorModels();
|
||||
for (let i = 0; i < models.length; i++) {
|
||||
if (models[i].uri.toString() === fileName) {
|
||||
return models[i];
|
||||
|
|
@ -69,7 +72,7 @@ export class TypeScriptWorker implements ts.LanguageServiceHost {
|
|||
let model = this._getModel(fileName);
|
||||
if (model) {
|
||||
// a true editor model
|
||||
text = model.getText();
|
||||
text = model.getValue();
|
||||
|
||||
} else if (fileName in this._extraLibs) {
|
||||
// static extra lib
|
||||
|
|
@ -177,6 +180,6 @@ export interface ICreateData {
|
|||
extraLibs:{ [path: string]: string };
|
||||
}
|
||||
|
||||
export function create(createData:ICreateData): TypeScriptWorker {
|
||||
return new TypeScriptWorker(createData);
|
||||
export function create(ctx:IWorkerContext, createData:ICreateData): TypeScriptWorker {
|
||||
return new TypeScriptWorker(ctx, createData);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue