[PORT] Support empty lg file. (#2109)
This commit is contained in:
Родитель
ce71c60c5a
Коммит
f23f9f0acf
|
@ -203,7 +203,7 @@ export class TemplatesParser {
|
|||
}
|
||||
|
||||
private static antlrParseTemplates(text: string, source: string): FileContext {
|
||||
if (!text) {
|
||||
if (!text || text.trim() === '') {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
@ -230,7 +230,10 @@ class TemplatesTransformer extends AbstractParseTreeVisitor<any> implements LGTe
|
|||
}
|
||||
|
||||
public transform(parseTree: ParseTree): Templates {
|
||||
this.visit(parseTree);
|
||||
if (parseTree) {
|
||||
this.visit(parseTree);
|
||||
}
|
||||
|
||||
return this.templates;
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ describe(`LGExceptionTest`, function() {
|
|||
assert.strictEqual(diagnostics[1].message.includes(`Duplicated definitions found for template: 'basicTemplate2'`), true);
|
||||
});
|
||||
|
||||
it(`TestEmptyLGFile`, function() {
|
||||
it(`TestEmptyTemplate`, function() {
|
||||
var diagnostics = GetDiagnostics(`EmptyTemplate.lg`);
|
||||
|
||||
assert.strictEqual(1, diagnostics.length);
|
||||
|
@ -82,6 +82,14 @@ describe(`LGExceptionTest`, function() {
|
|||
assert.strictEqual(diagnostics[0].message.includes(TemplateErrors.noTemplateBody('template')), true);
|
||||
});
|
||||
|
||||
it(`TestEmptyLGFile`, function() {
|
||||
var diagnostics = GetDiagnostics(`EmptyLGFile.lg`);
|
||||
|
||||
assert.strictEqual(1, diagnostics.length);
|
||||
assert.strictEqual(DiagnosticSeverity.Warning, diagnostics[0].severity);
|
||||
assert.strictEqual(diagnostics[0].message.includes(TemplateErrors.noTemplate), true);
|
||||
});
|
||||
|
||||
it(`TestErrorStructuredTemplate`, function() {
|
||||
var diagnostics = GetDiagnostics(`ErrorStructuredTemplate.lg`);
|
||||
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
> should throw WRAN
|
Загрузка…
Ссылка в новой задаче