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 };
}
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;
}
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());
}
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());
}
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));
}
Aggregations