Search in sources :

Example 1 with ParamDefHash

use of org.jetbrains.plugins.ruby.ruby.codeInsight.paramDefs.matcher.ParamDefHash in project intellij-plugins by JetBrains.

the class RubyMotionParamdefsProvider method buildExpression.

private static ParamDefExpression buildExpression(final Map<String, Collection<Function>> functions) {
    boolean hadOneArg = false;
    boolean hadMoreArg = false;
    for (Collection<Function> collection : functions.values()) {
        for (Function function : collection) {
            hadOneArg |= function.getArguments().size() == 1;
            hadMoreArg |= function.getArguments().size() > 1;
        }
    }
    if (hadOneArg && !hadMoreArg) {
        return new ParamDefLeaf(SelectorKeysProvider.METHOD_REF_PARAM);
    }
    final ParamDefHash hash = new ParamDefHash(false, true, null);
    final SelectorKeysProvider provider = new SelectorKeysProvider(functions);
    hash.addKey(provider, new ParamDefLeaf(AnyParamDef.getInstance()));
    return new ParamDefSeq(new ParamDefLeaf(hadOneArg ? SelectorKeysProvider.METHOD_REF_PARAM : AnyParamDef.getInstance()), hash);
}
Also used : Function(org.jetbrains.plugins.ruby.motion.bridgesupport.Function) ParamDefSeq(org.jetbrains.plugins.ruby.ruby.codeInsight.paramDefs.matcher.ParamDefSeq) ParamDefLeaf(org.jetbrains.plugins.ruby.ruby.codeInsight.paramDefs.matcher.ParamDefLeaf) ParamDefHash(org.jetbrains.plugins.ruby.ruby.codeInsight.paramDefs.matcher.ParamDefHash)

Aggregations

Function (org.jetbrains.plugins.ruby.motion.bridgesupport.Function)1 ParamDefHash (org.jetbrains.plugins.ruby.ruby.codeInsight.paramDefs.matcher.ParamDefHash)1 ParamDefLeaf (org.jetbrains.plugins.ruby.ruby.codeInsight.paramDefs.matcher.ParamDefLeaf)1 ParamDefSeq (org.jetbrains.plugins.ruby.ruby.codeInsight.paramDefs.matcher.ParamDefSeq)1