Java Code Examples for com.github.javaparser.ast.body.Parameter

The following examples show how to use com.github.javaparser.ast.body.Parameter. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: kogito-runtimes   Source File: ProcessConfigGenerator.java    License: Apache License 2.0 6 votes vote down vote up
private MethodDeclaration generateMergeEventListenerConfigMethod() {
    BlockStmt body = new BlockStmt().addStatement(new ReturnStmt(newObject(CachedProcessEventListenerConfig.class,
            callMerge(
                    VAR_PROCESS_EVENT_LISTENER_CONFIGS,
                    ProcessEventListenerConfig.class, "listeners",
                    VAR_PROCESS_EVENT_LISTENERS
            )
    )));

    return method(Modifier.Keyword.PRIVATE, ProcessEventListenerConfig.class, METHOD_MERGE_PROCESS_EVENT_LISTENER_CONFIG,
            NodeList.nodeList(
                    new Parameter().setType(genericType(Collection.class, ProcessEventListenerConfig.class)).setName(VAR_PROCESS_EVENT_LISTENER_CONFIGS),
                    new Parameter().setType(genericType(Collection.class, ProcessEventListener.class)).setName(VAR_PROCESS_EVENT_LISTENERS)
            ),
            body);
}
 
Example 2
Source Project: kogito-runtimes   Source File: QueryEndpointGenerator.java    License: Apache License 2.0 6 votes vote down vote up
private BlockStmt wrapBodyAddingExceptionLogging(BlockStmt body, String nameURL) {
    TryStmt ts = new TryStmt();
    ts.setTryBlock(body);
    CatchClause cc = new CatchClause();
    String exceptionName = "e";
    cc.setParameter(new Parameter().setName(exceptionName).setType(Exception.class));
    BlockStmt cb = new BlockStmt();
    cb.addStatement(parseStatement(
            String.format(
                    "SystemMetricsCollector.registerException(\"%s\", %s.getStackTrace()[0].toString());",
                    nameURL,
                    exceptionName)
    ));
    cb.addStatement(new ThrowStmt(new NameExpr(exceptionName)));
    cc.setBody(cb);
    ts.setCatchClauses(new NodeList<>(cc));
    return new BlockStmt(new NodeList<>(ts));
}
 
Example 3
Source Project: kogito-runtimes   Source File: RuleConfigGenerator.java    License: Apache License 2.0 6 votes vote down vote up
private MethodDeclaration generateMergeEventListenerConfigMethod() {
    BlockStmt body = new BlockStmt().addStatement(new ReturnStmt(newObject(CachedRuleEventListenerConfig.class,
            callMerge(
                    VAR_RULE_EVENT_LISTENER_CONFIGS,
                    RuleEventListenerConfig.class, "agendaListeners",
                    VAR_AGENDA_EVENT_LISTENERS
            ),
            callMerge(
                    VAR_RULE_EVENT_LISTENER_CONFIGS,
                    RuleEventListenerConfig.class, "ruleRuntimeListeners",
                    VAR_RULE_RUNTIME_EVENT_LISTENERS
            )
    )));

    return method(Modifier.Keyword.PRIVATE, RuleEventListenerConfig.class, METHOD_MERGE_RULE_EVENT_LISTENER_CONFIG,
            NodeList.nodeList(
                    new Parameter().setType(genericType(Collection.class, RuleEventListenerConfig.class)).setName(VAR_RULE_EVENT_LISTENER_CONFIGS),
                    new Parameter().setType(genericType(Collection.class, AgendaEventListener.class)).setName(VAR_AGENDA_EVENT_LISTENERS),
                    new Parameter().setType(genericType(Collection.class, RuleRuntimeEventListener.class)).setName(VAR_RULE_RUNTIME_EVENT_LISTENERS)
            ),
            body);
}
 
Example 4
Source Project: kogito-runtimes   Source File: DecisionConfigGenerator.java    License: Apache License 2.0 6 votes vote down vote up
private MethodDeclaration generateMergeEventListenerConfigMethod() {
    BlockStmt body = new BlockStmt().addStatement(new ReturnStmt(newObject(CachedDecisionEventListenerConfig.class,
            callMerge(
                    VAR_DECISION_EVENT_LISTENER_CONFIG,
                    DecisionEventListenerConfig.class, "listeners",
                    VAR_DMN_RUNTIME_EVENT_LISTENERS
            )
    )));

    return method(Modifier.Keyword.PRIVATE, DecisionEventListenerConfig.class, METHOD_MERGE_DECISION_EVENT_LISTENER_CONFIG,
            nodeList(
                    new Parameter().setType(genericType(Collection.class, DecisionEventListenerConfig.class)).setName(VAR_DECISION_EVENT_LISTENER_CONFIG),
                    new Parameter().setType(genericType(Collection.class, DMNRuntimeEventListener.class)).setName(VAR_DMN_RUNTIME_EVENT_LISTENERS)
            ),
            body);
}
 
Example 5
Source Project: kogito-runtimes   Source File: TriggerMetaData.java    License: Apache License 2.0 6 votes vote down vote up
public static LambdaExpr buildLambdaExpr(Node node, ProcessMetaData metadata) {
    Map<String, Object> nodeMetaData = node.getMetaData();
    TriggerMetaData triggerMetaData = new TriggerMetaData(
            (String) nodeMetaData.get(TRIGGER_REF),
            (String) nodeMetaData.get(TRIGGER_TYPE),
            (String) nodeMetaData.get(MESSAGE_TYPE),
            (String) nodeMetaData.get(MAPPING_VARIABLE),
            String.valueOf(node.getId()))
            .validate();
    metadata.getTriggers().add(triggerMetaData);

    // and add trigger action
    BlockStmt actionBody = new BlockStmt();
    CastExpr variable = new CastExpr(
            new ClassOrInterfaceType(null, triggerMetaData.getDataType()),
            new MethodCallExpr(new NameExpr(KCONTEXT_VAR), "getVariable")
                    .addArgument(new StringLiteralExpr(triggerMetaData.getModelRef())));
    MethodCallExpr producerMethodCall = new MethodCallExpr(new NameExpr("producer_" + node.getId()), "produce").addArgument(new MethodCallExpr(new NameExpr("kcontext"), "getProcessInstance")).addArgument(variable);
    actionBody.addStatement(producerMethodCall);
    return new LambdaExpr(
            new Parameter(new UnknownType(), KCONTEXT_VAR), // (kcontext) ->
            actionBody
    );
}
 
Example 6
Source Project: kogito-runtimes   Source File: RuleSetNodeVisitor.java    License: Apache License 2.0 6 votes vote down vote up
private MethodCallExpr handleDecision(RuleSetNode.RuleType.Decision ruleType) {

        StringLiteralExpr namespace = new StringLiteralExpr(ruleType.getNamespace());
        StringLiteralExpr model = new StringLiteralExpr(ruleType.getModel());
        Expression decision = ruleType.getDecision() == null ?
                new NullLiteralExpr() : new StringLiteralExpr(ruleType.getDecision());

        MethodCallExpr decisionModels =
                new MethodCallExpr(new NameExpr("app"), "decisionModels");
        MethodCallExpr decisionModel =
                new MethodCallExpr(decisionModels, "getDecisionModel")
                        .addArgument(namespace)
                        .addArgument(model);

        BlockStmt actionBody = new BlockStmt();
        LambdaExpr lambda = new LambdaExpr(new Parameter(new UnknownType(), "()"), actionBody);
        actionBody.addStatement(new ReturnStmt(decisionModel));

        return new MethodCallExpr(METHOD_DECISION)
                .addArgument(namespace)
                .addArgument(model)
                .addArgument(decision)
                .addArgument(lambda);
    }
 
Example 7
Source Project: kogito-runtimes   Source File: RuleSetNodeVisitor.java    License: Apache License 2.0 6 votes vote down vote up
private MethodCallExpr handleRuleFlowGroup(RuleSetNode.RuleType ruleType) {
    // build supplier for rule runtime
    BlockStmt actionBody = new BlockStmt();
    LambdaExpr lambda = new LambdaExpr(new Parameter(new UnknownType(), "()"), actionBody);

    MethodCallExpr ruleRuntimeBuilder = new MethodCallExpr(
            new MethodCallExpr(new NameExpr("app"), "ruleUnits"), "ruleRuntimeBuilder");
    MethodCallExpr ruleRuntimeSupplier = new MethodCallExpr(
            ruleRuntimeBuilder, "newKieSession",
            NodeList.nodeList(new StringLiteralExpr("defaultStatelessKieSession"), new NameExpr("app.config().rule()")));
    actionBody.addStatement(new ReturnStmt(ruleRuntimeSupplier));

    return new MethodCallExpr("ruleFlowGroup")
            .addArgument(new StringLiteralExpr(ruleType.getName()))
            .addArgument(lambda);

}
 
Example 8
private void getParameterNames(MethodDeclaration methodDeclaration, boolean isInterface) {
  NodeList<Modifier> modifiers = methodDeclaration.getModifiers();
  if (isInterface || modifiers.contains(Modifier.publicModifier())) {
    String methodName = methodDeclaration.getName().getIdentifier();
    List<Parameter> parameters = methodDeclaration.getParameters();
    names.className = this.className;
    List<List<ParameterName>> parameterNames =
        names.names.computeIfAbsent(methodName, k -> new ArrayList<>(4));

    final List<ParameterName> temp = new ArrayList<>(8);
    for (final Parameter parameter : parameters) {
      ParameterName parameterName = new ParameterName();
      String type = parameter.getType().toString();
      String name = parameter.getName().getIdentifier();
      if (name.contains("[]")) {
        type = type + "[]";
        name = COMPILE.matcher(name).replaceAll(Matcher.quoteReplacement(""));
      }
      parameterName.type = type;
      parameterName.name = name;
      temp.add(parameterName);
    }
    parameterNames.add(temp);
  }
}
 
Example 9
Source Project: JRemapper   Source File: ParserTypeUtil.java    License: MIT License 6 votes vote down vote up
/**
 * @param md
 *            JavaParser method declaration.
 * @return Internal descriptor from declaration, or {@code null} if any parsing
 *         failures occured.
 */
private static String getMethodDesc(MethodDeclaration md) {
	StringBuilder sbDesc = new StringBuilder("(");
	// Append the method parameters for the descriptor
	NodeList<Parameter> params = md.getParameters();
	for (Parameter param : params) {
		Type pType = param.getType();
		String pDesc = getDescriptor(pType);
		if (pDesc == null)
			return null;
		sbDesc.append(pDesc);
	}
	// Append the return type for the descriptor
	Type typeRet = md.getType();
	String retDesc = getDescriptor(typeRet);
	if (retDesc == null)
		return null;
	sbDesc.append(")");
	sbDesc.append(retDesc);
	return sbDesc.toString();
}
 
Example 10
Source Project: groovy   Source File: GroovydocJavaVisitor.java    License: Apache License 2.0 6 votes vote down vote up
private void setConstructorOrMethodCommon(CallableDeclaration<? extends CallableDeclaration<?>> n, SimpleGroovyExecutableMemberDoc methOrCons) {
    n.getJavadocComment().ifPresent(javadocComment ->
            methOrCons.setRawCommentText(javadocComment.getContent()));
    NodeList<Modifier> mods = n.getModifiers();
    if (currentClassDoc.isInterface()) {
        mods.add(Modifier.publicModifier());
    }
    setModifiers(mods, methOrCons);
    processAnnotations(methOrCons, n);
    for (Parameter param : n.getParameters()) {
        SimpleGroovyParameter p = new SimpleGroovyParameter(param.getNameAsString());
        processAnnotations(p, param);
        p.setType(makeType(param.getType()));
        methOrCons.add(p);
    }
}
 
Example 11
Source Project: kogito-runtimes   Source File: CodegenUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static MethodDeclaration method(Modifier.Keyword modifier, Class<?> type, String name, NodeList<Parameter> parameters, BlockStmt body) {
    return new MethodDeclaration()
            .setModifiers(modifier)
            .setType(type == null ? "void" : type.getCanonicalName())
            .setName(name)
            .setParameters(parameters)
            .setBody(body);
}
 
Example 12
Source Project: kogito-runtimes   Source File: AbstractResourceGenerator.java    License: Apache License 2.0 5 votes vote down vote up
private void enableValidation(ClassOrInterfaceDeclaration template) {
    Optional.ofNullable(context)
            .map(GeneratorContext::getBuildContext)
            .filter(KogitoBuildContext::isValidationSupported)
            .ifPresent(c -> template.findAll(Parameter.class)
                    .stream()
                    .filter(param -> param.getTypeAsString().equals(dataClazzName + "Input"))
                    .forEach(this::insertValidationAnnotations));
}
 
Example 13
private String formatPattern(Parameter el) {
    Optional<AnnotationExpr> w = el.getAnnotationByName("When");
    AnnotationExpr when = w.orElseThrow(() -> new IllegalArgumentException("No When annotation"));
    return String.format(
            "  %s : %s\n",
            el.getNameAsString(),
            when.asSingleMemberAnnotationExpr().getMemberValue().asStringLiteralExpr().getValue());
}
 
Example 14
Source Project: kogito-runtimes   Source File: AbstractNodeVisitor.java    License: Apache License 2.0 5 votes vote down vote up
protected static LambdaExpr createLambdaExpr(String consequence, VariableScope scope) {
    BlockStmt conditionBody = new BlockStmt();
    List<Variable> variables = scope.getVariables();
    variables.stream()
            .map(ActionNodeVisitor::makeAssignment)
            .forEach(conditionBody::addStatement);

    conditionBody.addStatement(new ReturnStmt(new EnclosedExpr(new NameExpr(consequence))));

    return new LambdaExpr(
            new Parameter(new UnknownType(), KCONTEXT_VAR), // (kcontext) ->
            conditionBody
    );
}
 
Example 15
Source Project: kogito-runtimes   Source File: SplitNodeVisitor.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void visitNode(String factoryField, Split node, BlockStmt body, VariableScope variableScope, ProcessMetaData metadata) {
    body.addStatement(getAssignedFactoryMethod(factoryField, SplitFactory.class, getNodeId(node), getNodeKey(), new LongLiteralExpr(node.getId())))
            .addStatement(getNameMethod(node, "Split"))
            .addStatement(getFactoryMethod(getNodeId(node), METHOD_TYPE, new IntegerLiteralExpr(node.getType())));

    visitMetaData(node.getMetaData(), body, getNodeId(node));

    if (node.getType() == Split.TYPE_OR || node.getType() == Split.TYPE_XOR) {
        for (Entry<ConnectionRef, Constraint> entry : node.getConstraints().entrySet()) {
            if (entry.getValue() != null) {
                BlockStmt actionBody = new BlockStmt();
                LambdaExpr lambda = new LambdaExpr(
                        new Parameter(new UnknownType(), KCONTEXT_VAR), // (kcontext) ->
                        actionBody
                );

                for (Variable v : variableScope.getVariables()) {
                    actionBody.addStatement(makeAssignment(v));
                }
                BlockStmt constraintBody = new BlockStmt();
                constraintBody.addStatement(entry.getValue().getConstraint());

                actionBody.addStatement(constraintBody);

                body.addStatement(getFactoryMethod(getNodeId(node), METHOD_CONSTRAINT,
                        new LongLiteralExpr(entry.getKey().getNodeId()),
                        new StringLiteralExpr(getOrDefault(entry.getKey().getConnectionId(), "")),
                        new StringLiteralExpr(entry.getKey().getToType()),
                        new StringLiteralExpr(entry.getValue().getDialect()),
                        lambda,
                        new IntegerLiteralExpr(entry.getValue().getPriority())));
            }
        }
    }
    body.addStatement(getDoneMethod(getNodeId(node)));
}
 
Example 16
Source Project: joyqueue   Source File: AutoDoc.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Write the method parameters and it's doc to target api doc
 *
 * @param doc     target doc
 * @param comment parameters and method doc
 **/
private void fillParamDoc(APIDoc doc, JavadocComment comment, StringBuilder methodDesBuilder) {
    Javadoc javadoc = comment.parse();
    toString(javadoc.getDescription(), methodDesBuilder);
    doc.setDesc(methodDesBuilder.toString());
    methodDesBuilder.setLength(0);
    List<JavadocBlockTag> tags = javadoc.getBlockTags();
    if (comment.getCommentedNode().isPresent()) {
        Node node = comment.getCommentedNode().get();
        if (node instanceof MethodDeclaration) {
            MethodDeclaration method = (MethodDeclaration) node;
            for (Parameter p : method.getParameters()) {
                String type = p.getType().asString();
                String name = p.getName().asString();
                List<Param> params = doc.getParams();
                Param param = new Param();
                param.setName(name);
                param.setType(type);
                for (JavadocBlockTag t : tags) {
                    if (t.getName().isPresent()) {
                        if (name.endsWith(t.getName().get())) {
                            toString(t.getContent(), methodDesBuilder);
                            param.setComment(methodDesBuilder.toString());
                            methodDesBuilder.setLength(0);
                        }
                    }
                }
                if (params == null) {
                    params = new ArrayList<>();
                    doc.setParams(params);
                }
                params.add(param);
            }
        }
    }
}
 
Example 17
@Override
public void visit(final ConstructorDeclaration n, final Void arg) {
    printJavaComment(n.getComment(), arg);
    printMemberAnnotations(n.getAnnotations(), arg);
    printModifiers(n.getModifiers());

    printTypeParameters(n.getTypeParameters(), arg);
    if (n.isGeneric()) {
        printer.print(" ");
    }
    n.getName().accept(this, arg);

    printer.print("(");
    if (!n.getParameters().isEmpty()) {
        for (final Iterator<Parameter> i = n.getParameters().iterator(); i.hasNext(); ) {
            final Parameter p = i.next();
            p.accept(this, arg);
            if (i.hasNext()) {
                printer.print(", ");
            }
        }
    }
    printer.print(")");

    if (!isNullOrEmpty(n.getThrownExceptions())) {
        printer.print(" throws ");
        for (final Iterator<ReferenceType<?>> i = n.getThrownExceptions().iterator(); i.hasNext(); ) {
            final ReferenceType name = i.next();
            name.accept(this, arg);
            if (i.hasNext()) {
                printer.print(", ");
            }
        }
    }
    printer.print(" ");
    n.getBody().accept(this, arg);
}
 
Example 18
@Override
public void visit(final Parameter n, final Void arg) {
    printJavaComment(n.getComment(), arg);
    printAnnotations(n.getAnnotations(), false, arg);
    printModifiers(n.getModifiers());
    n.getType().accept(this, arg);
    if (n.isVarArgs()) {
        printAnnotations(n.getVarArgsAnnotations(), false, arg);
        printer.print("...");
    }
    if (!(n.getType() instanceof UnknownType)) {
        printer.print(" ");
    }
    n.getName().accept(this, arg);
}
 
Example 19
@Override
public void visit(LambdaExpr n, Void arg) {
    printJavaComment(n.getComment(), arg);

    final NodeList<Parameter> parameters = n.getParameters();
    final boolean printPar = n.isEnclosingParameters();

    if (printPar) {
        printer.print("(");
    }
    for (Iterator<Parameter> i = parameters.iterator(); i.hasNext(); ) {
        Parameter p = i.next();
        p.accept(this, arg);
        if (i.hasNext()) {
            printer.print(", ");
        }
    }
    if (printPar) {
        printer.print(")");
    }

    printer.print(" -> ");
    final Statement body = n.getBody();
    if (body instanceof ExpressionStmt) {
        // Print the expression directly
        ((ExpressionStmt) body).getExpression().accept(this, arg);
    } else {
        body.accept(this, arg);
    }
}
 
Example 20
Source Project: apigcc   Source File: SpringParser.java    License: MIT License 5 votes vote down vote up
/**
 * 解析PathVariable
 *
 * @param n
 * @param section
 */
private void visitPathVariable(MethodDeclaration n, Section section) {
    for (Parameter parameter : n.getParameters()) {
        if (ParameterHelper.isPathVariable(parameter)) {
            section.getPathVariable().put(parameter.getNameAsString(), "");
            Row row = new Row();
            row.setKey(parameter.getNameAsString());
            row.setType(parameter.getType().toString());
            section.param(row.getKey()).ifPresent(tag -> row.setRemark(tag.getContent()));
            section.addRequestRow(row);
        }
    }
}
 
Example 21
Source Project: apigcc   Source File: ParameterHelper.java    License: MIT License 5 votes vote down vote up
public static boolean hasRequestBody(NodeList<Parameter> parameters) {
    for (Parameter parameter : parameters) {
        if (isRequestBody(parameter)) {
            return true;
        }
    }
    return false;
}
 
Example 22
Source Project: apigcc   Source File: ParameterHelper.java    License: MIT License 5 votes vote down vote up
public static Parameter getRequestBody(NodeList<Parameter> parameters){
    for (Parameter parameter : parameters) {
        if (isRequestBody(parameter)) {
            return parameter;
        }
    }
    return null;
}
 
Example 23
Source Project: apigcc   Source File: ParameterHelper.java    License: MIT License 5 votes vote down vote up
public static boolean isRequestParam(Parameter parameter) {
    if (!parameter.isAnnotationPresent(ANNOTATION_PATH_VARIABLE) &&
            !parameter.isAnnotationPresent(ANNOTATION_REQUEST_BODY) &&
            !parameter.isAnnotationPresent(ANNOTATION_REQUEST_HEADER) &&
            !parameter.isAnnotationPresent(ANNOTATION_COOKIE_VALUE) &&
            !parameter.isAnnotationPresent(ANNOTATION_REQUEST_PART) &&
            !parameter.isAnnotationPresent(ANNOTATION_MULTIPART_FILE) &&
            !parameter.isAnnotationPresent(ANNOTATION_REQUEST_ATTRIBUTE)) {
        return true;
    }
    return false;
}
 
Example 24
Source Project: Refactoring-Bot   Source File: RemoveMethodParameter.java    License: MIT License 5 votes vote down vote up
/**
 * @param methodDeclaration
 * @param parameterName
 * @return index of the parameter with the given name, or null if not found
 */
private Integer getMethodParameterIndex(MethodDeclaration methodDeclaration, String parameterName) {
	NodeList<Parameter> parameters = methodDeclaration.getParameters();
	for (int i = 0; i < parameters.size(); i++) {
		if (parameters.get(i).getName().asString().equals(parameterName)) {
			return i;
		}
	}
	return null;
}
 
Example 25
Source Project: Refactoring-Bot   Source File: RemoveMethodParameter.java    License: MIT License 5 votes vote down vote up
/**
 * Removes the parameter with the given name from the given method declaration
 * 
 * @param methodDeclaration
 * @param parameterName
 */
private void removeMethodParameter(MethodDeclaration methodDeclaration, String parameterName) {
	Optional<Parameter> parameterToBeRemoved = methodDeclaration.getParameterByName(parameterName);
	if (parameterToBeRemoved.isPresent()) {
		parameterToBeRemoved.get().remove();
	}
}
 
Example 26
Source Project: Refactoring-Bot   Source File: RemoveMethodParameterTest.java    License: MIT License 5 votes vote down vote up
/**
 * Asserts that all method calls in the body of methodWithTargetMethodCalls have
 * the same argument size as the refactoredMethod has arguments
 * 
 * @param methodWithTargetMethodCalls
 * @param refactoredMethod
 */
private void assertAllMethodCallsArgumentSizeEqualToRefactoredMethodParameterCount(
		MethodDeclaration methodWithTargetMethodCalls, MethodDeclaration refactoredMethod) {
	for (MethodCallExpr methodCall : methodWithTargetMethodCalls.getBody().get().findAll(MethodCallExpr.class)) {
		if (methodCall.getNameAsString().equals(refactoredMethod.getNameAsString())) {
			NodeList<Expression> callerMethodArguments = methodCall.getArguments();
			NodeList<Parameter> refactoredMethodParameters = refactoredMethod.getParameters();

			assertThat(callerMethodArguments).hasSameSizeAs(refactoredMethodParameters);
		}
	}
}
 
Example 27
Source Project: jql   Source File: ConstructorIndexer.java    License: MIT License 5 votes vote down vote up
public void index(ConstructorDeclaration constructorDeclaration, int typeId) {
    List<Parameter> parameters = constructorDeclaration.getParameters();
    String name = constructorDeclaration.getNameAsString();
    int methodId = methodDao.save(new Method(name,
            constructorDeclaration.isPublic(), constructorDeclaration.isStatic(), constructorDeclaration.isFinal(), constructorDeclaration.isAbstract(), true, typeId));
    for (Parameter parameter : parameters) {
        parameterIndexer.index(parameter, methodId);
    }
}
 
Example 28
Source Project: jql   Source File: MethodIndexer.java    License: MIT License 5 votes vote down vote up
public void index(MethodDeclaration methodDeclaration, int typeId) {
    List<Parameter> parameters = methodDeclaration.getParameters();
    String name = methodDeclaration.getNameAsString();
    int methodId = methodDao.save(new Method(name,
            methodDeclaration.isPublic(), methodDeclaration.isStatic(), methodDeclaration.isFinal(), methodDeclaration.isAbstract(), false, typeId));
    for (Parameter parameter : parameters) {
        parameterIndexer.index(parameter, methodId);
    }
}
 
Example 29
Source Project: jaxrs-analyzer   Source File: JavaDocParserVisitor.java    License: Apache License 2.0 5 votes vote down vote up
private MemberParameterTag createMethodParameterTag(JavadocBlockTag tag, MethodDeclaration method) {
    Stream<AnnotationExpr> annotations = method.getParameterByName(tag.getName().orElse(null))
            .map(Parameter::getAnnotations)
            .map(NodeList::stream)
            .orElseGet(Stream::empty);

    return createMemberParamTag(tag.getContent(), annotations);
}
 
Example 30
Source Project: dolphin   Source File: ParameterMerger.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Parameter doMerge(Parameter first, Parameter second) {

    Parameter parameter = new Parameter();

    parameter.setType(first.getType());
    parameter.setId(first.getId());
    parameter.setVarArgs(first.isVarArgs());
    parameter.setModifiers(mergeModifiers(first.getModifiers(), second.getModifiers()));
    parameter.setAnnotations(mergeCollections(first.getAnnotations(), second.getAnnotations()));

    return parameter;
}