mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[groovy] validate class name in New Class dialog (IDEA-175434)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,10 +31,9 @@ import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.psi.JavaDirectoryService;
|
||||
import com.intellij.psi.PsiDirectory;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.openapi.ui.InputValidatorEx;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import icons.JetgroovyIcons;
|
||||
@@ -76,6 +75,20 @@ public class NewGroovyClassAction extends JavaCreateTemplateInPackageAction<GrTy
|
||||
builder.addKind(template.getName(), JetgroovyIcons.Groovy.Class, template.getName());
|
||||
}
|
||||
}
|
||||
|
||||
builder.setValidator(new InputValidatorEx() {
|
||||
|
||||
@Override
|
||||
public String getErrorText(String inputString) { return "This is not a valid Groovy qualified name"; }
|
||||
|
||||
@Override
|
||||
public boolean checkInput(String inputString) { return true; }
|
||||
|
||||
@Override
|
||||
public boolean canClose(String inputString) {
|
||||
return !StringUtil.isEmptyOrSpaces(inputString) && PsiNameHelper.getInstance(project).isQualifiedName(inputString);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user