Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private extractLUISContent(text: string): Promise {
let parsedContent: any;
const log = false;
const locale = 'en-us';
try {
parsedContent = parseFile(text, log, locale);
} catch (e) {
// nothing to do in catch block
}
if (parsedContent !== undefined) {
return Promise.resolve(parsedContent.LUISJsonStructure);
} else {
return undefined;
}
}
}
function updateDiagnostics(document: vscode.TextDocument, collection: vscode.DiagnosticCollection): void {
if (!util.isLuFile(document.fileName)) {
collection.clear();
return;
}
let luResource = LUParser.parse(document.getText());
let diagnostics = luResource.Errors;
let vscodeDiagnostics: vscode.Diagnostic[] = [];
const severityConverter = {
ERROR: 0,
WARN: 1
}
diagnostics.forEach(u => {
const diagItem = new vscode.Diagnostic(
new vscode.Range(
new vscode.Position(u.Range.Start.Line - 1, u.Range.Start.Character),
new vscode.Position(u.Range.End.Line - 1, u.Range.End.Character)),
u.Message,
severityConverter[u.Severity]
async function changeEntityEnumLU(schemaName: string, oldPath: string, oldFileList: string[], newFileList: string[], mergedPath: string, filename: string, feedback: Feedback): Promise {
let newFilePath = newFileList.filter(file => file.match(filename))[0]
let text = await fs.readFile(newFilePath, 'utf8')
let newLUResource = LUParser.parse(text)
let newEntitySections = newLUResource.Sections.filter(s => s.SectionType === lusectiontypes.NEWENTITYSECTION)
let oldFilePath = oldFileList.filter(file => file.match(filename))[0]
text = await fs.readFile(oldFilePath, 'utf8')
let oldLUResource = LUParser.parse(text)
let oldEntitySections = oldLUResource.Sections.filter(s => s.SectionType === lusectiontypes.NEWENTITYSECTION)
let oldIntentSections = oldLUResource.Sections.filter(s => s.SectionType === lusectiontypes.SIMPLEINTENTSECTION && s.Name === schemaName)
let oldSectionOp = new sectionOperator(oldLUResource)
let updatedLUResource: any = null
let oldListEntitySections = oldEntitySections.filter(s => s.Type === 'list')
for (let oldListEntitySection of oldListEntitySections) {
if (!oldListEntitySection.Name.match('Entity')) {
continue
}
for (let newEntitySection of newEntitySections) {
if (newEntitySection.Name !== oldListEntitySection.Name) {
continue
}
async function changeEntityEnumLU(schemaName: string, oldPath: string, oldFileList: string[], newFileList: string[], mergedPath: string, filename: string, feedback: Feedback): Promise {
let newFilePath = newFileList.filter(file => file.match(filename))[0]
let text = await fs.readFile(newFilePath, 'utf8')
let newLUResource = LUParser.parse(text)
let newEntitySections = newLUResource.Sections.filter(s => s.SectionType === lusectiontypes.NEWENTITYSECTION)
let oldFilePath = oldFileList.filter(file => file.match(filename))[0]
text = await fs.readFile(oldFilePath, 'utf8')
let oldLUResource = LUParser.parse(text)
let oldEntitySections = oldLUResource.Sections.filter(s => s.SectionType === lusectiontypes.NEWENTITYSECTION)
let oldIntentSections = oldLUResource.Sections.filter(s => s.SectionType === lusectiontypes.SIMPLEINTENTSECTION && s.Name === schemaName)
let oldSectionOp = new sectionOperator(oldLUResource)
let updatedLUResource: any = null
let oldListEntitySections = oldEntitySections.filter(s => s.Type === 'list')
for (let oldListEntitySection of oldListEntitySections) {
if (!oldListEntitySection.Name.match('Entity')) {
continue
}
let oldEntitySections = oldLUResource.Sections.filter(s => s.SectionType === lusectiontypes.NEWENTITYSECTION)
let oldIntentSections = oldLUResource.Sections.filter(s => s.SectionType === lusectiontypes.SIMPLEINTENTSECTION && s.Name === schemaName)
let newEntitySections = newLUResource.Sections.filter(s => s.SectionType === lusectiontypes.NEWENTITYSECTION)
let oldIntentSections = oldLUResource.Sections.filter(s => s.SectionType === lusectiontypes.SIMPLEINTENTSECTION && s.Name === schemaName)