<commit_before>/*
 *
 *  Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  See the NOTICE file distributed with
 *  this work for additional information regarding copyright ownership.
 *  The ASF licenses this file to You under the Apache License, Version 2.0
 *  (the "License"); you may not use this file except in compliance with
 *  the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 */

package org.apache.flex.compiler.internal.codegen.externals.reference;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;

import org.apache.flex.compiler.clients.ExternCConfiguration;
import org.apache.flex.compiler.clients.ExternCConfiguration.ExcludedMember;
import org.apache.flex.compiler.internal.codegen.externals.utils.DebugLogUtils;

import com.google.javascript.jscomp.Compiler;
import com.google.javascript.jscomp.NodeUtil;
import com.google.javascript.rhino.JSDocInfo;
import com.google.javascript.rhino.JSTypeExpression;
import com.google.javascript.rhino.Node;
import com.google.javascript.rhino.jstype.JSType;

public class ReferenceModel
{
    private ExternCConfiguration configuration;
    private Compiler jscompiler;

    private List<String> namespaces = new ArrayList<String>();

    private HashMap<String, ClassReference> typedefs = new HashMap<String, ClassReference>();
    private HashMap<String, ClassReference> classes = new HashMap<String, ClassReference>();
    private HashMap<String, FunctionReference> functions = new HashMap<String, FunctionReference>();
    private HashMap<String, ConstantReference> constants = new HashMap<String, ConstantReference>();

    //    public Compiler getJSCompiler()
    //    {
    //        return jscompiler;
    //    }

    public void setJSCompiler(Compiler compiler)
    {
        this.jscompiler = compiler;
    }

    public ExternCConfiguration getConfiguration()
    {
        return configuration;
    }

    public ClassReference getObjectReference()
    {
        return classes.get("Object");
    }

    public Collection<String> getNamespaces()
    {
        return namespaces;
    }

    public Collection<ClassReference> getTypedefs()
    {
        return typedefs.values();
    }

    public Collection<ClassReference> getClasses()
    {
        return classes.values();
    }

    public Collection<FunctionReference> getFunctions()
    {
        return functions.values();
    }

    public Collection<ConstantReference> getConstants()
    {
        return constants.values();
    }

    public ReferenceModel(ExternCConfiguration config)
    {
        this.configuration = config;
    }

    public ClassReference getClassReference(String qualifiedName)
    {
        return classes.get(qualifiedName);
    }

    public ClassReference getInterfaceReference(String qualifiedName)
    {
        ClassReference reference = classes.get(qualifiedName);
        if (reference != null && reference.isInterface())
            return reference;
        return null;
    }

    public void addNamespace(Node node, String qualifiedName)
    {
        if (namespaces.contains(qualifiedName))
        {
            err("Duplicate namesapce [" + qualifiedName + "]");
            return;
        }

        log("Model.addNamespace(" + qualifiedName + ")");

        namespaces.add(qualifiedName);
    }

    public void addClass(Node node, String qualifiedName)<commit_msg>externc: added getTypeDefReference() to ReferenceModel to match getClassReference() and getInterfaceReference()<commit_after>/*
 *
 *  Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  See the NOTICE file distributed with
 *  this work for additional information regarding copyright ownership.
 *  The ASF licenses this file to You under the Apache License, Version 2.0
 *  (the "License"); you may not use this file except in compliance with
 *  the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 */

package org.apache.flex.compiler.internal.codegen.externals.reference;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;

import org.apache.flex.compiler.clients.ExternCConfiguration;
import org.apache.flex.compiler.clients.ExternCConfiguration.ExcludedMember;
import org.apache.flex.compiler.internal.codegen.externals.utils.DebugLogUtils;

import com.google.javascript.jscomp.Compiler;
import com.google.javascript.jscomp.NodeUtil;
import com.google.javascript.rhino.JSDocInfo;
import com.google.javascript.rhino.JSTypeExpression;
import com.google.javascript.rhino.Node;
import com.google.javascript.rhino.jstype.JSType;

public class ReferenceModel
{
    private ExternCConfiguration configuration;
    private Compiler jscompiler;

    private List<String> namespaces = new ArrayList<String>();

    private HashMap<String, ClassReference> typedefs = new HashMap<String, ClassReference>();
    private HashMap<String, ClassReference> classes = new HashMap<String, ClassReference>();
    private HashMap<String, FunctionReference> functions = new HashMap<String, FunctionReference>();
    private HashMap<String, ConstantReference> constants = new HashMap<String, ConstantReference>();

    //    public Compiler getJSCompiler()
    //    {
    //        return jscompiler;
    //    }

    public void setJSCompiler(Compiler compiler)
    {
        this.jscompiler = compiler;
    }

    public ExternCConfiguration getConfiguration()
    {
        return configuration;
    }

    public ClassReference getObjectReference()
    {
        return classes.get("Object");
    }

    public Collection<String> getNamespaces()
    {
        return namespaces;
    }

    public Collection<ClassReference> getTypedefs()
    {
        return typedefs.values();
    }

    public Collection<ClassReference> getClasses()
    {
        return classes.values();
    }

    public Collection<FunctionReference> getFunctions()
    {
        return functions.values();
    }

    public Collection<ConstantReference> getConstants()
    {
        return constants.values();
    }

    public ReferenceModel(ExternCConfiguration config)
    {
        this.configuration = config;
    }

    public ClassReference getClassReference(String qualifiedName)
    {
        return classes.get(qualifiedName);
    }

    public ClassReference getInterfaceReference(String qualifiedName)
    {
        ClassReference reference = classes.get(qualifiedName);
        if (reference != null && reference.isInterface())
            return reference;
        return null;
    }

    public ClassReference getTypeDefReference(String qualifiedName)
    {
        return typedefs.get(qualifiedName);
    }

    public void addNamespace(Node node, String qualifiedName)
    {
        if (namespaces.contains(qualifiedName))
        {
            err("Duplicate namesapce [" + qualifiedName + "]");
            return;
        }

        log("Model.addNamespace(" + qualifiedName + ")");

        namespaces.add(qualifiedName);
    }

    public void addClass(Node node, String qualifiedName)
{'fraction_non_alphanumeric': 0.0866540164452878, 'fraction_numerical': 0.0010120177103099305, 'mean_word_length': 3.372787610619469, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '23617', 'n_tokens_mistral': 2033, 'n_tokens_neox': 1990, 'n_words': 566}