Merge pull request #3 from luomoyuyi/BugFixForLanguageService

Bug Fix For Language Service
This commit is contained in:
Yanzhe Du 2019-01-08 20:32:00 +08:00 committed by GitHub
commit 819cda6f9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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.onmessage = function (ev) {
var processedResults = [];
var results = ev.data;
var parseResults = ev.data;
if (parseReason === ParseReason.GetCompletionWords) {
results.forEach(function (label) {
parseResults.forEach(function (label) {
if (!!label) {
processedResults.push({
label: label,
insertText: label,
kind: monaco_editor_1.languages.CompletionItemKind.Keyword
});
}
});
var finalResult = { suggestions: processedResults };
resolve(finalResult);
}
else if (parseReason === ParseReason.GetErrors) {
results.forEach(function (err) {
parseResults.forEach(function (err) {
var mark = {
severity: monaco_editor_1.MarkerSeverity.Error,
message: err.Message,
@ -58,9 +61,8 @@ var LanguageServiceFacade = /** @class */ (function () {
};
processedResults.push(mark);
});
resolve(processedResults);
}
var completionItemList = { suggestions: processedResults };
resolve(completionItemList);
};
var source = {
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,WAAyB;QAC/E,IAAM,YAAY,GAAG,CAAC,CAAC,OAAO,CAAM,UAAC,OAAa,EAAE,MAAY;YAC5D,IAAM,IAAI,GAAG,UAAU,CAAC;gBACpB,IAAM,KAAK,GAAS,EAAE,CAAC;gBACvB,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IACL,4BAAC;CAAA,AArED,IAqEC;AArEY,sDAAqB"}

View File

@ -28,31 +28,32 @@ export class LanguageServiceFacade {
private static GetParseResult = (str : string, parseReason : ParseReason) : Q.Promise<any> => {
return Q.Promise((resolve : any) => {
if (LanguageServiceFacade.workingWorker != null) {
LanguageServiceFacade.workingWorker.terminate();
}
const currentUrlWithoutQueryParamsAndHashRoute: string = `${window.location.protocol}//${window.location.host}${window.location.pathname}`;
let url = currentUrlWithoutQueryParamsAndHashRoute.replace(/\/[^\/]*$/, '/node_modules/@azure/cosmos-language-service/dist/worker/dist/LanguageServiceWorker.js');
LanguageServiceFacade.workingWorker = new Worker(url);
LanguageServiceFacade.workingWorker.onmessage = (ev : MessageEvent) => {
var processedResults: any = [];
var results : any[] = ev.data;
LanguageServiceFacade.workingWorker.onmessage = (ev : MessageEvent) => {
var processedResults: any[] = [];
var parseResults: any[] = ev.data;
if (parseReason === ParseReason.GetCompletionWords) {
results.forEach((label: string) => {
parseResults.forEach((label: string) => {
if (!!label) {
processedResults.push({
label: label,
insertText: label,
kind: languages.CompletionItemKind.Keyword
});
}
});
let finalResult : languages.CompletionList = {suggestions : processedResults};
resolve(finalResult);
} else if (parseReason === ParseReason.GetErrors) {
results.forEach((err: any) => {
parseResults.forEach((err: any) => {
const mark: editor.IMarkerData = {
severity: MarkerSeverity.Error,
message: err.Message,
@ -61,13 +62,10 @@ export class LanguageServiceFacade {
endLineNumber: err.line,
endColumn: err.column
};
processedResults.push(mark)
});
processedResults.push(mark);
});
resolve(processedResults);
}
let completionItemList : languages.CompletionList = {suggestions : processedResults};
resolve(completionItemList);
}
const source = {