// Detect It Easy: DiE-JS framework file
// Don't change anything unless you're sure about what you're doing

// Author: DosX
// E-Mail: collab@kay-software.ru
// GitHub: https://github.com/DosX-dev
// Telegram: @DosX_dev

function _isLangPresent(languageName) {
    return _isResultPresent("language", languageName) || _isResultPresent("~language", languageName);
}

function _isLangDetected() {
    return _getNumberOfResults("language") || _getNumberOfResults("~language");
}

function _setLang(languageName, version) {
    // if "C/C++" already detected
    if (_isLangPresent("C/C++") && (languageName == "C" || languageName == "C++")) {
        _removeResult("language", "C/C++");
    }

    // if "C" or "C++"" detected
    if (languageName == "C/C++" && (_isLangPresent("C") || _isLangPresent("C++"))) {
        return null;
    }

    // False-positive detection of C
    if (_isLangPresent("C") && languageName !== "C") {
        _removeResult("language", "C");
    }

    // False-positive detection of C++
    if (_isLangPresent("C++") && languageName !== "C++") {
        _removeResult("language", "C++");
    }

    // If the language already detected
    if (_isLangDetected() && (languageName == "C/C++" || languageName == "C++" || languageName == "C")) {
        return null;
    }

    if (File.isVerbose() && !_isLangPresent(languageName)) {
        var isHeurResult = (version == "HEUR");

        _setResult((isHeurResult ? "~" : "") + "language", languageName, (version && !isHeurResult ? version : ""), "");
    }

}