Search in sources :

Example 1 with RListOfExpressions

use of org.jetbrains.plugins.ruby.ruby.lang.psi.expressions.RListOfExpressions in project intellij-plugins by JetBrains.

the class SelectorKeysProvider method determineArgNumberAndPath.

private static Pair<Integer, List<String>> determineArgNumberAndPath(ParamContext context) {
    final RPsiElement element = context.getValueElement();
    final PsiElement parent = element.getParent();
    final PsiElement argument = parent instanceof RAssoc ? parent : element;
    final RListOfExpressions expressions = RListOfExpressionsNavigator.getByPsiElement(argument);
    if (expressions == null)
        return Pair.create(-1, null);
    final List<String> path = new ArrayList<>();
    for (int i = 1; i < expressions.getElements().size(); i++) {
        PsiElement arg = expressions.getElements().get(i);
        if (arg == argument)
            return Pair.create(i, path);
        if (arg instanceof RAssoc) {
            path.add(((RAssoc) arg).getKeyText());
        }
    }
    return Pair.create(-1, null);
}
Also used : RPsiElement(org.jetbrains.plugins.ruby.ruby.lang.psi.RPsiElement) RAssoc(org.jetbrains.plugins.ruby.ruby.lang.psi.assoc.RAssoc) RListOfExpressions(org.jetbrains.plugins.ruby.ruby.lang.psi.expressions.RListOfExpressions) PsiElement(com.intellij.psi.PsiElement) RPsiElement(org.jetbrains.plugins.ruby.ruby.lang.psi.RPsiElement)

Aggregations

PsiElement (com.intellij.psi.PsiElement)1 RPsiElement (org.jetbrains.plugins.ruby.ruby.lang.psi.RPsiElement)1 RAssoc (org.jetbrains.plugins.ruby.ruby.lang.psi.assoc.RAssoc)1 RListOfExpressions (org.jetbrains.plugins.ruby.ruby.lang.psi.expressions.RListOfExpressions)1