use of org.jetbrains.plugins.ruby.ruby.codeInsight.resolve.scope.ScopeVariable in project intellij-plugins by JetBrains.
the class MotionDebuggerTypesHelper method resolveToDeclaration.
@Override
public PsiElement resolveToDeclaration(XSourcePosition position, LLValue var) {
final String name = var.getName();
final VirtualFile file = position.getFile();
final int offset = position.getOffset();
final PsiFile psiFile = PsiManager.getInstance(myProcess.getProject()).findFile(file);
if (psiFile == null)
return null;
final PsiElement element = RubyPsiUtil.getSignificantLeafToTheRight(psiFile.findElementAt(offset));
final RContainer container = element != null ? RubyPsiUtil.getParentContainerOrSelf(element) : null;
if (container == null)
return null;
ScopeVariable variable = null;
for (ScopeVariable scopeVariable : container.getScope().getAllDeclaredVariables()) {
if (name.equals(scopeVariable.getName())) {
variable = scopeVariable;
break;
}
}
if (variable == null)
return null;
final RPsiElement item = ContainerUtil.getFirstItem(variable.getDeclarations());
if (item == null)
return null;
return item;
}
Aggregations