дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-03 16:51:16 +02:00
feat(cpp): report functions declared but never defined (#7540)
A C or C++ function declared but never defined only failed at link time. A new inspection, Function declared but never defined (C/C++, weak warning), reports a prototype when clangd's go to definition finds only the declaration itself. Pure virtual, defaulted and deleted functions, operators, macro calls and Qt signals are left out. Quick fixes: Create Definition in the header's source file, and Implement Inline. Co-authored-by: yohannlog <[email protected]>
Цей коміт міститься в:
1 джерело
aa003541a3
коміт
304674d0fe
12 files changed
+800
No files matched your search
@@ -34,6 +34,15 @@ clangd needs the flags each file is compiled with. Without them it guesses, and
|
||||
With CMake profiles or enabled presets, clangd reads the **active profile's** `compile_commands.json`: OpenIDEA starts it with `--compile-commands-dir` set to that profile's build directory, and restarts it when you choose another profile in the title bar, or once the active profile's directory is configured for the first time. A `compile_commands.json` at the project root, a `.clangd` file naming a `CompilationDatabase`, or a `--compile-commands-dir` in the server's arguments take precedence. Otherwise clangd looks for `compile_commands.json` in the file's parent directories and in a `build/` subdirectory of each; for another directory, add a `.clangd` file with `CompileFlags: { CompilationDatabase: <dir> }`.
|
||||
</Tip>
|
||||
|
||||
### Functions without a definition
|
||||
|
||||
A function declared without a body (in a header, a namespace or a class) that clangd finds no definition for is greyed out, with "Function 'name' is declared but never defined" on hover. Pure virtual, defaulted and deleted functions, operators and the `signals:` of Qt classes (moc writes them) are left out. Nothing is decided while clangd is still indexing, since a definition in a file it has not indexed yet would look missing.
|
||||
|
||||
It is the **Function declared but never defined** inspection (C/C++ group of **Settings › Editor › Inspections**, a weak warning by default), so it also shows in the Problems tool window. Its fixes, under `⌥↵` / `Alt+Enter`:
|
||||
|
||||
- **Create Definition** writes an empty definition, qualified with its namespaces and classes and without default arguments, at the end of the header's source file (found as **Switch Header/Source** finds it), or of the file itself when it is a source file, and puts the caret in its body. Not offered for templates.
|
||||
- **Implement Inline** gives the declaration an empty body where it is (adding `inline` to a free function in a header).
|
||||
|
||||
### Xcode projects
|
||||
|
||||
In a folder with a `buildServer.json` (the build server config for Xcode projects, see [Swift › Xcode projects](/en/languages/swift#xcode-projects)), C, C++, Objective-C and Objective-C++ files use sourcekit-lsp instead of clangd. sourcekit-lsp gets each file's flags from the build server and passes them to its own clangd, so headers on the target's search paths and the generated `<Module>-Swift.h` resolve. Swift and C-family files of the project share one sourcekit-lsp. A build server config only under `.bsp/` is not used for this, because sbt, Mill and Bazel write that folder too. Without `buildServer.json`, or when sourcekit-lsp is not installed, clangd serves the files as described above.
|
||||
|
||||
@@ -34,6 +34,15 @@ clangd 需要知道每个文件的编译参数,否则只能猜测,常见的
|
||||
使用 CMake 配置或启用的预设时,clangd 读取**当前配置**的 `compile_commands.json`:OpenIDEA 启动 clangd 时把 `--compile-commands-dir` 设为该配置的构建目录,并在标题栏切换配置或当前配置的目录首次完成配置后重启 clangd。项目根目录下的 `compile_commands.json`、指定了 `CompilationDatabase` 的 `.clangd` 文件或服务器参数中的 `--compile-commands-dir` 优先。其他情况下,clangd 会在文件的各级父目录以及这些目录下的 `build/` 子目录里查找 `compile_commands.json`;如需使用其他目录,添加一个 `.clangd` 文件,写上 `CompileFlags: { CompilationDatabase: <目录> }`。
|
||||
</Tip>
|
||||
|
||||
### 未定义的函数
|
||||
|
||||
声明了但没有函数体(在头文件、命名空间或类中)、且 clangd 找不到定义的函数会显示为灰色,悬停时提示“函数 'name' 已声明但从未定义”。纯虚函数、默认和删除的函数、运算符以及 Qt 类的 `signals:`(由 moc 生成)不在此列。clangd 仍在建立索引时不作判断,因为尚未索引的文件中的定义会被误认为缺失。
|
||||
|
||||
这是 **已声明但从未定义的函数** 检查(位于 **设置 › 编辑器 › 检查** 的 C/C++ 分组,默认为弱警告),因此也会显示在“问题”工具窗口中。`⌥↵` / `Alt+Enter` 中的修复:
|
||||
|
||||
- **创建定义**:在头文件对应的源文件(与 **切换头文件/源文件** 的查找方式相同)末尾写入一个空的定义,带上命名空间和类的限定、去掉默认参数,并把光标放到函数体中;当前文件本身是源文件时写在它的末尾。模板不提供此修复。
|
||||
- **内联实现**:在原位置为声明加上空的函数体(头文件中的自由函数会加上 `inline`)。
|
||||
|
||||
### Xcode 项目
|
||||
|
||||
文件夹里有 `buildServer.json`(Xcode 项目的构建服务器配置,见 [Swift › Xcode 项目](/zh/languages/swift#xcode-项目))时,C、C++、Objective-C 和 Objective-C++ 文件改由 sourcekit-lsp 处理,不再用 clangd。sourcekit-lsp 从构建服务器拿到每个文件的编译参数,再交给它自带的 clangd,因此 target 搜索路径里的头文件和生成的 `<Module>-Swift.h` 都能找到。同一项目的 Swift 文件和 C 系文件共用一个 sourcekit-lsp。只放在 `.bsp/` 下的构建服务器配置不在此列,因为 sbt、Mill 和 Bazel 也会写这个文件夹。没有 `buildServer.json`,或者没有安装 sourcekit-lsp 时,仍由 clangd 处理,方式同上。
|
||||
|
||||
@@ -80,6 +80,8 @@ type Settle = (server: number, spellStart: number, loading: boolean) => void;
|
||||
|
||||
/** Servers starting (`-Infinity`) or busy since when. */
|
||||
const spells = new Map<number, number>();
|
||||
/** Each server's name (`clangd`, `jdtls`…), as its events report it. */
|
||||
const serverNames = new Map<number, string>();
|
||||
/** When servers became ready after starting, until their next spell ends. */
|
||||
const readyAfterStart = new Map<number, number>();
|
||||
const settles = new Set<Settle>();
|
||||
@@ -93,6 +95,7 @@ function trackSpells() {
|
||||
if (tracking || !isTauri()) return;
|
||||
tracking = true;
|
||||
onIdeEvent("languageServer", (e) => {
|
||||
serverNames.set(e.server, e.name);
|
||||
if (e.status === "starting") {
|
||||
spells.set(e.server, -Infinity);
|
||||
readyAfterStart.delete(e.server);
|
||||
@@ -124,6 +127,13 @@ export function anyServerBusy(): boolean {
|
||||
return spells.size > 0;
|
||||
}
|
||||
|
||||
/** Whether one of the servers named `names` is mid-spell (starting or busy), like {@link anyServerBusy} for them only. */
|
||||
export function serverBusy(names: readonly string[]): boolean {
|
||||
trackSpells();
|
||||
for (const server of spells.keys()) if (names.includes(serverNames.get(server) ?? "")) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls `fn` when a server becomes ready after starting or after a long busy
|
||||
* spell (indexing), when earlier answers may have been incomplete. Short busy
|
||||
|
||||
@@ -29,6 +29,7 @@ import { inlayExtension } from "./inlay";
|
||||
import { inlineCompletionExtension, registerInlineCompletionActions } from "./inlineCompletion";
|
||||
import { semanticExtension } from "./semantic";
|
||||
import { usagesLensExtension } from "./codeLens";
|
||||
import { unimplementedFunctionsExtension } from "./semantic/cpp/unimplemented";
|
||||
import { autoImportExtension } from "./autoImport";
|
||||
import { jsxAttrValueExtension } from "./jsxAttrValue";
|
||||
import { importsOnPasteExtension, registerImportsOnPasteActions } from "./importsOnPaste";
|
||||
@@ -54,6 +55,9 @@ import {
|
||||
runJavaRefactoringCommand,
|
||||
} from "@/editor/refactor";
|
||||
|
||||
/** Languages clangd serves: their prototypes without a definition are greyed out. */
|
||||
const C_FAMILY = new Set(["c", "cpp", "objective-c", "objective-cpp"]);
|
||||
|
||||
export function lspExtensions(ctx: EditorDocContext): Extension[] {
|
||||
return [
|
||||
lspDoc.of(ctx),
|
||||
@@ -73,6 +77,7 @@ export function lspExtensions(ctx: EditorDocContext): Extension[] {
|
||||
inlineCompletionExtension(),
|
||||
semanticExtension(ctx),
|
||||
usagesLensExtension(),
|
||||
...(C_FAMILY.has(ctx.language ?? "") ? [unimplementedFunctionsExtension()] : []),
|
||||
autoImportExtension(),
|
||||
jsxAttrValueExtension(ctx.language),
|
||||
importsOnPasteExtension(),
|
||||
|
||||
@@ -0,0 +1,222 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { indentUnit } from "@codemirror/language";
|
||||
import { EditorState } from "@codemirror/state";
|
||||
import { EditorView } from "@codemirror/view";
|
||||
import type { EditorDocContext } from "@/editor/api";
|
||||
import { lspDoc } from "../../lsp";
|
||||
import {
|
||||
definitionText,
|
||||
functionPrototypes,
|
||||
implementInline,
|
||||
onlyItself,
|
||||
rememberUnimplemented,
|
||||
} from "./unimplemented";
|
||||
|
||||
const names = (src: string) => functionPrototypes(src).map((p) => p.name);
|
||||
|
||||
describe("C / C++ function prototypes", () => {
|
||||
it("finds declarations without a body in headers, namespaces and classes", () => {
|
||||
const src = `#pragma once
|
||||
#include <optional>
|
||||
|
||||
int add(int a, int b);
|
||||
extern "C" void c_api(const char *name);
|
||||
|
||||
namespace net {
|
||||
[[nodiscard]] std::optional<QString> addressIn(QStringView text);
|
||||
template <typename T> std::vector<T> collect(const T &value);
|
||||
|
||||
class Bluetooth : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Bluetooth(QObject *parent = nullptr);
|
||||
~Bluetooth() override;
|
||||
[[nodiscard]] quint8 getCapacity(QStringView& uid) const noexcept;
|
||||
virtual void scan() = 0;
|
||||
Bluetooth(const Bluetooth &) = delete;
|
||||
Bluetooth &operator=(const Bluetooth &) = default;
|
||||
auto level() const -> int;
|
||||
void inline_defined() { scan(); }
|
||||
static int count;
|
||||
int value_{0};
|
||||
std::function<void(int)> callback_;
|
||||
public slots:
|
||||
void onFound(int id);
|
||||
signals:
|
||||
void found(int id);
|
||||
void lost();
|
||||
private:
|
||||
void helper() const;
|
||||
friend void swap(Bluetooth &, Bluetooth &);
|
||||
};
|
||||
} // namespace net
|
||||
`;
|
||||
expect(names(src)).toEqual([
|
||||
"add",
|
||||
"c_api",
|
||||
"addressIn",
|
||||
"collect",
|
||||
"Bluetooth",
|
||||
"~Bluetooth",
|
||||
"getCapacity",
|
||||
"level",
|
||||
"onFound",
|
||||
"helper",
|
||||
]);
|
||||
});
|
||||
|
||||
it("leaves out definitions, macros, calls and variables", () => {
|
||||
const src = `Q_DECLARE_METATYPE(Foo);
|
||||
static Foo foo(1, "x");
|
||||
int (*handler)(int);
|
||||
using Callback = void (*)(int);
|
||||
typedef int (*Fn)(int);
|
||||
void defined(int x) {
|
||||
helper(x);
|
||||
int local(int);
|
||||
}
|
||||
void Foo::bar();
|
||||
enum class E { A, B };
|
||||
auto lambda = [](int) { return 0; };
|
||||
`;
|
||||
expect(names(src)).toEqual([]);
|
||||
});
|
||||
|
||||
it("tells variables initialized with parentheses from prototypes", () => {
|
||||
const src = `static Logger logger(kName);
|
||||
Logger channel(LOG_CHANNEL);
|
||||
std::vector<int> table(size);
|
||||
const QFont font(QStringLiteral("x"));
|
||||
QString title(QString);
|
||||
void open(std::string, int flags = 0);
|
||||
quint8 capacity(qint64 id, const char *name = "x");
|
||||
`;
|
||||
expect(names(src)).toEqual(["title", "open", "capacity"]);
|
||||
});
|
||||
|
||||
it("leaves out Qt signals declared one by one, and checks template class constructors", () => {
|
||||
const src = `class W : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
Q_SIGNAL void changed();
|
||||
void apply();
|
||||
};
|
||||
template <class T> class Box {
|
||||
public:
|
||||
Box(T v);
|
||||
~Box();
|
||||
};
|
||||
`;
|
||||
expect(names(src)).toEqual(["apply", "Box", "~Box"]);
|
||||
});
|
||||
|
||||
it("gives the offsets of the name, past comments and strings", () => {
|
||||
const src = `// void commented();\nconst char *s = "void inString();";\n void real(int);`;
|
||||
const [p] = functionPrototypes(src);
|
||||
expect(p).toMatchObject({ name: "real" });
|
||||
expect(src.slice(p!.from, p!.to)).toBe("real");
|
||||
});
|
||||
});
|
||||
|
||||
describe("definition answers", () => {
|
||||
const at = (path: string, line: number) => ({
|
||||
path,
|
||||
range: { start: { line, col: 0 }, end: { line, col: 4 } },
|
||||
});
|
||||
it("counts a prototype as defined nowhere only when it is its own answer", () => {
|
||||
expect(onlyItself([at("/p/a.h", 3)], "/p/a.h", 3)).toBe(true);
|
||||
expect(onlyItself([at("C:\\p\\a.h", 3)], "C:/p/a.h", 3)).toBe(true);
|
||||
expect(onlyItself([at("c:/P/A.h", 3)], "C:/p/a.h", 3)).toBe(true);
|
||||
expect(onlyItself([at("/p/A.h", 3)], "/p/a.h", 3)).toBe(false);
|
||||
expect(onlyItself([at("/p/a.cpp", 10)], "/p/a.h", 3)).toBe(false);
|
||||
expect(onlyItself([at("/p/a.h", 3), at("/p/a.h", 20)], "/p/a.h", 3)).toBe(false);
|
||||
// No answer (no server, no compile flags): nothing is claimed.
|
||||
expect(onlyItself([], "/p/a.h", 3)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("fixes", () => {
|
||||
const header = `#pragma once
|
||||
namespace net {
|
||||
class Bluetooth {
|
||||
public:
|
||||
explicit Bluetooth(QObject *parent = nullptr);
|
||||
[[nodiscard]] static std::optional<QString> addressIn(QStringView text, int from = 0) noexcept;
|
||||
virtual quint8 capacity(const QString &uid = QStringLiteral("x"), std::pair<int, int> r = {1, 2}) const override;
|
||||
const char *label() const &;
|
||||
};
|
||||
template <class T> class Box { public: void put(T v); };
|
||||
}
|
||||
int add(int a, int b = 1);
|
||||
static int helper(int);
|
||||
`;
|
||||
const defs = () => {
|
||||
const protos = functionPrototypes(header);
|
||||
return Object.fromEntries(protos.map((p) => [p.name, { text: definitionText(header, p), templated: p.templated }]));
|
||||
};
|
||||
|
||||
it("writes a qualified definition without default arguments or declaration-only specifiers", () => {
|
||||
const d = defs();
|
||||
expect(d.Bluetooth!.text).toBe("net::Bluetooth::Bluetooth(QObject *parent) {\n}\n");
|
||||
expect(d.addressIn!.text).toBe(
|
||||
"std::optional<QString> net::Bluetooth::addressIn(QStringView text, int from) noexcept {\n}\n",
|
||||
);
|
||||
expect(d.capacity!.text).toBe(
|
||||
"quint8 net::Bluetooth::capacity(const QString &uid, std::pair<int, int> r) const {\n}\n",
|
||||
);
|
||||
expect(d.label!.text).toBe("const char *net::Bluetooth::label() const & {\n}\n");
|
||||
expect(d.add!.text).toBe("int add(int a, int b) {\n}\n");
|
||||
// A free function keeps `static`: its definition must have internal linkage too.
|
||||
expect(d.helper!.text).toBe("static int helper(int) {\n}\n");
|
||||
expect(d.put!.templated).toBe(true);
|
||||
expect(d.add!.templated).toBe(false);
|
||||
});
|
||||
|
||||
const inline = (path: string, src: string, name: string) => {
|
||||
const ctx = { doc: 1, path, language: "cpp", uiMode: "C++", readOnly: false } as unknown as EditorDocContext;
|
||||
const view = new EditorView({
|
||||
state: EditorState.create({ doc: src, extensions: [indentUnit.of(" "), lspDoc.of(ctx)] }),
|
||||
});
|
||||
implementInline(
|
||||
view,
|
||||
functionPrototypes(src).find((p) => p.name === name)!,
|
||||
);
|
||||
return { text: view.state.doc.toString(), caret: view.state.selection.main.head };
|
||||
};
|
||||
|
||||
it("gives a declaration an empty body, inline for a free function in a header", () => {
|
||||
const member = inline("/p/a.h", "struct S {\n void run() const;\n};\n", "run");
|
||||
expect(member.text).toBe("struct S {\n void run() const {\n \n }\n};\n");
|
||||
expect(member.text.slice(0, member.caret)).toBe("struct S {\n void run() const {\n ");
|
||||
expect(inline("/p/a.h", "int add(int a);\n", "add").text).toBe("inline int add(int a) {\n \n}\n");
|
||||
expect(inline("/p/a.cpp", "int add(int a);\n", "add").text).toBe("int add(int a) {\n \n}\n");
|
||||
expect(inline("/p/a.h", "constexpr int one();\n", "one").text).toBe("constexpr int one() {\n \n}\n");
|
||||
});
|
||||
});
|
||||
|
||||
describe("fixes at the caret", () => {
|
||||
it("lists Create Definition and Implement Inline in the caret's intentions, as on the problem", async () => {
|
||||
const { languageSemantics } = await import("../languages");
|
||||
const src = "struct S {\n void run();\n template <class T> void put(T v);\n};\n";
|
||||
const ctx = {
|
||||
doc: 1,
|
||||
path: "/p/s.h",
|
||||
language: "cpp",
|
||||
uiMode: "C++",
|
||||
readOnly: false,
|
||||
} as unknown as EditorDocContext;
|
||||
const view = new EditorView({ state: EditorState.create({ doc: src, extensions: [lspDoc.of(ctx)] }) });
|
||||
rememberUnimplemented(view.state.doc, functionPrototypes(src));
|
||||
const at = (name: string) => {
|
||||
view.dispatch({ selection: { anchor: src.indexOf(name) + 1 } });
|
||||
return languageSemantics("cpp")!.intentions!(view).map((i) => i.id);
|
||||
};
|
||||
expect(at("run")).toEqual(["cpp.createDefinition", "cpp.implementInline"]);
|
||||
// A template's definition stays in the header: only Implement Inline.
|
||||
expect(at("put")).toEqual(["cpp.implementInline"]);
|
||||
view.dispatch({ selection: { anchor: 0 } });
|
||||
expect(languageSemantics("cpp")!.intentions!(view)).toEqual([]);
|
||||
const fixes = languageSemantics("cpp")!.quickFixes!(view, src.indexOf("run"), src.indexOf("run") + 3);
|
||||
expect(fixes.map((f) => f.id)).toEqual(["cpp.createDefinition", "cpp.implementInline"]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,508 @@
|
||||
/**
|
||||
* C / C++: the "Function declared but never defined" inspection. A function declared without a body
|
||||
* (in a header, a namespace or a class) that clangd finds no definition for is reported as an unused
|
||||
* weak warning (greyed out, with the message on hover), with two fixes: Create Definition (an empty
|
||||
* definition in the header's source file) and Implement Inline (the declaration gets a body).
|
||||
*
|
||||
* clangd's go to definition answers a prototype with its definition when its index knows one, else
|
||||
* with the declaration itself, so a prototype whose only target is itself has no definition. Nothing
|
||||
* is decided while clangd is indexing (a definition in a file not indexed yet would look missing),
|
||||
* and results are cached per document text.
|
||||
*/
|
||||
import { EditorSelection, type Extension, type Text } from "@codemirror/state";
|
||||
import { EditorView, ViewPlugin, type ViewUpdate } from "@codemirror/view";
|
||||
import { indentUnit } from "@codemirror/language";
|
||||
import {
|
||||
attachDocument,
|
||||
intentionsChanged,
|
||||
isLibrarySource,
|
||||
openCodeLocation,
|
||||
type ContributedIntention,
|
||||
} from "@/editor/api";
|
||||
import { switchHeaderSource } from "@/editor/navigation/headerSource";
|
||||
import { tx } from "@/platform/i18n";
|
||||
import {
|
||||
CPP_UNIMPLEMENTED_INSPECTION,
|
||||
CPP_UNIMPLEMENTED_PRODUCER,
|
||||
inspectionProfile,
|
||||
subscribeInspectionProfile,
|
||||
} from "@/platform/inspections";
|
||||
import { call, commands, nextRequestId, type Diagnostic, type Location, type RequestId } from "@/platform/ipc";
|
||||
import { onServerSettled, serverBusy } from "../../availability";
|
||||
import { setFileDiagnostics } from "../../diagnostics";
|
||||
import { showHint } from "../../hint";
|
||||
import { debounce, docOf, lspRequest } from "../../lsp";
|
||||
import { offsetToPos } from "../../positions";
|
||||
import { registerLanguageSemantics } from "../languages";
|
||||
import { maskCode } from "./scan";
|
||||
|
||||
/** A function declaration without a body. Offsets are in the text it was read from. */
|
||||
export interface Prototype {
|
||||
name: string;
|
||||
/** The name. */
|
||||
from: number;
|
||||
to: number;
|
||||
/** The declaration, from its first word to its `;` (`declTo` is the `;`). */
|
||||
declFrom: number;
|
||||
declTo: number;
|
||||
/** Its parameter list's `(` and `)`. */
|
||||
open: number;
|
||||
close: number;
|
||||
/** Names of the namespaces and classes around it, outermost first (`["net", "Bluetooth"]`). */
|
||||
scopes: string[];
|
||||
/** Declared in a class (a member function). */
|
||||
member: boolean;
|
||||
/** A template, or in a class template: its definition can't simply be written elsewhere. */
|
||||
templated: boolean;
|
||||
}
|
||||
|
||||
type Scope = { kind: "namespace" | "record" | "other"; name: string; signals: boolean; templated: boolean };
|
||||
|
||||
const SKIP_START =
|
||||
/^(typedef|using|friend|return|static_assert|namespace|extern\s+template|template\s+(class|struct)\b)/;
|
||||
/** Words before a declaration's return type that are not one. */
|
||||
const SPECIFIERS =
|
||||
/\b(explicit|virtual|static|inline|constexpr|consteval|extern|friend|Q_INVOKABLE|Q_SCRIPTABLE|Q_SLOT)\b|\[\[[^\]]*\]\]|template\s*<[^>]*>/g;
|
||||
/** What may follow a declaration's parameters: cv / ref qualifiers, noexcept, override, a trailing return type, macros. */
|
||||
const TAIL =
|
||||
/^(?:\s+|const\b|volatile\b|&&|&|noexcept\b(?:\s*\([^)]*\))?|override\b|final\b|throw\s*\([^)]*\)|->[^=]+|\[\[[^\]]*\]\]|[A-Z_][A-Z0-9_]*\b(?:\s*\([^)]*\))?)*$/;
|
||||
|
||||
/** Builtin type names that make a parameter on their own (`void f(int);`). */
|
||||
const BUILTIN =
|
||||
/^(void|bool|char\w*|wchar_t|short|int|long|float|double|signed|unsigned|auto|size_t|ssize_t|ptrdiff_t|u?int\d+_t|uint|ulong|ushort|uchar|qu?int\d*|qreal|qsizetype)$/;
|
||||
|
||||
/**
|
||||
* Whether `p` reads as a parameter (`int x`, `const QString &`, `QString`, `int x = 0`) and not as an
|
||||
* argument of a variable's initializer (`Logger logger(kName);`, `font(QStringLiteral("x"))`): a
|
||||
* literal, a call, or a lone name that is not a type (lower case, or an upper-case constant).
|
||||
*/
|
||||
function isParameter(p: string): boolean {
|
||||
const decl = p.replace(/=[^]*$/, "").trim();
|
||||
if (!decl) return p.trim() === "";
|
||||
if (/^(-?\d|"|'|true\b|false\b|nullptr\b)/.test(decl) || /^[\w:]+\(/.test(decl)) return false;
|
||||
if (/^[A-Za-z_][\w:]*$/.test(decl))
|
||||
return BUILTIN.test(decl) || /^std::\w+$/.test(decl) || /^(?:\w+::)*[A-Z]\w*[a-z]\w*$/.test(decl);
|
||||
return true;
|
||||
}
|
||||
|
||||
function scopeOf(header: string, parent: Scope | undefined): Scope {
|
||||
const other: Scope = { kind: "other", name: "", signals: false, templated: false };
|
||||
if (parent?.kind === "other") return other;
|
||||
const h = header.replace(/\s+/g, " ").trim();
|
||||
if (/^extern\s*"/.test(h)) return { ...other, kind: "namespace" };
|
||||
if (/(^|\s)namespace\b/.test(h))
|
||||
return { ...other, kind: "namespace", name: /namespace\s+([\w:]+)/.exec(h)?.[1] ?? "" };
|
||||
// The last `class` keyword: `template <class T> class Box` declares `Box`.
|
||||
const record = /^.*\b(class|struct|union)\b\s*(?:\[\[[^\]]*\]\]\s*)*(?:[A-Z_][A-Z0-9_]*\s+)?(\w*)[^(){};=]*$/.exec(h);
|
||||
if (record && !/\benum\b/.test(h))
|
||||
return { kind: "record", name: record[2] ?? "", signals: false, templated: /\btemplate\s*</.test(h) };
|
||||
return other;
|
||||
}
|
||||
|
||||
/** `s` split at its top-level commas (not those in `<…>`, `(…)`, `[…]` or `{…}`). */
|
||||
function splitTopLevel(s: string): string[] {
|
||||
return topLevelParts(s, 0, s.length).map(([from, to]) => s.slice(from, to));
|
||||
}
|
||||
|
||||
/** Index of the `)` closing the `(` at `open`, or -1. */
|
||||
function closing(s: string, open: number): number {
|
||||
let depth = 0;
|
||||
for (let i = open; i < s.length; i++) {
|
||||
if (s[i] === "(") depth++;
|
||||
else if (s[i] === ")" && --depth === 0) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/** First `(` of `s` outside template arguments and brackets, or -1. */
|
||||
function firstParen(s: string): number {
|
||||
let angle = 0;
|
||||
for (let i = 0; i < s.length; i++) {
|
||||
const c = s[i]!;
|
||||
if (c === "<") angle++;
|
||||
else if (c === ">" && angle > 0) angle--;
|
||||
else if (c === "(" && angle === 0) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/** The prototype a statement (`masked[start, end)`, `end` its `;`) declares, if it is one. */
|
||||
function prototype(masked: string, start: number, end: number, stack: readonly Scope[]): Prototype | null {
|
||||
const scope = stack.at(-1);
|
||||
const stmt = masked.slice(start, end);
|
||||
const lead = stmt.length - stmt.trimStart().length;
|
||||
const body = stmt.trim();
|
||||
if (!body || SKIP_START.test(body) || (scope?.kind === "record" && scope.signals)) return null;
|
||||
const open = firstParen(body);
|
||||
if (open < 0) return null;
|
||||
const close = closing(body, open);
|
||||
if (close < 0) return null;
|
||||
const tail = body.slice(close + 1);
|
||||
// Pure virtual, defaulted, deleted, or a variable initialized with a call.
|
||||
if (tail.includes("=") || !TAIL.test(tail)) return null;
|
||||
const head = body.slice(0, open);
|
||||
const name = /(~?[A-Za-z_]\w*)\s*$/.exec(head);
|
||||
if (!name) return null;
|
||||
const before = head.slice(0, name.index);
|
||||
// `Foo::bar();` is not a declaration; operators and macros (`Q_DECLARE_METATYPE(X);`) are left out.
|
||||
if (/::\s*$/.test(before) || /\boperator\s*$/.test(before) || /^[A-Z][A-Z0-9_]+$/.test(name[1]!)) return null;
|
||||
const type = before.replace(SPECIFIERS, " ").trim();
|
||||
const ctor = scope?.kind === "record" && name[1]!.replace(/^~/, "") === scope.name;
|
||||
if (!type && !ctor) return null;
|
||||
if (/[=(){}]/.test(type) || /^(else|case|goto|delete|new|throw)$/.test(type)) return null;
|
||||
// A Qt signal declared on its own: moc writes its body.
|
||||
if (/\bQ_SIGNAL\b/.test(before)) return null;
|
||||
const params = body.slice(open + 1, close);
|
||||
if (!splitTopLevel(params).every(isParameter)) return null;
|
||||
const declFrom = start + lead;
|
||||
const from = declFrom + name.index;
|
||||
return {
|
||||
name: name[1]!,
|
||||
from,
|
||||
to: from + name[1]!.length,
|
||||
declFrom,
|
||||
declTo: end,
|
||||
open: declFrom + open,
|
||||
close: declFrom + close,
|
||||
scopes: stack.filter((s) => s.kind !== "other" && s.name).map((s) => s.name),
|
||||
member: scope?.kind === "record",
|
||||
templated: stack.some((s) => s.templated) || /\btemplate\s*</.test(before),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* The function declarations without a body in `text`: at file scope, in namespaces, `extern "C"`
|
||||
* blocks and classes (not in a class's Qt `signals:` section, whose bodies moc writes).
|
||||
*/
|
||||
export function functionPrototypes(text: string): Prototype[] {
|
||||
const masked = maskCode(text);
|
||||
const stack: Scope[] = [];
|
||||
const out: Prototype[] = [];
|
||||
let start = 0;
|
||||
// Parentheses open in the current statement, and braces opened inside them (`int r = {1, 2}` as a
|
||||
// default argument): those are part of the statement, not a body.
|
||||
let parens = 0;
|
||||
let inner = 0;
|
||||
for (let i = 0; i < masked.length; i++) {
|
||||
const c = masked[i]!;
|
||||
const scope = stack.at(-1);
|
||||
if (scope?.kind !== "other" && parens > 0 && (c === "{" || (c === "}" && inner > 0))) {
|
||||
inner += c === "{" ? 1 : -1;
|
||||
continue;
|
||||
}
|
||||
if (scope?.kind !== "other" && (c === "(" || c === ")")) parens = Math.max(0, parens + (c === "(" ? 1 : -1));
|
||||
if (c === "{" || c === "}" || c === ";") parens = 0;
|
||||
if (c === "{") {
|
||||
stack.push(scopeOf(masked.slice(start, i), scope));
|
||||
start = i + 1;
|
||||
} else if (c === "}") {
|
||||
stack.pop();
|
||||
start = i + 1;
|
||||
} else if (scope?.kind === "other") {
|
||||
continue;
|
||||
} else if (c === ";") {
|
||||
const p = prototype(masked, start, i, stack);
|
||||
if (p) out.push(p);
|
||||
start = i + 1;
|
||||
} else if (c === ":" && masked[i + 1] !== ":" && masked[i - 1] !== ":" && scope?.kind === "record") {
|
||||
const label =
|
||||
/(?:^|\s)((?:public|private|protected)(?:\s+(?:slots|Q_SLOTS))?|signals|Q_SIGNALS|slots|Q_SLOTS)\s*$/.exec(
|
||||
masked.slice(start, i),
|
||||
);
|
||||
if (label) {
|
||||
scope.signals = /^(signals|Q_SIGNALS)$/.test(label[1]!);
|
||||
start = i + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/** Paths compared as the OS does: Windows paths (`C:/…`, `c:\…`) without case. */
|
||||
const samePath = (a: string, b: string) => {
|
||||
const norm = (p: string) => {
|
||||
const s = p.replace(/\\/g, "/");
|
||||
return /^[A-Za-z]:\//.test(s) ? s.toLowerCase() : s;
|
||||
};
|
||||
return norm(a) === norm(b);
|
||||
};
|
||||
|
||||
/** Whether go to definition on a prototype at `line` of `path` found nothing but the prototype itself. */
|
||||
export function onlyItself(locations: readonly Location[], path: string, line: number): boolean {
|
||||
return locations.length > 0 && locations.every((l) => samePath(l.path, path) && l.range.start.line === line);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ fixes
|
||||
|
||||
const isHeader = (path: string) => /\.(h|hh|hpp|hxx|h\+\+|inl|ipp|tpp)$/i.test(path);
|
||||
const isSource = (path: string) => /\.(c|cc|cpp|cxx|c\+\+|m|mm)$/i.test(path);
|
||||
|
||||
/** `[from, to)` of each top-level comma-separated part of `masked[from, to)`. */
|
||||
function topLevelParts(masked: string, from: number, to: number): Array<[number, number]> {
|
||||
const parts: Array<[number, number]> = [];
|
||||
let depth = 0;
|
||||
let start = from;
|
||||
for (let i = from; i < to; i++) {
|
||||
const c = masked[i]!;
|
||||
if ("(<[{".includes(c)) depth++;
|
||||
else if (")>]}".includes(c)) depth = Math.max(0, depth - 1);
|
||||
else if (c === "," && depth === 0) {
|
||||
parts.push([start, i]);
|
||||
start = i + 1;
|
||||
}
|
||||
}
|
||||
parts.push([start, to]);
|
||||
return parts;
|
||||
}
|
||||
|
||||
/** First top-level `=` of `masked[from, to)` (a default value), or `to`. */
|
||||
function defaultAt(masked: string, from: number, to: number): number {
|
||||
let depth = 0;
|
||||
for (let i = from; i < to; i++) {
|
||||
const c = masked[i]!;
|
||||
if ("(<[{".includes(c)) depth++;
|
||||
else if (")>]}".includes(c)) depth = Math.max(0, depth - 1);
|
||||
else if (c === "=" && depth === 0) return i;
|
||||
}
|
||||
return to;
|
||||
}
|
||||
|
||||
/**
|
||||
* The out-of-class definition of `p`, qualified with its namespaces and classes, with an empty body:
|
||||
* without default arguments and the specifiers only a declaration takes (`virtual`, `static` of a
|
||||
* member, `explicit`, `override`, attributes).
|
||||
*/
|
||||
export function definitionText(text: string, p: Prototype): string {
|
||||
const masked = maskCode(text);
|
||||
const drop = p.member
|
||||
? /\b(explicit|virtual|static|inline|extern|friend|Q_INVOKABLE|Q_SCRIPTABLE|Q_SLOT)\b|\[\[[^\]]*\]\]/g
|
||||
: /\b(inline|extern|Q_INVOKABLE)\b|\[\[[^\]]*\]\]/g;
|
||||
const head = text.slice(p.declFrom, p.from).replace(drop, " ").replace(/\s+/g, " ").trim();
|
||||
const params = topLevelParts(masked, p.open + 1, p.close)
|
||||
.map(([from, to]) =>
|
||||
text
|
||||
.slice(from, defaultAt(masked, from, to))
|
||||
.replace(/\s+/g, " ")
|
||||
.trim(),
|
||||
)
|
||||
.filter(Boolean)
|
||||
.join(", ");
|
||||
const tail = text
|
||||
.slice(p.close + 1, p.declTo)
|
||||
.replace(/\b(override|final)\b/g, " ")
|
||||
.replace(/\s+/g, " ")
|
||||
.trim();
|
||||
const name = [...p.scopes, p.name].join("::");
|
||||
const space = head && !/[*&]$/.test(head) ? " " : "";
|
||||
return `${head}${space}${name}(${params})${tail ? ` ${tail}` : ""} {\n}\n`;
|
||||
}
|
||||
|
||||
/** Implement Inline: the declaration gets an empty body (`inline` too, for a function in a header). */
|
||||
export function implementInline(view: EditorView, p: Prototype) {
|
||||
const state = view.state;
|
||||
const line = state.doc.lineAt(p.declFrom);
|
||||
const indent = /^\s*/.exec(line.text)![0];
|
||||
const unit = state.facet(indentUnit) || " ";
|
||||
const head = state.doc.sliceString(p.declFrom, p.from);
|
||||
const path = docOf(view)?.path ?? "";
|
||||
const inline = !p.member && isHeader(path) && !/\b(inline|constexpr|consteval|template)\b/.test(head);
|
||||
const body = ` {\n${indent}${unit}\n${indent}}`;
|
||||
const shift = inline ? "inline ".length : 0;
|
||||
view.dispatch({
|
||||
changes: [
|
||||
...(inline ? [{ from: p.declFrom, insert: "inline " }] : []),
|
||||
{ from: p.declTo, to: p.declTo + 1, insert: body },
|
||||
],
|
||||
selection: EditorSelection.cursor(p.declTo + shift + ` {\n${indent}${unit}`.length),
|
||||
scrollIntoView: true,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Definition: an empty definition at the end of the header's source file (found as Switch
|
||||
* Header/Source finds it), or of this file when it is a source file; the caret goes into its body.
|
||||
*/
|
||||
export async function createDefinition(view: EditorView, p: Prototype) {
|
||||
const doc = docOf(view);
|
||||
if (!doc) return;
|
||||
const definition = definitionText(view.state.doc.toString(), p);
|
||||
let target = doc.path;
|
||||
if (isHeader(doc.path)) {
|
||||
const other = await switchHeaderSource(
|
||||
doc.path,
|
||||
() => lspRequest(() => commands.lspSwitchSourceHeader(nextRequestId(), doc.doc)),
|
||||
(name) => call(commands.findFilesNamed(name)),
|
||||
);
|
||||
if (!other || !isSource(other)) {
|
||||
showHint(view, tx("This header has no source file: use Implement Inline"));
|
||||
return;
|
||||
}
|
||||
target = other;
|
||||
}
|
||||
const attachment = await attachDocument(target);
|
||||
try {
|
||||
const text = attachment.contents();
|
||||
const end = text.length;
|
||||
const insert = `${text.toString().endsWith("\n") || !end ? "" : "\n"}${end ? "\n" : ""}${definition}`;
|
||||
attachment.edit({ from: end, insert });
|
||||
const after = attachment.contents();
|
||||
const caret = offsetToPos(after, end + insert.indexOf(" {\n") + 3);
|
||||
await openCodeLocation(target, { line: caret.line, col: caret.col });
|
||||
} finally {
|
||||
attachment.release();
|
||||
}
|
||||
}
|
||||
|
||||
/** What was found defined nowhere, per document text (the fixes read it). */
|
||||
const found = new WeakMap<Text, Prototype[]>();
|
||||
|
||||
/** Records what was found defined nowhere in `text`, for the fixes. */
|
||||
export function rememberUnimplemented(text: Text, list: Prototype[]) {
|
||||
found.set(text, list);
|
||||
}
|
||||
|
||||
function unimplementedFixes(view: EditorView, from: number, to: number): ContributedIntention[] {
|
||||
const p = found.get(view.state.doc)?.find((x) => x.from <= to && x.to >= from);
|
||||
if (!p) return [];
|
||||
return [
|
||||
...(p.templated
|
||||
? []
|
||||
: [
|
||||
{
|
||||
id: "cpp.createDefinition",
|
||||
label: tx("Create Definition"),
|
||||
quickFix: true,
|
||||
emphasis: true,
|
||||
run: () => createDefinition(view, p),
|
||||
},
|
||||
]),
|
||||
{ id: "cpp.implementInline", label: tx("Implement Inline"), quickFix: true, run: () => implementInline(view, p) },
|
||||
];
|
||||
}
|
||||
|
||||
const C_FAMILY = ["c", "cpp", "objective-c", "objective-cpp"];
|
||||
// The problem's fixes (its tooltip, the Problems view), and the same rows in ⌥↵ at the caret.
|
||||
registerLanguageSemantics(C_FAMILY, {
|
||||
quickFixes: unimplementedFixes,
|
||||
intentions: (view) => {
|
||||
const { from, to } = view.state.selection.main;
|
||||
return unimplementedFixes(view, from, to);
|
||||
},
|
||||
});
|
||||
|
||||
// ------------------------------------------------------------------ inspection
|
||||
|
||||
const MAX_PROTOTYPES = 300;
|
||||
/** The servers answering for C-family files: another language's busy server does not hold the results. */
|
||||
const SERVERS = ["clangd", "sourcekit-lsp"];
|
||||
|
||||
const enabled = () => inspectionProfile()[CPP_UNIMPLEMENTED_INSPECTION]?.enabled !== false;
|
||||
|
||||
function diagnostic(text: Text, p: Prototype): Diagnostic {
|
||||
return {
|
||||
range: { start: offsetToPos(text, p.from), end: offsetToPos(text, p.to) },
|
||||
severity: "info",
|
||||
message: tx`Function '${p.name}' is declared but never defined`,
|
||||
source: "C/C++",
|
||||
code: null,
|
||||
unnecessary: true,
|
||||
};
|
||||
}
|
||||
|
||||
class UnimplementedPlugin {
|
||||
private schedule = debounce(() => void this.run(), 1500);
|
||||
/** Results for `cacheDoc`: `from:name` → defined nowhere. */
|
||||
private cache = new Map<string, boolean>();
|
||||
private cacheDoc: Text | null = null;
|
||||
private request: RequestId | null = null;
|
||||
private path: string | null;
|
||||
private offSettled: () => void;
|
||||
private offProfile: () => void;
|
||||
|
||||
constructor(private view: EditorView) {
|
||||
this.path = docOf(view)?.path ?? null;
|
||||
this.schedule();
|
||||
// Definitions found by indexing that was still running.
|
||||
this.offSettled = onServerSettled(() => {
|
||||
this.cache.clear();
|
||||
this.cacheDoc = null;
|
||||
this.schedule();
|
||||
});
|
||||
this.offProfile = subscribeInspectionProfile(() => this.schedule());
|
||||
}
|
||||
|
||||
update(u: ViewUpdate) {
|
||||
if (u.docChanged) this.schedule();
|
||||
}
|
||||
|
||||
destroy() {
|
||||
this.schedule.cancel();
|
||||
this.offSettled();
|
||||
this.offProfile();
|
||||
this.cancel();
|
||||
if (this.path) setFileDiagnostics(this.path, CPP_UNIMPLEMENTED_PRODUCER, []);
|
||||
}
|
||||
|
||||
private cancel() {
|
||||
if (this.request !== null) void commands.cancelRequest(this.request).catch(() => {});
|
||||
this.request = null;
|
||||
}
|
||||
|
||||
private publish(text: Text, list: Prototype[]) {
|
||||
if (!this.path) return;
|
||||
rememberUnimplemented(text, list);
|
||||
setFileDiagnostics(
|
||||
this.path,
|
||||
CPP_UNIMPLEMENTED_PRODUCER,
|
||||
list.map((p) => diagnostic(text, p)),
|
||||
);
|
||||
this.view.dispatch({ effects: intentionsChanged.of(null) });
|
||||
}
|
||||
|
||||
private async run() {
|
||||
const view = this.view;
|
||||
const doc = docOf(view);
|
||||
if (!doc || isLibrarySource(doc)) return;
|
||||
const text = view.state.doc;
|
||||
if (!enabled()) {
|
||||
this.publish(text, []);
|
||||
return;
|
||||
}
|
||||
// Keep what is shown while clangd indexes: its answers may still miss definitions.
|
||||
if (serverBusy(SERVERS)) return;
|
||||
if (this.cacheDoc !== text) {
|
||||
this.cache.clear();
|
||||
this.cacheDoc = text;
|
||||
}
|
||||
const protos = functionPrototypes(text.toString()).slice(0, MAX_PROTOTYPES);
|
||||
const key = (p: Prototype) => `${p.from}:${p.name}`;
|
||||
const missing = protos.filter((p) => !this.cache.has(key(p)));
|
||||
if (missing.length) {
|
||||
this.cancel();
|
||||
const request = (this.request = nextRequestId());
|
||||
const positions = missing.map((p) => offsetToPos(text, p.from));
|
||||
let answers: Location[][];
|
||||
try {
|
||||
answers = await lspRequest(
|
||||
() => commands.lspGotos(request, doc.doc, "definition", positions),
|
||||
() => this.request === request && view.state.doc === text,
|
||||
);
|
||||
} catch {
|
||||
return;
|
||||
} finally {
|
||||
if (this.request === request) this.request = null;
|
||||
}
|
||||
if (view.state.doc !== text || serverBusy(SERVERS)) return;
|
||||
missing.forEach((p, i) => this.cache.set(key(p), onlyItself(answers[i] ?? [], doc.path, positions[i]!.line)));
|
||||
}
|
||||
this.publish(
|
||||
text,
|
||||
protos.filter((p) => this.cache.get(key(p))),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/** Reports the C / C++ functions declared but defined nowhere. */
|
||||
export function unimplementedFunctionsExtension(): Extension {
|
||||
return ViewPlugin.fromClass(UnimplementedPlugin);
|
||||
}
|
||||
@@ -103,6 +103,7 @@ describe("inspections tree", () => {
|
||||
|
||||
it("groups servers by language with seen and configured codes, built-ins by category", () => {
|
||||
expect(tree.map((g) => g.name)).toEqual([
|
||||
"C/C++",
|
||||
"Cargo",
|
||||
"General",
|
||||
"Gherkin",
|
||||
|
||||
@@ -239,6 +239,9 @@ export const DEPENDENCY_PRODUCER = "dependency-versions";
|
||||
export const DEPENDENCY_INSPECTION = "builtin:dependency-versions";
|
||||
export const PYTHON_REQUIREMENTS_PRODUCER = "python-requirements";
|
||||
export const PYTHON_REQUIREMENTS_INSPECTION = "builtin:python-requirements";
|
||||
/** C / C++ prototypes clangd finds no definition for (`editor/lsp/semantic/cpp/unimplemented.ts`). */
|
||||
export const CPP_UNIMPLEMENTED_PRODUCER = "cpp-unimplemented";
|
||||
export const CPP_UNIMPLEMENTED_INSPECTION = "builtin:cpp-unimplemented";
|
||||
|
||||
/** Conflict markers left in a file by a merge, rebase, cherry-pick or stash that stopped on conflicts. */
|
||||
export const CONFLICT_MARKERS_PRODUCER = "merge-conflict-markers";
|
||||
@@ -295,6 +298,15 @@ export const BUILTIN_INSPECTIONS: readonly BuiltinInspection[] = [
|
||||
"Reports requirements in requirements.txt and pyproject.toml that the project's Python interpreter does not have installed, or whose installed version does not match.",
|
||||
defaultLevel: "warning",
|
||||
},
|
||||
{
|
||||
id: CPP_UNIMPLEMENTED_INSPECTION,
|
||||
producer: CPP_UNIMPLEMENTED_PRODUCER,
|
||||
name: "Function declared but never defined",
|
||||
group: "C/C++",
|
||||
description:
|
||||
"Reports C and C++ function declarations (in headers, namespaces and classes) that clangd finds no definition for, once it has indexed the project. Pure virtual, defaulted and deleted functions, operators and Qt signals are left out.",
|
||||
defaultLevel: "weakWarning",
|
||||
},
|
||||
{
|
||||
id: "builtin:syntax",
|
||||
producer: SYNTAX_ERRORS_PRODUCER,
|
||||
|
||||
@@ -4143,6 +4143,12 @@
|
||||
"Loading preview…": "Loading preview…",
|
||||
"Left": "Left",
|
||||
"Result": "Result",
|
||||
"Function '{name}' is declared but never defined": "Function '{name}' is declared but never defined",
|
||||
"Create Definition": "Create Definition",
|
||||
"Implement Inline": "Implement Inline",
|
||||
"This header has no source file: use Implement Inline": "This header has no source file: use Implement Inline",
|
||||
"Function declared but never defined": "Function declared but never defined",
|
||||
"Reports C and C++ function declarations (in headers, namespaces and classes) that clangd finds no definition for, once it has indexed the project. Pure virtual, defaulted and deleted functions, operators and Qt signals are left out.": "Reports C and C++ function declarations (in headers, namespaces and classes) that clangd finds no definition for, once it has indexed the project. Pure virtual, defaulted and deleted functions, operators and Qt signals are left out.",
|
||||
"Right": "Right",
|
||||
"16 unchanged lines": "16 unchanged lines",
|
||||
"Create exception breakpoint on {name}": "Create exception breakpoint on {name}",
|
||||
|
||||
@@ -4771,6 +4771,12 @@
|
||||
"Copies the change at the caret from the left side to the right one": "Copie la modification au niveau du curseur du côté gauche vers le côté droit",
|
||||
"Copies the change at the caret from the right side to the left one": "Copie la modification au niveau du curseur du côté droit vers le côté gauche",
|
||||
"Compare Next File": "Comparer le fichier suivant",
|
||||
"Function '{name}' is declared but never defined": "La fonction '{name}' est déclarée mais jamais définie",
|
||||
"Create Definition": "Créer la définition",
|
||||
"Implement Inline": "Implémenter en ligne",
|
||||
"This header has no source file: use Implement Inline": "Cet en-tête n’a pas de fichier source : utilisez Implémenter en ligne",
|
||||
"Function declared but never defined": "Fonction déclarée mais jamais définie",
|
||||
"Reports C and C++ function declarations (in headers, namespaces and classes) that clangd finds no definition for, once it has indexed the project. Pure virtual, defaulted and deleted functions, operators and Qt signals are left out.": "Signale les déclarations de fonctions C et C++ (dans les en-têtes, les namespaces et les classes) dont clangd ne trouve aucune définition, une fois le projet indexé. Les fonctions virtuelles pures, par défaut et supprimées, les opérateurs et les signaux Qt sont ignorés.",
|
||||
"Compare Previous File": "Comparer le fichier précédent",
|
||||
"Context Info": "Informations de contexte",
|
||||
"No context information here": "Aucune information de contexte ici",
|
||||
|
||||
@@ -7776,6 +7776,12 @@
|
||||
"Container ID": "容器 ID",
|
||||
"Created": "建立時間",
|
||||
"Started": "啟動時間",
|
||||
"Function '{name}' is declared but never defined": "函式 '{name}' 已宣告但從未定義",
|
||||
"Create Definition": "建立定義",
|
||||
"Implement Inline": "內嵌實作",
|
||||
"This header has no source file: use Implement Inline": "此標頭檔沒有對應的原始檔:請使用「內嵌實作」",
|
||||
"Function declared but never defined": "已宣告但從未定義的函式",
|
||||
"Reports C and C++ function declarations (in headers, namespaces and classes) that clangd finds no definition for, once it has indexed the project. Pure virtual, defaulted and deleted functions, operators and Qt signals are left out.": "回報 clangd 在索引專案後找不到定義的 C 和 C++ 函式宣告(位於標頭檔、命名空間和類別中)。純虛擬函式、預設和刪除的函式、運算子以及 Qt 訊號不在此列。",
|
||||
"Restart policy": "重啟策略",
|
||||
"Compose": "Compose 專案",
|
||||
"Resource Usage": "資源使用情況",
|
||||
|
||||
@@ -9650,6 +9650,12 @@
|
||||
"Stop recording the page and open the profile": "停止记录页面并打开性能分析结果",
|
||||
"Cannot record a CPU profile": "无法记录 CPU 性能分析",
|
||||
"No CPU profile to show": "没有可显示的 CPU 性能分析",
|
||||
"Function '{name}' is declared but never defined": "函数 '{name}' 已声明但从未定义",
|
||||
"Create Definition": "创建定义",
|
||||
"Implement Inline": "内联实现",
|
||||
"This header has no source file: use Implement Inline": "此头文件没有对应的源文件:请使用“内联实现”",
|
||||
"Function declared but never defined": "已声明但从未定义的函数",
|
||||
"Reports C and C++ function declarations (in headers, namespaces and classes) that clangd finds no definition for, once it has indexed the project. Pure virtual, defaulted and deleted functions, operators and Qt signals are left out.": "报告 clangd 在索引项目后找不到定义的 C 和 C++ 函数声明(位于头文件、命名空间和类中)。纯虚函数、默认和删除的函数、运算符以及 Qt 信号不在此列。",
|
||||
"Open Snapshot…": "打开快照…",
|
||||
"Open Snapshot": "打开快照",
|
||||
"Open in Profiler": "在性能分析器中打开",
|
||||
|
||||
Reference in new issue
Заблокувати користувача