code: private CourierImportDeclarations addFirstImport(CourierImportDeclaration importDecl) {
      TypeName first = importDecl.getFullname();
      CourierTopLevel root = getRoot();
      CourierImportDeclarations importDecls = root.getImportDeclarations();
      if (importDecls.getImportDeclarationList().size() == 0) {
        importDecls.delete();
        CourierImportDeclarations emptyImports =
          CourierElementFactory.createImports(getProject(), Collections.singleton(first));
  
        CourierNamespaceDeclaration namespaceDecl = root.getNamespaceDeclaration();
        if (namespaceDecl != null) {
          root.addAfter(emptyImports, namespaceDecl);
        } else {
          PsiElement firstChild = root.getFirstChild();
          if (firstChild != null) {
            root.addBefore(emptyImports, firstChild);
          } else {
            root.add(emptyImports);
          }
        }
        return emptyImports;
      } else {
        return importDecls;
      }
    }
docs: Position imports correctly when adding the first import.