<commit_before>package org.metaborg.meta.nabl2.spoofax.primitives;

import java.util.List;
import java.util.Optional;

import org.metaborg.meta.nabl2.scopegraph.terms.Occurrence;
import org.metaborg.meta.nabl2.spoofax.analysis.IScopeGraphContext;
import org.metaborg.meta.nabl2.stratego.ITermIndex;
import org.metaborg.meta.nabl2.stratego.TermIndex;
import org.metaborg.meta.nabl2.terms.ITerm;
import org.spoofax.interpreter.core.InterpreterException;

public class SG_get_decl_property extends ScopeGraphPrimitive {

    public SG_get_decl_property() {
        super(SG_get_decl_property.class.getSimpleName(), 0, 1);
    }

    @Override public Optional<ITerm> call(IScopeGraphContext<?> context, ITerm term, List<ITerm> terms)
            throws InterpreterException {
        if (terms.size() != 2) {
            throw new InterpreterException("Need two term arguments: analysis, key");
        }
        final ITermIndex analysis = TermIndex.get(terms.get(0))
                .orElseThrow(() -> new InterpreterException("Not an analysis term."));
        final ITerm key = terms.get(1);
        return Occurrence.matcher().match(term).<ITerm> flatMap(decl -> {
            return context.unit(analysis.getResource()).solution().<ITerm> flatMap(s -> {
                return s.getDeclProperties().getValue(decl, key).map(s.getUnifier()::find);
            });
        });
    }

}<commit_msg>Fix number of term parameters.<commit_after>package org.metaborg.meta.nabl2.spoofax.primitives;

import java.util.List;
import java.util.Optional;

import org.metaborg.meta.nabl2.scopegraph.terms.Occurrence;
import org.metaborg.meta.nabl2.spoofax.analysis.IScopeGraphContext;
import org.metaborg.meta.nabl2.stratego.ITermIndex;
import org.metaborg.meta.nabl2.stratego.TermIndex;
import org.metaborg.meta.nabl2.terms.ITerm;
import org.spoofax.interpreter.core.InterpreterException;

public class SG_get_decl_property extends ScopeGraphPrimitive {

    public SG_get_decl_property() {
        super(SG_get_decl_property.class.getSimpleName(), 0, 2);
    }

    @Override public Optional<ITerm> call(IScopeGraphContext<?> context, ITerm term, List<ITerm> terms)
            throws InterpreterException {
        if (terms.size() != 2) {
            throw new InterpreterException("Need two term arguments: analysis, key");
        }
        final ITermIndex analysis = TermIndex.get(terms.get(0))
                .orElseThrow(() -> new InterpreterException("Not an analysis term."));
        final ITerm key = terms.get(1);
        return Occurrence.matcher().match(term).<ITerm> flatMap(decl -> {
            return context.unit(analysis.getResource()).solution().<ITerm> flatMap(s -> {
                return s.getDeclProperties().getValue(decl, key).map(s.getUnifier()::find);
            });
        });
    }

}
{'fraction_non_alphanumeric': 0.1235315058739765, 'fraction_numerical': 0.007831968672125312, 'mean_word_length': 3.488817891373802, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2899153', 'n_tokens_mistral': 909, 'n_tokens_neox': 887, 'n_words': 150}