From 0592e8cd33b4a405139720b1029b0e033b4d0734 Mon Sep 17 00:00:00 2001 From: Chanaka Lakmal Date: Tue, 8 Jun 2021 18:38:33 +0530 Subject: [PATCH 1/3] Improve desugar implementation for websocket auth --- .../compiler/desugar/HttpFiltersDesugar.java | 140 ++++++++++++++---- .../compiler/desugar/ServiceDesugar.java | 26 +--- 2 files changed, 109 insertions(+), 57 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/HttpFiltersDesugar.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/HttpFiltersDesugar.java index 5df5e1f5cf7b..137c9dfd216e 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/HttpFiltersDesugar.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/HttpFiltersDesugar.java @@ -18,6 +18,7 @@ package org.wso2.ballerinalang.compiler.desugar; import io.ballerina.tools.diagnostics.Location; +import org.ballerinalang.model.tree.NodeKind; import org.wso2.ballerinalang.compiler.semantics.analyzer.SymbolResolver; import org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv; import org.wso2.ballerinalang.compiler.semantics.model.SymbolTable; @@ -29,6 +30,9 @@ import org.wso2.ballerinalang.compiler.semantics.model.types.BObjectType; import org.wso2.ballerinalang.compiler.semantics.model.types.BType; import org.wso2.ballerinalang.compiler.semantics.model.types.BUnionType; +import org.wso2.ballerinalang.compiler.tree.BLangBlockFunctionBody; +import org.wso2.ballerinalang.compiler.tree.BLangExprFunctionBody; +import org.wso2.ballerinalang.compiler.tree.BLangFunction; import org.wso2.ballerinalang.compiler.tree.BLangIdentifier; import org.wso2.ballerinalang.compiler.tree.BLangImportPackage; import org.wso2.ballerinalang.compiler.tree.BLangResourceFunction; @@ -37,6 +41,7 @@ import org.wso2.ballerinalang.compiler.tree.expressions.BLangListConstructorExpr; import org.wso2.ballerinalang.compiler.tree.expressions.BLangLiteral; import org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef; +import org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt; import org.wso2.ballerinalang.compiler.tree.statements.BLangSimpleVariableDef; import org.wso2.ballerinalang.compiler.tree.statements.BLangStatement; import org.wso2.ballerinalang.compiler.util.CompilerContext; @@ -49,13 +54,14 @@ import static org.ballerinalang.model.symbols.SymbolOrigin.VIRTUAL; /** - * This class injects the code that invokes the http filters to the first lines of an http resource. The code injected - * is as follows: + * This class injects the code that is required for declarative authentication, to the first lines of an given resource. + * The code injected will be one of the followings: *
  *     authenticateResource(self, "resourceMethod", ["resourcePath", "resourcePath"])
+ *     authenticateResource(self)
  * 
- * `authenticateResource` is expected to panic with a distinct error that http:Listener knows and the listener handle - * that error specifically. + * `authenticateResource` is expected to panic with a `distinct error` that the relevant listener knows and the listener + * handles that error specifically. * * @since 0.974.1 */ @@ -66,7 +72,8 @@ public class HttpFiltersDesugar { private final Names names; private static final String ORG_NAME = "ballerina"; - private static final String PACKAGE_NAME = "http"; + private static final String HTTP_PACKAGE_NAME = "http"; + private static final String WEBSOCKET_PACKAGE_NAME = "websocket"; private static final String AUTHENTICATE_RESOURCE = "authenticateResource"; private static final CompilerContext.Key HTTP_FILTERS_DESUGAR_KEY = @@ -88,47 +95,51 @@ private HttpFiltersDesugar(CompilerContext context) { this.names = Names.getInstance(context); } - boolean isHttpPackage(List expressionTypes) { + void desugarFunction(BLangFunction functionNode, SymbolEnv env, List expressionTypes) { + if (isValidPackage(expressionTypes, HTTP_PACKAGE_NAME)) { + addHttpAuthDesugarFunctionInvocation(functionNode, env); + } else if (isValidPackage(expressionTypes, WEBSOCKET_PACKAGE_NAME)) { + addWebSocketAuthDesugarFunctionInvocation(functionNode, env); + } + } + + boolean isValidPackage(List expressionTypes, String packageName) { for (BType expressionType : expressionTypes) { if (expressionType.tag == TypeTags.UNION) { for (BType memberType : ((BUnionType) expressionType).getMemberTypes()) { - if (memberType.tag == TypeTags.OBJECT && isHttpPackage((BObjectType) memberType)) { + if (memberType.tag == TypeTags.OBJECT && isValidPackage((BObjectType) memberType, packageName)) { return true; } } - } else if (expressionType.tag == TypeTags.OBJECT && isHttpPackage((BObjectType) expressionType)) { + } else if (expressionType.tag == TypeTags.OBJECT && + isValidPackage((BObjectType) expressionType, packageName)) { return true; } } return false; } - private boolean isHttpPackage(BObjectType type) { - return type.tsymbol.pkgID.orgName.value.equals(ORG_NAME) && type.tsymbol.pkgID.name.value.equals(PACKAGE_NAME); - } - - void addFilterStatements(BLangResourceFunction resourceNode, SymbolEnv env, List statements) { - addHttpFilterFunctionInvocation(resourceNode, env, statements); + private boolean isValidPackage(BObjectType type, String packageName) { + return type.tsymbol.pkgID.orgName.value.equals(ORG_NAME) && type.tsymbol.pkgID.name.value.equals(packageName); } - private void addHttpFilterFunctionInvocation(BLangResourceFunction resourceNode, SymbolEnv env, - List statements) { - BPackageSymbol httpPackageSymbol = getHttpPackageSymbol(env); - if (httpPackageSymbol == null) { - // Couldn't find http package in imports list. + void addHttpAuthDesugarFunctionInvocation(BLangFunction functionNode, SymbolEnv env) { + BPackageSymbol packageSymbol = getPackageSymbol(env, HTTP_PACKAGE_NAME); + if (packageSymbol == null) { + // Couldn't find http package in imports list or symbols list. return; } // Expected method type: - // `function authenticateResource(service object {} servieRef, string methodName, string[] resourcePath)` + // `function authenticateResource(service object {} serviceRef, string methodName, string[] resourcePath)` // The function is expected to panic with a distinct error when fail to authenticate. - // http listener will handle this error. - BSymbol methodSym = symResolver.lookupMethodInModule(httpPackageSymbol, - names.fromString(AUTHENTICATE_RESOURCE), env); + // HTTP listener will handle this error. + BSymbol methodSym = symResolver.lookupMethodInModule(packageSymbol, names.fromString(AUTHENTICATE_RESOURCE), + env); if (methodSym == symTable.notFoundSymbol || !(methodSym instanceof BInvokableSymbol)) { return; } - BInvokableSymbol filterInvocationSymbol = (BInvokableSymbol) methodSym; - + BInvokableSymbol invocationSymbol = (BInvokableSymbol) methodSym; + BLangResourceFunction resourceNode = (BLangResourceFunction) functionNode; Location pos = resourceNode.getPosition(); // Create method invocation. @@ -151,25 +162,90 @@ private void addHttpFilterFunctionInvocation(BLangResourceFunction resourceNode, args.add(methodNameLiteral); args.add(resourcePathLiteral); - BLangInvocation invocationExpr = ASTBuilderUtil - .createInvocationExprForMethod(pos, filterInvocationSymbol, args, symResolver); + BLangInvocation invocationExpr = + ASTBuilderUtil.createInvocationExprForMethod(pos, invocationSymbol, args, symResolver); + BLangSimpleVariableDef result = ASTBuilderUtil.createVariableDef(pos, + ASTBuilderUtil.createVariable(pos, "$temp$http$desugar$result", + symTable.anyType, invocationExpr, null)); + List statements = getFunctionBodyStatementList(functionNode); + statements.add(0, result); + + BVarSymbol resultSymbol = new BVarSymbol(0, names.fromIdNode(result.var.name), env.enclPkg.packageID, + result.var.type, resourceNode.symbol, pos, VIRTUAL); + resourceNode.symbol.scope.define(resultSymbol.name, resultSymbol); + result.var.symbol = resultSymbol; + } + + void addWebSocketAuthDesugarFunctionInvocation(BLangFunction functionNode, SymbolEnv env) { + BPackageSymbol packageSymbol = getPackageSymbol(env, "websocket"); + if (packageSymbol == null) { + // Couldn't find websocket package in imports list or symbols list. + return; + } + // Expected method type: + // `function authenticateResource(service object {} serviceRef)` + // The function is expected to panic with a distinct error when fail to authenticate. + // WebSocket listener will handle this error. + BSymbol methodSym = symResolver.lookupMethodInModule(packageSymbol, names.fromString(AUTHENTICATE_RESOURCE), + env); + if (methodSym == symTable.notFoundSymbol || !(methodSym instanceof BInvokableSymbol)) { + return; + } + BInvokableSymbol invocationSymbol = (BInvokableSymbol) methodSym; + BLangResourceFunction resourceNode = (BLangResourceFunction) functionNode; + + Location pos = resourceNode.getPosition(); + + // Create method invocation. + BLangSimpleVarRef selfRef = ASTBuilderUtil.createVariableRef( + pos, resourceNode.symbol.receiverSymbol); + + ArrayList args = new ArrayList<>(); + args.add(selfRef); + + BLangInvocation invocationExpr = + ASTBuilderUtil.createInvocationExprForMethod(pos, invocationSymbol, args, symResolver); BLangSimpleVariableDef result = ASTBuilderUtil.createVariableDef(pos, - ASTBuilderUtil.createVariable(pos, "$temp$http$filter$result", symTable.anyType, invocationExpr, null)); + ASTBuilderUtil.createVariable(pos, "$temp$websocket$desugar$result", + symTable.anyType, invocationExpr, null)); + List statements = getFunctionBodyStatementList(functionNode); statements.add(0, result); BVarSymbol resultSymbol = new BVarSymbol(0, names.fromIdNode(result.var.name), env.enclPkg.packageID, - result.var.type, - resourceNode.symbol, pos, VIRTUAL); + result.var.type, resourceNode.symbol, pos, VIRTUAL); resourceNode.symbol.scope.define(resultSymbol.name, resultSymbol); result.var.symbol = resultSymbol; } - private BPackageSymbol getHttpPackageSymbol(SymbolEnv env) { + private BPackageSymbol getPackageSymbol(SymbolEnv env, String packageName) { + // This resolves the package symbol when the code have an import relevant to the particular service for (BLangImportPackage pkg : env.enclPkg.imports) { - if (pkg.symbol.pkgID.orgName.value.equals(ORG_NAME) && pkg.symbol.pkgID.name.value.equals(PACKAGE_NAME)) { + if (pkg.symbol.pkgID.orgName.value.equals(ORG_NAME) && pkg.symbol.pkgID.name.value.equals(packageName)) { return pkg.symbol; } } + // This resolves the package symbol when the code is at a submodule of the module which have the service + // definition. In that case there is no any import relevant to the particular service. + while (env.enclEnv != null) { + if (env.enclEnv.scope.owner.pkgID.orgName.value.equals(ORG_NAME) && + env.enclEnv.scope.owner.pkgID.name.value.equals(packageName)) { + return env.enclEnv.enclPkg.symbol; + } + env = env.enclEnv; + } return null; } + + private List getFunctionBodyStatementList(BLangFunction functionNode) { + List statements; + if (functionNode.body.getKind() == NodeKind.EXPR_FUNCTION_BODY) { + BLangExprFunctionBody exprFunctionBody = (BLangExprFunctionBody) functionNode.body; + BLangBlockStmt blockStmt = ASTBuilderUtil.createBlockStmt(functionNode.getPosition()); + statements = blockStmt.stmts; + exprFunctionBody.expr = ASTBuilderUtil.createStatementExpression(blockStmt, exprFunctionBody.expr); + } else { + statements = ((BLangBlockFunctionBody) functionNode.body).stmts; + } + return statements; + } } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ServiceDesugar.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ServiceDesugar.java index 628818344efa..71fcb2e1a5de 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ServiceDesugar.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ServiceDesugar.java @@ -33,9 +33,7 @@ import org.wso2.ballerinalang.compiler.semantics.model.types.BType; import org.wso2.ballerinalang.compiler.semantics.model.types.BUnionType; import org.wso2.ballerinalang.compiler.tree.BLangBlockFunctionBody; -import org.wso2.ballerinalang.compiler.tree.BLangExprFunctionBody; import org.wso2.ballerinalang.compiler.tree.BLangFunction; -import org.wso2.ballerinalang.compiler.tree.BLangResourceFunction; import org.wso2.ballerinalang.compiler.tree.BLangService; import org.wso2.ballerinalang.compiler.tree.BLangSimpleVariable; import org.wso2.ballerinalang.compiler.tree.BLangVariable; @@ -45,11 +43,9 @@ import org.wso2.ballerinalang.compiler.tree.expressions.BLangListConstructorExpr; import org.wso2.ballerinalang.compiler.tree.expressions.BLangLiteral; import org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef; -import org.wso2.ballerinalang.compiler.tree.expressions.BLangStatementExpression; import org.wso2.ballerinalang.compiler.tree.expressions.BLangTypeConversionExpr; import org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt; import org.wso2.ballerinalang.compiler.tree.statements.BLangExpressionStmt; -import org.wso2.ballerinalang.compiler.tree.statements.BLangStatement; import org.wso2.ballerinalang.compiler.util.CompilerContext; import org.wso2.ballerinalang.compiler.util.Name; import org.wso2.ballerinalang.compiler.util.Names; @@ -303,26 +299,6 @@ private void engageCustomResourceDesugar(BLangFunction functionNode, SymbolEnv e .createBeginParticipantInvocation(functionNode.pos)); ((BLangBlockFunctionBody) functionNode.body).stmts.add(0, stmt); } - if (httpFiltersDesugar.isHttpPackage(expressionTypes)) { - List statements = getFunctionBodyStatementList(functionNode); - httpFiltersDesugar.addFilterStatements((BLangResourceFunction) functionNode, env, statements); - } - } - - private List getFunctionBodyStatementList(BLangFunction functionNode) { - List statements = null; - if (functionNode.body.getKind() == NodeKind.EXPR_FUNCTION_BODY) { - BLangExprFunctionBody exprFunctionBody = (BLangExprFunctionBody) functionNode.body; - BLangBlockStmt blockStmt = ASTBuilderUtil.createBlockStmt(functionNode.getPosition()); - statements = blockStmt.stmts; - - BLangStatementExpression statementExpression = ASTBuilderUtil.createStatementExpression( - blockStmt, - exprFunctionBody.expr); - exprFunctionBody.expr = statementExpression; - } else { - statements = ((BLangBlockFunctionBody) functionNode.body).stmts; - } - return statements; + httpFiltersDesugar.desugarFunction(functionNode, env, expressionTypes); } } From 3fa1caa01bbc1215c45f9044b99ab6d73a4efee6 Mon Sep 17 00:00:00 2001 From: Chanaka Lakmal Date: Wed, 9 Jun 2021 14:56:26 +0530 Subject: [PATCH 2/3] Refactor code with review suggestions --- .../compiler/desugar/HttpFiltersDesugar.java | 100 ++++++------------ 1 file changed, 32 insertions(+), 68 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/HttpFiltersDesugar.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/HttpFiltersDesugar.java index 137c9dfd216e..68c8279e554b 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/HttpFiltersDesugar.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/HttpFiltersDesugar.java @@ -96,43 +96,46 @@ private HttpFiltersDesugar(CompilerContext context) { } void desugarFunction(BLangFunction functionNode, SymbolEnv env, List expressionTypes) { - if (isValidPackage(expressionTypes, HTTP_PACKAGE_NAME)) { - addHttpAuthDesugarFunctionInvocation(functionNode, env); - } else if (isValidPackage(expressionTypes, WEBSOCKET_PACKAGE_NAME)) { - addWebSocketAuthDesugarFunctionInvocation(functionNode, env); + if (isDefinedInStdLibPackage(expressionTypes, HTTP_PACKAGE_NAME)) { + addAuthDesugarFunctionInvocation(functionNode, env, HTTP_PACKAGE_NAME); + } else if (isDefinedInStdLibPackage(expressionTypes, WEBSOCKET_PACKAGE_NAME)) { + addAuthDesugarFunctionInvocation(functionNode, env, WEBSOCKET_PACKAGE_NAME); } } - boolean isValidPackage(List expressionTypes, String packageName) { + boolean isDefinedInStdLibPackage(List expressionTypes, String packageName) { for (BType expressionType : expressionTypes) { if (expressionType.tag == TypeTags.UNION) { for (BType memberType : ((BUnionType) expressionType).getMemberTypes()) { - if (memberType.tag == TypeTags.OBJECT && isValidPackage((BObjectType) memberType, packageName)) { + if (memberType.tag == TypeTags.OBJECT && isDefinedInStdLibPackage((BObjectType) memberType, packageName)) { return true; } } } else if (expressionType.tag == TypeTags.OBJECT && - isValidPackage((BObjectType) expressionType, packageName)) { + isDefinedInStdLibPackage((BObjectType) expressionType, packageName)) { return true; } } return false; } - private boolean isValidPackage(BObjectType type, String packageName) { + private boolean isDefinedInStdLibPackage(BObjectType type, String packageName) { return type.tsymbol.pkgID.orgName.value.equals(ORG_NAME) && type.tsymbol.pkgID.name.value.equals(packageName); } - void addHttpAuthDesugarFunctionInvocation(BLangFunction functionNode, SymbolEnv env) { - BPackageSymbol packageSymbol = getPackageSymbol(env, HTTP_PACKAGE_NAME); + void addAuthDesugarFunctionInvocation(BLangFunction functionNode, SymbolEnv env, String packageName) { + BPackageSymbol packageSymbol = getPackageSymbol(env, packageName); if (packageSymbol == null) { // Couldn't find http package in imports list or symbols list. return; } - // Expected method type: + + // Expected method type for HTTP: // `function authenticateResource(service object {} serviceRef, string methodName, string[] resourcePath)` + // Expected method type for WebSocket: + // `function authenticateResource(service object {} serviceRef)` // The function is expected to panic with a distinct error when fail to authenticate. - // HTTP listener will handle this error. + // Relevant listener will handle this error. BSymbol methodSym = symResolver.lookupMethodInModule(packageSymbol, names.fromString(AUTHENTICATE_RESOURCE), env); if (methodSym == symTable.notFoundSymbol || !(methodSym instanceof BInvokableSymbol)) { @@ -143,71 +146,32 @@ void addHttpAuthDesugarFunctionInvocation(BLangFunction functionNode, SymbolEnv Location pos = resourceNode.getPosition(); // Create method invocation. - BLangSimpleVarRef selfRef = ASTBuilderUtil.createVariableRef( - pos, resourceNode.symbol.receiverSymbol); - - BLangLiteral methodNameLiteral = ASTBuilderUtil.createLiteral( - pos, symTable.stringType, resourceNode.methodName.value); - - ArrayList pathLiterals = new ArrayList<>(); - for (BLangIdentifier path : resourceNode.resourcePath) { - pathLiterals.add(ASTBuilderUtil.createLiteral(pos, symTable.stringType, path.value)); - } - BLangListConstructorExpr.BLangArrayLiteral resourcePathLiteral = ASTBuilderUtil.createEmptyArrayLiteral( - pos, (BArrayType) symTable.stringArrayType); - resourcePathLiteral.exprs = pathLiterals; + BLangSimpleVarRef selfRef = ASTBuilderUtil.createVariableRef(pos, resourceNode.symbol.receiverSymbol); ArrayList args = new ArrayList<>(); args.add(selfRef); - args.add(methodNameLiteral); - args.add(resourcePathLiteral); - BLangInvocation invocationExpr = - ASTBuilderUtil.createInvocationExprForMethod(pos, invocationSymbol, args, symResolver); - BLangSimpleVariableDef result = ASTBuilderUtil.createVariableDef(pos, - ASTBuilderUtil.createVariable(pos, "$temp$http$desugar$result", - symTable.anyType, invocationExpr, null)); - List statements = getFunctionBodyStatementList(functionNode); - statements.add(0, result); + if (packageName.equals(HTTP_PACKAGE_NAME)) { + BLangLiteral methodNameLiteral = ASTBuilderUtil.createLiteral( + pos, symTable.stringType, resourceNode.methodName.value); - BVarSymbol resultSymbol = new BVarSymbol(0, names.fromIdNode(result.var.name), env.enclPkg.packageID, - result.var.type, resourceNode.symbol, pos, VIRTUAL); - resourceNode.symbol.scope.define(resultSymbol.name, resultSymbol); - result.var.symbol = resultSymbol; - } + ArrayList pathLiterals = new ArrayList<>(); + for (BLangIdentifier path : resourceNode.resourcePath) { + pathLiterals.add(ASTBuilderUtil.createLiteral(pos, symTable.stringType, path.value)); + } + BLangListConstructorExpr.BLangArrayLiteral resourcePathLiteral = ASTBuilderUtil.createEmptyArrayLiteral( + pos, (BArrayType) symTable.stringArrayType); + resourcePathLiteral.exprs = pathLiterals; - void addWebSocketAuthDesugarFunctionInvocation(BLangFunction functionNode, SymbolEnv env) { - BPackageSymbol packageSymbol = getPackageSymbol(env, "websocket"); - if (packageSymbol == null) { - // Couldn't find websocket package in imports list or symbols list. - return; + args.add(methodNameLiteral); + args.add(resourcePathLiteral); } - // Expected method type: - // `function authenticateResource(service object {} serviceRef)` - // The function is expected to panic with a distinct error when fail to authenticate. - // WebSocket listener will handle this error. - BSymbol methodSym = symResolver.lookupMethodInModule(packageSymbol, names.fromString(AUTHENTICATE_RESOURCE), - env); - if (methodSym == symTable.notFoundSymbol || !(methodSym instanceof BInvokableSymbol)) { - return; - } - BInvokableSymbol invocationSymbol = (BInvokableSymbol) methodSym; - BLangResourceFunction resourceNode = (BLangResourceFunction) functionNode; - - Location pos = resourceNode.getPosition(); - - // Create method invocation. - BLangSimpleVarRef selfRef = ASTBuilderUtil.createVariableRef( - pos, resourceNode.symbol.receiverSymbol); - - ArrayList args = new ArrayList<>(); - args.add(selfRef); BLangInvocation invocationExpr = ASTBuilderUtil.createInvocationExprForMethod(pos, invocationSymbol, args, symResolver); BLangSimpleVariableDef result = ASTBuilderUtil.createVariableDef(pos, - ASTBuilderUtil.createVariable(pos, "$temp$websocket$desugar$result", - symTable.anyType, invocationExpr, null)); + ASTBuilderUtil.createVariable(pos, "$temp$auth$desugar$result", + symTable.anyType, invocationExpr, null)); List statements = getFunctionBodyStatementList(functionNode); statements.add(0, result); @@ -224,8 +188,8 @@ private BPackageSymbol getPackageSymbol(SymbolEnv env, String packageName) { return pkg.symbol; } } - // This resolves the package symbol when the code is at a submodule of the module which have the service - // definition. In that case there is no any import relevant to the particular service. + // This resolves the package symbol when the code is at a submodule of the module which have the listener + // definition. In that case, there is no any import relevant to the particular service. while (env.enclEnv != null) { if (env.enclEnv.scope.owner.pkgID.orgName.value.equals(ORG_NAME) && env.enclEnv.scope.owner.pkgID.name.value.equals(packageName)) { From 3fc4a76885b2f5c0b45b25c3d46a8fe7c470531f Mon Sep 17 00:00:00 2001 From: Chanaka Lakmal Date: Wed, 9 Jun 2021 15:21:45 +0530 Subject: [PATCH 3/3] Fix a checkstyle issue --- .../ballerinalang/compiler/desugar/HttpFiltersDesugar.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/HttpFiltersDesugar.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/HttpFiltersDesugar.java index 68c8279e554b..5aea3451d385 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/HttpFiltersDesugar.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/HttpFiltersDesugar.java @@ -107,7 +107,8 @@ boolean isDefinedInStdLibPackage(List expressionTypes, String packageName for (BType expressionType : expressionTypes) { if (expressionType.tag == TypeTags.UNION) { for (BType memberType : ((BUnionType) expressionType).getMemberTypes()) { - if (memberType.tag == TypeTags.OBJECT && isDefinedInStdLibPackage((BObjectType) memberType, packageName)) { + if (memberType.tag == TypeTags.OBJECT && + isDefinedInStdLibPackage((BObjectType) memberType, packageName)) { return true; } }