//    @Override
  protected void buildDialog(
      Project project, PsiDirectory directory, CreateFileFromTemplateDialog.Builder builder) {

    PsiFile childs[] = directory.getFiles();

    Set<String> packages = new HashSet<String>();

    for (PsiFile child : childs) {
      if (child instanceof GoFile) {
        GoFile goFile = (GoFile) child;

        if (!goFile.getPackage().isMainPackage()) {
          packages.add(goFile.getPackage().getPackageName());
        }
      }
    }

    builder.addKind("New file", GoIcons.GO_ICON_16x16, "single");

    for (String packageName : packages) {
      builder.addKind(
          "New file in library: " + packageName, GoIcons.GO_ICON_16x16, "lib." + packageName);
    }
  }
  public GoFileMetadata(GoFile file) {
    packageName = file.getPackage().getPackageName();
    main = file.getMainFunction() != null;

    imports = new ArrayList<String>();

    GoImportDeclarations[] importDeclarations = file.getImportDeclarations();

    for (GoImportDeclarations importDeclaration : importDeclarations) {
      GoImportDeclaration[] importSpecs = importDeclaration.getDeclarations();

      for (GoImportDeclaration importSpec : importSpecs) {
        imports.add(importSpec.getImportPath());
      }
    }
  }
 private static void addImportUnderPackage(GoFile file, Document document, String pathToImport) {
   int insertPoint = file.getPackage().getTextRange().getEndOffset();
   document.insertString(insertPoint, String.format("\n\nimport \"%s\"", pathToImport));
 }