mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 15:05:39 +01:00
Adapt SnippetString, publish 1.2.1
This commit is contained in:
parent
8b2dab26d2
commit
3549972fdf
3 changed files with 49 additions and 40 deletions
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
|
|
@ -5,6 +5,5 @@
|
||||||
"**/node_modules": true,
|
"**/node_modules": true,
|
||||||
"**/release": true,
|
"**/release": true,
|
||||||
"**/out": true
|
"**/out": true
|
||||||
},
|
}
|
||||||
"typescript.tsdk": "./node_modules/typescript/lib"
|
|
||||||
}
|
}
|
||||||
14
package.json
14
package.json
|
|
@ -1,13 +1,13 @@
|
||||||
{
|
{
|
||||||
"name": "monaco-json",
|
"name": "monaco-json",
|
||||||
"version": "1.2.0",
|
"version": "1.2.1",
|
||||||
"description": "JSON plugin for the Monaco Editor",
|
"description": "JSON plugin for the Monaco Editor",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"compile": "gulp compile",
|
"compile": "gulp compile",
|
||||||
"watch": "gulp watch",
|
"watch": "gulp watch",
|
||||||
"prepublish": "gulp release",
|
"prepublish": "gulp release",
|
||||||
"install-service-next": "npm install vscode-json-languageservice@next -f -S",
|
"install-service-next": "npm install vscode-json-languageservice@next -f -D && npm install vscode-languageserver-types@next -f -D",
|
||||||
"install-service-local": "npm install ../vscode-json-languageservice -f -S"
|
"install-service-local": "npm install ../vscode-json-languageservice -f -D && npm install ../vscode-languageserver-node/types -f -D"
|
||||||
},
|
},
|
||||||
"author": "Microsoft Corporation",
|
"author": "Microsoft Corporation",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|
@ -25,12 +25,12 @@
|
||||||
"gulp-tsb": "^2.0.0",
|
"gulp-tsb": "^2.0.0",
|
||||||
"gulp-uglify": "^1.5.3",
|
"gulp-uglify": "^1.5.3",
|
||||||
"merge-stream": "^1.0.0",
|
"merge-stream": "^1.0.0",
|
||||||
"monaco-editor-core": "^0.8.0",
|
"monaco-editor-core": "^0.8.1",
|
||||||
"monaco-languages": "^0.7.0",
|
"monaco-languages": "^0.7.0",
|
||||||
"object-assign": "^4.1.0",
|
"object-assign": "^4.1.0",
|
||||||
"rimraf": "^2.5.2",
|
"rimraf": "^2.5.2",
|
||||||
"typescript": "2.0.3",
|
"typescript": "^2.1.5",
|
||||||
"vscode-json-languageservice": "1.1.7",
|
"vscode-json-languageservice": "^2.0.0-next.12",
|
||||||
"vscode-languageserver-types": "1.0.4"
|
"vscode-languageserver-types": "^3.0.2-beta.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -240,18 +240,30 @@ function toCompletionItem(entry: ls.CompletionItem): DataCompletionItem {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fromInsertText(text: string | monaco.languages.SnippetString) : string {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function fromCompletionItem(entry: DataCompletionItem): ls.CompletionItem {
|
function fromCompletionItem(entry: DataCompletionItem): ls.CompletionItem {
|
||||||
return {
|
let item : ls.CompletionItem = {
|
||||||
label: entry.label,
|
label: entry.label,
|
||||||
insertText: entry.insertText,
|
|
||||||
sortText: entry.sortText,
|
sortText: entry.sortText,
|
||||||
filterText: entry.filterText,
|
filterText: entry.filterText,
|
||||||
documentation: entry.documentation,
|
documentation: entry.documentation,
|
||||||
detail: entry.detail,
|
detail: entry.detail,
|
||||||
kind: fromCompletionItemKind(entry.kind),
|
kind: fromCompletionItemKind(entry.kind),
|
||||||
textEdit: fromTextEdit(entry.textEdit),
|
|
||||||
data: entry.data
|
data: entry.data
|
||||||
};
|
};
|
||||||
|
if (typeof entry.insertText === 'object' && typeof entry.insertText.value === 'string') {
|
||||||
|
item.insertText = entry.insertText.value;
|
||||||
|
item.insertTextFormat = ls.InsertTextFormat.Snippet
|
||||||
|
} else {
|
||||||
|
item.insertText = <string> entry.insertText;
|
||||||
|
}
|
||||||
|
if (entry.range) {
|
||||||
|
item.textEdit = ls.TextEdit.replace(fromRange(entry.range), item.insertText);
|
||||||
|
}
|
||||||
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -269,37 +281,35 @@ export class CompletionAdapter implements monaco.languages.CompletionItemProvide
|
||||||
const resource = model.uri;
|
const resource = model.uri;
|
||||||
|
|
||||||
return wireCancellationToken(token, this._worker(resource).then(worker => {
|
return wireCancellationToken(token, this._worker(resource).then(worker => {
|
||||||
return worker.doComplete(resource.toString(), fromPosition(position)).then(info => {
|
return worker.doComplete(resource.toString(), fromPosition(position));
|
||||||
if (!info) {
|
}).then(info => {
|
||||||
return;
|
if (!info) {
|
||||||
}
|
return;
|
||||||
let items: monaco.languages.CompletionItem[] = info.items.map(entry => {
|
}
|
||||||
return {
|
let items: monaco.languages.CompletionItem[] = info.items.map(entry => {
|
||||||
label: entry.label,
|
let item : monaco.languages.CompletionItem = {
|
||||||
insertText: entry.insertText,
|
label: entry.label,
|
||||||
sortText: entry.sortText,
|
insertText: entry.insertText,
|
||||||
filterText: entry.filterText,
|
sortText: entry.sortText,
|
||||||
documentation: entry.documentation,
|
filterText: entry.filterText,
|
||||||
detail: entry.detail,
|
documentation: entry.documentation,
|
||||||
kind: toCompletionItemKind(entry.kind),
|
detail: entry.detail,
|
||||||
textEdit: toTextEdit(entry.textEdit)
|
kind: toCompletionItemKind(entry.kind),
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
return <monaco.languages.CompletionList>{
|
|
||||||
isIncomplete: info.isIncomplete,
|
|
||||||
items: items
|
|
||||||
};
|
};
|
||||||
|
if (entry.textEdit) {
|
||||||
|
item.range = toRange(entry.textEdit.range);
|
||||||
|
item.insertText = entry.textEdit.newText;
|
||||||
|
}
|
||||||
|
if (entry.insertTextFormat === ls.InsertTextFormat.Snippet) {
|
||||||
|
item.insertText = { value: <string> item.insertText };
|
||||||
|
}
|
||||||
|
return item;
|
||||||
});
|
});
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
resolveCompletionItem(item: monaco.languages.CompletionItem, token: CancellationToken): Thenable<monaco.languages.CompletionItem> {
|
return {
|
||||||
return wireCancellationToken(token, this._worker().then(worker => {
|
isIncomplete: info.isIncomplete,
|
||||||
let lsItem = fromCompletionItem(item);
|
items: items
|
||||||
return worker.doResolve(lsItem).then(result => {
|
};
|
||||||
return toCompletionItem(result);
|
|
||||||
});
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue