Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ jobs:
node scripts/compiler/test-live.mjs "$package"
LITHE_JAVA_PROJECT_KIND=eclipse node scripts/compiler/test-live.mjs "$package"
node scripts/compiler/test-project-models.mjs "$package"
node scripts/compiler/test-module-structure.mjs "$package"
- name: Upload native compiler projections
uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -146,6 +147,7 @@ jobs:
package=$(mktemp -d)
unzip -q dist/*-linux-${{ matrix.arch }}.zip -d "$package"
node scripts/compiler/test-project-models.mjs "$package/io.github.lithe-idea.java-support"
node scripts/compiler/test-module-structure.mjs "$package/io.github.lithe-idea.java-support"
rm -rf "$package"
- uses: actions/upload-artifact@v4
with:
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Java Support for Lithe

> **4.0.0 项目结构**:对标 IDEA“项目结构 → 模块”,在设置里逐个模块配置 Eclipse 工程的源文件夹、输出文件夹、JRE 和依赖(JAR、类文件夹、库、其他模块,可标导出与仅测试),保存时写回 `.classpath` 并保留其余内容;Maven/Gradle 模块只读显示解析出的类路径。需要支持 `sourceSettings` 1 的 Lithe 宿主,详见 [docs/module-structure.md](docs/module-structure.md)。
>
> **3.0.1 识别旧式与跨 IDE 工程**:没有 Maven/Gradle 的项目,插件只读识别 Eclipse WTP/MyEclipse 容器
> (Web App Libraries、EAR Libraries、Server Runtime)、IntelliJ IDEA 的模块与库,以及传统 Web 的 `WEB-INF/lib`,
> 在内存中补全类路径并自动找到 Tomcat 等 Servlet 容器,不修改项目文件,详见 [docs/project-models.md](docs/project-models.md)。
Expand Down
1 change: 1 addition & 0 deletions backend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ pub mod class_content;
pub mod jdtls;
pub mod launch;
pub mod library_settings;
pub mod module_structure;
pub mod plugin_functions;
pub mod project_model;
pub mod project_settings;
Expand Down
55 changes: 4 additions & 51 deletions backend/src/library_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ pub const SOURCE_PATHS_FACT: &str = "org.eclipse.jdt.ls.core.sourcePaths";
pub const DESCRIBE_COMMAND: &str = "lithe.java.projectModel.describe";
/// Most lines of one read-only list; the host shows at most 256.
const MAX_LINES: usize = 256;
/// The contract's bound of an effective-source label.
const MAX_LABEL_BYTES: usize = 1024;
/// The contract's bound of one list item.
const MAX_ITEM_BYTES: usize = 4096;

Expand Down Expand Up @@ -147,22 +145,6 @@ impl Page<'_> {
fields
}

/// The effective-source label of an Eclipse project's `.classpath`.
pub fn classpath_label(&self, project: &Path) -> String {
let zh = self.zh;
let mut label = text(
zh,
"Eclipse JDT project settings",
"Eclipse JDT 项目生效配置",
);
let lines = self.container_lines(project, true);
if !lines.is_empty() {
label.push_str(if zh { ";容器:" } else { "; containers: " });
label.push_str(&lines.join(if zh { "," } else { ", " }));
}
truncate(label, MAX_LABEL_BYTES)
}

/// Read-only sources of the model. `taken` holds the paths of the
/// writable sources, which a read-only row must not reuse.
pub fn model_sources(&self, taken: &[PathBuf]) -> Vec<(String, PathBuf, Vec<Value>)> {
Expand Down Expand Up @@ -256,7 +238,7 @@ impl Page<'_> {
continue;
}
let path = location.join(".project");
let lines = self.container_lines(&location, false);
let lines = self.container_lines(&location);
if lines.is_empty()
|| taken.contains(&path)
|| sources.iter().any(|(_, known, _)| known == &path)
Expand Down Expand Up @@ -290,8 +272,8 @@ impl Page<'_> {
}

/// One line per container, variable and missing library of the project
/// at `location`. `brief` keeps only the containers this plugin resolves.
fn container_lines(&self, location: &Path, brief: bool) -> Vec<String> {
/// at `location`.
fn container_lines(&self, location: &Path) -> Vec<String> {
let zh = self.zh;
let Some(project) = self.described_projects().into_iter().find(|project| {
project["location"].as_str().is_some_and(|value| {
Expand All @@ -305,10 +287,6 @@ impl Page<'_> {
for entry in project["entries"].as_array().into_iter().flatten() {
let kind = entry["containerKind"].as_str().unwrap_or("other");
let status = entry["status"].as_str().unwrap_or("unbound");
let ours = entry["kind"] == "container" && kind != "other";
if brief && !ours {
continue;
}
if entry["kind"] == "container" && kind == "other" && status != "unbound" {
continue;
}
Expand Down Expand Up @@ -359,28 +337,7 @@ impl Page<'_> {
}
_ => text(zh, "cannot be resolved", "无法解析"),
};
lines.push(
format!(
"{name}{}{state}",
if brief {
if zh {
"("
} else {
" ("
}
} else {
" — "
}
) + if brief {
if zh {
")"
} else {
")"
}
} else {
""
},
);
lines.push(format!("{name} — {state}"));
if lines.len() >= MAX_LINES {
break;
}
Expand Down Expand Up @@ -813,10 +770,6 @@ mod tests {
explicit: &explicit,
described: Some(&described),
};
assert_eq!(
page.classpath_label(&root.join("app")),
"Eclipse JDT project settings; containers: Web App Libraries (37 JARs), Server Runtime [Tomcat] (no servlet container found)"
);
let rows = page.eclipse_sources(&[]);
assert_eq!(rows.len(), 1);
assert_eq!(rows[0].1, root.join("app/.project"));
Expand Down
Loading
Loading