class MacroDefinitionRepository extends NodeRepository<MacroDefinitionBlock> {
    final private ArrayList<MacroDefinitionBlock> myReferencedMacroDefinitionBlocks = new ArrayList<>();

    public void addMacrosReference(MacroDefinitionBlock macroDefinitionBlock, MacroReference macros) {
        if (!macroDefinitionBlock.isReferenced()) {
            myReferencedMacroDefinitionBlocks.add(macroDefinitionBlock);
        }

        macroDefinitionBlock.setFirstReferenceOffset(macros.getStartOffset());
    }

    public void resolveMacrosOrdinals() {<FILL_FUNCTION_BODY>}

    public List<MacroDefinitionBlock> getReferencedMacroDefinitionBlocks() {
        return myReferencedMacroDefinitionBlocks;
    }

    public MacroDefinitionRepository(DataHolder options) {
        super(MacrosExtension.MACRO_DEFINITIONS_KEEP.get(options));
    }

    @NotNull
    @Override
    public DataKey<MacroDefinitionRepository> getDataKey() {
        return MacrosExtension.MACRO_DEFINITIONS;
    }

    @NotNull
    @Override
    public DataKey<KeepType> getKeepDataKey() {
        return MacrosExtension.MACRO_DEFINITIONS_KEEP;
    }

    @NotNull
    @Override
    public Set<MacroDefinitionBlock> getReferencedElements(Node parent) {
        HashSet<MacroDefinitionBlock> references = new HashSet<>();
        visitNodes(parent, value -> {
            if (value instanceof MacroReference) {
                MacroDefinitionBlock reference = ((MacroReference) value).getReferenceNode(MacroDefinitionRepository.this);
                if (reference != null) {
                    references.add(reference);
                }
            }
        }, MacroReference.class);
        return references;
    }
}

        // need to sort by first referenced offset then set each to its ordinal position in the array+1
        myReferencedMacroDefinitionBlocks.sort(Comparator.comparing(MacroDefinitionBlock::getFirstReferenceOffset));
        int ordinal = 0;
        for (MacroDefinitionBlock macroDefinitionBlock : myReferencedMacroDefinitionBlocks) {
            macroDefinitionBlock.setOrdinal(++ordinal);
        }
    
<methods>public void <init>(@Nullable KeepType) ,public void clear() ,public boolean containsKey(@NotNull Object) ,public boolean containsValue(java.lang.Object) ,public @NotNull Set<Map.Entry<String,MacroDefinitionBlock>> entrySet() ,public boolean equals(java.lang.Object) ,public @Nullable MacroDefinitionBlock get(@NotNull Object) ,public abstract @NotNull DataKey<? extends NodeRepository<MacroDefinitionBlock>> getDataKey() ,public @Nullable MacroDefinitionBlock getFromRaw(@NotNull CharSequence) ,public abstract @NotNull DataKey<KeepType> getKeepDataKey() ,public abstract @NotNull Set<MacroDefinitionBlock> getReferencedElements(com.vladsch.flexmark.util.ast.Node) ,public @NotNull Collection<MacroDefinitionBlock> getValues() ,public int hashCode() ,public boolean isEmpty() ,public @NotNull Set<String> keySet() ,public @NotNull String normalizeKey(@NotNull CharSequence) ,public @Nullable MacroDefinitionBlock put(@NotNull String, @NotNull MacroDefinitionBlock) ,public void putAll(@NotNull Map<? extends String,? extends MacroDefinitionBlock>) ,public @Nullable MacroDefinitionBlock putRawKey(@NotNull CharSequence, @NotNull MacroDefinitionBlock) ,public @Nullable MacroDefinitionBlock remove(@NotNull Object) ,public int size() ,public static boolean transferReferences(@NotNull NodeRepository<T>, @NotNull NodeRepository<T>, boolean, @Nullable Map<String,String>) ,public @NotNull List<MacroDefinitionBlock> values() <variables>protected final non-sealed com.vladsch.flexmark.util.ast.KeepType keepType,protected final ArrayList<com.vladsch.flexmark.ext.macros.MacroDefinitionBlock> nodeList,protected final Map<java.lang.String,com.vladsch.flexmark.ext.macros.MacroDefinitionBlock> nodeMap