private void apply(@NotNull Project project, @NotNull TargetDirectory directory, @Nullable Editor editor) {
    myIsAvailableTimeStamp = 0; // to revalidate applicability

    try {
      Supplier<PsiDirectory> toDirectory = () -> {
        PsiDirectory currentDirectory = directory.getDirectory();
        if (currentDirectory == null) {
          return null;
        }

        for (String pathPart : directory.getPathToCreate()) {
          currentDirectory = findOrCreateSubdirectory(currentDirectory, pathPart);
        }

        for (String pathPart : mySubPath) {
          currentDirectory = findOrCreateSubdirectory(currentDirectory, pathPart);
        }

        if (currentDirectory == null) {
          if (editor != null) {
            throw new IncorrectCreateFilePathException(CodeInsightBundle.message("create.file.incorrect.path.hint", myNewFileName));
          }
          return null;
        }
        return currentDirectory;
      };

      apply(project, toDirectory, editor);
    }
    catch (IncorrectOperationException e) {
      myIsAvailable = false;
    }
  }
private void apply(@NotNull Project project, @NotNull TargetDirectory directory, @Nullable Editor editor)