ani-lang / anilang-core

Core functionality of Ani language.
Other
1 stars 0 forks source link

31-01-23 test case: only declaration, no reference #95

Closed github-actions[bot] closed 1 year ago

github-actions[bot] commented 1 year ago

https://github.com/ani-lang/anilang-core/blob/d6aa831f1ceccbf695900a8e0dd43ec5f093fadb/anilang-context/src/main/java/com/anilang/context/impl/ContextToKeys.java#L19


/*
 * Property of Opencore
 */

package com.anilang.context.impl;

import com.anilang.context.AniContext;
import java.util.Map;
import java.util.stream.Collectors;

public final class ContextToKeys {
    private final AniContext aniContext;

    public ContextToKeys(final AniContext aniContext) {
        this.aniContext = aniContext;
    }

    public Map<String, String> asMap() {
        // TODO: 31-01-23 test case: only declaration, no reference
        return aniContext.asMap()
            .entrySet()
            .stream()
            .filter(item -> item.getValue().getIdentifierType() == IdentifierType.DECLARATION)
            .collect(
                Collectors.toMap(
                    entry -> entry.getValue().getParents(),
                    Map.Entry::getKey
                )
            );
    }
}