Порівняти коміти

..
Автор SHA1 Повідомлення Дата
l0ng-ai 1d7ca96a09 chore(github): add PR template, contributing guide and PR description check
- PR template: linked issue, what and why, how it was verified, review focus.
- Bug form gains an optional minimal reproduction; feature form requires
  acceptance criteria.
- CONTRIBUTING.md states the issue and PR rules for people and coding agents.
- PR check labels `needs-info` and leaves one comment when the issue link or the
  verification section is missing, and clears both once the description is fixed.
  It reads only the title and description and never runs PR code.
2026-11-03 21:34:04 +08:00
14 змінених файлів з 174 додано та 201 видалено

No files matched your search

+6
Переглянути файл
@@ -42,6 +42,12 @@ body:
3. ...
validations:
required: true
- type: textarea
id: reproduction
attributes:
label: Minimal reproduction
description: A link to a small public repository, or the smallest files/snippet that trigger the problem. Optional, but it's the fastest way to get a fix.
placeholder: https://github.com/you/repro-project
- type: textarea
id: expected
attributes:
+10
Переглянути файл
@@ -27,6 +27,16 @@ body:
description: How you'd like it to work. Mockups or examples from other tools are welcome.
validations:
required: true
- type: textarea
id: acceptance
attributes:
label: Acceptance criteria
description: How we'll know it's done. One observable behavior per line.
placeholder: |
- [ ] Right-clicking a test class shows "Run with Coverage"
- [ ] Coverage results open in the Coverage tool window
validations:
required: true
- type: textarea
id: alternatives
attributes:
+17
Переглянути файл
@@ -0,0 +1,17 @@
Closes #
## What and why
<!-- 2–4 sentences: the change a user notices, and the root cause.
If it doesn't fit, the PR is probably too big; split it. -->
## How it was verified
<!-- Required. Commands you actually ran and their results; what else this could
affect and how you checked it still works.
UI changes: before/after screenshots. Multi-step interactions: a recording.
Backend changes: logs or command output. -->
## Review focus
<!-- Optional: anything you want reviewers to look at closely. -->
+69
Переглянути файл
@@ -0,0 +1,69 @@
name: PR check
on:
# pull_request_target so the check can label PRs from forks. It never checks out
# or runs PR code: it only reads the PR title and description.
pull_request_target:
types: [opened, edited, reopened, ready_for_review]
permissions:
issues: write
pull-requests: write
concurrency:
group: pr-check-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
check:
if: github.event.pull_request.user.type != 'Bot' && !github.event.pull_request.draft
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v7
with:
script: |
const pr = context.payload.pull_request;
const LABEL = 'needs-info';
const MARKER = '<!-- pr-check -->';
// Docs, CI and pure refactors may skip the linked issue.
const NO_ISSUE_TYPES = /^(docs|ci|build|chore|refactor|style|test)(\(.+\))?!?:/;
const body = (pr.body || '').replace(/<!--[\s\S]*?-->/g, '');
const problems = [];
const linksIssue =
/\b(close[sd]?|fix(e[sd])?|resolve[sd]?)\s*:?\s+(#\d+|https:\/\/github\.com\/[\w.-]+\/[\w.-]+\/issues\/\d+)/i.test(body);
if (!linksIssue && !NO_ISSUE_TYPES.test(pr.title)) {
problems.push('Link the issue this PR resolves, e.g. `Closes #123`.');
}
const verified = body.match(/^##+\s*How it was verified\s*$([\s\S]*?)(?=^##+\s|(?![\s\S]))/im);
if (!verified || !verified[1].trim()) {
problems.push('Fill in **How it was verified**: the commands you ran and their results. UI changes need before/after screenshots.');
}
const { owner, repo } = context.repo;
const issue_number = pr.number;
const comments = await github.paginate(github.rest.issues.listComments, { owner, repo, issue_number });
const existing = comments.find(c => c.user.type === 'Bot' && c.body.includes(MARKER));
const labeled = pr.labels.some(l => l.name === LABEL);
if (problems.length) {
const text = `${MARKER}\nThanks for the PR. Before review, please update the description (see [CONTRIBUTING.md](https://github.com/${owner}/${repo}/blob/main/CONTRIBUTING.md)):\n\n${problems.map(p => `- ${p}`).join('\n')}\n\nThis check reruns when you edit the description.`;
if (existing) {
await github.rest.issues.updateComment({ owner, repo, comment_id: existing.id, body: text });
} else {
await github.rest.issues.createComment({ owner, repo, issue_number, body: text });
}
if (!labeled) {
await github.rest.issues.addLabels({ owner, repo, issue_number, labels: [LABEL] });
}
return;
}
// Only undo what this check did: the label is cleared only when our comment exists.
if (existing) {
await github.rest.issues.deleteComment({ owner, repo, comment_id: existing.id });
if (labeled) {
await github.rest.issues.removeLabel({ owner, repo, issue_number, name: LABEL }).catch(() => {});
}
}
+34
Переглянути файл
@@ -0,0 +1,34 @@
# Contributing to OpenIDEA
These rules apply to everyone, and to any coding agent working on their behalf.
## Issues
- One problem or request per issue. Use the issue forms.
- Bugs: steps that reproduce the problem from a fresh start. A minimal sample
project is the fastest way to get a fix.
- Features: state the problem and the acceptance criteria. A feature is ready to
build once a maintainer labels it `planned`.
- Labels track status: `needs-info` waits on the reporter, `needs-decision` waits
on a maintainer, `planned` is accepted, `needs-acceptance` has a fix waiting to be
checked.
## Pull requests
- One issue per PR, linked with `Closes #123`. Feature PRs need a `planned` issue.
Docs, CI and pure refactors may skip the issue.
- Reproduce the problem first, or write a test that fails before the fix.
- Fix the cause, and check whether the same cause breaks anything nearby.
- Keep the diff focused. Unrelated refactors go in their own PR.
- Title: [Conventional Commits](https://www.conventionalcommits.org/), e.g.
`fix(editor): keep the caret visible after folding`.
- Fill in the template. Keep the description short and in plain words. If it
doesn't fit in a few sentences, the PR is probably too big.
- **How it was verified** is required: the commands you ran and their results,
and what else the change could affect. UI changes need before/after screenshots;
multi-step interactions need a recording.
- If a change needs a product decision you can't make, ask in the issue and stop
rather than guessing.
A check on each PR adds `needs-info` when the issue link or the verification
section is missing, and removes it once they're filled in.
+1 -8
Переглянути файл
@@ -7,12 +7,7 @@
*/
import type { Extension } from "@codemirror/state";
import { registerEditorContribution, type EditorDocContext } from "@/editor/api";
import {
registerEditorBanner,
registerOverlay,
registerStatusItem,
registerToolWindow,
} from "@/workbench/contributions";
import { registerOverlay, registerStatusItem, registerToolWindow } from "@/workbench/contributions";
import { lspDoc } from "./lsp";
import { hintExtension } from "./hint";
import { completionExtension } from "./completion";
@@ -36,7 +31,6 @@ import { spellingExtension } from "./spelling";
import { DocumentationWindow, LspPopups, UsagesStatus } from "./Popups";
import { DOCUMENTATION_WINDOW } from "./docs";
import { prefetchMarkdown } from "./markdown";
import { outsideProjectBanner } from "./outsideProject";
import { implementationGutter, registerNavigationActions } from "@/editor/navigation";
export function lspExtensions(ctx: EditorDocContext): Extension[] {
@@ -72,7 +66,6 @@ export function activate(): () => void {
// After the templates (order 90): live template / postfix expansion keeps ⇥ first.
registerEditorContribution({ id: "lsp.parameterTab", order: 95, extensions: () => parameterTabKeys }),
registerOverlay({ id: "editor-lsp.popups", component: LspPopups }),
registerEditorBanner(outsideProjectBanner),
registerStatusItem({ id: "editor-lsp.usagesStatus", align: "left", priority: 10, component: UsagesStatus }),
// IDEA's Documentation tool window: right side, listed once F1 moved documentation there.
registerToolWindow({
+1 -11
Переглянути файл
@@ -47,7 +47,6 @@ import {
type DeclarationTarget,
} from "./syntaxFallback";
import { showHint, showPendingHint } from "./hint";
import { outsideProjectReason } from "./outsideProject";
import { caretAnchor, openPopup, type ListPopupItem } from "./popupStore";
import { readManyFileLines, targetLabel } from "./files";
import { documentLinks, followReference, knownLinks, linkReference, referenceAt, textReference } from "./links";
@@ -199,16 +198,7 @@ export async function gotoTargets(view: EditorView, kind: GotoKind, at?: number)
((await gotoWebReference(view, doc, pos, offset)) || (await followReferenceAt(view, doc, offset)))
)
return;
// The server only checks this file's syntax: say why instead of just "not found".
const reason = serverDown ? null : outsideProjectReason(doc.path);
showHint(
view,
serverDown
? `${NOT_FOUND[kind]}: no language server is running for this file`
: reason
? `${tx(NOT_FOUND[kind])}. ${tx(reason)}`
: NOT_FOUND[kind],
);
showHint(view, serverDown ? `${NOT_FOUND[kind]}: no language server is running for this file` : NOT_FOUND[kind]);
return;
}
// IDEA: ⌘B on a declaration shows its usages.
-66
Переглянути файл
@@ -1,66 +0,0 @@
import { expect, it } from "vitest";
import { outsideProjectNotice } from "./outsideProject";
const text = (message: string) => outsideProjectNotice(message)?.text ?? null;
it("recognizes each server's report that a file is outside its projects", () => {
const cases: [string, RegExp | null][] = [
// jdtls: a file outside the module's source folders, and one outside every project.
[
"Extra.java is not on the classpath of project service, only syntax errors are reported",
/source folders of its Java module/,
],
["Scratch.java is a non-project file, only syntax errors are reported", /imported Java project/],
// gopls: build constraints win over the generic "no package".
["No packages found for open file x.go.\nThis file may be excluded due to its build tags", /build constraints/],
["This file may be excluded due to its GOOS/GOARCH, or other build constraints.", /build constraints/],
["No packages found for open file x.go.", /no package of the workspace/],
// rust-analyzer `unlinked-file`.
[
"This file is not included in any crates, so rust-analyzer can't offer IDE services.",
/not included in any crate/,
],
// Ordinary errors are not such reports.
["undefined: missingSymbol", null],
["invalid build tags syntax", null],
["ActionDTO cannot be resolved to a type", null],
["Missing artifact demo:api:jar:1.0", null],
];
for (const [message, expected] of cases) {
const got = text(message);
if (expected) expect(got, message).toMatch(expected);
else expect(got, message).toBeNull();
}
// A build reload is offered only where it can bring the file into a project.
expect(outsideProjectNotice("A.java is a non-project file, only syntax errors are reported")?.reload).toBe(true);
expect(outsideProjectNotice("No packages found for open file x.go.")?.reload).toBeFalsy();
});
it("shows a banner while the server reports the file, with the build reloads available", async () => {
const { renderHook, act } = await import("@testing-library/react");
const { setFileDiagnostics } = await import("./diagnostics");
const { registerActions } = await import("@/platform/actions");
const { outsideProjectBanner } = await import("./outsideProject");
const off = registerActions([{ id: "maven.reload", title: "Reload All Maven Projects", run: () => {} }]);
const path = "/p/service/src/extra/Extra.java";
try {
const { result } = renderHook(() => outsideProjectBanner.useBanner(path));
expect(result.current).toBeNull();
const warning = {
range: { start: { line: 0, col: 0 }, end: { line: 0, col: 1 } },
severity: "warning" as const,
message: "Extra.java is not on the classpath of project service, only syntax errors are reported",
source: "Java",
code: "32",
};
act(() => setFileDiagnostics(path, "jdtls", [warning]));
expect(result.current?.level).toBe("warning");
expect(result.current?.text).toMatch(/source folders of its Java module/);
expect(result.current?.actions?.map((a) => a.label)).toEqual(["Reload Maven Projects"]);
act(() => setFileDiagnostics(path, "jdtls", []));
expect(result.current).toBeNull();
} finally {
off();
setFileDiagnostics(path, "jdtls", []);
}
});
-85
Переглянути файл
@@ -1,85 +0,0 @@
/**
* Files a language server only checks for syntax because they belong to none of
* its projects: a Java file outside every module's source folders, a Rust file in
* no crate, a Go file in no package of the workspace. The server says so in a
* diagnostic; navigation, completion and usages then fail without saying why.
*/
import { useSyncExternalStore } from "react";
import { executeAction, getAction, isActionEnabled } from "@/platform/actions";
import type { EditorBannerContribution } from "@/workbench/contributions";
import { diagnosticsFor, subscribeDiagnostics } from "./diagnostics";
/** `reload`: a build reload may bring the file into a project (a module the import missed). */
const NOTICES: readonly { test: RegExp; text: string; reload?: boolean }[] = [
// jdtls: "Foo.java is not on the classpath of project app, only syntax errors are reported"
{
test: /is not on the classpath of project .*only syntax errors are reported/,
text: "This file is outside the source folders of its Java module: only syntax errors are reported, and navigation and completion don't work.",
reload: true,
},
// jdtls: "Foo.java is a non-project file, only syntax errors are reported"
{
test: /is a non-project file, only syntax errors are reported/,
text: "This file does not belong to an imported Java project: only syntax errors are reported, and navigation and completion don't work.",
reload: true,
},
// gopls, before its generic "No packages found" below.
{
test: /excluded[^\n]*(?:build|GOOS\/GOARCH)/i,
text: "This Go file is excluded by the current build constraints.",
},
{
test: /^No packages found for open file/,
text: "This Go file belongs to no package of the workspace: code insight is limited.",
},
// rust-analyzer's `unlinked-file`.
{
test: /not included in any crates/,
text: "This Rust file is not included in any crate: rust-analyzer can't offer code insight for it.",
},
];
type Notice = (typeof NOTICES)[number];
/** What a server's `message` means for its file, when it says the file is outside its projects. */
export function outsideProjectNotice(message: string): Notice | null {
return NOTICES.find((n) => n.test.test(message)) ?? null;
}
function noticeFor(path: string): Notice | null {
for (const d of diagnosticsFor(path)) {
const notice = outsideProjectNotice(d.message);
if (notice) return notice;
}
return null;
}
/** Why code insight is limited in `path`, from its current diagnostics, or null. */
export function outsideProjectReason(path: string): string | null {
return noticeFor(path)?.text ?? null;
}
const RELOADS = [
{ id: "maven.reload", label: "Reload Maven Projects" },
{ id: "gradle.reload", label: "Reload Gradle Project" },
];
/** The notice above an editor whose file a language server treats as outside its projects. */
export const outsideProjectBanner: EditorBannerContribution = {
id: "lsp.outsideProject",
order: 5,
useBanner: (path) => {
const notice = useSyncExternalStore(
(l) => subscribeDiagnostics(path, l),
() => noticeFor(path),
);
if (!notice) return null;
const actions = notice.reload
? RELOADS.filter(({ id }) => {
const action = getAction(id);
return action && isActionEnabled(action);
}).map(({ id, label }) => ({ label, run: () => void executeAction(id) }))
: [];
return { text: notice.text, level: "warning", actions };
},
};
-23
Переглянути файл
@@ -303,29 +303,6 @@ describe("navigation wiring", () => {
expect(document.querySelector(".cm-lsp-hint")?.textContent).toBe("Cannot find declaration to go to");
});
it("says why when the server only checks the file's syntax", async () => {
const { setFileDiagnostics } = await import("./diagnostics");
setFileDiagnostics("/p/a.ts", "jdtls", [
{
range: { start: { line: 0, col: 0 }, end: { line: 0, col: 1 } },
severity: "warning",
message: "a.ts is not on the classpath of project app, only syntax errors are reported",
source: "Java",
code: "32",
},
]);
try {
cmd.lspGoto.mockReturnValueOnce(ok([]));
const view = editor("const x = 1;\nx;", "typescript", 13);
await gotoTargets(view, "definition");
expect(document.querySelector(".cm-lsp-hint")?.textContent).toBe(
"Cannot find declaration to go to. This file is outside the source folders of its Java module: only syntax errors are reported, and navigation and completion don't work.",
);
} finally {
setFileDiagnostics("/p/a.ts", "jdtls", []);
}
});
it("falls back to the local definition when the server is not ready", async () => {
cmd.syntaxLocals.mockReturnValueOnce(ok(local({ references: [r(1, 0, 1)] })));
const view = editor("const x = 1;\nx;", "typescript", 13);
+14
Переглянути файл
@@ -0,0 +1,14 @@
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);
});
+4
Переглянути файл
@@ -0,0 +1,4 @@
/** Only gopls diagnostics that explicitly identify build exclusion qualify. */
export function goConstraintExcluded(message: string): boolean {
return /excluded[^\n]*(?:build|GOOS\/GOARCH)/i.test(message);
}
+17 -1
Переглянути файл
@@ -5,7 +5,12 @@
*/
import { registerActions } from "@/platform/actions";
import { useProject } from "@/platform/project";
import { registerOverlay, registerStatusItem, registerToolWindow } from "@/workbench/contributions";
import {
registerEditorBanner,
registerOverlay,
registerStatusItem,
registerToolWindow,
} from "@/workbench/contributions";
import { clearProblems, installProblemsEvents, useProblems } from "./problemsStore";
import { installProblemDecorations } from "./decorations";
import { ProblemsHeaderActions, ProblemsTabs, ProblemsView, useProblemsHeaderMenu } from "./ProblemsView";
@@ -15,6 +20,7 @@ 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";
@@ -42,6 +48,16 @@ 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(),
+1 -7
Переглянути файл
@@ -5554,11 +5554,5 @@
"External file changes sync may be slow": "外部文件更改同步可能较慢",
"recursive": "递归",
"Java project import failed": "Java 项目导入失败",
"The Java project cannot be imported because these files use a name Windows reserves for devices: {paths}. Delete or rename them, then restart the Java language server.": "无法导入 Java 项目,因为这些文件使用了 Windows 保留的设备名:{paths}。请删除或重命名这些文件,然后重启 Java 语言服务器。",
"This file is outside the source folders of its Java module: only syntax errors are reported, and navigation and completion don't work.": "此文件不在所属 Java 模块的源码目录中:只报告语法错误,跳转和补全不可用。",
"This file does not belong to an imported Java project: only syntax errors are reported, and navigation and completion don't work.": "此文件不属于已导入的 Java 项目:只报告语法错误,跳转和补全不可用。",
"This Go file belongs to no package of the workspace: code insight is limited.": "此 Go 文件不属于工作区中的任何包:代码洞察功能受限。",
"This Rust file is not included in any crate: rust-analyzer can't offer code insight for it.": "此 Rust 文件未包含在任何 crate 中:rust-analyzer 无法为它提供代码洞察。",
"Reload Maven Projects": "重新加载 Maven 项目",
"Reload Gradle Project": "重新加载 Gradle 项目"
"The Java project cannot be imported because these files use a name Windows reserves for devices: {paths}. Delete or rename them, then restart the Java language server.": "无法导入 Java 项目,因为这些文件使用了 Windows 保留的设备名:{paths}。请删除或重命名这些文件,然后重启 Java 语言服务器。"
}