<commit_before>/*
Copyright 2015 Bowler Hat LLC

Licensed 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.
*/
/// <reference path="./as3.ts" />

import as3 = require("./as3");

let NEW_LINE = "\n";

let AS_TO_EXTERNS_TYPE_MAP = {};
AS_TO_EXTERNS_TYPE_MAP[as3.BuiltIns[as3.BuiltIns.Number]] = "number";
AS_TO_EXTERNS_TYPE_MAP[as3.BuiltIns[as3.BuiltIns.Boolean]] = "boolean";
AS_TO_EXTERNS_TYPE_MAP[as3.BuiltIns[as3.BuiltIns.String]] = "string";


class JSExternsEmitter
{
    constructor(types: as3.PackageLevelDefinition[])
    {
        this._types = types;
    }
    
    private _types: as3.PackageLevelDefinition[];
    
    emitFileHeader(): string
    {
        var header = "/**" + NEW_LINE;
 		header += " * @fileoverview Externs generated by dts2as from NextGenActionScript.com" + NEW_LINE;
		header += " * @externs" + NEW_LINE;
 		header += " */" + NEW_LINE + NEW_LINE;
        return header;
    }
    
    emitClass(as3Class: as3.ClassDefinition): string
    {
        let className = as3Class.getFullyQualifiedName();
        let superClass = as3Class.superClass;
        let interfaces = as3Class.interfaces;
        let constructorMethod = this.getConstructorMethod(as3Class);
		
        let classOutput = "/**" + NEW_LINE;
		classOutput += " * @constructor" + NEW_LINE;
        if(superClass)
        {
            classOutput += " * @extends {";
            classOutput += this.getNameToEmit(superClass, as3Class);
			classOutput += "}" + NEW_LINE;
        }
        if(interfaces.length > 0)
        {
            interfaces.forEach((otherInterface, index) =>
            {
            	classOutput += " * @implements {";
                classOutput += this.getNameToEmit(otherInterface, as3Class);
				classOutput += "}" + NEW_LINE;
            });
        }
        if(constructorMethod)
        {
            this.emitParameterDocs(constructorMethod, as3Class);
        }
		classOutput += " */" + NEW_LINE;
        classOutput += className;
		classOutput += " = function";<commit_msg>js-externs-emitter: fixed issue where constructor arguments were missing<commit_after>/*
Copyright 2015 Bowler Hat LLC

Licensed 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.
*/
/// <reference path="./as3.ts" />

import as3 = require("./as3");

let NEW_LINE = "\n";

let AS_TO_EXTERNS_TYPE_MAP = {};
AS_TO_EXTERNS_TYPE_MAP[as3.BuiltIns[as3.BuiltIns.Number]] = "number";
AS_TO_EXTERNS_TYPE_MAP[as3.BuiltIns[as3.BuiltIns.Boolean]] = "boolean";
AS_TO_EXTERNS_TYPE_MAP[as3.BuiltIns[as3.BuiltIns.String]] = "string";


class JSExternsEmitter
{
    constructor(types: as3.PackageLevelDefinition[])
    {
        this._types = types;
    }
    
    private _types: as3.PackageLevelDefinition[];
    
    emitFileHeader(): string
    {
        var header = "/**" + NEW_LINE;
 		header += " * @fileoverview Externs generated by dts2as from NextGenActionScript.com" + NEW_LINE;
		header += " * @externs" + NEW_LINE;
 		header += " */" + NEW_LINE + NEW_LINE;
        return header;
    }
    
    emitClass(as3Class: as3.ClassDefinition): string
    {
        let className = as3Class.getFullyQualifiedName();
        let superClass = as3Class.superClass;
        let interfaces = as3Class.interfaces;
        let constructorMethod = this.getConstructorMethod(as3Class);
		
        let classOutput = "/**" + NEW_LINE;
		classOutput += " * @constructor" + NEW_LINE;
        if(superClass)
        {
            classOutput += " * @extends {";
            classOutput += this.getNameToEmit(superClass, as3Class);
			classOutput += "}" + NEW_LINE;
        }
        if(interfaces.length > 0)
        {
            interfaces.forEach((otherInterface, index) =>
            {
            	classOutput += " * @implements {";
                classOutput += this.getNameToEmit(otherInterface, as3Class);
				classOutput += "}" + NEW_LINE;
            });
        }
        if(constructorMethod)
        {
            classOutput += this.emitParameterDocs(constructorMethod, as3Class);
        }
		classOutput += " */" + NEW_LINE;
        classOutput += className;
		classOutput += " = function";
{'fraction_non_alphanumeric': 0.1122408293460925, 'fraction_numerical': 0.011961722488038277, 'mean_word_length': 2.8831269349845203, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '5422108', 'n_tokens_mistral': 1541, 'n_tokens_neox': 1488, 'n_words': 367}