private void getJavaMethods (ArrayList<JavaMethod> methods, TypeDeclaration type) { classStack.push(type); if (type.getMembers() != null) { for (BodyDeclaration member : type.getMembers()) { if (member instanceof ClassOrInterfaceDeclaration || member instanceof EnumDeclaration) { getJavaMethods(methods, (TypeDeclaration)member); } else { if (member instanceof MethodDeclaration) { MethodDeclaration method = (MethodDeclaration)member; if (!ModifierSet.hasModifier(((MethodDeclaration)member).getModifiers(), ModifierSet.NATIVE)) continue; methods.add(createMethod(method)); } } } } classStack.pop(); }
private void getJavaMethods (ArrayList<JavaMethod> methods, TypeDeclaration type) { classStack.push(type); if (type.getMembers() != null) { for (BodyDeclaration member : type.getMembers()) { if (member instanceof ClassOrInterfaceDeclaration || member instanceof EnumDeclaration) { getJavaMethods(methods, (TypeDeclaration)member); } else { if (member instanceof MethodDeclaration) { MethodDeclaration method = (MethodDeclaration)member; if (!ModifierSet.hasModifier(((MethodDeclaration)member).getModifiers(), ModifierSet.NATIVE)) continue; methods.add(createMethod(method)); } } } } classStack.pop(); }
private JavaMethod createMethod (MethodDeclaration method) { String className = classStack.peek().getName(); String name = method.getName(); boolean isStatic = ModifierSet.hasModifier(method.getModifiers(), ModifierSet.STATIC); String returnType = method.getType().toString(); ArrayList<Argument> arguments = new ArrayList<Argument>(); if (method.getParameters() != null) { for (Parameter parameter : method.getParameters()) { arguments.add(new Argument(getArgumentType(parameter), parameter.getId().getName())); } } return new JavaMethod(className, name, isStatic, returnType, null, arguments, method.getBeginLine(), method.getEndLine()); }
private JavaMethod createMethod (MethodDeclaration method) { String className = classStack.peek().getName(); String name = method.getName(); boolean isStatic = ModifierSet.hasModifier(method.getModifiers(), ModifierSet.STATIC); String returnType = method.getType().toString(); ArrayList<Argument> arguments = new ArrayList<Argument>(); if (method.getParameters() != null) { for (Parameter parameter : method.getParameters()) { arguments.add(new Argument(getArgumentType(parameter), parameter.getId().getName())); } } return new JavaMethod(className, name, isStatic, returnType, null, arguments, method.getBeginLine(), method.getEndLine()); }
if (oldMethod.get(name) == null) { MethodDeclaration newMethod = old.getType(0) .addMethod(name, declaration.getModifiers().toArray(new Modifier[]{}));
@Override public AccessSpecifier accessSpecifier() { return Helper.toAccessLevel(wrappedNode.getModifiers()); }
@Override public AccessSpecifier accessSpecifier() { return Helper.toAccessLevel(wrappedNode.getModifiers()); }
public void visit(MethodDeclaration n, Void arg) { // only display public methods if (!n.getModifiers().contains(Modifier.PUBLIC)) { return; } javadoc.append(String.format("\nh4. Operation: %s\n", n.getNameAsString())); try { Comment comment = n.getComment().get(); javadoc.append(formatJavadoc(comment.getContent())); } catch (NoSuchElementException e) { } } }
private ModifierEnum[] getModifiers(final MethodDeclaration md) { return md.getModifiers() .stream() .map(mod -> { try { return ModifierEnum.valueOf(mod.name()); } catch (final Exception e) { return null; } }) .toArray(ModifierEnum[]::new); }
private static MethodInfo getMethodInfo(String packageName, List<String> imports, MethodDeclaration md) { MethodInfo info = new MethodInfo(); for (AnnotationExpr ae : md.getAnnotations()) { AnnotationInfo annotation = getAnnotationInfo(packageName, imports, ae); info.annotations.add(annotation); } info.name = md.getName(); info.isStatic = ModifierSet.isStatic(md.getModifiers()); info.visibility = Visibility.fromModifiers(md.getModifiers()); info.signature = md.getDeclarationAsString(); return info; }
private static MethodInfo getMethodInfo(String packageName, List<String> imports, MethodDeclaration md) { MethodInfo info = new MethodInfo(); for (AnnotationExpr ae : md.getAnnotations()) { AnnotationInfo annotation = getAnnotationInfo(packageName, imports, ae); info.annotations.add(annotation); } info.name = md.getName(); info.isStatic = ModifierSet.isStatic(md.getModifiers()); info.visibility = Visibility.fromModifiers(md.getModifiers()); info.signature = md.getDeclarationAsString(); return info; }
private void getJavaMethods (ArrayList<JavaMethod> methods, TypeDeclaration type) { classStack.push(type); if (type.getMembers() != null) { for (BodyDeclaration member : type.getMembers()) { if (member instanceof ClassOrInterfaceDeclaration || member instanceof EnumDeclaration) { getJavaMethods(methods, (TypeDeclaration)member); } else { if (member instanceof MethodDeclaration) { MethodDeclaration method = (MethodDeclaration)member; if (!ModifierSet.hasModifier(((MethodDeclaration)member).getModifiers(), ModifierSet.NATIVE)) continue; methods.add(createMethod(method)); } } } } classStack.pop(); }
private void getParameterNames(MethodDeclaration methodDeclaration, boolean isInterface) { final EnumSet<Modifier> modifiers = methodDeclaration.getModifiers(); if (isInterface || modifiers.contains(Modifier.PUBLIC)) { 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<>(); 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 = name.replace("[]", ""); } parameterName.type = type; parameterName.name = name; temp.add(parameterName); } parameterNames.add(temp); } } }
if (methoDec.getModifiers() == ModifierSet.PUBLIC) {
methodDeclaration.getModifiers(), methodDeclaration.getName(), methodDeclaration.getParameters().stream().map(p -> p.getName()).collect(Collectors.toList()), methodDeclaration.getType()));
private JavaMethod createMethod (MethodDeclaration method) { String className = classStack.peek().getName(); String name = method.getName(); boolean isStatic = ModifierSet.hasModifier(method.getModifiers(), ModifierSet.STATIC); String returnType = method.getType().toString(); ArrayList<Argument> arguments = new ArrayList<Argument>(); if (method.getParameters() != null) { for (Parameter parameter : method.getParameters()) { arguments.add(new Argument(getArgumentType(parameter), parameter.getId().getName())); } } return new JavaMethod(className, name, isStatic, returnType, null, arguments, method.getBeginLine(), method.getEndLine()); }
@Override public void visit(MethodDeclaration method, ClassBuilder builder) { super.visit(method, builder); TypeFactory factory = new TypeFactory(packageName, imports); if (method.getParentNode().isPresent() && method.getParentNode().get() instanceof ClassOrInterfaceDeclaration && isClass((ClassOrInterfaceDeclaration) method.getParentNode().get()) && isGetter(method.getNameAsString(), method.getType().asString()) && !skipFieldOrGetter(method.getModifiers())) { builder.withGetter(new Method( method.getNameAsString(), factory.build(method.getType().asString(), method.getType() instanceof PrimitiveType) )); } }
field.setModifiers(modifiersInCorrectOrder); } else if (method != null) { modifiersInCorrectOrder = getModifiersInCorrectOrder(method.getModifiers()); isModifierListUnchanged = method.getModifiers().equals(modifiersInCorrectOrder); method.setModifiers(new NodeList<Modifier>()); method.setModifiers(modifiersInCorrectOrder);
@Override public MethodDeclaration doMerge(MethodDeclaration first, MethodDeclaration second) { MethodDeclaration md = new MethodDeclaration(); md.setName(first.getName()); md.setType(mergeSingle(first.getType(), second.getType())); md.setJavaDoc(mergeSingle(first.getJavaDoc(), second.getJavaDoc())); md.setModifiers(mergeModifiers(first.getModifiers(), second.getModifiers())); md.setDefault(first.isDefault() || second.isDefault()); md.setArrayCount(Math.max(first.getArrayCount(), second.getArrayCount())); md.setAnnotations(mergeCollections(first.getAnnotations(), second.getAnnotations())); md.setThrows(mergeListNoDuplicate(first.getThrows(), second.getThrows(), false)); md.setParameters(mergeCollectionsInOrder(first.getParameters(), second.getParameters())); md.setTypeParameters(mergeCollectionsInOrder(first.getTypeParameters(), second.getTypeParameters())); md.setBody(mergeSingle(first.getBody(), second.getBody())); return md; }
public static MethodDeclaration mergeMethod(MethodDeclaration one, MethodDeclaration two) { if (isAllNull(one, two)) return null; MethodDeclaration md = null; if (isAllNotNull(one, two)) { md = new MethodDeclaration(); md.setName(one.getName()); md.setType(mergeSelective(one.getType(), two.getType())); md.setParameters(mergeParameters(one.getParameters(), two.getParameters())); md.setTypeParameters(findFirstNotNull(one.getTypeParameters(), two.getTypeParameters())); md.setThrows(mergeListNoDuplicate(one.getThrows(), two.getThrows())); md.setAnnotations(mergeListNoDuplicate(one.getAnnotations(), two.getAnnotations())); md.setArrayCount(one.getArrayCount()); md.setModifiers(mergeModifiers(one.getModifiers(), two.getModifiers())); md.setBody(mergeBlock(one.getBody(), two.getBody())); md.setJavaDoc(mergeSelective(one.getJavaDoc(), two.getJavaDoc())); LOG.info("merge MethodDeclaration --> {}", md.getName()); } else { md = findFirstNotNull(one, two); LOG.info("add MethodDeclaration --> {}", md.getName()); } return md; }