Java 类com.intellij.psi.scope.processor.VariablesNotProcessor 实例源码

项目:intellij-ce-playground    文件:ReuseVariableDeclarationFix.java   
@Nullable
private PsiVariable findPreviousVariable() {
  PsiElement scope = myVariable.getParent();
  while (scope != null) {
    if (scope instanceof PsiFile || scope instanceof PsiMethod || scope instanceof PsiClassInitializer) break;
    scope = scope.getParent();
  }
  if (scope == null) return null;

  PsiIdentifier nameIdentifier = myVariable.getNameIdentifier();
  if (nameIdentifier == null) {
    return null;
  }

  final VariablesNotProcessor processor = new VariablesNotProcessor(myVariable, false);
  PsiScopesUtil.treeWalkUp(processor, nameIdentifier, scope);
  return processor.size() > 0 ? processor.getResult(0) : null;
}
项目:tools-idea    文件:ReuseVariableDeclarationFix.java   
@Nullable
private PsiVariable findPreviousVariable() {
  PsiElement scope = myVariable.getParent();
  while (scope != null) {
    if (scope instanceof PsiFile || scope instanceof PsiMethod || scope instanceof PsiClassInitializer) break;
    scope = scope.getParent();
  }
  if (scope == null) return null;

  PsiIdentifier nameIdentifier = myVariable.getNameIdentifier();
  if (nameIdentifier == null) {
    return null;
  }

  final VariablesNotProcessor processor = new VariablesNotProcessor(myVariable, false);
  PsiScopesUtil.treeWalkUp(processor, nameIdentifier, scope);
  return processor.size() > 0 ? processor.getResult(0) : null;
}
项目:consulo-java    文件:ReuseVariableDeclarationFix.java   
@Nullable
private PsiVariable findPreviousVariable() {
  PsiElement scope = myVariable.getParent();
  while (scope != null) {
    if (scope instanceof PsiFile || scope instanceof PsiMethod || scope instanceof PsiClassInitializer) break;
    scope = scope.getParent();
  }
  if (scope == null) return null;

  PsiIdentifier nameIdentifier = myVariable.getNameIdentifier();
  if (nameIdentifier == null) {
    return null;
  }

  final VariablesNotProcessor processor = new VariablesNotProcessor(myVariable, false);
  PsiScopesUtil.treeWalkUp(processor, nameIdentifier, scope);
  return processor.size() > 0 ? processor.getResult(0) : null;
}