Search in sources :

Example 16 with Identifier

use of org.wso2.carbon.apimgt.api.model.Identifier in project ballerina by ballerina-lang.

the class SiddhiQueryBuilder method visit.

@Override
public void visit(BLangSelectExpression selectExpression) {
    BLangExpression expr = (BLangExpression) selectExpression.getExpression();
    selectExpr = new StringBuilder();
    addVarRefToClauseBuilder(expr, selectExpr);
    String identifier = selectExpression.getIdentifier();
    if (identifier != null) {
        selectExpr.append(" as ").append(identifier);
    }
}
Also used : BLangExpression(org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)

Example 17 with Identifier

use of org.wso2.carbon.apimgt.api.model.Identifier in project ballerina by ballerina-lang.

the class BLangPackageBuilder method addConstVariable.

public void addConstVariable(DiagnosticPos pos, Set<Whitespace> ws, String identifier, boolean publicVar, boolean safeAssignment) {
    BLangVariable var = (BLangVariable) this.generateBasicVarNode(pos, ws, identifier, true);
    var.flagSet.add(Flag.CONST);
    if (publicVar) {
        var.flagSet.add(Flag.PUBLIC);
    }
    var.docTag = DocTag.VARIABLE;
    var.safeAssignment = safeAssignment;
    attachAnnotations(var);
    attachDocumentations(var);
    attachDeprecatedNode(var);
    this.compUnit.addTopLevelNode(var);
}
Also used : BLangVariable(org.wso2.ballerinalang.compiler.tree.BLangVariable)

Example 18 with Identifier

use of org.wso2.carbon.apimgt.api.model.Identifier in project ballerina by ballerina-lang.

the class BLangPackageBuilder method addReturnParam.

public BLangVariable addReturnParam(DiagnosticPos pos, Set<Whitespace> ws, String identifier, boolean exprAvailable, int annotCount) {
    BLangVariable var = (BLangVariable) this.generateBasicVarNode(pos, ws, identifier, exprAvailable);
    attachAnnotations(var, annotCount);
    var.pos = pos;
    this.varStack.push(var);
    return var;
}
Also used : BLangVariable(org.wso2.ballerinalang.compiler.tree.BLangVariable)

Example 19 with Identifier

use of org.wso2.carbon.apimgt.api.model.Identifier in project ballerina by ballerina-lang.

the class BLangPackageBuilder method endTypeDefinition.

public void endTypeDefinition(DiagnosticPos pos, Set<Whitespace> ws, String identifier, boolean publicStruct) {
    // TODO only adding object type for now
    if (!this.objectStack.isEmpty()) {
        BLangObject objectNode = (BLangObject) this.objectStack.pop();
        objectNode.pos = pos;
        objectNode.setName(this.createIdentifier(identifier));
        if (publicStruct) {
            objectNode.flagSet.add(Flag.PUBLIC);
        }
        objectNode.isAnonymous = false;
        // Create an user defined type with object type
        TypeNode objectType = createUserDefinedType(pos, ws, (BLangIdentifier) TreeBuilder.createIdentifierNode(), objectNode.name);
        // Create and add receiver to attached functions
        BLangVariable receiver = (BLangVariable) TreeBuilder.createVariableNode();
        receiver.pos = pos;
        IdentifierNode name = createIdentifier(Names.SELF.getValue());
        receiver.setName(name);
        receiver.addWS(ws);
        receiver.docTag = DocTag.RECEIVER;
        receiver.setTypeNode(objectType);
        // Cache receiver to add to init function in symbolEnter
        objectNode.receiver = receiver;
        objectNode.functions.forEach(f -> f.setReceiver(receiver));
        this.compUnit.addTopLevelNode(objectNode);
    }
}
Also used : BLangObject(org.wso2.ballerinalang.compiler.tree.BLangObject) IdentifierNode(org.ballerinalang.model.tree.IdentifierNode) BLangTupleTypeNode(org.wso2.ballerinalang.compiler.tree.types.BLangTupleTypeNode) TypeNode(org.ballerinalang.model.tree.types.TypeNode) BLangUnionTypeNode(org.wso2.ballerinalang.compiler.tree.types.BLangUnionTypeNode) BLangFunctionTypeNode(org.wso2.ballerinalang.compiler.tree.types.BLangFunctionTypeNode) BLangBuiltInRefTypeNode(org.wso2.ballerinalang.compiler.tree.types.BLangBuiltInRefTypeNode) BLangVariable(org.wso2.ballerinalang.compiler.tree.BLangVariable)

Example 20 with Identifier

use of org.wso2.carbon.apimgt.api.model.Identifier in project ballerina by ballerina-lang.

the class BLangPackageBuilder method addVariableDefStatement.

public void addVariableDefStatement(DiagnosticPos pos, Set<Whitespace> ws, String identifier, boolean exprAvailable, boolean endpoint, boolean safeAssignment) {
    BLangVariable var = (BLangVariable) TreeBuilder.createVariableNode();
    BLangVariableDef varDefNode = (BLangVariableDef) TreeBuilder.createVariableDefinitionNode();
    // TODO : Remove endpoint logic from here.
    Set<Whitespace> wsOfSemiColon = null;
    if (endpoint) {
        var.addWS(endpointVarWs);
        var.addWS(endpointKeywordWs);
        endpointVarWs = null;
        endpointKeywordWs = null;
    } else {
        wsOfSemiColon = removeNthFromLast(ws, 0);
    }
    var.pos = pos;
    var.addWS(ws);
    var.setName(this.createIdentifier(identifier));
    var.setTypeNode(this.typeNodeStack.pop());
    var.safeAssignment = safeAssignment;
    if (exprAvailable) {
        var.setInitialExpression(this.exprNodeStack.pop());
    }
    varDefNode.pos = pos;
    varDefNode.setVariable(var);
    varDefNode.addWS(wsOfSemiColon);
    addStmtToCurrentBlock(varDefNode);
}
Also used : BLangVariableDef(org.wso2.ballerinalang.compiler.tree.statements.BLangVariableDef) BLangVariable(org.wso2.ballerinalang.compiler.tree.BLangVariable) Whitespace(org.ballerinalang.model.Whitespace)

Aggregations

APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)118 APIIdentifier (org.wso2.carbon.apimgt.api.model.APIIdentifier)83 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)66 API (org.wso2.carbon.apimgt.api.model.API)42 Resource (org.wso2.carbon.registry.core.Resource)40 APIProductIdentifier (org.wso2.carbon.apimgt.api.model.APIProductIdentifier)39 Test (org.junit.Test)36 PreparedStatement (java.sql.PreparedStatement)34 SQLException (java.sql.SQLException)34 SubscribedAPI (org.wso2.carbon.apimgt.api.model.SubscribedAPI)34 Connection (java.sql.Connection)33 UserStoreException (org.wso2.carbon.user.core.UserStoreException)31 ResultSet (java.sql.ResultSet)29 ArrayList (java.util.ArrayList)29 APIProvider (org.wso2.carbon.apimgt.api.APIProvider)29 UserRegistry (org.wso2.carbon.registry.core.session.UserRegistry)27 IOException (java.io.IOException)26 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)26 APIProductResource (org.wso2.carbon.apimgt.api.model.APIProductResource)25 HumanTaskException (org.wso2.carbon.humantask.core.engine.HumanTaskException)24