use of org.wso2.carbon.apimgt.api.doc.model.Operation in project ballerina by ballerina-lang.
the class IterableAnalyzer method calculatedGivenInputArgs.
private List<BType> calculatedGivenInputArgs(Operation operation) {
final BType inputParam = operation.lambdaType.getParameterTypes().get(0);
final List<BType> givenArgTypes;
if (inputParam.tag == TypeTags.TUPLE) {
final BTupleType bTupleType = (BTupleType) inputParam;
givenArgTypes = bTupleType.tupleTypes;
} else {
givenArgTypes = operation.lambdaType.getParameterTypes();
}
operation.arity = givenArgTypes.size();
return givenArgTypes;
}
use of org.wso2.carbon.apimgt.api.doc.model.Operation in project ballerina by ballerina-lang.
the class IterableCodeDesugar method desugar.
public void desugar(IterableContext ctx) {
// Gather required data for code generation.
processIterableContext(ctx);
// Generate Iterable Iteration.
generateIteratorFunction(ctx);
// Create invocation expression to invoke iterable operation.
final BLangInvocation iExpr = ASTBuilderUtil.createInvocationExpr(ctx.collectionExpr.pos, ctx.iteratorFuncSymbol, Collections.emptyList(), symResolver);
iExpr.requiredArgs.add(ctx.collectionExpr);
if (ctx.getLastOperation().expectedType == symTable.noType || ctx.getLastOperation().expectedType == symTable.voidType) {
ctx.iteratorCaller = iExpr;
} else {
ctx.iteratorCaller = ASTBuilderUtil.wrapToConversionExpr(ctx.getLastOperation().expectedType, iExpr, symTable, types);
}
}
use of org.wso2.carbon.apimgt.api.doc.model.Operation in project ballerina by ballerina-lang.
the class IterableCodeDesugar method generateSimpleIteratorBlock.
private void generateSimpleIteratorBlock(IterableContext ctx, BLangFunction funcNode) {
final Operation firstOperation = ctx.getFirstOperation();
final DiagnosticPos pos = firstOperation.pos;
// return result;
if (isReturningIteratorFunction(ctx)) {
createCounterVarDefStmt(funcNode, ctx);
createResultVarDefStmt(funcNode, ctx);
}
// Create variables required.
final List<BLangVariable> foreachVariables = createForeachVariables(ctx, ctx.getFirstOperation().argVar, funcNode);
ctx.iteratorResultVariables = foreachVariables;
final BLangForeach foreachStmt = ASTBuilderUtil.createForeach(pos, funcNode.body, ASTBuilderUtil.createVariableRef(pos, ctx.collectionVar.symbol), ASTBuilderUtil.createVariableRefList(pos, foreachVariables), ctx.foreachTypes);
if (isReturningIteratorFunction(ctx)) {
generateAggregator(foreachStmt.body, ctx);
generateFinalResult(funcNode.body, ctx);
}
final BLangReturn returnStmt = ASTBuilderUtil.createReturnStmt(firstOperation.pos, funcNode.body);
if (isReturningIteratorFunction(ctx)) {
returnStmt.addExpression(ASTBuilderUtil.createVariableRef(pos, ctx.resultVar.symbol));
}
}
use of org.wso2.carbon.apimgt.api.doc.model.Operation in project ballerina by ballerina-lang.
the class TopLevelNodeScopeResolver method isCursorBeforeNode.
/**
* Check whether the cursor is positioned before the given node start.
*
* @param nodePosition Position of the node
* @param node Node
* @param treeVisitor {@link TreeVisitor} current tree visitor instance
* @param completionContext Completion operation context
* @return {@link Boolean} Whether the cursor is before the node start or not
*/
@Override
public boolean isCursorBeforeNode(DiagnosticPos nodePosition, Node node, TreeVisitor treeVisitor, TextDocumentServiceContext completionContext) {
int line = completionContext.get(DocumentServiceKeys.POSITION_KEY).getPosition().getLine();
int col = completionContext.get(DocumentServiceKeys.POSITION_KEY).getPosition().getCharacter();
DiagnosticPos zeroBasedPos = CommonUtil.toZeroBasedPosition(nodePosition);
int nodeSLine = zeroBasedPos.sLine;
int nodeSCol = zeroBasedPos.sCol;
if (line < nodeSLine || (line == nodeSLine && col <= nodeSCol)) {
treeVisitor.setTerminateVisitor(true);
return true;
}
return false;
}
use of org.wso2.carbon.apimgt.api.doc.model.Operation in project product-iots by wso2.
the class AndroidOperation method testNotification.
@Test(groups = { Constants.AndroidOperations.OPERATIONS_GROUP }, description = "Test Android notification operation.")
public void testNotification() throws Exception {
HttpResponse response = client.post(Constants.AndroidOperations.OPERATION_ENDPOINT + Constants.AndroidOperations.NOTIFICATION_ENDPOINT, Constants.AndroidOperations.NOTIFICATION_PAYLOAD);
Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
}
Aggregations