IDE: Refactor. Move the timestamp classes to unit SourceFileManager.

git-svn-id: trunk@50193 -
This commit is contained in:
juha 2015-10-28 18:04:09 +00:00
parent 53914cd492
commit 83f4f4791e
2 changed files with 150 additions and 154 deletions

View File

@ -48,9 +48,7 @@
}
unit Main;
{$mode objfpc}
{$H+}
{$MODESWITCH ADVANCEDRECORDS}
{$mode objfpc}{$H+}
interface
@ -167,56 +165,6 @@ type
ctdUpdating
);
TFileCommandsStamp = record
private
SrcEdit: TSourceEditor;
public
function Changed(ASrcEdit: TSourceEditor): Boolean;
end;
TProjectCommandsStamp = record
private
UnitInfo: TUnitInfo;
ProjectChangeStamp: Int64;
public
function Changed(AUnitInfo: TUnitInfo): Boolean;
end;
TPackageCommandsStamp = record
private
UnitInfo: TUnitInfo;
PackagesChangeStamp: Int64;
public
function Changed(AUnitInfo: TUnitInfo): Boolean;
end;
TSourceEditorTabCommandsStamp = record
private
SrcEdit: TSourceEditor;
SrcEditLocked: Boolean;
SourceNotebook: TSourceNotebook;
PageIndex, PageCount: Integer;
public
function Changed(ASrcEdit: TSourceEditor): Boolean;
end;
TSourceEditorCommandsStamp = record
private
SrcEdit: TSourceEditor;
DisplayState: TDisplayState;
EditorComponentStamp: int64;
EditorCaretStamp: int64;
public
function Changed(ASrcEdit: TSourceEditor; ADisplayState: TDisplayState): Boolean;
end;
TBookmarkCommandsStamp = record
private
BookmarkChanged: Boolean;
public
function Changed: Boolean;
end;
{ TMainIDE }
TMainIDE = class(TMainIDEBase)
@ -1035,107 +983,6 @@ begin
end;
end;
{ TBookmarkCommandsStamp }
function TBookmarkCommandsStamp.Changed: Boolean;
begin
Result := BookmarkChanged;
if not Result then
Exit;
BookmarkChanged := True;
end;
{ TPackageCommandsStamp }
function TPackageCommandsStamp.Changed(AUnitInfo: TUnitInfo): Boolean;
begin
Result := not(
(UnitInfo = AUnitInfo)
and (PackagesChangeStamp = PackageGraph.ChangeStamp)
);
if not Result then Exit;
UnitInfo := AUnitInfo;
PackagesChangeStamp := PackageGraph.ChangeStamp;
end;
{ TProjectCommandsStamp }
function TProjectCommandsStamp.Changed(AUnitInfo: TUnitInfo): Boolean;
begin
Result := not(
(UnitInfo = AUnitInfo)
and (ProjectChangeStamp = Project1.ChangeStamp)
);
if not Result then Exit;
UnitInfo := AUnitInfo;
ProjectChangeStamp := Project1.ChangeStamp;
end;
{ TSourceEditorTabCommandsStamp }
function TSourceEditorTabCommandsStamp.Changed(ASrcEdit: TSourceEditor
): Boolean;
begin
Result := not(
(SrcEdit = ASrcEdit)
and (SrcEditLocked = ASrcEdit.IsLocked)
and (SourceNotebook = ASrcEdit.SourceNotebook)
and (PageIndex = ASrcEdit.SourceNotebook.PageIndex)
and (PageCount = ASrcEdit.SourceNotebook.PageCount)
);
if not Result then Exit;
SrcEdit := ASrcEdit;
SrcEditLocked := ASrcEdit.IsLocked;
SourceNotebook := ASrcEdit.SourceNotebook;
PageIndex := ASrcEdit.SourceNotebook.PageIndex;
PageCount := ASrcEdit.SourceNotebook.PageCount;
end;
{ TFileCommandsStamp }
function TFileCommandsStamp.Changed(ASrcEdit: TSourceEditor): Boolean;
begin
Result := not(
(SrcEdit = ASrcEdit)
);
if not Result then Exit;
SrcEdit := ASrcEdit;
end;
{ TSourceEditorCommandsStamp }
function TSourceEditorCommandsStamp.Changed(ASrcEdit: TSourceEditor;
ADisplayState: TDisplayState): Boolean;
begin
Assert(Assigned(ASrcEdit), 'TSourceEditorCommandsStamp.Changed: ASrcEdit=Nil');
Result := not(
(SrcEdit = ASrcEdit)
and (DisplayState = ADisplayState)
and (EditorComponentStamp = ASrcEdit.EditorComponent.ChangeStamp)
and (EditorCaretStamp = ASrcEdit.EditorComponent.CaretStamp)
);
if not Result then Exit;
SrcEdit := ASrcEdit;
DisplayState := ADisplayState;
EditorComponentStamp := ASrcEdit.EditorComponent.ChangeStamp;
EditorCaretStamp := ASrcEdit.EditorComponent.CaretStamp;
end;
//==============================================================================
{ TMainIDE }
{-------------------------------------------------------------------------------

View File

@ -27,6 +27,7 @@
unit SourceFileManager;
{$mode objfpc}{$H+}
{$MODESWITCH ADVANCEDRECORDS}
interface
@ -50,6 +51,55 @@ uses
type
TBookmarkCommandsStamp = record
public
BookmarkChanged: Boolean;
function Changed: Boolean;
end;
TFileCommandsStamp = record
private
SrcEdit: TSourceEditor;
public
function Changed(ASrcEdit: TSourceEditor): Boolean;
end;
TProjectCommandsStamp = record
private
UnitInfo: TUnitInfo;
ProjectChangeStamp: Int64;
public
function Changed(AUnitInfo: TUnitInfo): Boolean;
end;
TPackageCommandsStamp = record
private
UnitInfo: TUnitInfo;
PackagesChangeStamp: Int64;
public
function Changed(AUnitInfo: TUnitInfo): Boolean;
end;
TSourceEditorTabCommandsStamp = record
private
SrcEdit: TSourceEditor;
SrcEditLocked: Boolean;
SourceNotebook: TSourceNotebook;
PageIndex, PageCount: Integer;
public
function Changed(ASrcEdit: TSourceEditor): Boolean;
end;
TSourceEditorCommandsStamp = record
private
SrcEdit: TSourceEditor;
DisplayState: TDisplayState;
EditorComponentStamp: int64;
EditorCaretStamp: int64;
public
function Changed(ASrcEdit: TSourceEditor; ADisplayState: TDisplayState): Boolean;
end;
{ TFileOpener }
TFileOpener = class
@ -386,6 +436,105 @@ begin
end;
end;
{ TBookmarkCommandsStamp }
function TBookmarkCommandsStamp.Changed: Boolean;
begin
Result := BookmarkChanged;
if not Result then
Exit;
BookmarkChanged := True;
end;
{ TFileCommandsStamp }
function TFileCommandsStamp.Changed(ASrcEdit: TSourceEditor): Boolean;
begin
Result := not(
(SrcEdit = ASrcEdit)
);
if not Result then Exit;
SrcEdit := ASrcEdit;
end;
{ TProjectCommandsStamp }
function TProjectCommandsStamp.Changed(AUnitInfo: TUnitInfo): Boolean;
begin
Result := not(
(UnitInfo = AUnitInfo)
and (ProjectChangeStamp = Project1.ChangeStamp)
);
if not Result then Exit;
UnitInfo := AUnitInfo;
ProjectChangeStamp := Project1.ChangeStamp;
end;
{ TPackageCommandsStamp }
function TPackageCommandsStamp.Changed(AUnitInfo: TUnitInfo): Boolean;
begin
Result := not(
(UnitInfo = AUnitInfo)
and (PackagesChangeStamp = PackageGraph.ChangeStamp)
);
if not Result then Exit;
UnitInfo := AUnitInfo;
PackagesChangeStamp := PackageGraph.ChangeStamp;
end;
{ TSourceEditorTabCommandsStamp }
function TSourceEditorTabCommandsStamp.Changed(ASrcEdit: TSourceEditor): Boolean;
begin
Result := not(
(SrcEdit = ASrcEdit)
and (SrcEditLocked = ASrcEdit.IsLocked)
and (SourceNotebook = ASrcEdit.SourceNotebook)
and (PageIndex = ASrcEdit.SourceNotebook.PageIndex)
and (PageCount = ASrcEdit.SourceNotebook.PageCount)
);
if not Result then Exit;
SrcEdit := ASrcEdit;
SrcEditLocked := ASrcEdit.IsLocked;
SourceNotebook := ASrcEdit.SourceNotebook;
PageIndex := ASrcEdit.SourceNotebook.PageIndex;
PageCount := ASrcEdit.SourceNotebook.PageCount;
end;
{ TSourceEditorCommandsStamp }
function TSourceEditorCommandsStamp.Changed(ASrcEdit: TSourceEditor;
ADisplayState: TDisplayState): Boolean;
begin
Assert(Assigned(ASrcEdit), 'TSourceEditorCommandsStamp.Changed: ASrcEdit=Nil');
Result := not(
(SrcEdit = ASrcEdit)
and (DisplayState = ADisplayState)
and (EditorComponentStamp = ASrcEdit.EditorComponent.ChangeStamp)
and (EditorCaretStamp = ASrcEdit.EditorComponent.CaretStamp)
);
if not Result then Exit;
SrcEdit := ASrcEdit;
DisplayState := ADisplayState;
EditorComponentStamp := ASrcEdit.EditorComponent.ChangeStamp;
EditorCaretStamp := ASrcEdit.EditorComponent.CaretStamp;
end;
//==============================================================================
{ TFileOpener }
function TFileOpener.OpenFileInSourceEditor(AnEditorInfo: TUnitEditorInfo): TModalResult;