дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-08 19:02:17 +02:00
fix(editor): say when a file is outside the language server's projects (#1046)
jdtls only checks the syntax of a Java file outside every module's source folders (or outside any imported project) and answers navigation with nothing. The editor then said only "Cannot find declaration to go to", and the server's explanation was a warning squiggle on line 1. - A banner above the editor explains it while the server reports it, for jdtls (not on the classpath of a project / non-project file), gopls (no package, build constraints — this replaces the Go-only banner) and rust-analyzer (unlinked file). For Java it offers the Maven / Gradle reload when available. - Go to Declaration / Implementation / Type Declaration that finds nothing in such a file gives the reason in its hint. Fixes #827
Цей коміт міститься в:
1 джерело
ae406ca2fb
коміт
98517019e7
9 files changed
+201
-38
No files matched your search
@@ -1,14 +0,0 @@
|
||||
import { expect, it } from "vitest";
|
||||
import { goConstraintExcluded } from "./goConstraints";
|
||||
|
||||
it("recognizes build exclusion without confusing unrelated package errors", () => {
|
||||
expect(
|
||||
goConstraintExcluded("No packages found for open file x.go.\nThis file may be excluded due to its build tags"),
|
||||
).toBe(true);
|
||||
expect(goConstraintExcluded("This file may be excluded due to its GOOS/GOARCH, or other build constraints.")).toBe(
|
||||
true,
|
||||
);
|
||||
expect(goConstraintExcluded("No packages found for open file x.go.")).toBe(false);
|
||||
expect(goConstraintExcluded("undefined: missingSymbol")).toBe(false);
|
||||
expect(goConstraintExcluded("invalid build tags syntax")).toBe(false);
|
||||
});
|
||||
@@ -1,4 +0,0 @@
|
||||
/** Only gopls diagnostics that explicitly identify build exclusion qualify. */
|
||||
export function goConstraintExcluded(message: string): boolean {
|
||||
return /excluded[^\n]*(?:build|GOOS\/GOARCH)/i.test(message);
|
||||
}
|
||||
@@ -5,12 +5,7 @@
|
||||
*/
|
||||
import { registerActions } from "@/platform/actions";
|
||||
import { useProject } from "@/platform/project";
|
||||
import {
|
||||
registerEditorBanner,
|
||||
registerOverlay,
|
||||
registerStatusItem,
|
||||
registerToolWindow,
|
||||
} from "@/workbench/contributions";
|
||||
import { registerOverlay, registerStatusItem, registerToolWindow } from "@/workbench/contributions";
|
||||
import { clearProblems, installProblemsEvents, useProblems } from "./problemsStore";
|
||||
import { installProblemDecorations } from "./decorations";
|
||||
import { ProblemsHeaderActions, ProblemsTabs, ProblemsView, useProblemsHeaderMenu } from "./ProblemsView";
|
||||
@@ -20,7 +15,6 @@ import { findUsages, rerunActiveUsages, resetUsages, showUsageResults, showUsage
|
||||
import { HierarchyTabs, HierarchyView } from "./HierarchyView";
|
||||
import { resetHierarchy, showHierarchy } from "./hierarchy";
|
||||
import { installServerEvents } from "./servers";
|
||||
import { goConstraintExcluded } from "./goConstraints";
|
||||
import { ServerStatus } from "./ServerStatus";
|
||||
import { installWorkspaceEditUndo } from "./workspaceUndo";
|
||||
|
||||
@@ -48,16 +42,6 @@ export function activate(): () => void {
|
||||
});
|
||||
const disposers = [
|
||||
unsubProject,
|
||||
registerEditorBanner({
|
||||
id: "go.buildConstraints",
|
||||
useBanner: (path) => {
|
||||
const excluded = useProblems(
|
||||
(s) =>
|
||||
path.endsWith(".go") && (s.map.get(path)?.get("gopls") ?? []).some((d) => goConstraintExcluded(d.message)),
|
||||
);
|
||||
return excluded ? { text: "This Go file is excluded by the current build constraints." } : null;
|
||||
},
|
||||
}),
|
||||
installProblemsEvents(),
|
||||
installProblemDecorations(),
|
||||
installServerEvents(),
|
||||
|
||||
Reference in new issue
Заблокувати користувача