class NodeMetaModelGenerator extends AbstractGenerator {

    private final InitializePropertyMetaModelsStatementsGenerator initializePropertyMetaModelsStatementsGenerator = new InitializePropertyMetaModelsStatementsGenerator();
    private final InitializeConstructorParametersStatementsGenerator initializeConstructorParametersStatementsGenerator = new InitializeConstructorParametersStatementsGenerator();

    public static final String GENERATED_CLASS_COMMENT = "" +
            "This file, class, and its contents are completely generated based on:" +
            "\n<ul>" +
            "\n    <li>The contents and annotations within the package `com.github.javaparser.ast`, and</li>" +
            "\n    <li>`ALL_NODE_CLASSES` within the class `com.github.javaparser.generator.metamodel.MetaModelGenerator`.</li>" +
            "\n</ul>" +
            "\n" +
            "\nFor this reason, any changes made directly to this file will be overwritten the next time generators are run." +
            "";

    private static final String GENERATED_JAVADOC_COMMENT = "Warning: The content of this class is partially or completely generated - manual edits risk being overwritten.";

    protected NodeMetaModelGenerator(SourceRoot sourceRoot) {
        super(sourceRoot);
    }

    public void generate(Class<? extends Node> nodeClass, ClassOrInterfaceDeclaration metaModelCoid, NodeList<Statement> initializeNodeMetaModelsStatements, NodeList<Statement> initializePropertyMetaModelsStatements, NodeList<Statement> initializeConstructorParametersStatements, SourceRoot sourceRoot) throws NoSuchMethodException {<FILL_FUNCTION_BODY>}

    private void moveStaticInitializeToTheEndOfTheClassBecauseWeNeedTheFieldsToInitializeFirst(ClassOrInterfaceDeclaration metaModelCoid) {
        for (BodyDeclaration<?> m : metaModelCoid.getMembers()) {
            if (m instanceof InitializerDeclaration) {
                m.remove();
                metaModelCoid.addMember(m);
                return;
            }
        }
    }

    private boolean fieldShouldBeIgnored(Field reflectionField) {
        return java.lang.reflect.Modifier.isStatic(reflectionField.getModifiers()) ||
                reflectionField.isAnnotationPresent(InternalProperty.class);
    }
}

        metaModelCoid.setJavadocComment(GENERATED_JAVADOC_COMMENT);

        final AstTypeAnalysis typeAnalysis = new AstTypeAnalysis(nodeClass);

        final String className = MetaModelGenerator.nodeMetaModelName(nodeClass);
        final String nodeMetaModelFieldName = decapitalize(className);
        metaModelCoid.getFieldByName(nodeMetaModelFieldName).ifPresent(Node::remove);

        initializeNodeMetaModelsStatements.add(parseStatement(f("nodeMetaModels.add(%s);", nodeMetaModelFieldName)));
        this.initializeConstructorParametersStatementsGenerator.generate(nodeClass, initializeConstructorParametersStatements);

        final Class<?> superclass = nodeClass.getSuperclass();
        final String superNodeMetaModel = MetaModelGenerator.nodeMetaModelName(superclass);
        final boolean isRootNode = !MetaModelGenerator.isNode(superclass);

        final FieldDeclaration nodeField = metaModelCoid.addField(className, nodeMetaModelFieldName, PUBLIC, STATIC, FINAL);
        annotateGenerated(nodeField);
        nodeField.getVariable(0).setInitializer(
                parseExpression(
                        f("new %s(%s)",
                                className,
                                optionalOf(decapitalize(superNodeMetaModel), !isRootNode))
                )
        );


        // The node-specific metamodel file
        final CompilationUnit classMetaModelJavaFile = new CompilationUnit(MetaModelGenerator.METAMODEL_PACKAGE);
        classMetaModelJavaFile.setBlockComment(COPYRIGHT_NOTICE_JP_CORE);
        classMetaModelJavaFile.addImport(Optional.class);
        classMetaModelJavaFile.addImport(nodeClass);

        //
        final ClassOrInterfaceDeclaration nodeMetaModelClass = classMetaModelJavaFile.addClass(className, PUBLIC);
        annotateGenerated(nodeMetaModelClass);
        nodeMetaModelClass.setJavadocComment(GENERATED_CLASS_COMMENT);

        if (isRootNode) {
            nodeMetaModelClass.addExtendedType(MetaModelGenerator.BASE_NODE_META_MODEL);
        } else {
            nodeMetaModelClass.addExtendedType(superNodeMetaModel);
        }

        // Constructors
        final ConstructorDeclaration classMMConstructor = nodeMetaModelClass
                .addConstructor()
                .addParameter(
                        f("Optional<%s>", MetaModelGenerator.BASE_NODE_META_MODEL),
                        f("super%s", MetaModelGenerator.BASE_NODE_META_MODEL)
                );
        classMMConstructor
                .getBody()
                .addStatement(
                        parseExplicitConstructorInvocationStmt(f("super(super%s, %s.class, \"%s\", \"%s\", %s, %s);",
                                MetaModelGenerator.BASE_NODE_META_MODEL,
                                nodeClass.getSimpleName(),
                                nodeClass.getSimpleName(),
                                nodeClass.getPackage().getName(),
                                typeAnalysis.isAbstract,
                                typeAnalysis.isSelfType
                        ))
                );
        annotateGenerated(classMMConstructor);

        // ?Abstract protected constructor?
        if (typeAnalysis.isAbstract) {
            classMetaModelJavaFile.addImport(Node.class);
            BodyDeclaration<?> bodyDeclaration = parseBodyDeclaration(f(
                    "protected %s(Optional<%s> superNodeMetaModel, Class<? extends Node> type, String name, String packageName, boolean isAbstract, boolean hasWildcard) {" +
                            "super(superNodeMetaModel, type, name, packageName, isAbstract, hasWildcard);" +
                            " }",
                    className,
                    MetaModelGenerator.BASE_NODE_META_MODEL
            ));
            annotateGenerated(bodyDeclaration);
            nodeMetaModelClass.addMember(bodyDeclaration);
        }

        // Fields, sorted by name.
        final List<Field> fields = new ArrayList<>(Arrays.asList(nodeClass.getDeclaredFields()));
        fields.sort(Comparator.comparing(Field::getName));
        for (Field field : fields) {
            if (this.fieldShouldBeIgnored(field)) {
                continue;
            }

            this.initializePropertyMetaModelsStatementsGenerator.generate(field, nodeMetaModelClass, nodeMetaModelFieldName, initializePropertyMetaModelsStatements);
        }

        // Methods, sorted by name.
        final List<Method> methods = new ArrayList<>(Arrays.asList(nodeClass.getMethods()));
        methods.sort(Comparator.comparing(Method::getName));
        for (Method method : methods) {
            if (method.isAnnotationPresent(DerivedProperty.class)) {
                this.initializePropertyMetaModelsStatementsGenerator.generateDerivedProperty(method, nodeMetaModelClass, nodeMetaModelFieldName, initializePropertyMetaModelsStatements);
            }
        }


        this.moveStaticInitializeToTheEndOfTheClassBecauseWeNeedTheFieldsToInitializeFirst(metaModelCoid);

        // Add the file to the source root, enabling it to be saved later.
        sourceRoot.add(MetaModelGenerator.METAMODEL_PACKAGE, className + ".java", classMetaModelJavaFile);
    
<methods><variables>protected static final java.lang.String COPYRIGHT_NOTICE_JP_CORE,protected static final java.lang.String COPYRIGHT_NOTICE_JP_SS,protected final non-sealed com.github.javaparser.utils.SourceRoot sourceRoot