use of org.jetbrains.plugins.ruby.motion.bridgesupport.Function in project intellij-plugins by JetBrains.
the class RubyMotionParamdefsProvider method loadAvailableSelectors.
private static void loadAvailableSelectors(Framework framework, Map<String, Map<String, Collection<Function>>> mergedFunctions) {
final String version = framework.getVersion();
for (Class clazz : framework.getClasses()) {
for (Function function : clazz.getFunctions()) {
if (!canHaveParamdef(function))
continue;
final String name = clazz.getName() + "." + MotionSymbolUtil.getSelectorNames(function).get(0);
Map<String, Collection<Function>> allFunctions = mergedFunctions.get(name);
if (allFunctions == null) {
allFunctions = new HashMap<>();
mergedFunctions.put(name, allFunctions);
}
Collection<Function> frameworkFunctions = allFunctions.get(version);
if (frameworkFunctions == null) {
frameworkFunctions = new ArrayList<>();
allFunctions.put(version, frameworkFunctions);
}
frameworkFunctions.add(function);
}
}
}
use of org.jetbrains.plugins.ruby.motion.bridgesupport.Function in project intellij-plugins by JetBrains.
the class RubyMotionTypeProvider method createTypeForRef.
@Nullable
private static RType createTypeForRef(@NotNull RReference ref, @NotNull Module module) {
final RPsiElement value = ref.getValue();
// method name may be identifier on constant
if (value instanceof RPossibleCall) {
final String shortName = ((RPossibleCall) value).getPossibleCommand();
final String sdkVersion = RubyMotionUtil.getInstance().getSdkVersion(module);
final String[] frameworks = RubyMotionUtil.getInstance().getRequiredFrameworks(module);
boolean isIdSelector = false;
for (String framework : frameworks) {
if (BridgeSupportLoader.getInstance().isIdSelector(shortName, sdkVersion, framework)) {
isIdSelector = true;
break;
}
}
if (isIdSelector) {
final Symbol callSymbol = ResolveUtil.resolveToSymbolWithCaching(ref.getReference());
if (callSymbol instanceof FunctionSymbol) {
final Function function = ((FunctionSymbol) callSymbol).getFunction();
if (function.isId()) {
return RTypeUtil.createTypeSameAsReceiverInstance(ref);
}
}
}
}
return null;
}
use of org.jetbrains.plugins.ruby.motion.bridgesupport.Function in project intellij-plugins by JetBrains.
the class RubyMotionOverriddenMethodGenerator method createMemberToOverride.
@Nullable
@Override
public ClassMember createMemberToOverride(final Symbol methodSymbol) {
if (methodSymbol instanceof FunctionSymbol) {
final FunctionSymbol symbol = (FunctionSymbol) methodSymbol;
final Function function = symbol.getFunction();
if (!function.isClassMethod() && symbol.getParentSymbol() != null) {
return new FunctionMember(symbol);
}
}
return null;
}
use of org.jetbrains.plugins.ruby.motion.bridgesupport.Function 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;
}
use of org.jetbrains.plugins.ruby.motion.bridgesupport.Function in project intellij-plugins by JetBrains.
the class SelectorKeysProvider method getKeys.
@NotNull
@Override
public List<String> getKeys(ParamContext context) {
final Collection<Function> functions = getFunctions(context);
if (functions == null)
return Collections.emptyList();
final Pair<Integer, List<String>> pair = determineArgNumberAndPath(context);
final int argument = pair.first;
if (argument < 1)
return Collections.emptyList();
final List<String> result = new ArrayList<>();
for (Function function : functions) {
final String[] namedArguments = function.getName().split(":");
if (pathMatches(argument, namedArguments, pair.second)) {
result.add(namedArguments[argument]);
}
}
return result;
}
Aggregations