use of org.jetbrains.plugins.ruby.ruby.codeInsight.paramDefs.matcher.ParamDefLeaf 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);
}
use of org.jetbrains.plugins.ruby.ruby.codeInsight.paramDefs.matcher.ParamDefLeaf in project intellij-plugins by JetBrains.
the class SelectorKeysProvider method getValue.
@Nullable
@Override
public ParamDefExpression getValue(ParamContext context, String text) {
final Collection<Function> functions = getFunctions(context);
if (functions == null)
return null;
final Pair<Integer, List<String>> pair = determineArgNumberAndPath(context);
final int argument = pair.first;
if (argument < 1)
return null;
for (Function function : functions) {
final List<Pair<String, String>> arguments = function.getArguments();
final String[] namedArguments = function.getName().split(":");
if (pathMatches(argument, namedArguments, pair.second) && "SEL".equals(arguments.get(argument).second)) {
return new ParamDefLeaf(METHOD_REF_PARAM);
}
}
return null;
}
Aggregations