use of com.intellij.psi.PsiNameHelper in project intellij-community by JetBrains.
the class GroovyCreateClassDialog method createCenterPanel.
@Override
@Nullable
protected JComponent createCenterPanel() {
myPackageTextField.getDocument().addDocumentListener(new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent e) {
PsiNameHelper nameHelper = PsiNameHelper.getInstance(myProject);
String packageName = getPackageName();
getOKAction().setEnabled(nameHelper.isQualifiedName(packageName) || packageName != null && packageName.isEmpty());
}
});
new AnAction() {
@Override
public void actionPerformed(AnActionEvent e) {
myPackageChooseButton.doClick();
}
}.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.SHIFT_DOWN_MASK)), myPackageTextField);
return myContentPane;
}
use of com.intellij.psi.PsiNameHelper in project intellij-community by JetBrains.
the class ClassPatternsPanel method getValidationError.
public String getValidationError(Project project) {
TableUtil.stopEditing(myTable);
final PsiNameHelper nameHelper = PsiNameHelper.getInstance(project);
final ClassPatternValidator validator = new ClassPatternValidator(nameHelper);
for (EntryPointsManagerBase.ClassPattern pattern : myModifiedPatterns) {
final String errorText = validator.getErrorText(pattern.pattern);
if (errorText != null) {
return errorText;
}
final String subst = pattern.method.replace("*", "");
if (!subst.isEmpty()) {
if (!nameHelper.isIdentifier(subst)) {
return "Method pattern '" + pattern.method + "' must be a valid java identifier, only '*' are accepted as placeholders";
}
}
}
return null;
}
use of com.intellij.psi.PsiNameHelper in project intellij-community by JetBrains.
the class CreatePackageInfoAction method isAvailable.
private static boolean isAvailable(DataContext dataContext) {
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
if (project == null || view == null) {
return false;
}
final PsiDirectory[] directories = view.getDirectories();
if (directories.length == 0) {
return false;
}
final ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(project).getFileIndex();
final JavaDirectoryService directoryService = JavaDirectoryService.getInstance();
final PsiNameHelper nameHelper = PsiNameHelper.getInstance(project);
for (PsiDirectory directory : directories) {
if (projectFileIndex.isUnderSourceRootOfType(directory.getVirtualFile(), JavaModuleSourceRootTypes.SOURCES) && PsiUtil.isLanguageLevel5OrHigher(directory)) {
final PsiPackage aPackage = directoryService.getPackage(directory);
if (aPackage != null) {
final String qualifiedName = aPackage.getQualifiedName();
if (StringUtil.isEmpty(qualifiedName) || nameHelper.isQualifiedName(qualifiedName)) {
return true;
}
}
}
}
return false;
}
use of com.intellij.psi.PsiNameHelper in project intellij-community by JetBrains.
the class BindToNewBeanStep method _commit.
public void _commit(boolean finishChosen) throws CommitStepException {
// Stop editing if any
final TableCellEditor cellEditor = myTable.getCellEditor();
if (cellEditor != null) {
cellEditor.stopCellEditing();
}
// Check that all included fields are bound to valid bean properties
final PsiNameHelper nameHelper = PsiNameHelper.getInstance(myData.myProject);
for (int i = 0; i < myData.myBindings.length; i++) {
final FormProperty2BeanProperty binding = myData.myBindings[i];
if (binding.myBeanProperty == null) {
continue;
}
if (!nameHelper.isIdentifier(binding.myBeanProperty.myName)) {
throw new CommitStepException(UIDesignerBundle.message("error.X.is.not.a.valid.property.name", binding.myBeanProperty.myName));
}
}
myData.myGenerateIsModified = myChkIsModified.isSelected();
}
use of com.intellij.psi.PsiNameHelper in project liferay-ide by liferay.
the class LiferayModuleWizardStep method validate.
@Override
public boolean validate() throws ConfigurationException {
String validationTitle = "Validation Error";
if (CoreUtil.isNullOrEmpty(getSelectedType())) {
throw new ConfigurationException("Please click one of the items to select a template", validationTitle);
}
ProjectManager projectManager = ProjectManager.getInstance();
Project workspaceProject = projectManager.getOpenProjects()[0];
String packageNameValue = getPackageName();
String classNameValue = getClassName();
PsiDirectoryFactory psiDirectoryFactory = PsiDirectoryFactory.getInstance(workspaceProject);
PsiNameHelper psiNameHelper = PsiNameHelper.getInstance(workspaceProject);
if (!CoreUtil.isNullOrEmpty(packageNameValue) && !psiDirectoryFactory.isValidPackageName(packageNameValue)) {
throw new ConfigurationException(packageNameValue + " is not a valid package name", validationTitle);
}
if (!CoreUtil.isNullOrEmpty(classNameValue) && !psiNameHelper.isQualifiedName(classNameValue)) {
throw new ConfigurationException(classNameValue + " is not a valid java class name", validationTitle);
}
return true;
}
Aggregations