GrVariable (GrIntroduceContext context, GrIntroduceConstantSettings settings, boolean processUsages) { return refactorInWriteAction(() -> { if (processUsages) { return new GrIntroduceConstantProcessor(context, settings).run(); } else { PsiElement scope = context.getScope(); return new GrIntroduceConstantProcessor(context, settings).addDeclaration(scope instanceof GroovyFileBase ? ((GroovyFileBase)scope).getScriptClass() : (PsiClass)scope).getVariables()[0]; } }); }