void (final PsiDirectory baseDirectory, PsiElement myContext) { final PsiManager manager = baseDirectory.getManager(); PsiDirectory directory = baseDirectory; String lastName; for (StringTokenizer st = new StringTokenizer(myRedPart, "."); ;) { lastName = st.nextToken(); if (st.hasMoreTokens()) { try { final PsiDirectory subdirectory = directory.findSubdirectory(lastName); directory = subdirectory != null ? subdirectory : directory.createSubdirectory(lastName); } catch (IncorrectOperationException e) { CreateFromUsageUtils.scheduleFileOrPackageCreationFailedMessageBox(e, lastName, directory, true); return; } } else { break; } } if (myClassKind != null) { PsiClass createdClass; if (myTemplateName != null) { createdClass = CreateClassUtil.createClassFromCustomTemplate(directory, null, lastName, myTemplateName); } else { createdClass = CreateFromUsageUtils .createClass(myClassKind == ClassKind.INTERFACE ? CreateClassKind.INTERFACE : CreateClassKind.CLASS, directory, lastName, manager, myContext, null, mySuperClass); } if (createdClass != null) { createdClass.navigate(true); } } else { try { directory.createSubdirectory(lastName); } catch (IncorrectOperationException e) { CreateFromUsageUtils.scheduleFileOrPackageCreationFailedMessageBox(e, lastName, directory, true); } } }