Search in sources :

Example 1 with RSymbolTypeImpl

use of org.jetbrains.plugins.ruby.ruby.codeInsight.types.impl.RSymbolTypeImpl 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)

Aggregations

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