boolean (@NotNull PsiElement elementToRename, PsiElement nameSuggestionContext) { //local vars & params renames GrVariableInplaceRenameHandler if (nameSuggestionContext != null && nameSuggestionContext.getContainingFile() != elementToRename.getContainingFile()) return false; if (!(elementToRename instanceof GrLabeledStatement)) { return false; } SearchScope useScope = PsiSearchHelper.getInstance(elementToRename.getProject()).getUseScope(elementToRename); if (!(useScope instanceof LocalSearchScope)) return false; PsiElement[] scopeElements = ((LocalSearchScope)useScope).getScope(); if (scopeElements.length > 1) { return false; } PsiFile containingFile = elementToRename.getContainingFile(); return PsiTreeUtil.isAncestor(containingFile, scopeElements[0], false); }