使用 OTA 将文件设置为已修改

发布于 2024-10-28 12:43:39 字数 317 浏览 2 评论 0原文

正如我们所知,Build 编译所有使用的单元,而 Compile 仅编译更改的使用单元。但是,当您使用 ifdef 并需要多次更改它时,您必须多次构建项目。 如果您有很多库并且知道此 IFDEF 不会改变行为,则没有理由再次构建此库。

我想要做的发现是向 IDE 告知某些文件已更改并调用编译而不是构建。

如何获取单位和其他我知道的信息,但有些人知道如何将单位设置为修改后的单位?

Tks


还找不到解决我的问题的原因。我找到了一种将其设置为修改后的方法,问题是它不会强制 IDE 按照我的想法构建它。 有人知道对发送编译的存档进行了哪些检查?

As we know Build compiles all used units and Compile compiles only changed used units. But when you are working with ifdefs and need to change it a lot of times you must Build the project a lot of times.
If you have to much libraries that you know that this IFDEF will not change the behavior, there is no reason to build this library again.

What I want to do discovery is a way to say to the IDE that some files was changed and call the Compile and not the Build.

How to get the units and every else I know, but some know how to set the unit as modified?

Tks


Couldn't find a why to solve my problem yet. I found a way to set it as modified the problem is that it doesn't force the IDE to build it as I thought it'll.
Some one know what checks is made to an archive be sent to compile ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

一瞬间的火花 2024-11-04 12:43:39

用更简单的方法解决了。我刚刚删除了文件的DCU,好吧,它会再次编译它。 :D
http://paste.ideaslabs.com/show/KCB9cq2Z8c

Solved in a simpler way. I just deleted the DCU of the file and ok, it'll compile it again. :D
http://paste.ideaslabs.com/show/KCB9cq2Z8c

安穩 2024-11-04 12:43:39

让我们假设您想要将编辑器缓冲区标记为已修改。假设有一个编辑器缓冲区需要修改,但在大多数情况下,对于项目中的大多数项目来说,没有编辑器缓冲区。假设您始终始终打开项目中的每个文件,那么也许您可以通过这种方式调整这些打开的单元。

我的想法是,您实际上不仅需要标记编辑器缓冲区已修改,还需要触摸磁盘上由于 #define 更改而需要重建的所有文件。

要了解哪些文件受到影响,您需要读取所有文件。我认为,您一次又一次可靠地执行此操作并且比仅执行 BUILD 更快的可能性非常小。

但是,如果您确实决定这样做,则不仅需要修改缓冲区修改标志,而且对于当前项目组中的任何其他文件,或者位于搜索或库路径中包含的文件夹中,查找任何文件可能会受到影响。

您可能会发现这比您最初想象的要复杂。

而且,就 OTA 而言,这里是 IOTAEditor 属性,已修改,它是只读的。

OTA 不希望您更改它:

IOTAEditor = interface(IUnknown)
    ['{F17A7BD0-E07D-11D1-AB0B-00C04FB16FB3}']
    ...
    function GetModified: Boolean;
    ..
    property Modified: Boolean read GetModified;
    ..
  end;

但您实际上可以修改缓冲区内容本身,这会设置标志。

使用IOTAEditorContent,获取内容(IStream),修改它(添加一个空格),然后再次修改它(去掉空格)。您现在已经设置了脏位(调用 GetModified 只是为了运气)。

我从 JCL JclStackTraceViewerStackCodeUtils.pas 中找到了一些示例代码,它向您展示了如何使用 IOTAEditorContent 读取编辑器内容:

function GetFileEditorContent(const AFileName: string): IStream;
var
      I: Integer;
      Module: IOTAModule;
      EditorContent: IOTAEditorContent;
begin
      Result := nil;
      Module := (BorlandIDEServices as IOTAModuleServices).FindModule(AFileName);
      if Assigned(Module) then
      begin
        for I := 0 to Module.ModuleFileCount - 1 do
          if Supports(Module.ModuleFileEditors[I], IOTAEditorContent, EditorContent) then
          begin
            Result := EditorContent.Content;
            Break;
          end;
      end;
end;

重新阅读您的问题后,在我看来您只想将打开的编辑器缓冲区标记为全部更改,然后进行编译,为了速度。所以你可能想要这样做:使用上面的代码,使用 Supports() 获取 IOTAEditorContent,然后调整每一个。

更新:简短而甜蜜的版本:修改缓冲区是不够的。另外,您不会为需要更改的文件提供缓冲区,而且触摸磁盘上的文件也不会执行您想要的操作。所以不,你不能完全做你想做的事。即使您可以以某种方式修改编译器执行 Make 风格的依赖项和修改检查的能力,也可能会在 IDE 中引起很多问题。

Let us assume that what you want is to mark editor buffers modified. That assumes there is an editor buffer to modify, which in most cases, there isn't, for most items in your Project. Let's suppose that you ALWAYS have every file in your project open at all times, then perhaps you can tweak those open units, this way.

My thinking is that you would actually need not only to mark editor buffers modified, but also TOUCH all the files on disk that would need to be rebuilt because of the #define change.

To know which files are affected, you would need to read all the files. I think, that the odds of you doing this reliably, over and over again, and faster than just doing a BUILD are pretty slim.

But if you did decide to go for it, you need not only to modify buffer Modified flags, but also, for any other file in the current project group, or which is in a folder included in the search or library path, find any file which might be affected.

You can see perhaps that this is more complex than you first thought.

And, as far as OTA goes, here is IOTAEditor property, Modified, it is read only.

The OTA doesn't want you changing it:

IOTAEditor = interface(IUnknown)
    ['{F17A7BD0-E07D-11D1-AB0B-00C04FB16FB3}']
    ...
    function GetModified: Boolean;
    ..
    property Modified: Boolean read GetModified;
    ..
  end;

But you could actually modify the buffer CONTENT itself, and that would set the flag.

Use IOTAEditorContent, get the content (IStream), modify it (add a space), then modify it again (take away the space). You have now set the dirty bit (call GetModified just for luck).

I found some sample code from JCL JclStackTraceViewerStackCodeUtils.pas that shows you how to read editor content using IOTAEditorContent:

function GetFileEditorContent(const AFileName: string): IStream;
var
      I: Integer;
      Module: IOTAModule;
      EditorContent: IOTAEditorContent;
begin
      Result := nil;
      Module := (BorlandIDEServices as IOTAModuleServices).FindModule(AFileName);
      if Assigned(Module) then
      begin
        for I := 0 to Module.ModuleFileCount - 1 do
          if Supports(Module.ModuleFileEditors[I], IOTAEditorContent, EditorContent) then
          begin
            Result := EditorContent.Content;
            Break;
          end;
      end;
end;

After re-reading your question, it seems to me you only want to mark open editor buffers as all changed, and then do a compile, for speed. So you might want to do this: Take the code above, get the IOTAEditorContent using Supports(), and tweak each one.

Update: Short and sweet version: Modifying the buffer isn't sufficient. Plus, you won't have buffers for the files you need to change, plus Touching the file on the disk doesn't do what you want. So no, you can't do exactly what you wanted to do. And even if you could somehow modify the compiler's ability to do Make-style dependency and modification checks, you would probably cause a lot of problems inside the IDE.

暖心男生 2024-11-04 12:43:39

在 IOTAModule70 = interface(IOTAModule50) 上我会找到 MarkModified:
描述:
{ MarkModifed 会将此模块标记为“已修改”,而不实际指示
为什么被修改(这将导致内部文件日期保持不变)。
当用户尝试时,这强制 IDE 要求保存此模块
关闭它。它还将清除新的未命名的“可废弃性”
模块,例如选择文件|新建|应用程序时。 }

On IOTAModule70 = interface(IOTAModule50) I'll find MarkModified:
Description:
{ MarkModifed will mark this module as "modified" without actually indicating
why is it modified (which will cause internal file dates to remain constant).
This will force the IDE to ask to save this module when the user attempts
to close it. It will also clear the "discardability" of a new unnamed
module such as when File|New|Application is selected. }

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文