Search in sources :

Example 1 with Class

use of org.jetbrains.plugins.ruby.motion.bridgesupport.Class in project intellij-plugins by JetBrains.

the class RubyMotionSymbolProvider method findClassOrStruct.

@Nullable
public static Symbol findClassOrStruct(Module module, Collection<Framework> frameworks, List<String> name) {
    final List<Class> classes = new ArrayList<>();
    for (Framework framework : frameworks) {
        final Class clazz = framework.getClass(name);
        ContainerUtil.addIfNotNull(classes, clazz);
    }
    if (!classes.isEmpty()) {
        return new MotionClassSymbol(module, classes);
    }
    if (name.size() > 1)
        return null;
    for (Framework framework : frameworks) {
        final Struct struct = framework.getStruct(name.get(0));
        if (struct != null) {
            return new StructSymbol(module, struct);
        }
    }
    return null;
}
Also used : ArrayList(java.util.ArrayList) Class(org.jetbrains.plugins.ruby.motion.bridgesupport.Class) RClass(org.jetbrains.plugins.ruby.ruby.lang.psi.controlStructures.classes.RClass) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with Class

use of org.jetbrains.plugins.ruby.motion.bridgesupport.Class 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);
        }
    }
}
Also used : Function(org.jetbrains.plugins.ruby.motion.bridgesupport.Function) Collection(java.util.Collection) Class(org.jetbrains.plugins.ruby.motion.bridgesupport.Class)

Example 3 with Class

use of org.jetbrains.plugins.ruby.motion.bridgesupport.Class in project intellij-plugins by JetBrains.

the class MotionClassSymbol method getChildren.

@NotNull
@Override
public Children getChildren() {
    return new ChildrenImpl() {

        @Override
        public boolean processChildren(SymbolPsiProcessor processor, final PsiElement invocationPoint) {
            final MotionClassSymbol parent = MotionClassSymbol.this;
            for (Class clazz : myClasses) {
                for (Function function : clazz.getFunctions()) {
                    for (RTypedSyntheticSymbol functionSymbol : MotionSymbolUtil.createSelectorSymbols(myModule, parent, function)) {
                        if (!processor.process(functionSymbol)) {
                            return false;
                        }
                    }
                }
                for (Class subClass : clazz.getSubClasses()) {
                    final MotionClassSymbol symbol = new MotionClassSymbol(myModule, Collections.singletonList(subClass));
                    if (!processor.process(symbol)) {
                        return false;
                    }
                }
            }
            final Symbol superClass = getSuperClassSymbol(invocationPoint);
            if (superClass != null) {
                final Children children = superClass.getChildren();
                if (!children.processChildren(processor, invocationPoint)) {
                    return false;
                }
            }
            return true;
        }
    };
}
Also used : Function(org.jetbrains.plugins.ruby.motion.bridgesupport.Function) SymbolPsiProcessor(org.jetbrains.plugins.ruby.ruby.codeInsight.symbols.v2.SymbolPsiProcessor) Class(org.jetbrains.plugins.ruby.motion.bridgesupport.Class) PsiElement(com.intellij.psi.PsiElement) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

Class (org.jetbrains.plugins.ruby.motion.bridgesupport.Class)3 Function (org.jetbrains.plugins.ruby.motion.bridgesupport.Function)2 PsiElement (com.intellij.psi.PsiElement)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1 SymbolPsiProcessor (org.jetbrains.plugins.ruby.ruby.codeInsight.symbols.v2.SymbolPsiProcessor)1 RClass (org.jetbrains.plugins.ruby.ruby.lang.psi.controlStructures.classes.RClass)1