Einzelnen Beitrag anzeigen

Assarbad
(Gast)

n/a Beiträge
 
#8

Re: Delphi Preprocessor und Subprocessor?

  Alt 10. Aug 2003, 18:41
Hiho,

auch mit Delphi 4 geht es ... man muß nur TNotifierObject durch TInterfacedObject ersetzen und ein paar Methoden implementieren. Ich werde das nochmal umschreiben. Wenn du erlaubst, würde ich es dann als OpenSource hier ins Forum stellen. Schreib mir doch mal ne PN was du drinstehen haben möchtest, jbg

Delphi-Quellcode:
unit ...
interface
uses
  SysUtils, ToolsAPI;

type
  TCompilerNotifier = class(TInterfacedObject, IOTAIDENotifier)
  public
// IOTAIDENotifier
    procedure FileNotification(NotifyCode: TOTAFileNotification; const FileName: string; var Cancel: Boolean); virtual;
    procedure BeforeCompile(const Project: IOTAProject; var Cancel: Boolean); overload; virtual;
    procedure AfterCompile(Succeeded: Boolean); overload; virtual;
// IOTANotifier
    procedure AfterSave;
    procedure BeforeSave;
    procedure Modified;
    procedure Destroyed;
// IOTAIDENotifier50
    procedure BeforeCompile(const Project: IOTAProject; IsCodeInsight: Boolean;
      var Cancel: Boolean); overload; virtual;
    procedure AfterCompile(Succeeded: Boolean; IsCodeInsight: Boolean); overload; virtual;
  end;


implementation
{ TCompilerNotifier }

procedure TCompilerNotifier.AfterSave;
begin
end;

procedure TCompilerNotifier.BeforeSave;
begin
end;

procedure TCompilerNotifier.Modified;
begin
end;

procedure TCompilerNotifier.Destroyed;
begin
end;

{ veraltete Methoden }

procedure TCompilerNotifier.BeforeCompile(const Project: IOTAProject; var Cancel: Boolean);
begin
end;

procedure TCompilerNotifier.AfterCompile(Succeeded: Boolean);
begin
end;

{ neue Methoden }

procedure TCompilerNotifier.BeforeCompile(const Project: IOTAProject; IsCodeInsight: Boolean; var Cancel: Boolean);
begin
  if not IsCodeInsight then
  begin
    if not (BorlandIDEServices as IOTAModuleServices).SaveAll then
      Exit;
  end;
end;

procedure TCompilerNotifier.AfterCompile(Succeeded: Boolean; IsCodeInsight: Boolean);
begin
  if not IsCodeInsight then
  begin
  end;
end;

procedure TCompilerNotifier.FileNotification(NotifyCode: TOTAFileNotification; const FileName: string; var Cancel: Boolean);
begin
  Cancel := False;
end;

var
  NotifierIndex: Integer;

{ CompilerNotifier registrieren }
initialization
  NotifierIndex := (BorlandIDEServices as IOTAServices).AddNotifier(TCompilerNotifier.Create);

finalization
  if NotifierIndex >= 0 then
    (BorlandIDEServices as IOTAServices).RemoveNotifier(NotifierIndex);
// clear all IOTACustomMessages here, else Delphi unloads the dll and then
// it wants to free the messages -> AccessViolation
  (BorlandIDEServices as IOTAMessageServices).ClearToolMessages;

end.
  Mit Zitat antworten Zitat