private void selectOnMethod(ModuleDeclaration parsedUnit, CallExpression parentCall) { String methodName = parentCall.getName(); ASTNode receiver = parentCall.getReceiver(); final List<IModelElement> availableMethods = new ArrayList<IModelElement>(); if (receiver == null) { IEvaluatedType type = RubyTypeInferencingUtils.determineSelfClass( mixinModel, sourceModule, parsedUnit, parentCall.sourceStart()); if ((type != null) && "Object".equals(type.getTypeName())) { // $NON-NLS-1$ ExpressionTypeGoal goal = new ExpressionTypeGoal(new BasicContext(sourceModule, parsedUnit), parsedUnit); IEvaluatedType type2 = inferencer.evaluateType(goal, 2000); if (type2 != null) { type = type2; } } IMethod[] m = RubyModelUtils.searchClassMethodsExact( mixinModel, sourceModule, parsedUnit, type, methodName); addArrayToCollection(m, availableMethods); } else { ExpressionTypeGoal goal = new ExpressionTypeGoal(new BasicContext(sourceModule, parsedUnit), receiver); IEvaluatedType type = inferencer.evaluateType(goal, 5000); IMethod[] m = RubyModelUtils.searchClassMethodsExact( mixinModel, sourceModule, parsedUnit, type, methodName); addArrayToCollection(m, availableMethods); if (receiver instanceof VariableReference) { IMethod[] availableMethods2 = RubyModelUtils.getSingletonMethods( mixinModel, (VariableReference) receiver, parsedUnit, sourceModule, methodName); addArrayToCollection(availableMethods2, availableMethods); } } if (availableMethods.isEmpty()) { searchMethodDeclarations(sourceModule.getScriptProject(), methodName, availableMethods); } if (!availableMethods.isEmpty()) { for (int i = 0, size = availableMethods.size(); i < size; ++i) { final IMethod m = (IMethod) availableMethods.get(i); if (methodName.equals(methodName)) { selectionElements.add(m); } } } }
private void selectOnSuper(ModuleDeclaration parsedUnit, RubySuperExpression superExpr) { RubyClassType selfClass = RubyTypeInferencingUtils.determineSelfClass( mixinModel, sourceModule, parsedUnit, superExpr.sourceStart()); MethodDeclaration enclosingMethod = ASTUtils.getEnclosingMethod(wayToNode, superExpr, false); if (enclosingMethod != null) { String name = enclosingMethod.getName(); RubyMixinClass rubyClass = mixinModel.createRubyClass(selfClass); RubyMixinClass superclass = rubyClass.getSuperclass(); RubyMixinMethod method = superclass.getMethod(name); if (method != null) { IMethod[] sourceMethods = method.getSourceMethods(); addArrayToCollection(sourceMethods, selectionElements); } } }