Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
title: tabTitle,
icon: tabIcon,
customTitleClass,
component: withViewFeatures(component, pluginID),
propsProvider,
activate: true,
});
break;
}
case REGIONS.LEFT_PANEL: {
layoutManager.trigger(EVENTS.SHOW_LEFT_PANEL, id);
break;
}
// TODO: Implement show view for other regions
default: log.warn('Cannot find region to render');
}
} else {
log.error(`Cannot find a view with id ${id}`);
}
},
},
}
// We keep updating the yaml for a service instead of merging to the service AST
if (_.isEqual(this._swaggerData.serviceDefinitionAST.getID(), serviceDefinition.getID())) {
this._swaggerData.swagger = YAML.safeLoad(this._swaggerAceEditor.getValue());
}
// Pasting a content within replacing lines will trigger onChange twice, once with 'remove' action
// and another with 'insert'. Hence we are updating the services only once and not on both events.
if (!(this._pasteTriggered && e.action === 'remove')) {
this._pasteTriggered = false;
// this.updateServices();
}
}
} catch (error) {
log.warn(error);
}
});
const replaced = LambdaExpression.replaceSymbol(stmtString, this.getLambdaChildren());
const fragment = FragmentUtils.createStatementFragment(replaced + ';');
const parsedJson = FragmentUtils.parseFragment(fragment);
let state = true;
if (parsedJson.children) {
this.viewState.source = null;
if (parsedJson.children.length !== 1) {
// Only checks for the simple literals
if (parsedJson.children[1].type === 'basic_literal_expression') {
const variableType = parsedJson.children[0].children[0].variable_type;
if (variableType !== undefined) {
const defaultValueType = parsedJson.children[1].basic_literal_type;
if (variableType !== defaultValueType &&
!(variableType === 'float' && defaultValueType === 'int')) {
state = false;
log.warn('Variable type and the default value type are not the same');
if (_.isFunction(callback)) {
callback({ isValid: false, response: parsedJson });
}
}
}
}
}
if (state === true) {
if ((!_.has(parsedJson, 'error') && !_.has(parsedJson, 'syntax_errors'))) {
let nodeToFireEvent = this;
if (_.isEqual(parsedJson.type, 'assignment_statement')) {
this.initFromJson(parsedJson);
} else if (_.has(parsedJson, 'type')) {
// user may want to change the statement type
const newNode = ASTFactory.createFromJson(parsedJson);
if (ASTFactory.isStatement(newNode)) {
unRegisterCommand(cmd) {
if (!_.isEqual(_.findIndex(this.commands, ['id', cmd.id]), -1)) {
_.remove(this.commands, ['id', cmd.id]);
// remove all handlers for the command
this.commandBus.off(cmd, null, this.app);
log.debug(`Command: ${cmd
} is unregistered.`);
} else {
log.warn(`Command: ${cmd
} cannot be found in registered commands. `);
}
}
unRegisterCommand(cmdID) {
if (!_.isEqual(_.findIndex(this.commands, ['id', cmdID]), -1)) {
_.remove(this.commands, ['id', cmdID]);
// remove all handlers for the command
this.commandChannel.off(cmdID, null);
log.debug(`Command: ${cmdID} is unregistered.`);
} else {
log.warn(`Command: ${cmdID} cannot be found in registered commands.`);
}
}
it('does not return a report', function() {
subject[methodName]('test/file.txt');
expect(logger.warn).toHaveBeenCalledWith('File extension not supported by sloc: test/file.txt');
});
});
} else if (TreeUtil.isVariableDef(tempStmt)) {
const assStmt = NodeFactory.createAssignment();
assStmt.setExpression(tempStmt.getVariable().getInitialExpression());
assStmt.addVariables(this.getVariables(tempUsedStmts[0])[0]);
this._transformStmt.body.replaceStatements(tempStmt, assStmt, true);
}
this._transformStmt.body.removeStatements(tempUsedStmts[0], true);
}
}
} else if (TreeUtil.isAssignment(stmt)) {
stmt.setDeclaredWithVar(true, true);
const outputVarName = TransformUtils.getNewTempVarName(this._transformStmt, VarPrefix.VAR);
const simpleVarRefExpression = TransformerFactory.createVariableRefExpression(outputVarName);
stmt.replaceVariablesByIndex(index, simpleVarRefExpression, true);
} else {
log.warn('Cannot remove output expressions in other statement types');
}
} else if (TreeUtil.isFieldBasedAccessExpr(stmt.getVariables()[0])) {
this.removeNestedOutputExpressions(stmt, stmt.getVariables()[0], expStr);
}
});
}
const logParentUndefined = function (parent) {
if (_.isUndefined(parent)) {
const errMsg = 'Parent Undefined';
log.warn(errMsg);
throw errMsg;
}
};
} else if (TreeUtil.isVariableDef(tempStmt)) {
const assStmt = NodeFactory.createAssignment();
assStmt.setExpression(tempStmt.getVariable().getInitialExpression());
assStmt.addVariables(this.getVariables(tempUsedStmts[0])[0]);
this._transformStmt.body.replaceStatements(tempStmt, assStmt, true);
}
this._transformStmt.body.removeStatements(tempUsedStmts[0], true);
}
}
} else if (TreeUtil.isAssignment(stmt)) {
stmt.setDeclaredWithVar(true, true);
const outputVarName = TransformUtils.getNewTempVarName(this._transformStmt, VarPrefix.VAR);
const simpleVarRefExpression = TransformerFactory.createVariableRefExpression(outputVarName);
stmt.replaceVariablesByIndex(index, simpleVarRefExpression, true);
} else {
log.warn('Cannot remove output expressions in other statement types');
}
} else if (TreeUtil.isFieldBasedAccessExpr(stmt.getVariables()[0])) {
this.removeNestedOutputExpressions(stmt, stmt.getVariables()[0], expStr);
}
});
}
setAnnotations(annotations, options) {
if (!_.isNil(annotations)) {
this.setAttribute('annotations', annotations, options);
} else {
log.warn('Trying to set a null or undefined array to annotations');
}
}