Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
addImport(importNode, silent) {
const pkgName = this.getPackageName(importNode);
if (this.isExistingPackage(pkgName)) {
const errorString = 'Package "' + pkgName + '" is already imported.';
log.debug(errorString);
return;
}
const pkgDeclIndex = _.findLastIndex(this.getTopLevelNodes(), node => TreeUtils.isPackageDeclaration(node));
const lastImportIndex = _.findLastIndex(this.getTopLevelNodes(), node => TreeUtils.isImport(node));
let targetIndex = 0; // If there is no a pck node or any import, we'll add it to 0
if (lastImportIndex !== -1) {
targetIndex = lastImportIndex + 1;
} else if (pkgDeclIndex !== -1) {
targetIndex = pkgDeclIndex + 1;
}
let startIndex = 0;
let insertBefore = this.topLevelNodes[targetIndex];
if(insertBefore !== undefined){
const wsList = ASTUtil.extractWS(insertBefore);
if(wsList.length > 0){
endVisit() {
log.debug('end visit IfStatementPositionCalcVisitor');
}
}
beginVisit(node) {
log.debug('visit IfStatementPositionCalcVisitor');
const parentViewState = node.getParent().getViewState();
const parentBBox = parentViewState.bBox;
const viewState = node.getViewState();
const bBox = viewState.bBox;
const x = parentBBox.x;
const y = parentBBox.y + parentViewState.components['drop-zone'].h;
const statementContainerX = x;
const statementContainerY = y + DesignerDefaults.blockStatement.heading.height;
bBox.x = x;
bBox.y = y;
viewState.components.statementContainer.x = statementContainerX;
viewState.components.statementContainer.y = statementContainerY;
}
beginVisit(node) {
log.debug('visit VariableDefinitionStatementPositionCalc');
PositioningUtils.getSimpleStatementPosition(node);
}
visit() {
log.debug('visit ForkJoinStatementPositionCalcVisitor');
}
beginVisit(node) {
log.debug('visit AssignmentStatementPositionCalc');
PositioningUtils.getSimpleStatementPosition(node);
if (ASTFactory.isConnectorInitExpression(node.getChildren()[1])) {
this.calculateConnectorDeclarationPosition(node);
}
}
beginVisit(node) {
log.debug('visit ElseIfStatementPositionCalcVisitor');
Utils.getCompoundStatementChildPosition(node);
}
canVisit() {
log.debug('can visit CommittedStatementPositionCalcVisitor');
return true;
}
this.on('all', (cmdName) => {
log.debug(`Command Channel: Executing command ${cmdName}`);
});
}
visitFuncInvocationExpression(functionInvocation) {
var parent = functionInvocation.getParent();
var index = _.findIndex(parent.getChildren(), function (aExp) {
return aExp === functionInvocation;
});
if (index !== 0) {
this.appendSource(',');
}
var args = {model: functionInvocation, parent: this};
functionInvocation.accept(new TypeMapperFunctionInvocationExpressionVisitor(_.get(args, "parent")));
log.debug('Visit Type Mapper Function Invocation expression');
}