Search in sources :

Example 6 with DefaultGroovyVariableNameValidator

use of org.jetbrains.plugins.groovy.refactoring.DefaultGroovyVariableNameValidator in project intellij-community by JetBrains.

the class GenerationUtil method suggestVarName.

static String suggestVarName(GrExpression expr, ExpressionContext expressionContext) {
    final DefaultGroovyVariableNameValidator nameValidator = new DefaultGroovyVariableNameValidator(expr, expressionContext.myUsedVarNames, true);
    final String[] varNames = GroovyNameSuggestionUtil.suggestVariableNames(expr, nameValidator);
    LOG.assertTrue(varNames.length > 0);
    expressionContext.myUsedVarNames.add(varNames[0]);
    return varNames[0];
}
Also used : DefaultGroovyVariableNameValidator(org.jetbrains.plugins.groovy.refactoring.DefaultGroovyVariableNameValidator)

Aggregations

DefaultGroovyVariableNameValidator (org.jetbrains.plugins.groovy.refactoring.DefaultGroovyVariableNameValidator)6 GrParameter (org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter)3 GroovyPsiElementFactory (org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory)2 JavaCodeStyleManager (com.intellij.psi.codeStyle.JavaCodeStyleManager)1 SuggestedNameInfo (com.intellij.psi.codeStyle.SuggestedNameInfo)1 VariableKind (com.intellij.psi.codeStyle.VariableKind)1 JavaThrownExceptionInfo (com.intellij.refactoring.changeSignature.JavaThrownExceptionInfo)1 ThrownExceptionInfo (com.intellij.refactoring.changeSignature.ThrownExceptionInfo)1 ArrayList (java.util.ArrayList)1 NotNull (org.jetbrains.annotations.NotNull)1 GrField (org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField)1 GrStatement (org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement)1 GrVariable (org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable)1 GrOpenBlock (org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrOpenBlock)1 GrExpression (org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression)1 GrReferenceExpression (org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression)1 GrChangeInfoImpl (org.jetbrains.plugins.groovy.refactoring.changeSignature.GrChangeInfoImpl)1 GrChangeSignatureProcessor (org.jetbrains.plugins.groovy.refactoring.changeSignature.GrChangeSignatureProcessor)1 GrParameterInfo (org.jetbrains.plugins.groovy.refactoring.changeSignature.GrParameterInfo)1