如何使用 OTA 获取文件错误?

How to get errors of the file using OTA?

我想访问活动文件 (.pas) 上的错误。 现在我可以在 IDE 的左侧找到它,正如您在图片上看到的那样。

我在OTA上找到了接口IOTAModuleErrors,这似乎是我想要的。但是我没有在 BorlandIDEServices.QueryInterface 或 BorlandIDEServices.GetService 上找到它。有人知道如何访问它吗?

我找到了! 这比我想象的要简单得多,只需将模块上的 IOTAModule 转换为 IOTAModuleErrors。

如果你想要一个实际的例子,你可以查看this project 我在单元 Source/FindUnit.OTAUtils.pas 上使用函数 GetErrorListFromActiveModule.

样本:

function GetErrorsListFromActiveModule: TOTAErrors;
var
  ModuleServices: IOTAModuleServices;
  ModuleErrors: IOTAModuleErrors;
begin
  ModuleServices := BorlandIDEServices as IOTAModuleServices;
  Assert(Assigned(ModuleServices));
  ModuleErrors := ModuleServices.CurrentModule as IOTAModuleErrors;
  Result := ModuleErrors.GetErrors(ModuleServices.CurrentModule.FileName);
end;

谢谢