This commit is contained in:
yadu 2019-01-08 20:13:06 +08:00
parent 25a05667f3
commit ff9a652973
3 changed files with 21 additions and 21 deletions

View File

@ -35,19 +35,22 @@ var LanguageServiceFacade = /** @class */ (function () {
LanguageServiceFacade.workingWorker = new Worker(url); LanguageServiceFacade.workingWorker = new Worker(url);
LanguageServiceFacade.workingWorker.onmessage = function (ev) { LanguageServiceFacade.workingWorker.onmessage = function (ev) {
var processedResults = []; var processedResults = [];
var results = ev.data; var parseResults = ev.data;
if (parseReason === ParseReason.GetCompletionWords) { if (parseReason === ParseReason.GetCompletionWords) {
results.forEach(function (label) { parseResults.forEach(function (label) {
if (!!label) { if (!!label) {
processedResults.push({ processedResults.push({
label: label, label: label,
insertText: label,
kind: monaco_editor_1.languages.CompletionItemKind.Keyword kind: monaco_editor_1.languages.CompletionItemKind.Keyword
}); });
} }
}); });
var finalResult = { suggestions: processedResults };
resolve(finalResult);
} }
else if (parseReason === ParseReason.GetErrors) { else if (parseReason === ParseReason.GetErrors) {
results.forEach(function (err) { parseResults.forEach(function (err) {
var mark = { var mark = {
severity: monaco_editor_1.MarkerSeverity.Error, severity: monaco_editor_1.MarkerSeverity.Error,
message: err.Message, message: err.Message,
@ -58,9 +61,8 @@ var LanguageServiceFacade = /** @class */ (function () {
}; };
processedResults.push(mark); processedResults.push(mark);
}); });
resolve(processedResults);
} }
var completionItemList = { suggestions: processedResults };
resolve(completionItemList);
}; };
var source = { var source = {
code: str, code: str,

View File

@ -1 +1 @@
{"version":3,"file":"LanguageServiceFacade.js","sourceRoot":"","sources":["../../src/facade/LanguageServiceFacade.ts"],"names":[],"mappings":";;AAAA,qBAAuB;AACvB,+CAAgE;AAEhE,IAAY,WAGX;AAHD,WAAY,WAAW;IACnB,yEAAsB,CAAA;IACtB,uDAAa,CAAA;AACjB,CAAC,EAHW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAGtB;AAED;IAAA;IAuEA,CAAC;IAlEiB,mDAA6B,GAA3C,UAA4C,GAAY,EAAE,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ACX,IAAI,EAAG,GAAG;gBACV,MAAM,EAAG,WAAW;aACvB,CAAC;YACF,qBAAqB,CAAC,aAAa,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAC5D,CAAC,CAAC,CAAC;IACP,CAAC,CAAA;IACL,4BAAC;CAAA,AArED,IAqEC;AArEY,sDAAqB"}

View File

@ -28,7 +28,6 @@ export class LanguageServiceFacade {
private static GetParseResult = (str : string, parseReason : ParseReason) : Q.Promise<any> => { private static GetParseResult = (str : string, parseReason : ParseReason) : Q.Promise<any> => {
return Q.Promise((resolve : any) => { return Q.Promise((resolve : any) => {
if (LanguageServiceFacade.workingWorker != null) { if (LanguageServiceFacade.workingWorker != null) {
LanguageServiceFacade.workingWorker.terminate(); LanguageServiceFacade.workingWorker.terminate();
} }
@ -38,21 +37,23 @@ export class LanguageServiceFacade {
LanguageServiceFacade.workingWorker = new Worker(url); LanguageServiceFacade.workingWorker = new Worker(url);
LanguageServiceFacade.workingWorker.onmessage = (ev : MessageEvent) => { LanguageServiceFacade.workingWorker.onmessage = (ev : MessageEvent) => {
var processedResults: any = []; var processedResults: any[] = [];
var parseResults: any[] = ev.data;
var results : any[] = ev.data;
if (parseReason === ParseReason.GetCompletionWords) { if (parseReason === ParseReason.GetCompletionWords) {
results.forEach((label: string) => { parseResults.forEach((label: string) => {
if (!!label) { if (!!label) {
processedResults.push({ processedResults.push({
label: label, label: label,
insertText: label,
kind: languages.CompletionItemKind.Keyword kind: languages.CompletionItemKind.Keyword
}); });
} }
}); });
let finalResult : languages.CompletionList = {suggestions : processedResults};
resolve(finalResult);
} else if (parseReason === ParseReason.GetErrors) { } else if (parseReason === ParseReason.GetErrors) {
results.forEach((err: any) => { parseResults.forEach((err: any) => {
const mark: editor.IMarkerData = { const mark: editor.IMarkerData = {
severity: MarkerSeverity.Error, severity: MarkerSeverity.Error,
message: err.Message, message: err.Message,
@ -61,13 +62,10 @@ export class LanguageServiceFacade {
endLineNumber: err.line, endLineNumber: err.line,
endColumn: err.column endColumn: err.column
}; };
processedResults.push(mark);
processedResults.push(mark)
}); });
resolve(processedResults);
} }
let completionItemList : languages.CompletionList = {suggestions : processedResults};
resolve(completionItemList);
} }
const source = { const source = {