Search in sources :

Example 1 with RType

use of org.jetbrains.plugins.ruby.ruby.codeInsight.types.RType in project intellij-plugins by JetBrains.

the class MotionSymbolUtil method createStructFieldSymbols.

public static Symbol[] createStructFieldSymbols(final Module module, Symbol parent, Struct struct, String name) {
    final String typeName = struct.getFieldType(name);
    final RType type = getTypeByName(module, typeName);
    final RTypedSyntheticSymbol reader = new RTypedSyntheticSymbol(module.getProject(), name, Type.FIELD_READER, parent, type, 0);
    final RTypedSyntheticSymbol writer = new RTypedSyntheticSymbol(module.getProject(), name + "=", Type.FIELD_WRITER, parent, type, 1);
    return new Symbol[] { reader, writer };
}
Also used : Symbol(org.jetbrains.plugins.ruby.ruby.codeInsight.symbols.structure.Symbol) RTypedSyntheticSymbol(org.jetbrains.plugins.ruby.ruby.codeInsight.symbols.structure.RTypedSyntheticSymbol) RType(org.jetbrains.plugins.ruby.ruby.codeInsight.types.RType) RTypedSyntheticSymbol(org.jetbrains.plugins.ruby.ruby.codeInsight.symbols.structure.RTypedSyntheticSymbol)

Example 2 with RType

use of org.jetbrains.plugins.ruby.ruby.codeInsight.types.RType in project intellij-plugins by JetBrains.

the class MotionSymbolUtil method doGetTypeByName.

@NotNull
private static RType doGetTypeByName(@Nullable Module module, String typeName) {
    if (module == null) {
        return REmptyType.INSTANCE;
    }
    final Project project = module.getProject();
    if (typeName.endsWith("*")) {
        final RType type = doGetTypeByName(module, dereferencePointerType(typeName));
        if (type != REmptyType.INSTANCE || "void".equals(dereferencePointerType(typeName))) {
            return new RArrayType(project, type);
        }
    }
    final RType primitiveType = getPrimitiveType(project, typeName);
    if (primitiveType != null) {
        return primitiveType;
    }
    final Collection<Framework> frameworks = ((RubyMotionUtilImpl) RubyMotionUtil.getInstance()).getFrameworks(module);
    if (!typeName.endsWith("*")) {
        final Symbol symbol = RubyMotionSymbolProvider.findClassOrStruct(module, frameworks, FQN.Builder.fromString(typeName).asList());
        return symbol instanceof StructSymbol || (symbol != null && RubyMotionUtil.getInstance().isAndroid(module)) ? new RSymbolTypeImpl(symbol, Context.INSTANCE) : REmptyType.INSTANCE;
    }
    typeName = dereferencePointerType(typeName);
    final Symbol symbol = RubyMotionSymbolProvider.findClassOrStruct(module, frameworks, Collections.singletonList(typeName));
    return symbol != null ? new RSymbolTypeImpl(symbol, Context.INSTANCE) : REmptyType.INSTANCE;
}
Also used : RubyMotionUtilImpl(org.jetbrains.plugins.ruby.motion.RubyMotionUtilImpl) Project(com.intellij.openapi.project.Project) Symbol(org.jetbrains.plugins.ruby.ruby.codeInsight.symbols.structure.Symbol) RTypedSyntheticSymbol(org.jetbrains.plugins.ruby.ruby.codeInsight.symbols.structure.RTypedSyntheticSymbol) RType(org.jetbrains.plugins.ruby.ruby.codeInsight.types.RType) RArrayType(org.jetbrains.plugins.ruby.ruby.codeInsight.types.collections.RArrayType) RSymbolTypeImpl(org.jetbrains.plugins.ruby.ruby.codeInsight.types.impl.RSymbolTypeImpl) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with RType

use of org.jetbrains.plugins.ruby.ruby.codeInsight.types.RType in project intellij-plugins by JetBrains.

the class RubyMotionCodeInsightTest method testSelectorChainType.

public void testSelectorChainType() throws Throwable {
    defaultConfigure();
    final RType type = RubyTestUtil.getCoveringReferenceType(findPsiBySignature("UIView.alloc.initWith<caret>Frame"));
    assertInstanceOf(type, RSymbolType.class);
    assertEquals("UIView", ((RSymbolType) type).getSymbol().getName());
}
Also used : RSymbolType(org.jetbrains.plugins.ruby.ruby.codeInsight.types.RSymbolType) RType(org.jetbrains.plugins.ruby.ruby.codeInsight.types.RType)

Example 4 with RType

use of org.jetbrains.plugins.ruby.ruby.codeInsight.types.RType in project intellij-plugins by JetBrains.

the class RubyMotionCodeInsightTest method testSelectorType.

public void testSelectorType() throws Throwable {
    defaultConfigure();
    final RType type = RubyTestUtil.getCoveringReferenceType(findPsiBySignature("UIView.al<caret>loc"));
    assertInstanceOf(type, RSymbolType.class);
    assertEquals("UIView", ((RSymbolType) type).getSymbol().getName());
}
Also used : RSymbolType(org.jetbrains.plugins.ruby.ruby.codeInsight.types.RSymbolType) RType(org.jetbrains.plugins.ruby.ruby.codeInsight.types.RType)

Example 5 with RType

use of org.jetbrains.plugins.ruby.ruby.codeInsight.types.RType in project intellij-plugins by JetBrains.

the class RubyMotionCodeInsightTest method testStructType.

public void testStructType() throws Throwable {
    defaultConfigure();
    final RType type = RubyTestUtil.getCoveringIdentifierType(findPsiBySignature("tra<caret>nsform"));
    assertInstanceOf(type, RSymbolType.class);
    assertNotNull(type.getMemberForName("tx", SymbolFilterFactory.EMPTY_FILTER, null));
    assertNotNull(type.getMemberForName("tx=", SymbolFilterFactory.EMPTY_FILTER, null));
}
Also used : RType(org.jetbrains.plugins.ruby.ruby.codeInsight.types.RType)

Aggregations

RType (org.jetbrains.plugins.ruby.ruby.codeInsight.types.RType)5 RTypedSyntheticSymbol (org.jetbrains.plugins.ruby.ruby.codeInsight.symbols.structure.RTypedSyntheticSymbol)2 Symbol (org.jetbrains.plugins.ruby.ruby.codeInsight.symbols.structure.Symbol)2 RSymbolType (org.jetbrains.plugins.ruby.ruby.codeInsight.types.RSymbolType)2 Project (com.intellij.openapi.project.Project)1 NotNull (org.jetbrains.annotations.NotNull)1 RubyMotionUtilImpl (org.jetbrains.plugins.ruby.motion.RubyMotionUtilImpl)1 RArrayType (org.jetbrains.plugins.ruby.ruby.codeInsight.types.collections.RArrayType)1 RSymbolTypeImpl (org.jetbrains.plugins.ruby.ruby.codeInsight.types.impl.RSymbolTypeImpl)1