improved file checking

git-svn-id: trunk@4120 -
This commit is contained in:
mattias 2003-05-02 10:28:59 +00:00
parent d69ad8c66e
commit b005241c46
5 changed files with 66 additions and 28 deletions

View File

@ -79,6 +79,7 @@ type
function FileNeedsUpdate: boolean; function FileNeedsUpdate: boolean;
function FileOnDiskNeedsUpdate: boolean; function FileOnDiskNeedsUpdate: boolean;
function FileOnDiskHasChanged: boolean; function FileOnDiskHasChanged: boolean;
function FileOnDiskIsEqual: boolean;
function AutoRevertFromDisk: boolean; function AutoRevertFromDisk: boolean;
procedure LockAutoDiskRevert; procedure LockAutoDiskRevert;
procedure UnlockAutoDiskRevert; procedure UnlockAutoDiskRevert;
@ -832,7 +833,7 @@ begin
end; end;
function TCodeBuffer.FileNeedsUpdate: boolean; function TCodeBuffer.FileNeedsUpdate: boolean;
// file needs update, if file is not modified and file on disk is changed // file needs update, if file is not modified and file on disk has changed
begin begin
if LoadDateValid then if LoadDateValid then
Result:=(not Modified) and (FFileChangeStep=ChangeStep) Result:=(not Modified) and (FFileChangeStep=ChangeStep)
@ -842,10 +843,11 @@ begin
end; end;
function TCodeBuffer.FileOnDiskNeedsUpdate: boolean; function TCodeBuffer.FileOnDiskNeedsUpdate: boolean;
// file on disk needs update, if file is modified // file on disk needs update, if file is modified or does not exists
begin begin
if LoadDateValid then if LoadDateValid then
Result:=Modified or (FFileChangeStep<>ChangeStep) Result:=Modified or (FFileChangeStep<>ChangeStep)
or (not FileExists(Filename))
else else
Result:=false; Result:=false;
end; end;
@ -858,6 +860,11 @@ begin
Result:=false; Result:=false;
end; end;
function TCodeBuffer.FileOnDiskIsEqual: boolean;
begin
Result:=(not FileOnDiskNeedsUpdate) and (not FileOnDiskHasChanged);
end;
function TCodeBuffer.AutoRevertFromDisk: boolean; function TCodeBuffer.AutoRevertFromDisk: boolean;
begin begin
Result:=FAutoDiskRevertLock=0; Result:=FAutoDiskRevertLock=0;

View File

@ -3000,7 +3000,7 @@ var
OldFlags: TFindDeclarationFlags; OldFlags: TFindDeclarationFlags;
begin begin
{$IFDEF ShowExprEval} {$IFDEF ShowExprEval}
writeln('[TFindDeclarationTool.FindExpressionResultType] ', writeln('[TFindDeclarationTool.FindExpressionResultType] Start ',
'"',copy(Src,StartPos,EndPos-StartPos),'" Context=',Params.ContextNode.DescAsString); '"',copy(Src,StartPos,EndPos-StartPos),'" Context=',Params.ContextNode.DescAsString);
{$ENDIF} {$ENDIF}
Result:=CleanExpressionType; Result:=CleanExpressionType;
@ -3012,9 +3012,16 @@ begin
repeat repeat
// read operand // read operand
CurExprType:=ReadOperandTypeAtCursor(Params); CurExprType:=ReadOperandTypeAtCursor(Params);
{$IFDEF ShowExprEval}
writeln('[TFindDeclarationTool.FindExpressionResultType] Operand: ',
ExprTypeToString(CurExprType));
{$ENDIF}
if CurExprType.Desc=xtNone then exit; if CurExprType.Desc=xtNone then exit;
// read operator // read operator
ReadNextAtom; ReadNextAtom;
{$IFDEF ShowExprEval}
writeln('[TFindDeclarationTool.FindExpressionResultType] Operator: ',GetAtom,' CurPos.EndPos=',CurPos.EndPos,' EndPos=',EndPos);
{$ENDIF}
// put operand on stack // put operand on stack
inc(StackPtr); inc(StackPtr);
if StackPtr>High(ExprStack) then if StackPtr>High(ExprStack) then
@ -3586,6 +3593,7 @@ type
var var
CurAtomType, NextAtomType: TVariableAtomType; CurAtomType, NextAtomType: TVariableAtomType;
CurAtom, NextAtom: TAtomPosition; CurAtom, NextAtom: TAtomPosition;
CurAtomBracketEndPos: integer;
StartContext: TFindContext; StartContext: TFindContext;
OldInput: TFindDeclarationInput; OldInput: TFindDeclarationInput;
StartFlags: TFindDeclarationFlags; StartFlags: TFindDeclarationFlags;
@ -3636,6 +3644,7 @@ var
CurAtomType:=GetCurrentAtomType; CurAtomType:=GetCurrentAtomType;
if CurAtomType in [vatRoundBracketOpen,vatEdgedBracketOpen] then if CurAtomType in [vatRoundBracketOpen,vatEdgedBracketOpen] then
ReadTilBracketClose(true); ReadTilBracketClose(true);
CurAtomBracketEndPos:=CurPos.EndPos;
ReadNextAtom; ReadNextAtom;
NextAtom:=CurPos; NextAtom:=CurPos;
if NextAtom.EndPos<=EndPos then if NextAtom.EndPos<=EndPos then
@ -3654,6 +3663,7 @@ var
ReadNextAtom; ReadNextAtom;
if CurAtomType in [vatRoundBracketOpen,vatEdgedBracketOpen] then if CurAtomType in [vatRoundBracketOpen,vatEdgedBracketOpen] then
ReadTilBracketClose(true); ReadTilBracketClose(true);
CurAtomBracketEndPos:=CurPos.EndPos;
ReadNextAtom; ReadNextAtom;
NextAtom:=CurPos; NextAtom:=CurPos;
if NextAtom.EndPos<=EndPos then if NextAtom.EndPos<=EndPos then
@ -4048,7 +4058,7 @@ var
end else begin end else begin
// expression // expression
ExprType:=FindExpressionResultType(Params,CurAtom.StartPos+1, ExprType:=FindExpressionResultType(Params,CurAtom.StartPos+1,
CurAtom.EndPos-1); CurAtomBracketEndPos-1);
end; end;
end; end;
@ -4128,8 +4138,7 @@ begin
repeat repeat
{$IFDEF ShowExprEval} {$IFDEF ShowExprEval}
writeln(' FindExpressionTypeOfVariable CurAtomType=', writeln(' FindExpressionTypeOfVariable CurAtomType=',
VariableAtomTypeNames[CurAtomType], VariableAtomTypeNames[CurAtomType],' CurAtom="',GetAtom(CurAtom),'"');
' CurAtom="',copy(Src,CurAtom.StartPos,CurAtom.EndPos-CurAtom.StartPos),'"');
{$ENDIF} {$ENDIF}
case CurAtomType of case CurAtomType of
vatIdentifier, vatPreDefIdentifier: ResolveIdentifier; vatIdentifier, vatPreDefIdentifier: ResolveIdentifier;
@ -4441,8 +4450,7 @@ begin
{$IFDEF ShowExprEval} {$IFDEF ShowExprEval}
writeln('[TFindDeclarationTool.CalculateBinaryOperator] A', writeln('[TFindDeclarationTool.CalculateBinaryOperator] A',
' LeftOperand=',ExpressionTypeDescNames[LeftOperand.Desc], ' LeftOperand=',ExpressionTypeDescNames[LeftOperand.Desc],
' Operator=',copy(Src,BinaryOperator.StartPos, ' Operator=',GetAtom(BinaryOperator),
BinaryOperator.EndPos-BinaryOperator.StartPos),
' RightOperand=',ExpressionTypeDescNames[RightOperand.Desc] ' RightOperand=',ExpressionTypeDescNames[RightOperand.Desc]
); );
{$ENDIF} {$ENDIF}

View File

@ -134,7 +134,7 @@ type
function IsVirtual: boolean; function IsVirtual: boolean;
function NeedsSaveToDisk: boolean; function NeedsSaveToDisk: boolean;
function ReadOnly: boolean; function ReadOnly: boolean;
function ReadUnitSource(ReadUnitName:boolean): TModalResult; function ReadUnitSource(ReadUnitName,Revert:boolean): TModalResult;
function ShortFilename: string; function ShortFilename: string;
function WriteUnitSource: TModalResult; function WriteUnitSource: TModalResult;
function WriteUnitSourceToFile(const AFileName: string): TModalResult; function WriteUnitSourceToFile(const AFileName: string): TModalResult;
@ -623,14 +623,14 @@ end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
TUnitInfo ReadUnitSource TUnitInfo ReadUnitSource
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TUnitInfo.ReadUnitSource(ReadUnitName:boolean): TModalResult; function TUnitInfo.ReadUnitSource(ReadUnitName,Revert:boolean): TModalResult;
var var
ACaption:string; ACaption:string;
AText:string; AText:string;
NewSource: TCodeBuffer; NewSource: TCodeBuffer;
begin begin
repeat repeat
NewSource:=CodeToolBoss.LoadFile(fFilename,true,false); NewSource:=CodeToolBoss.LoadFile(fFilename,true,Revert);
if NewSource=nil then begin if NewSource=nil then begin
ACaption:='Read error'; ACaption:='Read error';
AText:='Unable to read file "'+fFilename+'"!'; AText:='Unable to read file "'+fFilename+'"!';
@ -767,7 +767,7 @@ begin
CodeToolBoss.RenameSource(fSource,NewUnitName); CodeToolBoss.RenameSource(fSource,NewUnitName);
end; end;
fUnitName:=NewUnitName; fUnitName:=NewUnitName;
fModified:=true; if Project<>nil then Project.Modified:=true;
end; end;
end; end;
@ -2653,6 +2653,9 @@ end.
{ {
$Log$ $Log$
Revision 1.117 2003/05/02 10:28:59 mattias
improved file checking
Revision 1.116 2003/04/29 19:00:41 mattias Revision 1.116 2003/04/29 19:00:41 mattias
added package gtkopengl added package gtkopengl

View File

@ -440,6 +440,7 @@ type
FDescription: string; FDescription: string;
FDirectory: string; FDirectory: string;
FFilename: string; FFilename: string;
FFileReadOnly: boolean;
FFiles: TList; // TList of TPkgFile FFiles: TList; // TList of TPkgFile
FFirstRemovedDependency: TPkgDependency; FFirstRemovedDependency: TPkgDependency;
FFirstRequiredDependency: TPkgDependency; FFirstRequiredDependency: TPkgDependency;
@ -458,13 +459,13 @@ type
FOutputStateFile: string; FOutputStateFile: string;
FPackageEditor: TBasePackageEditor; FPackageEditor: TBasePackageEditor;
FPackageType: TLazPackageType; FPackageType: TLazPackageType;
FReadOnly: boolean;
FRemovedFiles: TList; // TList of TPkgFile FRemovedFiles: TList; // TList of TPkgFile
FRegistered: boolean; FRegistered: boolean;
FSourceDirectories: TFileReferenceList; FSourceDirectories: TFileReferenceList;
FStateFileDate: longint; FStateFileDate: longint;
FUpdateLock: integer; FUpdateLock: integer;
FUsageOptions: TPkgAdditionalCompilerOptions; FUsageOptions: TPkgAdditionalCompilerOptions;
FUserReadOnly: boolean;
function GetAutoIncrementVersionOnBuild: boolean; function GetAutoIncrementVersionOnBuild: boolean;
function GetComponentCount: integer; function GetComponentCount: integer;
function GetComponents(Index: integer): TPkgComponent; function GetComponents(Index: integer): TPkgComponent;
@ -479,6 +480,7 @@ type
procedure SetAutoInstall(const AValue: TPackageInstallType); procedure SetAutoInstall(const AValue: TPackageInstallType);
procedure SetAutoUpdate(const AValue: TPackageUpdatePolicy); procedure SetAutoUpdate(const AValue: TPackageUpdatePolicy);
procedure SetDescription(const AValue: string); procedure SetDescription(const AValue: string);
procedure SetFileReadOnly(const AValue: boolean);
procedure SetFilename(const AValue: string); procedure SetFilename(const AValue: string);
procedure SetFlags(const AValue: TLazPackageFlags); procedure SetFlags(const AValue: TLazPackageFlags);
procedure SetIconFile(const AValue: string); procedure SetIconFile(const AValue: string);
@ -490,9 +492,9 @@ type
procedure SetName(const AValue: string); override; procedure SetName(const AValue: string); override;
procedure SetPackageEditor(const AValue: TBasePackageEditor); procedure SetPackageEditor(const AValue: TBasePackageEditor);
procedure SetPackageType(const AValue: TLazPackageType); procedure SetPackageType(const AValue: TLazPackageType);
procedure SetReadOnly(const AValue: boolean);
procedure OnMacroListSubstitution(TheMacro: TTransferMacro; var s: string; procedure OnMacroListSubstitution(TheMacro: TTransferMacro; var s: string;
var Handled, Abort: boolean); var Handled, Abort: boolean);
procedure SetUserReadOnly(const AValue: boolean);
function SubstitutePkgMacro(const s: string): string; function SubstitutePkgMacro(const s: string): string;
procedure Clear; procedure Clear;
procedure UpdateSourceDirectories; procedure UpdateSourceDirectories;
@ -501,20 +503,23 @@ type
public public
constructor Create; constructor Create;
destructor Destroy; override; destructor Destroy; override;
// modified
procedure BeginUpdate; procedure BeginUpdate;
procedure EndUpdate; procedure EndUpdate;
procedure LockModified; procedure LockModified;
procedure UnlockModified; procedure UnlockModified;
function ReadOnly: boolean;
// streaming
procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string); procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string);
procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string); procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string);
function IsVirtual: boolean; // consistency
function HasDirectory: boolean;
procedure CheckInnerDependencies; procedure CheckInnerDependencies;
function MakeSense: boolean; function MakeSense: boolean;
procedure ShortenFilename(var ExpandedFilename: string);
procedure LongenFilename(var AFilename: string);
function GetResolvedFilename: string;
procedure ConsistencyCheck; procedure ConsistencyCheck;
// paths, define templates
function IsVirtual: boolean;
function HasDirectory: boolean;
function GetResolvedFilename: string;
procedure GetInheritedCompilerOptions(var OptionsList: TList); procedure GetInheritedCompilerOptions(var OptionsList: TList);
function GetCompileSourceFilename: string; function GetCompileSourceFilename: string;
function GetOutputDirectory: string; function GetOutputDirectory: string;
@ -525,6 +530,8 @@ type
function GetIncludePath(RelativeToBaseDir: boolean): string; function GetIncludePath(RelativeToBaseDir: boolean): string;
function NeedsDefineTemplates: boolean; function NeedsDefineTemplates: boolean;
// files // files
procedure ShortenFilename(var ExpandedFilename: string);
procedure LongenFilename(var AFilename: string);
function FindPkgFile(const AFilename: string; function FindPkgFile(const AFilename: string;
ResolveLinks, IgnoreRemoved: boolean): TPkgFile; ResolveLinks, IgnoreRemoved: boolean): TPkgFile;
function FindUnit(const TheUnitName: string; IgnoreRemoved: boolean): TPkgFile; function FindUnit(const TheUnitName: string; IgnoreRemoved: boolean): TPkgFile;
@ -610,7 +617,8 @@ type
property OutputStateFile: string read FOutputStateFile write SetOutputStateFile; property OutputStateFile: string read FOutputStateFile write SetOutputStateFile;
property PackageType: TLazPackageType read FPackageType property PackageType: TLazPackageType read FPackageType
write SetPackageType; write SetPackageType;
property ReadOnly: boolean read FReadOnly write SetReadOnly; property UserReadOnly: boolean read FUserReadOnly write SetUserReadOnly;
property FileReadOnly: boolean read FFileReadOnly write SetFileReadOnly;
property Registered: boolean read FRegistered write SetRegistered; property Registered: boolean read FRegistered write SetRegistered;
property RemovedFilesCount: integer read GetRemovedCount; property RemovedFilesCount: integer read GetRemovedCount;
property RemovedFiles[Index: integer]: TPkgFile read GetRemovedFiles; property RemovedFiles[Index: integer]: TPkgFile read GetRemovedFiles;
@ -1582,6 +1590,12 @@ begin
end; end;
end; end;
procedure TLazPackage.SetUserReadOnly(const AValue: boolean);
begin
if FUserReadOnly=AValue then exit;
FUserReadOnly:=AValue;
end;
function TLazPackage.SubstitutePkgMacro(const s: string): string; function TLazPackage.SubstitutePkgMacro(const s: string): string;
begin begin
Result:=s; Result:=s;
@ -1639,7 +1653,7 @@ procedure TLazPackage.SetAutoCreated(const AValue: boolean);
begin begin
if FAutoCreated=AValue then exit; if FAutoCreated=AValue then exit;
FAutoCreated:=AValue; FAutoCreated:=AValue;
if AutoCreated then ReadOnly:=true; if AutoCreated then UserReadOnly:=true;
end; end;
procedure TLazPackage.SetAutoIncrementVersionOnBuild(const AValue: boolean); procedure TLazPackage.SetAutoIncrementVersionOnBuild(const AValue: boolean);
@ -1672,6 +1686,12 @@ begin
Modified:=true; Modified:=true;
end; end;
procedure TLazPackage.SetFileReadOnly(const AValue: boolean);
begin
if FFileReadOnly=AValue then exit;
FFileReadOnly:=AValue;
end;
procedure TLazPackage.SetFilename(const AValue: string); procedure TLazPackage.SetFilename(const AValue: string);
var var
NewFilename: String; NewFilename: String;
@ -1766,12 +1786,6 @@ begin
Modified:=true; Modified:=true;
end; end;
procedure TLazPackage.SetReadOnly(const AValue: boolean);
begin
if FReadOnly=AValue then exit;
FReadOnly:=AValue;
end;
constructor TLazPackage.Create; constructor TLazPackage.Create;
begin begin
inherited Create; inherited Create;
@ -1902,6 +1916,11 @@ begin
dec(FModifiedLock); dec(FModifiedLock);
end; end;
function TLazPackage.ReadOnly: boolean;
begin
Result:=UserReadOnly or FileReadOnly;
end;
procedure TLazPackage.LoadFromXMLConfig(XMLConfig: TXMLConfig; procedure TLazPackage.LoadFromXMLConfig(XMLConfig: TXMLConfig;
const Path: string); const Path: string);
var var

View File

@ -636,6 +636,7 @@ begin
Name:='AutoIncrementOnBuildCheckBox'; Name:='AutoIncrementOnBuildCheckBox';
Parent:=VersionGroupBox; Parent:=VersionGroupBox;
Caption:='Automatically increment version on build'; Caption:='Automatically increment version on build';
Enabled:=false;
end; end;
end; end;