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

View File

@ -60,6 +60,26 @@ type
function VersionBound(v: integer): integer;
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 }
@ -95,9 +115,13 @@ type
FFilename: string;
FChangeStamp: integer;
function GetDirectoryExpanded: string; virtual; abstract;
function GetFileCount: integer; virtual; abstract;
function GetPkgFiles(Index: integer): TLazPackageFile; virtual; abstract;
function GetModified: boolean; virtual; abstract;
procedure SetFilename(const AValue: string); virtual; abstract;
procedure SetModified(const AValue: boolean); virtual; abstract;
function GetRemovedCount: integer; virtual; abstract;
function GetRemovedPkgFiles(Index: integer): TLazPackageFile; virtual; abstract;
public
function IsVirtual: boolean; virtual; abstract;
function ReadOnly: boolean; virtual; abstract;
@ -110,6 +134,10 @@ type
property DirectoryExpanded: string read GetDirectoryExpanded;
property CustomOptions: TConfigStorage read FCustomOptions;
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;
type
@ -646,6 +674,18 @@ begin
RemoveHandler(pihtPackageFileLoaded,TMethod(OnPkgLoaded));
end;
{ TLazPackageFile }
procedure TLazPackageFile.SetFilename(const AValue: string);
begin
FFilename:=AValue;
end;
procedure TLazPackageFile.SetRemoved(const AValue: boolean);
begin
FRemoved:=AValue;
end;
initialization
PackageEditingInterface:=nil;

View File

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