Skip to content

Commit

Permalink
Merge pull request #27820 from ldclakmal/dev
Browse files Browse the repository at this point in the history
Fix http filter desugar aligned with new service type changes
  • Loading branch information
rdhananjaya authored Jan 13, 2021
2 parents 5009cda + 5a25de9 commit 8f9d534
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,6 @@ private BLangSimpleVariable addFilterContextCreation(BLangFunction resourceNode,
serviceRef.type = serviceSelf.type;
serviceRef.pos = resourceNode.pos;

BLangLiteral serviceName = new BLangLiteral();
serviceName.value = getServiceName(serviceSelf.type.tsymbol.name.value);
serviceName.type = symTable.stringType;
serviceName.pos = resourceNode.pos;

BLangLiteral resourceName = new BLangLiteral();
resourceName.value = resourceNode.name.value;
resourceName.type = symTable.stringType;
Expand All @@ -215,10 +210,8 @@ private BLangSimpleVariable addFilterContextCreation(BLangFunction resourceNode,
filterInvocation.symbol = ((BObjectTypeSymbol) filterContextType.tsymbol).initializerFunc.symbol;
filterInvocation.pos = resourceNode.pos;
filterInvocation.requiredArgs.add(serviceRef);
filterInvocation.requiredArgs.add(serviceName);
filterInvocation.requiredArgs.add(resourceName);
filterInvocation.argExprs.add(serviceRef);
filterInvocation.argExprs.add(serviceName);
filterInvocation.argExprs.add(resourceName);
filterInvocation.type = symTable.nilType;

Expand All @@ -227,7 +220,6 @@ private BLangSimpleVariable addFilterContextCreation(BLangFunction resourceNode,
filterInitNode.type = filterContextType;
filterInitNode.initInvocation = filterInvocation;
filterInitNode.argsExpr.add(serviceRef);
filterInitNode.argsExpr.add(serviceName);
filterInitNode.argsExpr.add(resourceName);


Expand Down Expand Up @@ -267,11 +259,6 @@ private BLangStatementExpression desugarExprFuncBody(BLangExpression expr, BLang
return stmtExpr;
}

private String getServiceName(String serviceTypeName) {
int serviceIndex = serviceTypeName.lastIndexOf("$$service$");
return serviceTypeName.substring(0, serviceIndex);
}

/**
* Get the alias name of the http import.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ private void engageCustomResourceDesugar(BLangFunction functionNode, SymbolEnv e
.createBeginParticipantInvocation(functionNode.pos));
((BLangBlockFunctionBody) functionNode.body).stmts.add(0, stmt);
}
// httpFiltersDesugar.addHttpFilterStatementsToResource(functionNode, env);
httpFiltersDesugar.addHttpFilterStatementsToResource(functionNode, env);
// httpFiltersDesugar.addCustomAnnotationToResource(functionNode, env);
}
}

0 comments on commit 8f9d534

Please sign in to comment.