<commit_before>package com.redhat.ceylon.compiler.loader;

import java.util.Map;

import com.redhat.ceylon.compiler.js.CompilerErrorException;
import com.redhat.ceylon.compiler.typechecker.model.Module;

public class JsonModule extends Module {

    private Map<String,Object> model;
    private final JsModuleManager modman;

    JsonModule(JsModuleManager manager) {
        modman = manager;
    }

    @SuppressWarnings("unchecked")
    public void setModel(Map<String, Object> value) {
        if (model != null) {
            throw new IllegalStateException("JsonModule should only receive model once");
        }
        model = value;
        for (Map.Entry<String, Object> e : model.entrySet()) {
            String k = e.getKey();
            if (!k.startsWith("$mod-")) {
                com.redhat.ceylon.compiler.typechecker.model.Package pkg = getDirectPackage(k);
                if (pkg == null) {
                    pkg = modman.createPackage(k, this);
                }
                if (pkg instanceof JsonPackage && ((JsonPackage)pkg).getModel() == null) {
                    ((JsonPackage) pkg).setModel((Map<String,Object>)e.getValue());
                }
            }
        }
    }
    public Map<String, Object> getModel() {
        return model;
    }

    void loadDeclarations() {
        if (model != null) {
            for (com.redhat.ceylon.compiler.typechecker.model.Package pkg : getPackages()) {
                if (pkg instanceof JsonPackage) {
                    ((JsonPackage) pkg).loadDeclarations();
                }
            }
        }
    }

    @SuppressWarnings("unchecked")
    public Map<String,Object> getModelForPackage(String name) {
        return model == null ? null : (Map<String,Object>)model.get(name);
    }

    @Override
    public com.redhat.ceylon.compiler.typechecker.model.Package getPackage(String name) {
        final com.redhat.ceylon.compiler.typechecker.model.Package p = super.getPackage(name);
        if (p == null) {
            throw new CompilerErrorException("Package " + name + " not available");
        }
        return p;
    }

}<commit_msg>Search for "default" package as ""<commit_after>package com.redhat.ceylon.compiler.loader;

import java.util.Map;

import com.redhat.ceylon.compiler.js.CompilerErrorException;
import com.redhat.ceylon.compiler.typechecker.model.Module;

public class JsonModule extends Module {

    private Map<String,Object> model;
    private final JsModuleManager modman;

    JsonModule(JsModuleManager manager) {
        modman = manager;
    }

    @SuppressWarnings("unchecked")
    public void setModel(Map<String, Object> value) {
        if (model != null) {
            throw new IllegalStateException("JsonModule should only receive model once");
        }
        model = value;
        for (Map.Entry<String, Object> e : model.entrySet()) {
            String k = e.getKey();
            if (!k.startsWith("$mod-")) {
                com.redhat.ceylon.compiler.typechecker.model.Package pkg = getDirectPackage(k);
                if (pkg == null) {
                    pkg = modman.createPackage(k, this);
                }
                if (pkg instanceof JsonPackage && ((JsonPackage)pkg).getModel() == null) {
                    ((JsonPackage) pkg).setModel((Map<String,Object>)e.getValue());
                }
            }
        }
    }
    public Map<String, Object> getModel() {
        return model;
    }

    void loadDeclarations() {
        if (model != null) {
            for (com.redhat.ceylon.compiler.typechecker.model.Package pkg : getPackages()) {
                if (pkg instanceof JsonPackage) {
                    ((JsonPackage) pkg).loadDeclarations();
                }
            }
        }
    }

    @SuppressWarnings("unchecked")
    public Map<String,Object> getModelForPackage(String name) {
        return model == null ? null : (Map<String,Object>)model.get(name);
    }

    @Override
    public com.redhat.ceylon.compiler.typechecker.model.Package getPackage(String name) {
        if ("default".equals(name)) {
            name = "";
        }
        final com.redhat.ceylon.compiler.typechecker.model.Package p = super.getPackage(name);
        if (p == null) {
            throw new CompilerErrorException("Package " + name + " not available");
        }
        return p;
    }

}
{'fraction_non_alphanumeric': 0.11863240018357045, 'fraction_numerical': 0.0, 'mean_word_length': 2.145021645021645, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '5395283', 'n_tokens_mistral': 1241, 'n_tokens_neox': 1209, 'n_words': 250}