如何在 VS 代码问题中添加消息 window

How to put a message in VS Code Problems window

我有一个 VS 代码扩展,它在 json 文件上强制执行 json 架构。当出现错误时,它会在问题 window 中发布一条消息,这很棒。

如何从我的分机写入此 window,将我自己的消息放入问题 window?

我搜索了文档,只能找到 showInformationMessage、showErrorMessage 和 showWarningMessage,但其中 none 将消息放在我能看到的任何可见位置。

任何有关正确方法或合适文档页面的提示都将非常有帮助。

您可以为此使用诊断。 API 的起点是 createDiagnosticCollection()vscode.languages namespace. vscode-extension-samples has a simple example for this. The basic idea is that DiagnosticCollection 充当以 URI 作为键和诊断数组作为值的映射。