<commit_before>import ceylon.ast.core {
    IsCondition,
    TypedVariable
}
import com.redhat.ceylon.compiler.typechecker.tree {
    Tree {
        JIsCondition=IsCondition,
        JStaticType=StaticType
    }
}

"Converts a RedHat AST [[IsCondition|JIsCondition]] to a `ceylon.ast` [[IsCondition]]."
shared IsCondition isConditionToCeylon(JIsCondition isCondition) {
    assert (is JStaticType jType = isCondition.type);
    value jVariable = isCondition.variable;
    value jSpecifierExpression = jVariable.specifierExpression;
    return IsCondition {
        variable = TypedVariable {
            name = lIdentifierToCeylon(jVariable.identifier);
            type = typeToCeylon(jType);
            specifier = jSpecifierExpression.mainToken exists then specifierToCeylon(jSpecifierExpression);
        };
        negated = isCondition.not;
    };
}

"Compiles the given [[code]] for an Is Condition
 into an [[IsCondition]] using the Ceylon compiler
 (more specifically, the rule for an `isCondition`)."
shared IsCondition? compileIsCondition(String code) {
    // if (exists jIsCondition = createParser(code + ",").isCondition()) {
    // TODO use above variant when possible
    /*
     At the moment, Ceylon sees the method isCondition() as a getter
     for an attribute ‘condition’ (this is intended for boolean attributes
     (isHidden()), but apparently applied to methods of every type).
     Because there’s also a condition() method, we can’t use the
     condition “attribute” either.
     */
    if (is JIsCondition jIsCondition = createParser(code + ",").condition()) {
        // the parser needs that comma for conditions without a specifier
        return isConditionToCeylon(jIsCondition);
    } else {
        return null;
    }
}<commit_msg>Remove workaround for ceylon/ceylon-compiler#1767<commit_after>import ceylon.ast.core {
    IsCondition,
    TypedVariable
}
import com.redhat.ceylon.compiler.typechecker.tree {
    Tree {
        JIsCondition=IsCondition,
        JStaticType=StaticType
    }
}

"Converts a RedHat AST [[IsCondition|JIsCondition]] to a `ceylon.ast` [[IsCondition]]."
shared IsCondition isConditionToCeylon(JIsCondition isCondition) {
    assert (is JStaticType jType = isCondition.type);
    value jVariable = isCondition.variable;
    value jSpecifierExpression = jVariable.specifierExpression;
    return IsCondition {
        variable = TypedVariable {
            name = lIdentifierToCeylon(jVariable.identifier);
            type = typeToCeylon(jType);
            specifier = jSpecifierExpression.mainToken exists then specifierToCeylon(jSpecifierExpression);
        };
        negated = isCondition.not;
    };
}

"Compiles the given [[code]] for an Is Condition
 into an [[IsCondition]] using the Ceylon compiler
 (more specifically, the rule for an `isCondition`)."
shared IsCondition? compileIsCondition(String code) {
    if (exists jIsCondition = createParser(code + ",").isCondition()) {
        // the parser needs that comma for conditions without a specifier
        return isConditionToCeylon(jIsCondition);
    } else {
        return null;
    }
}
{'fraction_non_alphanumeric': 0.08942307692307692, 'fraction_numerical': 0.001282051282051282, 'mean_word_length': 3.426950354609929, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5146003', 'n_tokens_mistral': 872, 'n_tokens_neox': 845, 'n_words': 246}