Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

sort module-info

未關閉
#643 0 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 2 天內回覆

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
35/100
Issue 類型
功能
描述清晰度
基本清楚
活躍度
停滯
技術堆疊
java
領域
tooling

研究方向

首先查看 issue 中的 module-info.java 範例以及連結的 JLS 第 7.7 節,以確定 directive 和 modifier 所需的排序。完成的標準是模組宣告能夠保持一致的排序,其中 requires、requires static 和 requires transitive 分成獨立的群組,同時 exports 和 opens 也依適當順序排列。

由索引模型根據 Issue 內容生成。

描述

Prettier-Java 2.5.0

Input:

module com.xenoterracide.tools.java {
  exports com.xenoterracide.tools0.java.function;
  exports com.xenoterracide.tools0.java.annotation;
  requires java.base;
  requires jakarta.annotation;
}

Output:

module com.xenoterracide.tools.java {
  exports com.xenoterracide.tools0.java.function;
  exports com.xenoterracide.tools0.java.annotation;
  requires java.base;
  requires jakarta.annotation;
}

Expected behavior:

some kind of sorting, for convienience, like sorting imports. Note: I don't think functionally the order matters, but I've linked the JLS spec in case it defines it. It does seem to show an order (that's not alphabetic only). Also I don't have an opinion other than it should sort and should conform to JLS.

I'll be honest, I haven't really read this spec, so please verify my output conforms.. but it looks like it should be as follows. Obviously my example is not comprehensive https://docs.oracle.com/javase/specs/jls/se9/html/jls-7.html#jls-7.7

module com.xenoterracide.tools.java {
  requires jakarta.annotation;
  requires java.base;
  exports com.xenoterracide.tools0.java.annotation;
  exports com.xenoterracide.tools0.java.function;
}

note: I think it's acceptable just to make this an alpha sort with some grouping, e.g. requires and requires static and requires transient are different groups. requires stuff shouldn't be mixed next to requires static. This is currently one of my most complex examples.

import org.jspecify.annotations.NullMarked;

/**
 * JPA utilities.
 */
@NullMarked module com.xenoterracide.commons.jpa {
  exports com.xenoterracide.commons.jpa;
  exports com.xenoterracide.commons.jpa.annotation;
  exports com.xenoterracide.commons.jpa.util;
  exports com.xenoterracide.commons.jpa.transaction to spring.beans, spring.context;

  opens com.xenoterracide.commons.jpa to org.hibernate.orm.core, spring.core, org.hibernate.validator;
  opens com.xenoterracide.commons.jpa.transaction to spring.core;

  requires org.apache.commons.lang3;
  requires spring.data.commons;
  requires spring.beans;
  requires spring.context;
  requires spring.tx;
  requires org.hibernate.orm.envers;

  requires static org.jspecify;
  requires static com.xenoterracide.tools.java;
  requires static jakarta.annotation;
  requires static org.jmolecules.architecture.layered;

  requires transitive jakarta.persistence;
  requires transitive jakarta.validation;
  requires transitive com.xenoterracide.model;
  requires org.jmolecules.ddd;
}
主要語言
Java
星號
1.2k
分支
123
平均合併
2 天 10 小時
30 天內合併 PR
35

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

jhipster/prettier-java 的其他 Issue

查看 jhipster/prettier-java 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。