use of org.jetbrains.plugins.ruby.ruby.codeInsight.symbols.structure.Symbol 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.ruby.codeInsight.symbols.structure.Symbol in project intellij-plugins by JetBrains.
the class RubyMotionSymbolProvider method createSymbolByContainer.
@Override
public Symbol createSymbolByContainer(@NotNull RContainer container, @NotNull FQN fqn, @Nullable Symbol parent) {
if (!RubyMotionUtil.getInstance().hasMacRubySupport(container))
return null;
final Module module = getModule(container);
if (module == null)
return null;
final Symbol motionSymbol = getCachedSpecificSymbol(container, container);
if (motionSymbol != null) {
return motionSymbol;
}
return null;
}
use of org.jetbrains.plugins.ruby.ruby.codeInsight.symbols.structure.Symbol in project intellij-plugins by JetBrains.
the class RubyMotionSymbolProvider method getSpecificSymbol.
@Nullable
@Override
protected Symbol getSpecificSymbol(PsiElement element, RContainer context) {
if (context instanceof RClass || context instanceof RModule) {
final boolean isObject = CoreTypes.Object.equals(context.getFQN().getFullPath());
final RubyMotionSymbol symbol = isObject ? new RubyMotionSymbol((RFile) context.getContainingFile()) : null;
final Symbol nsObject = SymbolUtil.findSymbol(element.getProject(), Type.CLASS, getParentName(context), element);
final List<Symbol> includes = isObject ? Collections.singletonList(symbol) : Collections.emptyList();
return new MotionEnabledClassModuleSymbol(context, includes, Collections.emptyList(), Collections.singletonList(nsObject));
}
return null;
}
use of org.jetbrains.plugins.ruby.ruby.codeInsight.symbols.structure.Symbol in project intellij-plugins by JetBrains.
the class RubyMotionUtilImpl method getMotionDoc.
@Nullable
public String getMotionDoc(PsiElement targetElement, @Nullable Symbol targetSymbol) {
String descriptionText;
final MotionSymbol motionSymbol = (MotionSymbol) targetSymbol;
CocoaDocumentationManagerImpl.DocTokenType type = motionSymbol.getInfoType();
CocoaDocumentationManagerImpl manager = (CocoaDocumentationManagerImpl) CocoaDocumentationManager.getInstance(targetSymbol.getProject());
final Symbol parent = targetSymbol.getParentSymbol();
final String parentName = parent != null ? parent.getName() : null;
final CocoaDocumentationManagerImpl.DocumentationBean info = manager.getTokenInfo(targetElement, motionSymbol.getInfoName(), Collections.singletonList(Pair.create(parentName, type)));
descriptionText = info != null ? patchObjCDoc(info.html, motionSymbol) : null;
return descriptionText;
}
use of org.jetbrains.plugins.ruby.ruby.codeInsight.symbols.structure.Symbol in project intellij-plugins by JetBrains.
the class RubyMotionOverrideTest method doTest.
private void doTest(@NotNull final String name, @NotNull final String result) throws Exception {
final Symbol controller = SymbolUtil.findSymbol(getProject(), Type.CLASS, "TestController", null);
assertNotNull(controller);
final List<ClassMember> list = RubyOverrideHandler.createOverrideMembers(controller, myFixture.getFile());
final StringBuilder namesInClass = new StringBuilder();
for (ClassMember classMember : list) {
MemberChooserObjectBase methodMember = (MemberChooserObjectBase) classMember;
if (name.equals(methodMember.getText())) {
final PsiElement element = OverriddenMethodGenerator.generate(classMember, LanguageLevel.RUBY19);
assertNotNull(element);
namesInClass.append(element.getText()).append("\n");
}
}
assertEquals(result, namesInClass.toString().trim());
}
Aggregations