IDEIntf: added package files

git-svn-id: trunk@26155 -
This commit is contained in:
mattias 2010-06-17 07:37:07 +00:00
parent cde3a2dc45
commit 8f79d17b08
3 changed files with 99 additions and 29 deletions

View File

@ -159,6 +159,7 @@ type
procedure SaveDialog1Show(Sender: TObject); procedure SaveDialog1Show(Sender: TObject);
procedure ToolButton1Click(Sender: TObject); procedure ToolButton1Click(Sender: TObject);
private private
FBaseDirectory: string;
fBuild : Boolean; fBuild : Boolean;
FIdleConnected: boolean; FIdleConnected: boolean;
fMainSourceFilename : String; fMainSourceFilename : String;
@ -166,6 +167,7 @@ type
fRootCBuffer : TCodeBuffer; fRootCBuffer : TCodeBuffer;
fScannedFiles: TAvgLvlTree;// tree of TTLScannedFile fScannedFiles: TAvgLvlTree;// tree of TTLScannedFile
procedure SetBaseDirectory(const AValue: string);
procedure SetIdleConnected(const AValue: boolean); procedure SetIdleConnected(const AValue: boolean);
procedure SetMainSourceFilename(const AValue: String); procedure SetMainSourceFilename(const AValue: String);
@ -181,6 +183,7 @@ type
destructor Destroy; override; destructor Destroy; override;
property MainSourceFilename : String read fMainSourceFilename write SetMainSourceFilename; property MainSourceFilename : String read fMainSourceFilename write SetMainSourceFilename;
property BaseDirectory: string read FBaseDirectory write SetBaseDirectory;
property OnOpenFile: TOnOpenFile read FOnOpenFile write FOnOpenFile; property OnOpenFile: TOnOpenFile read FOnOpenFile write FOnOpenFile;
property IdleConnected: boolean read FIdleConnected write SetIdleConnected; property IdleConnected: boolean read FIdleConnected write SetIdleConnected;
end; end;
@ -341,6 +344,13 @@ begin
Application.RemoveOnIdleHandler(@OnIdle); Application.RemoveOnIdleHandler(@OnIdle);
end; end;
procedure TIDETodoWindow.SetBaseDirectory(const AValue: string);
begin
if FBaseDirectory=AValue then exit;
FBaseDirectory:=AValue;
acRefresh.Execute;
end;
function TIDETodoWindow.CreateToDoItem(aTLFile: TTLScannedFile; function TIDETodoWindow.CreateToDoItem(aTLFile: TTLScannedFile;
const aFileName: string; const SComment, EComment: string; const aFileName: string; const SComment, EComment: string;
const TokenString: string; LineNumber: Integer): TTodoItem; const TokenString: string; LineNumber: Integer): TTodoItem;
@ -653,7 +663,7 @@ begin
if MainSourceFilename='' then exit; if MainSourceFilename='' then exit;
// Find an '.todo' file of the main source // Find a '.todo' file of the main source
St:=ChangeFileExt(MainSourceFilename,'.todo'); St:=ChangeFileExt(MainSourceFilename,'.todo');
if FileExistsUTF8(St) then if FileExistsUTF8(St) then
ScanFile(St); ScanFile(St);
@ -699,6 +709,7 @@ begin
if CurProject<>nil then begin if CurProject<>nil then begin
// scan all units of project // scan all units of project
FBaseDirectory:=ExtractFilePath(CurProject.ProjectInfoFile);
for i:=0 to CurProject.FileCount-1 do begin for i:=0 to CurProject.FileCount-1 do begin
CurProjFile:=CurProject.Files[i]; CurProjFile:=CurProject.Files[i];
if CurProjFile.IsPartOfProject if CurProjFile.IsPartOfProject
@ -708,6 +719,7 @@ begin
end; end;
if CurPackage<>nil then begin if CurPackage<>nil then begin
// scan all units of package // scan all units of package
FBaseDirectory:=ExtractFilePath(CurPackage.Filename);
{for i:=0 to CurPackage.FileCount-1 do begin {for i:=0 to CurPackage.FileCount-1 do begin
CurPkgFile:=CurPackage.Files[i]; CurPkgFile:=CurPackage.Files[i];
if FilenameIsPascalUnit(CurPkgFile.Filename) then if FilenameIsPascalUnit(CurPkgFile.Filename) then
@ -733,6 +745,7 @@ end;
procedure TIDETodoWindow.AddListItem(aTodoItem: TTodoItem); procedure TIDETodoWindow.AddListItem(aTodoItem: TTodoItem);
var var
aListItem: TListItem; aListItem: TListItem;
aFilename: String;
begin begin
if Assigned(aTodoItem) then if Assigned(aTodoItem) then
begin begin
@ -745,7 +758,10 @@ begin
aListItem.Caption := ' '; aListItem.Caption := ' ';
aListitem.SubItems.Add(aTodoItem.Text); aListitem.SubItems.Add(aTodoItem.Text);
aListitem.SubItems.Add(IntToStr(aTodoItem.Priority)); aListitem.SubItems.Add(IntToStr(aTodoItem.Priority));
aListitem.SubItems.Add(aTodoItem.Filename); aFilename:=aTodoItem.Filename;
if (BaseDirectory<>'') and FilenameIsAbsolute(aFilename) then
aFilename:=CreateRelativePath(aFilename,BaseDirectory);
aListitem.SubItems.Add(aFilename);
aListitem.SubItems.Add(IntToStr(aTodoItem.LineNumber)); aListitem.SubItems.Add(IntToStr(aTodoItem.LineNumber));
aListitem.SubItems.Add(aTodoItem.Owner); aListitem.SubItems.Add(aTodoItem.Owner);
aListitem.SubItems.Add(aTodoItem.Category); aListitem.SubItems.Add(aTodoItem.Category);

View File

@ -60,6 +60,26 @@ type
function VersionBound(v: integer): integer; function VersionBound(v: integer): integer;
end; end;
TIDEPackage = class;
{ TLazPackageFile }
TLazPackageFile = class
private
FFilename: string;
FRemoved: boolean;
protected
procedure SetFilename(const AValue: string); virtual;
function GetIDEPackage: TIDEPackage; virtual; abstract;
procedure SetRemoved(const AValue: boolean); virtual;
public
function GetFullFilename: string; virtual; abstract;
function GetShortFilename(UseUp: boolean): string; virtual; abstract;
public
property Filename: string read FFilename write SetFilename;
property LazPackage: TIDEPackage read GetIDEPackage;
property Removed: boolean read FRemoved write SetRemoved;
end;
{ TLazPackageID } { TLazPackageID }
@ -95,9 +115,13 @@ type
FFilename: string; FFilename: string;
FChangeStamp: integer; FChangeStamp: integer;
function GetDirectoryExpanded: string; virtual; abstract; function GetDirectoryExpanded: string; virtual; abstract;
function GetFileCount: integer; virtual; abstract;
function GetPkgFiles(Index: integer): TLazPackageFile; virtual; abstract;
function GetModified: boolean; virtual; abstract; function GetModified: boolean; virtual; abstract;
procedure SetFilename(const AValue: string); virtual; abstract; procedure SetFilename(const AValue: string); virtual; abstract;
procedure SetModified(const AValue: boolean); virtual; abstract; procedure SetModified(const AValue: boolean); virtual; abstract;
function GetRemovedCount: integer; virtual; abstract;
function GetRemovedPkgFiles(Index: integer): TLazPackageFile; virtual; abstract;
public public
function IsVirtual: boolean; virtual; abstract; function IsVirtual: boolean; virtual; abstract;
function ReadOnly: boolean; virtual; abstract; function ReadOnly: boolean; virtual; abstract;
@ -110,6 +134,10 @@ type
property DirectoryExpanded: string read GetDirectoryExpanded; property DirectoryExpanded: string read GetDirectoryExpanded;
property CustomOptions: TConfigStorage read FCustomOptions; property CustomOptions: TConfigStorage read FCustomOptions;
property ChangeStamp: integer read FChangeStamp; property ChangeStamp: integer read FChangeStamp;
property FileCount: integer read GetFileCount;
property Files[Index: integer]: TLazPackageFile read GetPkgFiles;
property RemovedFilesCount: integer read GetRemovedCount;
property RemovedFiles[Index: integer]: TLazPackageFile read GetRemovedPkgFiles;
end; end;
type type
@ -646,6 +674,18 @@ begin
RemoveHandler(pihtPackageFileLoaded,TMethod(OnPkgLoaded)); RemoveHandler(pihtPackageFileLoaded,TMethod(OnPkgLoaded));
end; end;
{ TLazPackageFile }
procedure TLazPackageFile.SetFilename(const AValue: string);
begin
FFilename:=AValue;
end;
procedure TLazPackageFile.SetRemoved(const AValue: boolean);
begin
FRemoved:=AValue;
end;
initialization initialization
PackageEditingInterface:=nil; PackageEditingInterface:=nil;

View File

@ -142,14 +142,12 @@ type
{ TPkgFile } { TPkgFile }
TPkgFile = class TPkgFile = class(TLazPackageFile)
private private
FAutoReferenceSourceDir: boolean; FAutoReferenceSourceDir: boolean;
FComponentPriority: TComponentPriority; FComponentPriority: TComponentPriority;
FComponents: TFPList; // list of TPkgComponent FComponents: TFPList; // list of TPkgComponent
FDirectory: string; FDirectory: string;
FRemoved: boolean;
FFilename: string;
FFileType: TPkgFileType; FFileType: TPkgFileType;
FFlags: TPkgFileFlags; FFlags: TPkgFileFlags;
fFullFilename: string; fFullFilename: string;
@ -164,13 +162,15 @@ type
function GetHasRegisterProc: boolean; function GetHasRegisterProc: boolean;
procedure SetAddToUsesPkgSection(const AValue: boolean); procedure SetAddToUsesPkgSection(const AValue: boolean);
procedure SetAutoReferenceSourceDir(const AValue: boolean); procedure SetAutoReferenceSourceDir(const AValue: boolean);
procedure SetRemoved(const AValue: boolean);
procedure SetFilename(const AValue: string);
procedure SetFileType(const AValue: TPkgFileType); procedure SetFileType(const AValue: TPkgFileType);
procedure SetFlags(const AValue: TPkgFileFlags); procedure SetFlags(const AValue: TPkgFileFlags);
procedure SetHasRegisterProc(const AValue: boolean); procedure SetHasRegisterProc(const AValue: boolean);
procedure UpdateUnitName; procedure UpdateUnitName;
function GetComponentList: TFPList; function GetComponentList: TFPList;
protected
function GetIDEPackage: TIDEPackage; override;
procedure SetFilename(const AValue: string); override;
procedure SetRemoved(const AValue: boolean); override;
public public
constructor Create(ThePackage: TLazPackage); constructor Create(ThePackage: TLazPackage);
destructor Destroy; override; destructor Destroy; override;
@ -181,15 +181,15 @@ type
UsePathDelim: TPathDelimSwitch); UsePathDelim: TPathDelimSwitch);
procedure ConsistencyCheck; procedure ConsistencyCheck;
function IsVirtual: boolean; function IsVirtual: boolean;
function GetShortFilename(UseUp: boolean): string; function GetShortFilename(UseUp: boolean): string; override;
function ComponentCount: integer; function ComponentCount: integer;
procedure AddPkgComponent(APkgComponent: TPkgComponent); procedure AddPkgComponent(APkgComponent: TPkgComponent);
procedure RemovePkgComponent(APkgComponent: TPkgComponent); procedure RemovePkgComponent(APkgComponent: TPkgComponent);
function GetResolvedFilename: string;
function HasRegisteredPlugins: boolean; function HasRegisteredPlugins: boolean;
function MakeSense: boolean; function MakeSense: boolean;
procedure UpdateSourceDirectoryReference; procedure UpdateSourceDirectoryReference;
function GetFullFilename: string; function GetFullFilename: string; override;
function GetResolvedFilename: string; // GetFullFilename + ReadAllLinks
public public
property AddToUsesPkgSection: boolean property AddToUsesPkgSection: boolean
read GetAddToUsesPkgSection write SetAddToUsesPkgSection; read GetAddToUsesPkgSection write SetAddToUsesPkgSection;
@ -201,13 +201,11 @@ type
write FComponentPriority; write FComponentPriority;
property Components[Index: integer]: TPkgComponent read GetComponents;// registered components property Components[Index: integer]: TPkgComponent read GetComponents;// registered components
property Directory: string read FDirectory; property Directory: string read FDirectory;
property Filename: string read FFilename write SetFilename;
property FileType: TPkgFileType read FFileType write SetFileType; property FileType: TPkgFileType read FFileType write SetFileType;
property Flags: TPkgFileFlags read FFlags write SetFlags; property Flags: TPkgFileFlags read FFlags write SetFlags;
property HasRegisterProc: boolean property HasRegisterProc: boolean
read GetHasRegisterProc write SetHasRegisterProc; read GetHasRegisterProc write SetHasRegisterProc;
property LazPackage: TLazPackage read FPackage; property LazPackage: TLazPackage read FPackage;
property Removed: boolean read FRemoved write SetRemoved;
property SourceDirectoryReferenced: boolean read FSourceDirectoryReferenced; property SourceDirectoryReferenced: boolean read FSourceDirectoryReferenced;
property Unit_Name: string read FUnitName write FUnitName; property Unit_Name: string read FUnitName write FUnitName;
end; end;
@ -589,9 +587,7 @@ type
function GetAutoIncrementVersionOnBuild: boolean; function GetAutoIncrementVersionOnBuild: boolean;
function GetComponentCount: integer; function GetComponentCount: integer;
function GetComponents(Index: integer): TPkgComponent; function GetComponents(Index: integer): TPkgComponent;
function GetRemovedCount: integer;
function GetRemovedFiles(Index: integer): TPkgFile; function GetRemovedFiles(Index: integer): TPkgFile;
function GetFileCount: integer;
function GetFiles(Index: integer): TPkgFile; function GetFiles(Index: integer): TPkgFile;
procedure SetAddToProjectUsesSection(const AValue: boolean); procedure SetAddToProjectUsesSection(const AValue: boolean);
procedure SetAuthor(const AValue: string); procedure SetAuthor(const AValue: string);
@ -624,12 +620,16 @@ type
procedure UpdateSourceDirectories; procedure UpdateSourceDirectories;
procedure SourceDirectoriesChanged(Sender: TObject); procedure SourceDirectoriesChanged(Sender: TObject);
protected protected
function GetFileCount: integer; override;
function GetPkgFiles(Index: integer): TLazPackageFile; override;
function GetDirectoryExpanded: string; override; function GetDirectoryExpanded: string; override;
function GetModified: boolean; override; function GetModified: boolean; override;
procedure SetFilename(const AValue: string); override; procedure SetFilename(const AValue: string); override;
procedure SetModified(const AValue: boolean); override; procedure SetModified(const AValue: boolean); override;
procedure SetName(const AValue: string); override; procedure SetName(const AValue: string); override;
procedure VersionChanged(Sender: TObject); override; procedure VersionChanged(Sender: TObject); override;
function GetRemovedCount: integer; override;
function GetRemovedPkgFiles(Index: integer): TLazPackageFile; override;
public public
constructor Create; constructor Create;
destructor Destroy; override; destructor Destroy; override;
@ -749,7 +749,6 @@ type
property Editor: TBasePackageEditor read FPackageEditor property Editor: TBasePackageEditor read FPackageEditor
write SetPackageEditor; write SetPackageEditor;
property EnableI18N: Boolean read FEnableI18N write SetEnableI18N; property EnableI18N: Boolean read FEnableI18N write SetEnableI18N;
property FileCount: integer read GetFileCount;
property FileReadOnly: boolean read FFileReadOnly write SetFileReadOnly; property FileReadOnly: boolean read FFileReadOnly write SetFileReadOnly;
property Files[Index: integer]: TPkgFile read GetFiles; property Files[Index: integer]: TPkgFile read GetFiles;
property FirstRemovedDependency: TPkgDependency property FirstRemovedDependency: TPkgDependency
@ -783,7 +782,6 @@ type
property PublishOptions: TPublishPackageOptions property PublishOptions: TPublishPackageOptions
read fPublishOptions write fPublishOptions; read fPublishOptions write fPublishOptions;
property Registered: boolean read FRegistered write SetRegistered; property Registered: boolean read FRegistered write SetRegistered;
property RemovedFilesCount: integer read GetRemovedCount;
property RemovedFiles[Index: integer]: TPkgFile read GetRemovedFiles; property RemovedFiles[Index: integer]: TPkgFile read GetRemovedFiles;
property SourceDirectories: TFileReferenceList read FSourceDirectories; property SourceDirectories: TFileReferenceList read FSourceDirectories;
property LastStateFileDate: longint read FLastStateFileDate write FLastStateFileDate; property LastStateFileDate: longint read FLastStateFileDate write FLastStateFileDate;
@ -1385,15 +1383,15 @@ begin
NewFilename:=AValue; NewFilename:=AValue;
DoDirSeparators(NewFilename); DoDirSeparators(NewFilename);
LazPackage.LongenFilename(NewFilename); LazPackage.LongenFilename(NewFilename);
if FFilename=NewFilename then exit; if Filename=NewFilename then exit;
FFilename:=NewFilename; inherited SetFilename(NewFilename);
fFullFilenameStamp:=CompilerParseStamp; fFullFilenameStamp:=CompilerParseStamp;
if fFullFilenameStamp=Low(fFullFilenameStamp) then if fFullFilenameStamp=Low(fFullFilenameStamp) then
fFullFilenameStamp:=High(fFullFilenameStamp) fFullFilenameStamp:=High(fFullFilenameStamp)
else else
dec(fFullFilenameStamp); dec(fFullFilenameStamp);
OldDirectory:=FDirectory; OldDirectory:=FDirectory;
FDirectory:=ExtractFilePath(fFilename); FDirectory:=ExtractFilePath(Filename);
if OldDirectory<>FDirectory then begin if OldDirectory<>FDirectory then begin
if FSourceDirNeedReference then begin if FSourceDirNeedReference then begin
LazPackage.SourceDirectories.RemoveFilename(OldDirectory); LazPackage.SourceDirectories.RemoveFilename(OldDirectory);
@ -1427,8 +1425,8 @@ end;
procedure TPkgFile.SetRemoved(const AValue: boolean); procedure TPkgFile.SetRemoved(const AValue: boolean);
begin begin
if FRemoved=AValue then exit; if Removed=AValue then exit;
FRemoved:=AValue; inherited SetRemoved(AValue);
FSourceDirNeedReference:=(FileType in PkgFileRealUnitTypes) and not Removed; FSourceDirNeedReference:=(FileType in PkgFileRealUnitTypes) and not Removed;
UpdateSourceDirectoryReference; UpdateSourceDirectoryReference;
end; end;
@ -1478,8 +1476,8 @@ procedure TPkgFile.UpdateUnitName;
var var
NewUnitName: String; NewUnitName: String;
begin begin
if FilenameIsPascalUnit(FFilename) then begin if FilenameIsPascalUnit(Filename) then begin
NewUnitName:=ExtractFileNameOnly(FFilename); NewUnitName:=ExtractFileNameOnly(Filename);
if CompareText(NewUnitName,FUnitName)<>0 then if CompareText(NewUnitName,FUnitName)<>0 then
FUnitName:=NewUnitName; FUnitName:=NewUnitName;
end else end else
@ -1492,6 +1490,11 @@ begin
Result:=FComponents; Result:=FComponents;
end; end;
function TPkgFile.GetIDEPackage: TIDEPackage;
begin
Result:=FPackage;
end;
function TPkgFile.HasRegisteredPlugins: boolean; function TPkgFile.HasRegisteredPlugins: boolean;
begin begin
Result:=ComponentCount>0; Result:=ComponentCount>0;
@ -1536,6 +1539,7 @@ end;
constructor TPkgFile.Create(ThePackage: TLazPackage); constructor TPkgFile.Create(ThePackage: TLazPackage);
begin begin
inherited Create;
Clear; Clear;
FPackage:=ThePackage; FPackage:=ThePackage;
FComponentPriority:=ComponentPriorityNormal; FComponentPriority:=ComponentPriorityNormal;
@ -1550,8 +1554,8 @@ end;
procedure TPkgFile.Clear; procedure TPkgFile.Clear;
begin begin
AutoReferenceSourceDir:=false; AutoReferenceSourceDir:=false;
FRemoved:=false; inherited SetRemoved(false);
FFilename:=''; inherited SetFilename('');
FDirectory:=''; FDirectory:='';
FFlags:=[]; FFlags:=[];
FFileType:=pftUnit; FFileType:=pftUnit;
@ -1614,18 +1618,18 @@ procedure TPkgFile.ConsistencyCheck;
begin begin
if FPackage=nil then if FPackage=nil then
RaiseGDBException('TPkgFile.ConsistencyCheck FPackage=nil'); RaiseGDBException('TPkgFile.ConsistencyCheck FPackage=nil');
if FFilename='' then if Filename='' then
RaiseGDBException('TPkgFile.ConsistencyCheck FFilename=""'); RaiseGDBException('TPkgFile.ConsistencyCheck FFilename=""');
end; end;
function TPkgFile.IsVirtual: boolean; function TPkgFile.IsVirtual: boolean;
begin begin
Result:=FilenameIsAbsolute(FFilename); Result:=FilenameIsAbsolute(Filename);
end; end;
function TPkgFile.GetShortFilename(UseUp: boolean): string; function TPkgFile.GetShortFilename(UseUp: boolean): string;
begin begin
Result:=FFilename; Result:=Filename;
LazPackage.ShortenFilename(Result,UseUp); LazPackage.ShortenFilename(Result,UseUp);
end; end;
@ -1655,7 +1659,7 @@ end;
function TPkgFile.GetResolvedFilename: string; function TPkgFile.GetResolvedFilename: string;
begin begin
Result:=ReadAllLinks(Filename,false); Result:=ReadAllLinks(GetFullFilename,false);
if Result='' then Result:=Filename; if Result='' then Result:=Filename;
end; end;
@ -2103,6 +2107,11 @@ begin
Result:=FRemovedFiles.Count; Result:=FRemovedFiles.Count;
end; end;
function TLazPackage.GetRemovedPkgFiles(Index: integer): TLazPackageFile;
begin
Result:=GetRemovedFiles(Index);
end;
function TLazPackage.GetRemovedFiles(Index: integer): TPkgFile; function TLazPackage.GetRemovedFiles(Index: integer): TPkgFile;
begin begin
Result:=TPkgFile(FRemovedFiles[Index]); Result:=TPkgFile(FRemovedFiles[Index]);
@ -2113,6 +2122,11 @@ begin
Result:=FFiles.Count; Result:=FFiles.Count;
end; end;
function TLazPackage.GetPkgFiles(Index: integer): TLazPackageFile;
begin
Result:=GetFiles(Index);
end;
function TLazPackage.GetFiles(Index: integer): TPkgFile; function TLazPackage.GetFiles(Index: integer): TPkgFile;
begin begin
Result:=TPkgFile(FFiles[Index]); Result:=TPkgFile(FFiles[Index]);