Ide/Project; SourceEditor: Decouple relationship via EditorIndex. Start using reference instead of index

git-svn-id: trunk@24015 -
This commit is contained in:
martin 2010-03-15 18:01:40 +00:00
parent 48c1748e02
commit 9e9e810073
5 changed files with 16 additions and 37 deletions

View File

@ -2067,7 +2067,7 @@ var
SrcFilename: String;
begin
if (AnUnitInfo.EditorIndex < 0) or Destroying then exit;
ASrcEdit := SourceNotebook.FindSourceEditorWithPageIndex(AnUnitInfo.EditorIndex);
ASrcEdit := TSourceEditor(AnUnitInfo.EditorComponent);
// set breakpoints for this unit
SrcFilename:=AnUnitInfo.Filename;
for i := 0 to FBreakpoints.Count-1 do

View File

@ -852,7 +852,6 @@ type
var ActiveSourceEditor: TSourceEditor; var ActiveUnitInfo: TUnitInfo); override;
procedure GetUnitWithPersistent(APersistent: TPersistent;
var ActiveSourceEditor: TSourceEditor; var ActiveUnitInfo: TUnitInfo); override;
function GetSourceEditorForUnitInfo(AnUnitInfo: TUnitInfo): TSourceEditor; override;
function CreateSrcEditPageName(const AnUnitName, AFilename: string;
IgnorePageIndex: integer): string;
function GetAncestorUnit(AnUnitInfo: TUnitInfo): TUnitInfo;
@ -4773,7 +4772,7 @@ var
IsPascal: Boolean;
begin
if AnUnitInfo<>nil then
SrcEdit:=GetSourceEditorForUnitInfo(AnUnitInfo)
SrcEdit := TSourceEditor(AnUnitInfo.EditorComponent)
else
SrcEdit:=nil;
//debugln('TMainIDE.DoShowSaveFileAsDialog ',AnUnitInfo.Filename);
@ -5363,7 +5362,7 @@ begin
OldFilename:=AnUnitInfo.Filename;
OldFilePath:=ExtractFilePath(OldFilename);
OldLFMFilename:=ChangeFileExt(OldFilename,'.lfm');
SrcEdit:=GetSourceEditorForUnitInfo(AnUnitInfo);
SrcEdit := TSourceEditor(AnUnitInfo.EditorComponent);
if NewUnitName='' then
NewUnitName:=AnUnitInfo.Unit_Name;
debugln(['TMainIDE.DoRenameUnit ',AnUnitInfo.Filename,' NewUnitName=',NewUnitName,' OldUnitName=',AnUnitInfo.Unit_Name,' ResourceCode=',ResourceCode<>nil,' NewFilename="',NewFilename,'"']);
@ -5811,7 +5810,7 @@ begin
for BookmarkID:=0 to 9 do begin
i:=Project1.Bookmarks.IndexOfID(BookmarkID);
if i<0 then continue;
if (Project1.Bookmarks[i].EditorIndex=AnUnitInfo.EditorIndex) then begin
if (Project1.Bookmarks[i].EditorComponent=AnUnitInfo.EditorComponent) then begin
//writeln('TMainIDE.DoRestoreBookMarks ',BookmarkID,' ',
// Project1.Bookmarks[i].CursorPos.X,' ',Project1.Bookmarks[i].CursorPos.Y);
ASrcEdit.EditorComponent.SetBookmark(BookmarkID,
@ -7196,8 +7195,7 @@ begin
if Project1.MainUnitID>=0 then begin
MainUnitInfo:=Project1.MainUnitInfo;
if MainUnitInfo.Loaded then begin
MainUnitSrcEdit:=SourceNoteBook.FindSourceEditorWithPageIndex(
MainUnitInfo.EditorIndex);
MainUnitSrcEdit := TSourceEditor(MainUnitInfo.EditorComponent);
if (MainUnitSrcEdit<>nil) and UpdateModified and MainUnitSrcEdit.Modified
then begin
MainUnitSrcEdit.UpdateCodeBuffer;
@ -7213,9 +7211,8 @@ var
BookmarkID, BookmarkX, BookmarkY: integer;
ASrcEdit: TSourceEditor;
begin
Project1.Bookmarks.DeleteAllWithEditorIndex(AnUnitInfo.EditorIndex);
ASrcEdit:=
SourceNoteBook.FindSourceEditorWithPageIndex(AnUnitInfo.EditorIndex);
Project1.Bookmarks.DeleteAllWithEditorComponent(AnUnitInfo.EditorComponent);
ASrcEdit := TSourceEditor(AnUnitInfo.EditorComponent);
if ASrcEdit=nil then exit;
AnUnitInfo.TopLine:=ASrcEdit.EditorComponent.TopLine;
AnUnitInfo.CursorPos:=ASrcEdit.EditorComponent.CaretXY;
@ -11467,8 +11464,7 @@ begin
ActiveUnitInfo:=Project1.FirstUnitWithComponent;
while ActiveUnitInfo<>nil do begin
if ActiveUnitInfo.Component=APersistent then begin
ActiveSourceEditor:=SourceNoteBook.FindSourceEditorWithPageIndex(
ActiveUnitInfo.EditorIndex);
ActiveSourceEditor := TSourceEditor(ActiveUnitInfo.EditorComponent);
exit;
end;
ActiveUnitInfo:=ActiveUnitInfo.NextUnitWithComponent;
@ -11478,12 +11474,6 @@ begin
ActiveUnitInfo:=nil;
end;
function TMainIDE.GetSourceEditorForUnitInfo(AnUnitInfo: TUnitInfo
): TSourceEditor;
begin
Result:=SourceNoteBook.FindSourceEditorWithPageIndex(AnUnitInfo.EditorIndex);
end;
function TMainIDE.DoLoadMemoryStreamFromFile(MemStream: TMemoryStream;
const AFilename:string): TModalResult;
var FileStream: TFileStream;
@ -12705,7 +12695,7 @@ begin
AnUnitInfo.Modified := True;
if AnUnitInfo.Loaded then
begin
SrcEdit := SourceNotebook.FindSourceEditorWithPageIndex(AnUnitInfo.EditorIndex);
SrcEdit := TSourceEditor(AnUnitInfo.EditorComponent);
if SrcEdit <> nil then
begin
SrcEdit.Modified := True;

View File

@ -153,7 +153,6 @@ type
var ActiveSourceEditor: TSourceEditor; var ActiveUnitInfo: TUnitInfo); virtual; abstract;
procedure GetUnitWithPersistent(APersistent: TPersistent;
var ActiveSourceEditor: TSourceEditor; var ActiveUnitInfo: TUnitInfo); virtual; abstract;
function GetSourceEditorForUnitInfo(AnUnitInfo: TUnitInfo): TSourceEditor; virtual; abstract;
function DoOpenMacroFile(Sender: TObject; const AFilename: string
): TModalResult; override;

View File

@ -683,7 +683,6 @@ type
procedure RemoveFromList(AnUnitInfo: TUnitInfo; ListType: TUnitInfoList);
procedure AddToOrRemoveFromAutoRevertLockedList(AnUnitInfo: TUnitInfo);
procedure AddToOrRemoveFromEditorWithIndexList(AnUnitInfo: TUnitInfo);
procedure AddToOrRemoveFromComponentList(AnUnitInfo: TUnitInfo);
procedure AddToOrRemoveFromLoadedList(AnUnitInfo: TUnitInfo);
procedure AddToOrRemoveFromPartOfProjectList(AnUnitInfo: TUnitInfo);
@ -2783,8 +2782,8 @@ begin
end;
// delete bookmarks of this unit
if OldUnitInfo.EditorIndex>=0 then
Bookmarks.DeleteAllWithEditorIndex(OldUnitInfo.EditorIndex);
if OldUnitInfo.EditorComponent <> nil then
Bookmarks.DeleteAllWithEditorComponent(OldUnitInfo.EditorComponent);
// adjust MainUnit
if MainUnitID>=Index then dec(fMainUnitID);
@ -3292,15 +3291,6 @@ begin
while (Result>=0) and (Units[Result]<>AUnitInfo) do dec(Result);
end;
procedure TProject.AddToOrRemoveFromEditorWithIndexList(AnUnitInfo: TUnitInfo);
begin
if AnUnitInfo.EditorIndex<0 then begin
RemoveFromList(AnUnitInfo,uilWithEditorIndex);
end else begin
AddToList(AnUnitInfo,uilWithEditorIndex);
end;
end;
procedure TProject.AddToOrRemoveFromComponentList(AnUnitInfo: TUnitInfo);
begin
if AnUnitInfo.Component=nil then begin
@ -3657,7 +3647,7 @@ var
UnitMark: TFileBookmark;
ProjectMark: TProjectBookmark;
begin
if AnUnitInfo.EditorIndex<0 then exit;
if AnUnitInfo.EditorComponent = nil then exit;
for i:=0 to AnUnitInfo.Bookmarks.Count-1 do begin
UnitMark:=AnUnitInfo.Bookmarks[i];
ProjectMark:=Bookmarks.BookmarkWithIndex(UnitMark.ID);
@ -4353,7 +4343,7 @@ function TProject.JumpHistoryCheckPosition(
var i: integer;
begin
i:=IndexOfFilename(APosition.Filename);
Result:=(i>=0) and (Units[i].EditorIndex>=0);
Result:=(i>=0) and (Units[i].EditorComponent <> nil);
end;
function TProject.SomethingModified(CheckData, CheckSession: boolean): boolean;
@ -4642,7 +4632,7 @@ begin
Result:=UnitCount-1;
while (Result>=0) do begin
if (pfsfOnlyEditorFiles in SearchFlags)
and (Units[Result].EditorIndex<0) then begin
and (Units[Result].EditorComponent = nil) then begin
dec(Result);
continue;
end;

View File

@ -205,8 +205,8 @@ type
procedure DeleteAllWithEditorComponent(AEditor:TSourceEditorInterface);
function IndexOfID(ID:integer):integer;
function BookmarkWithIndex(ID: integer): TProjectBookmark;
procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string);
procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string);
procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string); deprecated 'Does not link to Editorcomponent';
procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string); deprecated 'Does not link to Editorcomponent';
end;
type