public static Optional<TypeDeclaration<?>> findType(CompilationUnit cu, String qualifiedName) { if (cu.getTypes().isEmpty()) { return Optional.empty(); } final String typeName = getOuterTypeName(qualifiedName); Optional<TypeDeclaration<?>> type = cu.getTypes().stream().filter((t) -> t.getName().getId().equals(typeName)).findFirst(); final String innerTypeName = getInnerTypeName(qualifiedName); if (type.isPresent() && !innerTypeName.isEmpty()) { return findType(type.get(), innerTypeName); } return type; }
public static Optional<TypeDeclaration<?>> findType(CompilationUnit cu, String qualifiedName) { if (cu.getTypes().isEmpty()) { return Optional.empty(); } final String typeName = getOuterTypeName(qualifiedName); Optional<TypeDeclaration<?>> type = cu.getTypes().stream().filter((t) -> t.getName().getId().equals(typeName)).findFirst(); final String innerTypeName = getInnerTypeName(qualifiedName); if (type.isPresent() && !innerTypeName.isEmpty()) { return findType(type.get(), innerTypeName); } return type; }
/** * Looks among the type declared in the Compilation Unit for one having the specified name. * The name can be qualified with respect to the compilation unit. For example, if the compilation * unit is in package a.b; and it contains two top level classes named C and D, with class E being defined inside D * then the qualifiedName that can be resolved are "C", "D", and "D.E". */ public static Optional<TypeDeclaration<?>> findType(CompilationUnit cu, String qualifiedName) { if (cu.getTypes().isEmpty()) { return Optional.empty(); } final String typeName = getOuterTypeName(qualifiedName); Optional<TypeDeclaration<?>> type = cu.getTypes().stream().filter((t) -> t.getName().getId().equals(typeName)).findFirst(); final String innerTypeName = getInnerTypeName(qualifiedName); if (type.isPresent() && !innerTypeName.isEmpty()) { return findType(type.get(), innerTypeName); } return type; }
private static void writeClassDeclaration(PrintStream s, ClassOrInterfaceDeclaration c) { s.format("\npublic%s class %s", c.isFinal() ? " final" : "", c.getName()); if (c.getImplementedTypes() != null && !c.getImplementedTypes().isEmpty()) { s.format(" implements"); for (ClassOrInterfaceType iface : c.getImplementedTypes()) { s.append(" " + iface); } } s.append(" {\n"); Preconditions.checkArgument(c.getExtendedTypes().size() == 0); }
private static void writeClassDeclaration(PrintStream s, ClassOrInterfaceDeclaration c) { s.format("\npublic%s class %s", c.isFinal() ? " final" : "", c.getName()); if (c.getImplementedTypes() != null && !c.getImplementedTypes().isEmpty()) { s.format(" implements"); for (ClassOrInterfaceType iface : c.getImplementedTypes()) { s.append(" " + iface); } } s.append(" {\n"); Preconditions.checkArgument(c.getExtendedTypes().size() == 0); }
@Override public void visit(ClassOrInterfaceDeclaration n, Void arg) { if (!n.getExtendedTypes().isEmpty() && "SeleniumTestPlan".equals(n.getExtendedTypes().get(0).getName().toString())) { throw new DoNotVisitException("do not analyse SeleniumTestPlan sub classes"); } } }
@Override public ResolvedReferenceType getSuperClass() { if (wrappedNode.getExtendedTypes().isEmpty()) { return object(); } else { return toReferenceType(wrappedNode.getExtendedTypes().get(0)); } }
@Override public void visit(final FieldDeclaration field, final ConfigurationMetadataProperty property) { if (field.getVariables().isEmpty()) { throw new IllegalArgumentException("Field " + field + " has no variable definitions"); } val var = field.getVariable(0); if (field.getModifiers().contains(Modifier.STATIC)) { LOGGER.debug("Field [{}] is static and will be ignored for metadata generation", var.getNameAsString()); return; } if (field.getJavadoc().isEmpty()) { LOGGER.error("Field [{}] has no Javadoc defined", field); } val creator = new ConfigurationMetadataPropertyCreator(indexNameWithBrackets, properties, groups, parentClass); val prop = creator.createConfigurationProperty(field, property.getName()); processNestedClassOrInterfaceTypeIfNeeded(field, prop); }
@Override public ResolvedReferenceType getSuperClass() { if (wrappedNode.getExtendedTypes().isEmpty()) { return object(); } else { return toReferenceType(wrappedNode.getExtendedTypes().get(0)); } }
@Override public ResolvedReferenceType getSuperClass() { if (wrappedNode.getExtendedTypes().isEmpty()) { return object(); } else { return toReferenceType(wrappedNode.getExtendedTypes().get(0)); } }
val cu = JavaParser.parse(is); new ConfigurationMetadataFieldVisitor(collectedProps, collectedGroups, indexNameWithBrackets, typeName, sourcePath).visit(cu, p); if (!cu.getTypes().isEmpty()) { val decl = ClassOrInterfaceDeclaration.class.cast(cu.getType(0)); for (var i = 0; i < decl.getExtendedTypes().size(); i++) {