mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-10 08:36:26 +02:00
improved file checking
git-svn-id: trunk@4120 -
This commit is contained in:
parent
d69ad8c66e
commit
b005241c46
@ -79,6 +79,7 @@ type
|
||||
function FileNeedsUpdate: boolean;
|
||||
function FileOnDiskNeedsUpdate: boolean;
|
||||
function FileOnDiskHasChanged: boolean;
|
||||
function FileOnDiskIsEqual: boolean;
|
||||
function AutoRevertFromDisk: boolean;
|
||||
procedure LockAutoDiskRevert;
|
||||
procedure UnlockAutoDiskRevert;
|
||||
@ -832,7 +833,7 @@ begin
|
||||
end;
|
||||
|
||||
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
|
||||
if LoadDateValid then
|
||||
Result:=(not Modified) and (FFileChangeStep=ChangeStep)
|
||||
@ -842,10 +843,11 @@ begin
|
||||
end;
|
||||
|
||||
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
|
||||
if LoadDateValid then
|
||||
Result:=Modified or (FFileChangeStep<>ChangeStep)
|
||||
Result:=Modified or (FFileChangeStep<>ChangeStep)
|
||||
or (not FileExists(Filename))
|
||||
else
|
||||
Result:=false;
|
||||
end;
|
||||
@ -858,6 +860,11 @@ begin
|
||||
Result:=false;
|
||||
end;
|
||||
|
||||
function TCodeBuffer.FileOnDiskIsEqual: boolean;
|
||||
begin
|
||||
Result:=(not FileOnDiskNeedsUpdate) and (not FileOnDiskHasChanged);
|
||||
end;
|
||||
|
||||
function TCodeBuffer.AutoRevertFromDisk: boolean;
|
||||
begin
|
||||
Result:=FAutoDiskRevertLock=0;
|
||||
|
@ -3000,7 +3000,7 @@ var
|
||||
OldFlags: TFindDeclarationFlags;
|
||||
begin
|
||||
{$IFDEF ShowExprEval}
|
||||
writeln('[TFindDeclarationTool.FindExpressionResultType] ',
|
||||
writeln('[TFindDeclarationTool.FindExpressionResultType] Start ',
|
||||
'"',copy(Src,StartPos,EndPos-StartPos),'" Context=',Params.ContextNode.DescAsString);
|
||||
{$ENDIF}
|
||||
Result:=CleanExpressionType;
|
||||
@ -3012,9 +3012,16 @@ begin
|
||||
repeat
|
||||
// read operand
|
||||
CurExprType:=ReadOperandTypeAtCursor(Params);
|
||||
{$IFDEF ShowExprEval}
|
||||
writeln('[TFindDeclarationTool.FindExpressionResultType] Operand: ',
|
||||
ExprTypeToString(CurExprType));
|
||||
{$ENDIF}
|
||||
if CurExprType.Desc=xtNone then exit;
|
||||
// read operator
|
||||
ReadNextAtom;
|
||||
{$IFDEF ShowExprEval}
|
||||
writeln('[TFindDeclarationTool.FindExpressionResultType] Operator: ',GetAtom,' CurPos.EndPos=',CurPos.EndPos,' EndPos=',EndPos);
|
||||
{$ENDIF}
|
||||
// put operand on stack
|
||||
inc(StackPtr);
|
||||
if StackPtr>High(ExprStack) then
|
||||
@ -3586,6 +3593,7 @@ type
|
||||
var
|
||||
CurAtomType, NextAtomType: TVariableAtomType;
|
||||
CurAtom, NextAtom: TAtomPosition;
|
||||
CurAtomBracketEndPos: integer;
|
||||
StartContext: TFindContext;
|
||||
OldInput: TFindDeclarationInput;
|
||||
StartFlags: TFindDeclarationFlags;
|
||||
@ -3636,6 +3644,7 @@ var
|
||||
CurAtomType:=GetCurrentAtomType;
|
||||
if CurAtomType in [vatRoundBracketOpen,vatEdgedBracketOpen] then
|
||||
ReadTilBracketClose(true);
|
||||
CurAtomBracketEndPos:=CurPos.EndPos;
|
||||
ReadNextAtom;
|
||||
NextAtom:=CurPos;
|
||||
if NextAtom.EndPos<=EndPos then
|
||||
@ -3654,6 +3663,7 @@ var
|
||||
ReadNextAtom;
|
||||
if CurAtomType in [vatRoundBracketOpen,vatEdgedBracketOpen] then
|
||||
ReadTilBracketClose(true);
|
||||
CurAtomBracketEndPos:=CurPos.EndPos;
|
||||
ReadNextAtom;
|
||||
NextAtom:=CurPos;
|
||||
if NextAtom.EndPos<=EndPos then
|
||||
@ -4048,7 +4058,7 @@ var
|
||||
end else begin
|
||||
// expression
|
||||
ExprType:=FindExpressionResultType(Params,CurAtom.StartPos+1,
|
||||
CurAtom.EndPos-1);
|
||||
CurAtomBracketEndPos-1);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -4128,8 +4138,7 @@ begin
|
||||
repeat
|
||||
{$IFDEF ShowExprEval}
|
||||
writeln(' FindExpressionTypeOfVariable CurAtomType=',
|
||||
VariableAtomTypeNames[CurAtomType],
|
||||
' CurAtom="',copy(Src,CurAtom.StartPos,CurAtom.EndPos-CurAtom.StartPos),'"');
|
||||
VariableAtomTypeNames[CurAtomType],' CurAtom="',GetAtom(CurAtom),'"');
|
||||
{$ENDIF}
|
||||
case CurAtomType of
|
||||
vatIdentifier, vatPreDefIdentifier: ResolveIdentifier;
|
||||
@ -4441,8 +4450,7 @@ begin
|
||||
{$IFDEF ShowExprEval}
|
||||
writeln('[TFindDeclarationTool.CalculateBinaryOperator] A',
|
||||
' LeftOperand=',ExpressionTypeDescNames[LeftOperand.Desc],
|
||||
' Operator=',copy(Src,BinaryOperator.StartPos,
|
||||
BinaryOperator.EndPos-BinaryOperator.StartPos),
|
||||
' Operator=',GetAtom(BinaryOperator),
|
||||
' RightOperand=',ExpressionTypeDescNames[RightOperand.Desc]
|
||||
);
|
||||
{$ENDIF}
|
||||
|
@ -134,7 +134,7 @@ type
|
||||
function IsVirtual: boolean;
|
||||
function NeedsSaveToDisk: boolean;
|
||||
function ReadOnly: boolean;
|
||||
function ReadUnitSource(ReadUnitName:boolean): TModalResult;
|
||||
function ReadUnitSource(ReadUnitName,Revert:boolean): TModalResult;
|
||||
function ShortFilename: string;
|
||||
function WriteUnitSource: TModalResult;
|
||||
function WriteUnitSourceToFile(const AFileName: string): TModalResult;
|
||||
@ -623,14 +623,14 @@ end;
|
||||
{------------------------------------------------------------------------------
|
||||
TUnitInfo ReadUnitSource
|
||||
------------------------------------------------------------------------------}
|
||||
function TUnitInfo.ReadUnitSource(ReadUnitName:boolean): TModalResult;
|
||||
function TUnitInfo.ReadUnitSource(ReadUnitName,Revert:boolean): TModalResult;
|
||||
var
|
||||
ACaption:string;
|
||||
AText:string;
|
||||
NewSource: TCodeBuffer;
|
||||
begin
|
||||
repeat
|
||||
NewSource:=CodeToolBoss.LoadFile(fFilename,true,false);
|
||||
NewSource:=CodeToolBoss.LoadFile(fFilename,true,Revert);
|
||||
if NewSource=nil then begin
|
||||
ACaption:='Read error';
|
||||
AText:='Unable to read file "'+fFilename+'"!';
|
||||
@ -767,7 +767,7 @@ begin
|
||||
CodeToolBoss.RenameSource(fSource,NewUnitName);
|
||||
end;
|
||||
fUnitName:=NewUnitName;
|
||||
fModified:=true;
|
||||
if Project<>nil then Project.Modified:=true;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -2653,6 +2653,9 @@ end.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.117 2003/05/02 10:28:59 mattias
|
||||
improved file checking
|
||||
|
||||
Revision 1.116 2003/04/29 19:00:41 mattias
|
||||
added package gtkopengl
|
||||
|
||||
|
@ -440,6 +440,7 @@ type
|
||||
FDescription: string;
|
||||
FDirectory: string;
|
||||
FFilename: string;
|
||||
FFileReadOnly: boolean;
|
||||
FFiles: TList; // TList of TPkgFile
|
||||
FFirstRemovedDependency: TPkgDependency;
|
||||
FFirstRequiredDependency: TPkgDependency;
|
||||
@ -458,13 +459,13 @@ type
|
||||
FOutputStateFile: string;
|
||||
FPackageEditor: TBasePackageEditor;
|
||||
FPackageType: TLazPackageType;
|
||||
FReadOnly: boolean;
|
||||
FRemovedFiles: TList; // TList of TPkgFile
|
||||
FRegistered: boolean;
|
||||
FSourceDirectories: TFileReferenceList;
|
||||
FStateFileDate: longint;
|
||||
FUpdateLock: integer;
|
||||
FUsageOptions: TPkgAdditionalCompilerOptions;
|
||||
FUserReadOnly: boolean;
|
||||
function GetAutoIncrementVersionOnBuild: boolean;
|
||||
function GetComponentCount: integer;
|
||||
function GetComponents(Index: integer): TPkgComponent;
|
||||
@ -479,6 +480,7 @@ type
|
||||
procedure SetAutoInstall(const AValue: TPackageInstallType);
|
||||
procedure SetAutoUpdate(const AValue: TPackageUpdatePolicy);
|
||||
procedure SetDescription(const AValue: string);
|
||||
procedure SetFileReadOnly(const AValue: boolean);
|
||||
procedure SetFilename(const AValue: string);
|
||||
procedure SetFlags(const AValue: TLazPackageFlags);
|
||||
procedure SetIconFile(const AValue: string);
|
||||
@ -490,9 +492,9 @@ type
|
||||
procedure SetName(const AValue: string); override;
|
||||
procedure SetPackageEditor(const AValue: TBasePackageEditor);
|
||||
procedure SetPackageType(const AValue: TLazPackageType);
|
||||
procedure SetReadOnly(const AValue: boolean);
|
||||
procedure OnMacroListSubstitution(TheMacro: TTransferMacro; var s: string;
|
||||
var Handled, Abort: boolean);
|
||||
procedure SetUserReadOnly(const AValue: boolean);
|
||||
function SubstitutePkgMacro(const s: string): string;
|
||||
procedure Clear;
|
||||
procedure UpdateSourceDirectories;
|
||||
@ -501,20 +503,23 @@ type
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
// modified
|
||||
procedure BeginUpdate;
|
||||
procedure EndUpdate;
|
||||
procedure LockModified;
|
||||
procedure UnlockModified;
|
||||
function ReadOnly: boolean;
|
||||
// streaming
|
||||
procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string);
|
||||
procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string);
|
||||
function IsVirtual: boolean;
|
||||
function HasDirectory: boolean;
|
||||
// consistency
|
||||
procedure CheckInnerDependencies;
|
||||
function MakeSense: boolean;
|
||||
procedure ShortenFilename(var ExpandedFilename: string);
|
||||
procedure LongenFilename(var AFilename: string);
|
||||
function GetResolvedFilename: string;
|
||||
procedure ConsistencyCheck;
|
||||
// paths, define templates
|
||||
function IsVirtual: boolean;
|
||||
function HasDirectory: boolean;
|
||||
function GetResolvedFilename: string;
|
||||
procedure GetInheritedCompilerOptions(var OptionsList: TList);
|
||||
function GetCompileSourceFilename: string;
|
||||
function GetOutputDirectory: string;
|
||||
@ -525,6 +530,8 @@ type
|
||||
function GetIncludePath(RelativeToBaseDir: boolean): string;
|
||||
function NeedsDefineTemplates: boolean;
|
||||
// files
|
||||
procedure ShortenFilename(var ExpandedFilename: string);
|
||||
procedure LongenFilename(var AFilename: string);
|
||||
function FindPkgFile(const AFilename: string;
|
||||
ResolveLinks, IgnoreRemoved: boolean): TPkgFile;
|
||||
function FindUnit(const TheUnitName: string; IgnoreRemoved: boolean): TPkgFile;
|
||||
@ -610,7 +617,8 @@ type
|
||||
property OutputStateFile: string read FOutputStateFile write SetOutputStateFile;
|
||||
property PackageType: TLazPackageType read FPackageType
|
||||
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 RemovedFilesCount: integer read GetRemovedCount;
|
||||
property RemovedFiles[Index: integer]: TPkgFile read GetRemovedFiles;
|
||||
@ -1582,6 +1590,12 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TLazPackage.SetUserReadOnly(const AValue: boolean);
|
||||
begin
|
||||
if FUserReadOnly=AValue then exit;
|
||||
FUserReadOnly:=AValue;
|
||||
end;
|
||||
|
||||
function TLazPackage.SubstitutePkgMacro(const s: string): string;
|
||||
begin
|
||||
Result:=s;
|
||||
@ -1639,7 +1653,7 @@ procedure TLazPackage.SetAutoCreated(const AValue: boolean);
|
||||
begin
|
||||
if FAutoCreated=AValue then exit;
|
||||
FAutoCreated:=AValue;
|
||||
if AutoCreated then ReadOnly:=true;
|
||||
if AutoCreated then UserReadOnly:=true;
|
||||
end;
|
||||
|
||||
procedure TLazPackage.SetAutoIncrementVersionOnBuild(const AValue: boolean);
|
||||
@ -1672,6 +1686,12 @@ begin
|
||||
Modified:=true;
|
||||
end;
|
||||
|
||||
procedure TLazPackage.SetFileReadOnly(const AValue: boolean);
|
||||
begin
|
||||
if FFileReadOnly=AValue then exit;
|
||||
FFileReadOnly:=AValue;
|
||||
end;
|
||||
|
||||
procedure TLazPackage.SetFilename(const AValue: string);
|
||||
var
|
||||
NewFilename: String;
|
||||
@ -1766,12 +1786,6 @@ begin
|
||||
Modified:=true;
|
||||
end;
|
||||
|
||||
procedure TLazPackage.SetReadOnly(const AValue: boolean);
|
||||
begin
|
||||
if FReadOnly=AValue then exit;
|
||||
FReadOnly:=AValue;
|
||||
end;
|
||||
|
||||
constructor TLazPackage.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
@ -1902,6 +1916,11 @@ begin
|
||||
dec(FModifiedLock);
|
||||
end;
|
||||
|
||||
function TLazPackage.ReadOnly: boolean;
|
||||
begin
|
||||
Result:=UserReadOnly or FileReadOnly;
|
||||
end;
|
||||
|
||||
procedure TLazPackage.LoadFromXMLConfig(XMLConfig: TXMLConfig;
|
||||
const Path: string);
|
||||
var
|
||||
|
@ -636,6 +636,7 @@ begin
|
||||
Name:='AutoIncrementOnBuildCheckBox';
|
||||
Parent:=VersionGroupBox;
|
||||
Caption:='Automatically increment version on build';
|
||||
Enabled:=false;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user