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
26 changes: 26 additions & 0 deletions rust/lithe-core/src/execution/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,32 @@ pub fn inspect(request: InspectRequest) -> Result<Value, CoreError> {
}));
}
}
if let Some(document) = generated.as_ref() {
// A Java main entry without a recorded main class cannot launch and
// cannot be rebuilt from local sources -- JDT owns entry points -- so
// hosts must be told to regenerate while the language service can
// answer, instead of letting the stale entry surface as something
// else. A `spring-boot.maven` compatibility entry carries no main
// class by design and is not stale.
let stale = document
.configurations
.iter()
.filter(|configuration| configuration.provider == "java.main")
.filter(|configuration| {
configuration
.main_class()
.is_none_or(|main_class| main_class.trim().is_empty())
})
.count();
if stale > 0 {
diagnostics.push(json!({
"code": "staleJavaEntrypoint",
"message": format!(
"Java run entries are missing their main class ({stale}); regenerate run configurations"
)
}));
}
}
Ok(json!({
"status": if generated.is_some() { "ready" } else { "missing" },
"generated": generated,
Expand Down
7 changes: 5 additions & 2 deletions rust/lithe-core/src/lsp/interface/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9542,12 +9542,15 @@ public class Main {
.expect("a terminal build verdict must include its evidence");
assert_eq!(report.marker_scope, JavaBuildMarkerScope::Workspace);
assert!(!report.builder_failed_earlier);
assert_eq!(report.recovery, JavaBuildRecovery::None);
assert_eq!(report.recovery, JavaBuildRecovery::RebuildJavaIndex);
let serialized = serde_json::to_value(error).expect("runtime error should serialize");
assert_eq!(serialized["javaBuildReport"]["markerScope"], "workspace");
assert_eq!(serialized["javaBuildReport"]["builderFailedEarlier"], false);
assert!(serialized["javaBuildReport"]["elapsedMilliseconds"].is_u64());
assert_eq!(serialized["javaBuildReport"]["recovery"], "none");
assert_eq!(
serialized["javaBuildReport"]["recovery"],
"rebuildJavaIndex"
);
}
let builds_written = harness
.server
Expand Down
43 changes: 37 additions & 6 deletions rust/lithe-core/src/lsp/languages/jdt_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,13 @@ pub(crate) enum JavaBuildMarkerScope {
pub(crate) enum JavaBuildRecovery {
/// Nothing beyond fixing the reported code is indicated.
None,
/// The language service's own builder failed, which leaves error markers
/// that later builds neither refresh nor clear. Resetting the Java index is
/// the only way back to a trustworthy verdict.
/// The build reached a verdict about the code -- a builder failure or
/// error markers -- that may not describe the current sources: a failed
/// builder leaves markers that later builds neither refresh nor clear, and
/// error markers can also be decided by unrelated projects when the marker
/// scope widened. Resetting the Java index is the way back to a
/// trustworthy verdict, so it is offered alongside fixing the reported
/// errors.
RebuildJavaIndex,
}

Expand Down Expand Up @@ -224,13 +228,25 @@ pub(crate) fn java_build_marker_scope(command: &Value) -> JavaBuildMarkerScope {
}

/// Builds the report that accompanies an unsuccessful build.
///
/// Any verdict about the code carries the rebuild option: a builder failure
/// leaves markers that later builds neither refresh nor clear, error markers
/// can be decided by unrelated projects when the marker scope widened, and a
/// project opened for the first time can still be mid-import while its
/// markers already read as errors. Cancellation and unrecognized results
/// reached no verdict about the code, so there the only useful action is a
/// retry.
pub(crate) fn java_build_report(
outcome: JavaBuildOutcome,
command: &Value,
builder_failed_earlier: bool,
elapsed: Duration,
) -> JavaBuildReport {
let recovery = if outcome == JavaBuildOutcome::Failed || builder_failed_earlier {
let recovery = if matches!(
outcome,
JavaBuildOutcome::Failed | JavaBuildOutcome::CompilationErrors
) || builder_failed_earlier
{
JavaBuildRecovery::RebuildJavaIndex
} else {
JavaBuildRecovery::None
Expand Down Expand Up @@ -798,21 +814,36 @@ mod tests {
}

#[test]
fn compilation_errors_without_a_builder_failure_need_no_workspace_reset() {
fn every_code_verdict_offers_the_workspace_reset() {
let mut coordinator = JavaBuildCoordinator::default();
coordinator.observe_outcome(JavaBuildOutcome::Succeeded);
coordinator.observe_outcome(JavaBuildOutcome::Cancelled);
assert!(!coordinator.builder_failed_earlier());

// Error markers can predate or misdescribe the current sources even
// without a builder failure -- a first import can still be running,
// and a widened marker scope lets unrelated projects decide the
// verdict -- so the rebuild option stays available for every verdict
// about the code.
let report = java_build_report(
JavaBuildOutcome::CompilationErrors,
&json!({ "command": JAVA_BUILD_WORKSPACE_COMMAND, "arguments": [] }),
coordinator.builder_failed_earlier(),
Duration::from_millis(12511),
);
assert!(!report.builder_failed_earlier);
assert_eq!(report.recovery, JavaBuildRecovery::None);
assert_eq!(report.recovery, JavaBuildRecovery::RebuildJavaIndex);
assert_eq!(report.marker_scope, JavaBuildMarkerScope::Workspace);

// A cancelled build reached no verdict about the code, so resetting
// the workspace is not indicated.
let cancelled = java_build_report(
JavaBuildOutcome::Cancelled,
&json!({ "command": JAVA_BUILD_WORKSPACE_COMMAND, "arguments": [] }),
coordinator.builder_failed_earlier(),
Duration::from_millis(4),
);
assert_eq!(cancelled.recovery, JavaBuildRecovery::None);
}

#[test]
Expand Down
46 changes: 46 additions & 0 deletions rust/lithe-core/src/tests/run_configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2350,6 +2350,52 @@ fn run_configuration_regeneration_keeps_surviving_ids_and_orphans_removed_overri
fs::remove_dir_all(root).unwrap();
}

/// A `java.main` configuration whose recorded main class is missing cannot
/// launch and cannot be rebuilt from local sources, so inspection must report
/// it as stale -- while a complete entry and a `spring-boot.maven`
/// compatibility entry (which carries no main class by design) stay silent.
#[test]
fn run_configuration_inspection_reports_java_entries_missing_their_main_class() {
let root = temporary_root("run-config-stale-java-entry");
fs::create_dir_all(root.join(".lithe/run")).unwrap();
fs::write(
root.join(".lithe/run/generated.json"),
r#"{"version":2,"configurations":[
{"id":"java-main:demo.App","name":"App","provider":"java.main","execution":"application","toolchains":{"java":"project-jdk"},"extensions":{"maven":{"module":"."},"java":{"source":"src/App.java"}}},
{"id":"java-main:demo.Blank","name":"Blank","provider":"java.main","execution":"application","toolchains":{"java":"project-jdk"},"extensions":{"maven":{"module":".","mainClass":""},"java":{"source":"src/Blank.java"}}},
{"id":"java-main:demo.Whole","name":"Whole","provider":"java.main","execution":"application","toolchains":{"java":"project-jdk"},"extensions":{"maven":{"module":".","mainClass":"demo.Whole"},"java":{"source":"src/Whole.java"}}},
{"id":"spring-boot.maven:legacy","name":"Legacy","provider":"spring-boot.maven","execution":"service","toolchains":{"java":"project-jdk","maven":"project-maven"},"extensions":{"maven":{"module":"."}}}
]}"#,
)
.unwrap();

let inspected: Value = serde_json::from_str(&execute_json(
&serde_json::json!({
"id": "inspect-stale-java-entry",
"command": "runConfig.inspect",
"payload": {"root": root}
})
.to_string(),
))
.unwrap();
assert_eq!(inspected["ok"], true, "{inspected}");
let diagnostics = inspected["data"]["diagnostics"].as_array().unwrap();
let stale = diagnostics
.iter()
.filter(|value| value["code"] == "staleJavaEntrypoint")
.collect::<Vec<_>>();
assert_eq!(stale.len(), 1, "{inspected}");
assert!(
stale[0]["message"]
.as_str()
.unwrap_or_default()
.contains("(2)"),
"{inspected}"
);

fs::remove_dir_all(root).unwrap();
}

fn generator_fingerprint_for_revision(inputs: &Value, revision: &str) -> String {
let inputs = serde_json::from_value::<BTreeMap<String, String>>(inputs.clone()).unwrap();
let mut digest = Sha256::new();
Expand Down
2 changes: 1 addition & 1 deletion scripts/verify-shared-contracts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ windows_lithe_theme="windows/tauri/src/extensions/themes/builtin/lithe.json"
expected_fields = %w[builderFailedEarlier elapsedMilliseconds markerScope recovery]
abort "Java build report fields differ from v1" unless reports.all? { |report| report.keys.sort == expected_fields }
abort "Java build report fixture must cover both marker scopes" unless reports.map { |report| report.fetch("markerScope") }.sort == %w[launchTarget workspace]
abort "Java build report fixture must cover index recovery" unless reports.any? { |report| report.fetch("recovery") == "rebuildJavaIndex" }
abort "Java build report fixture must give every code verdict the index rebuild" unless reports.all? { |report| report.fetch("recovery") == "rebuildJavaIndex" }
non_continuable = fixture.fetch("nonContinuableCodes")
abort "Java build report fixture must keep cancellation and timeout non-continuable" unless %w[javaBuildCancelled requestCancelled requestTimeout].all? { |code| non_continuable.include?(code) }
' "$java_build_report_fixture"
Expand Down
2 changes: 1 addition & 1 deletion shared/fixtures/lsp/java-build-report-v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"markerScope": "launchTarget",
"builderFailedEarlier": false,
"elapsedMilliseconds": 506,
"recovery": "none"
"recovery": "rebuildJavaIndex"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
"verificationStatus": "pending"
},
"owner": "Java / Maven",
"verification": "使用成功、编译失败和进程失败构建 fixture,对比诊断位置、输出和退出状态。 Windows Maven 构建输出使用 Geist Mono 显示 ====、==>、=>、!=、>=,确认禁用连字后逐字符显示且复制文本与原始输出一致;检查有输出与空态、ANSI 颜色、自动换行切换及横向滚动。"
"verification": "使用成功、编译失败和进程失败构建 fixture,对比诊断位置、输出和退出状态。 Windows Maven 构建输出使用 Geist Mono 显示 ====、==>、=>、!=、>=,确认禁用连字后逐字符显示且复制文本与原始输出一致;检查有输出与空态、ANSI 颜色、自动换行切换及横向滚动;验证构建终态为编译错误或构建器失败时提供重建 Java 索引的恢复动作(取消与未知结果不提供),构建证据随失败上报。"
}
2 changes: 1 addition & 1 deletion shared/platform-feature-matrix/features/run-discovery.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@
"verificationStatus": "pending"
},
"owner": "Run",
"verification": "验证 Spring Boot、Java、Maven、Gradle、npm、Cargo、Go、Python 和 Docker Compose 入口识别;Maven 框架 plugin 只在父 POM 声明时,子模块沿 <parent> 链继承后仍识别为对应服务,父 POM 按 groupId:artifactId:version 完整坐标匹配、仅同名 artifactId 或版本不符的不继承、含未解析 ${...} 表达式的坐标不作数,聚合但未声明 <parent> 的模块不继承、<inherited>false</inherited> 的 plugin 不下传且对更深层级保持阻断、<pluginManagement> 声明保持不生效、框架 plugin 按完整坐标 groupId:artifactId 识别:每个框架的全部官方坐标组均被接受(Quarkus 的 io.quarkus 与平台再发布的 io.quarkus.platform,Micronaut 3.x 的 io.micronaut.build 与 4+ 的 io.micronaut.maven,Spring Boot 的 org.springframework.boot)、省略 <groupId> 的声明按 Maven 默认组 org.apache.maven.plugins 处理,其他组下的同名插件与含 ${...} 表达式的 group 不识别为框架,子模块的同名自定义 plugin 也不遮蔽父继承的正品;源码根与报告目录的提取同样按完整坐标匹配,build-helper 执行级源根与 Surefire/Failsafe 独立 reportsDirectory 均有官方组与自定义组对照;多模块项目把服务工作目录改成模块目录后,服务仍留在列表中并以该目录启动;填写不存在的目录或 ${workspaceFolder} 等变量时,保存被拒绝并提示原因;在 Windows 确认重新扫描服务使用双箭头刷新图标,配置按语言生态、类型与实例呈现三栏布局,Java 下展示 Maven、Gradle 与 Spring Boot 等已识别类型,Node.js 下展示包管理器与框架;语言切换和外部选中能定位配置,空生态不显示,语言和配置栏不显示重复栏头,生态不显示配置数量;语言侧栏通过拖动阈值折叠和展开,收起与展开阈值不同以避免边界跳动,不显示专门折叠按钮;键盘可调整宽度及恢复展开,保存展开宽度与拖动折叠状态,拖动期间只更新局部宽度和紧凑标记,文字与图标对齐即时切换,结束后保存;语言行、类型行和实例行使用一致的紧凑行高,去掉列表上下留白和选中实例的圆角边距;窄面板自动缩成带提示的图标栏且扩大后恢复,右侧输出保留可用空间,窗口缩放或卸载时清理正在进行的拖动;所选配置的日志、运行状态、顶部停止按钮、清空输出与标准输入均指向其自身会话;保持选中 application 并后台启动服务后,顶部停止仍指向 primary,不停止后台服务,左侧使用 SVG 箭头和类型图标,基础设施默认折叠,选择配置自动展开所在分组,运行、停止、编辑和完整名称提示可用;根据 Core 提供的 npm、Gradle 和 Python 元数据展示明确识别的框架图标,构建与测试任务保留工具图标,未知类型回退通用图标;同名自定义 provider 与已知框架分别分组且折叠状态独立,相同已知框架跨 Maven/Gradle provider 合组,项目与基础设施不合组;分组与子项图标一致,运行或失败不改变类型图标,深浅主题均可辨认。"
"verification": "验证 Spring Boot、Java、Maven、Gradle、npm、Cargo、Go、Python 和 Docker Compose 入口识别;Maven 框架 plugin 只在父 POM 声明时,子模块沿 <parent> 链继承后仍识别为对应服务,父 POM 按 groupId:artifactId:version 完整坐标匹配、仅同名 artifactId 或版本不符的不继承、含未解析 ${...} 表达式的坐标不作数,聚合但未声明 <parent> 的模块不继承、<inherited>false</inherited> 的 plugin 不下传且对更深层级保持阻断、<pluginManagement> 声明保持不生效、框架 plugin 按完整坐标 groupId:artifactId 识别:每个框架的全部官方坐标组均被接受(Quarkus 的 io.quarkus 与平台再发布的 io.quarkus.platform,Micronaut 3.x 的 io.micronaut.build 与 4+ 的 io.micronaut.maven,Spring Boot 的 org.springframework.boot)、省略 <groupId> 的声明按 Maven 默认组 org.apache.maven.plugins 处理,其他组下的同名插件与含 ${...} 表达式的 group 不识别为框架,子模块的同名自定义 plugin 也不遮蔽父继承的正品;源码根与报告目录的提取同样按完整坐标匹配,build-helper 执行级源根与 Surefire/Failsafe 独立 reportsDirectory 均有官方组与自定义组对照;Java 运行入口缺少主类时 inspect 报 staleJavaEntrypoint 并提示重新生成,重新生成后由 JDT 答案恢复;多模块项目把服务工作目录改成模块目录后,服务仍留在列表中并以该目录启动;填写不存在的目录或 ${workspaceFolder} 等变量时,保存被拒绝并提示原因;在 Windows 确认重新扫描服务使用双箭头刷新图标,配置按语言生态、类型与实例呈现三栏布局,Java 下展示 Maven、Gradle 与 Spring Boot 等已识别类型,Node.js 下展示包管理器与框架;语言切换和外部选中能定位配置,空生态不显示,语言和配置栏不显示重复栏头,生态不显示配置数量;语言侧栏通过拖动阈值折叠和展开,收起与展开阈值不同以避免边界跳动,不显示专门折叠按钮;键盘可调整宽度及恢复展开,保存展开宽度与拖动折叠状态,拖动期间只更新局部宽度和紧凑标记,文字与图标对齐即时切换,结束后保存;语言行、类型行和实例行使用一致的紧凑行高,去掉列表上下留白和选中实例的圆角边距;窄面板自动缩成带提示的图标栏且扩大后恢复,右侧输出保留可用空间,窗口缩放或卸载时清理正在进行的拖动;所选配置的日志、运行状态、顶部停止按钮、清空输出与标准输入均指向其自身会话;保持选中 application 并后台启动服务后,顶部停止仍指向 primary,不停止后台服务,左侧使用 SVG 箭头和类型图标,基础设施默认折叠,选择配置自动展开所在分组,运行、停止、编辑和完整名称提示可用;根据 Core 提供的 npm、Gradle 和 Python 元数据展示明确识别的框架图标,构建与测试任务保留工具图标,未知类型回退通用图标;同名自定义 provider 与已知框架分别分组且折叠状态独立,相同已知框架跨 Maven/Gradle provider 合组,项目与基础设施不合组;分组与子项图标一致,运行或失败不改变类型图标,深浅主题均可辨认。"
}
4 changes: 3 additions & 1 deletion windows/tauri/src/features/run/components/run-pane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ export default function RunPane() {
selectedConfiguration?.id,
);
const freshnessDiagnostic = diagnostics.find((diagnostic) =>
diagnostic.code === "staleFingerprint" || diagnostic.code === "fingerprintCheckFailed");
diagnostic.code === "staleFingerprint" ||
diagnostic.code === "fingerprintCheckFailed" ||
diagnostic.code === "staleJavaEntrypoint");
const isSelectedRunning = selection.isRunning;
const output = selection.output;
const exitCode = selection.exitCode;
Expand Down
Loading