Search in sources :

Example 1 with GroovyFieldValidator

use of org.jetbrains.plugins.groovy.refactoring.introduce.field.GroovyFieldValidator in project intellij-community by JetBrains.

the class GroovyIntroduceParameterUtil method suggestNames.

static LinkedHashSet<String> suggestNames(GrVariable var, GrExpression expr, StringPartInfo stringPart, GrParametersOwner scope, Project project) {
    if (expr != null) {
        final GrIntroduceContext introduceContext = new GrIntroduceContextImpl(project, null, expr, var, stringPart, PsiElement.EMPTY_ARRAY, scope);
        final GroovyFieldValidator validator = new GroovyFieldValidator(introduceContext);
        return new LinkedHashSet<>(Arrays.asList(GroovyNameSuggestionUtil.suggestVariableNames(expr, validator, true)));
    } else if (var != null) {
        final GrIntroduceContext introduceContext = new GrIntroduceContextImpl(project, null, expr, var, stringPart, PsiElement.EMPTY_ARRAY, scope);
        final GroovyFieldValidator validator = new GroovyFieldValidator(introduceContext);
        LinkedHashSet<String> names = new LinkedHashSet<>();
        names.add(var.getName());
        ContainerUtil.addAll(names, GroovyNameSuggestionUtil.suggestVariableNameByType(var.getType(), validator));
        return names;
    } else {
        LinkedHashSet<String> names = new LinkedHashSet<>();
        names.add("closure");
        return names;
    }
}
Also used : GrIntroduceContext(org.jetbrains.plugins.groovy.refactoring.introduce.GrIntroduceContext) GroovyFieldValidator(org.jetbrains.plugins.groovy.refactoring.introduce.field.GroovyFieldValidator) GrIntroduceContextImpl(org.jetbrains.plugins.groovy.refactoring.introduce.GrIntroduceContextImpl)

Aggregations

GrIntroduceContext (org.jetbrains.plugins.groovy.refactoring.introduce.GrIntroduceContext)1 GrIntroduceContextImpl (org.jetbrains.plugins.groovy.refactoring.introduce.GrIntroduceContextImpl)1 GroovyFieldValidator (org.jetbrains.plugins.groovy.refactoring.introduce.field.GroovyFieldValidator)1