MG: improved handling of ambigious source files

git-svn-id: trunk@3290 -
This commit is contained in:
lazarus 2002-09-05 19:03:36 +00:00
parent 477b2808f2
commit fa42cd6ebc
3 changed files with 280 additions and 110 deletions

View File

@ -64,25 +64,48 @@ type
TDebuggerType = (dtNone, dtGnuDebugger); TDebuggerType = (dtNone, dtGnuDebugger);
TPascalExtType = (petNone, petPAS, petPP);
TLazarusLanguage = (llAutomatic, llEnglish, llGerman);
const const
DebuggerName : array[TDebuggerType] of string = ( DebuggerName : array[TDebuggerType] of string = (
'(None)','GNU debugger (gdb)' '(None)','GNU debugger (gdb)'
); );
type
TPascalExtType = (petNone, petPAS, petPP);
const
PascalExtension: array[TPascalExtType] of string = ('', '.pas', '.pp');
type
TLazarusLanguage = (llAutomatic, llEnglish, llGerman);
const
LazarusLanguageNames: array[TLazarusLanguage] of string = ( LazarusLanguageNames: array[TLazarusLanguage] of string = (
'Automatic (default is english)', 'English', 'Deutsch' 'Automatic (default is english)', 'English', 'Deutsch'
); );
LazarusLanguageIDs: array[TLazarusLanguage] of string = ( LazarusLanguageIDs: array[TLazarusLanguage] of string = (
'', 'en', 'de' '', 'en', 'de'
); );
PascalExtension: array[TPascalExtType] of string = ('', '.pas', '.pp'); type
TAmbigiousFileAction = (
afaAsk,
afaAutoDelete,
afaAutoRename,
afaWarnOnCompile,
afaIgnore
);
TAmbigiousFileActions = set of TAmbigiousFileAction;
const
AmbigiousFileActionNames: array[TAmbigiousFileAction] of string = (
'Ask',
'AutoDelete',
'AutoRename',
'WarnOnCompile',
'Ignore'
);
type type
{ class for storing environment options } { class for storing environment options }
TEnvironmentOptions = class TEnvironmentOptions = class
@ -150,7 +173,7 @@ type
// naming conventions // naming conventions
fPascalFileExtension: TPascalExtType; fPascalFileExtension: TPascalExtType;
fPascalFileLowerCase: boolean; fPascalFileLowerCase: boolean;
fAutoDeleteAmbigiousSources: boolean; fAmbigiousFileAction: TAmbigiousFileAction;
// language // language
fLanguage: TLazarusLanguage; fLanguage: TLazarusLanguage;
@ -266,8 +289,8 @@ type
read fPascalFileExtension write fPascalFileExtension; read fPascalFileExtension write fPascalFileExtension;
property PascalFileLowerCase: boolean property PascalFileLowerCase: boolean
read fPascalFileLowerCase write fPascalFileLowerCase; read fPascalFileLowerCase write fPascalFileLowerCase;
property AutoDeleteAmbigiousSources: boolean property AmbigiousFileAction: TAmbigiousFileAction
read fAutoDeleteAmbigiousSources write fAutoDeleteAmbigiousSources; read fAmbigiousFileAction write fAmbigiousFileAction;
// language // language
property Language: TLazarusLanguage read fLanguage write fLanguage; property Language: TLazarusLanguage read fLanguage write fLanguage;
@ -376,7 +399,7 @@ type
// naming conventions // naming conventions
PascalFileExtRadiogroup: TRadioGroup; PascalFileExtRadiogroup: TRadioGroup;
PascalFileLowercaseCheckBox: TCheckBox; PascalFileLowercaseCheckBox: TCheckBox;
AutoDeleteAmbigiousSourcesCheckBox: TCheckBox; AmbigiousFileActionRadioGroup: TRadioGroup;
// buttons at bottom // buttons at bottom
OkButton: TButton; OkButton: TButton;
@ -432,7 +455,7 @@ function PascalExtToType(const Ext: string): TPascalExtType;
function FilenameIsPascalUnit(const Filename: string): boolean; function FilenameIsPascalUnit(const Filename: string): boolean;
function FilenameIsPascalSource(const Filename: string): boolean; function FilenameIsPascalSource(const Filename: string): boolean;
function FilenameIsFormText(const Filename: string): boolean; function FilenameIsFormText(const Filename: string): boolean;
function AmbigiousFileActionNameToType(const Action: string): TAmbigiousFileAction;
implementation implementation
@ -476,6 +499,16 @@ begin
Result:=petNone; Result:=petNone;
end; end;
function AmbigiousFileActionNameToType(
const Action: string): TAmbigiousFileAction;
begin
for Result:=Low(TAmbigiousFileAction) to High(TAmbigiousFileAction) do begin
if AnsiCompareText(AmbigiousFileActionNames[Result],Action)=0 then
exit;
end;
Result:=afaAsk;
end;
{ TEnvironmentOptions } { TEnvironmentOptions }
const const
@ -792,8 +825,9 @@ begin
LoadPascalFileExt('EnvironmentOptions/'); LoadPascalFileExt('EnvironmentOptions/');
fPascalFileLowerCase:=XMLConfig.GetValue( fPascalFileLowerCase:=XMLConfig.GetValue(
'EnvironmentOptions/PascalFileLowerCase/Value',true); 'EnvironmentOptions/PascalFileLowerCase/Value',true);
fAutoDeleteAmbigiousSources:=XMLConfig.GetValue( fAmbigiousFileAction:=AmbigiousFileActionNameToType(XMLConfig.GetValue(
'EnvironmentOptions/AutoDeleteAmbigiousSources/Value',true); 'EnvironmentOptions/AmbigiousFileAction/Value',
AmbigiousFileActionNames[fAmbigiousFileAction]));
XMLConfig.Free; XMLConfig.Free;
@ -951,7 +985,7 @@ begin
XMLConfig.SetValue('EnvironmentOptions/PascalFileLowerCase/Value', XMLConfig.SetValue('EnvironmentOptions/PascalFileLowerCase/Value',
fPascalFileLowerCase); fPascalFileLowerCase);
XMLConfig.SetValue('EnvironmentOptions/AutoDeleteAmbigiousSources/Value', XMLConfig.SetValue('EnvironmentOptions/AutoDeleteAmbigiousSources/Value',
fAutoDeleteAmbigiousSources); AmbigiousFileActionNames[fAmbigiousFileAction]);
XMLConfig.Flush; XMLConfig.Flush;
XMLConfig.Free; XMLConfig.Free;
@ -2159,14 +2193,24 @@ begin
Visible:=true; Visible:=true;
end; end;
AutoDeleteAmbigiousSourcesCheckBox:=TCheckBox.Create(Self); AmbigiousFileActionRadioGroup:=TRadioGroup.Create(Self);
with AutoDeleteAmbigiousSourcesCheckBox do begin with AmbigiousFileActionRadioGroup do begin
Name:='AutoDeleteAmbigiousSourcesCheckBox'; Name:='AmbigiousFileActionRadioGroup';
Parent:=NoteBook.Page[Page]; Parent:=NoteBook.Page[Page];
Left:=PascalFileLowercaseCheckBox.Left; Left:=PascalFileLowercaseCheckBox.Left;
Top:=PascalFileLowercaseCheckBox.Top+PascalFileLowercaseCheckBox.Height+10; Top:=PascalFileLowercaseCheckBox.Top+PascalFileLowercaseCheckBox.Height+15;
Width:=300; Width:=200;
Caption:='Auto delete ambigious sources'; Height:=130;
Caption:='Ambigious file action:';
with Items do begin
BeginUpdate;
Add('Ask');
Add('Auto delete file');
Add('Auto rename file');
Add('Warn on compile');
Add('Ignore');
EndUpdate;
end;
Visible:=true; Visible:=true;
end; end;
end; end;
@ -2672,10 +2716,11 @@ begin
Width:=300; Width:=300;
end; end;
with AutoDeleteAmbigiousSourcesCheckBox do begin with AmbigiousFileActionRadioGroup do begin
Left:=PascalFileLowercaseCheckBox.Left; Left:=PascalFileLowercaseCheckBox.Left;
Top:=PascalFileLowercaseCheckBox.Top+PascalFileLowercaseCheckBox.Height+10; Top:=PascalFileLowercaseCheckBox.Top+PascalFileLowercaseCheckBox.Height+15;
Width:=300; Width:=200;
Height:=130;
end; end;
end; end;
@ -2925,7 +2970,7 @@ begin
if PascalFileExtRadiogroup.Items[i]=PascalExtension[PascalFileExtension] if PascalFileExtRadiogroup.Items[i]=PascalExtension[PascalFileExtension]
then PascalFileExtRadiogroup.ItemIndex:=i; then PascalFileExtRadiogroup.ItemIndex:=i;
PascalFileLowercaseCheckBox.Checked:=PascalFileLowerCase; PascalFileLowercaseCheckBox.Checked:=PascalFileLowerCase;
AutoDeleteAmbigiousSourcesCheckBox.Checked:=AutoDeleteAmbigiousSources; AmbigiousFileActionRadioGroup.ItemIndex:=ord(AmbigiousFileAction);
end; end;
end; end;
@ -3038,7 +3083,8 @@ begin
else else
PascalFileExtension:=petPAS; PascalFileExtension:=petPAS;
PascalFileLowerCase:=PascalFileLowercaseCheckBox.Checked; PascalFileLowerCase:=PascalFileLowercaseCheckBox.Checked;
AutoDeleteAmbigiousSources:=AutoDeleteAmbigiousSourcesCheckBox.Checked; AmbigiousFileAction:=
TAmbigiousFileAction(AmbigiousFileActionRadioGroup.ItemIndex);
end; end;
end; end;

View File

@ -43,8 +43,8 @@ uses
Classes, LazarusIDEStrConsts, LCLType, LclLinux, Compiler, StdCtrls, Forms, Classes, LazarusIDEStrConsts, LCLType, LclLinux, Compiler, StdCtrls, Forms,
Buttons, Menus, ComCtrls, Spin, Project, SysUtils, FileCtrl, Controls, Buttons, Menus, ComCtrls, Spin, Project, SysUtils, FileCtrl, Controls,
Graphics, ExtCtrls, Dialogs, LazConf, CompReg, CodeToolManager, Graphics, ExtCtrls, Dialogs, LazConf, CompReg, CodeToolManager,
ObjectInspector, PropEdits, SynEditKeyCmds, ObjectInspector, PropEdits, SynEditKeyCmds, OutputFilter,
MsgView, EditorOptions, IDEComp, FormEditor, MsgView, EnvironmentOpts, EditorOptions, IDEComp, FormEditor,
KeyMapping, IDEProcs, UnitEditor, Debugger, IDEOptionDefs, CodeToolsDefines; KeyMapping, IDEProcs, UnitEditor, Debugger, IDEOptionDefs, CodeToolsDefines;
const const
@ -224,6 +224,9 @@ type
HintTimer1 : TTimer; HintTimer1 : TTimer;
HintWindow1 : THintWindow; HintWindow1 : THintWindow;
protected protected
TheCompiler: TCompiler;
TheOutputFilter: TOutputFilter;
function CreateMenuSeparator : TMenuItem; function CreateMenuSeparator : TMenuItem;
procedure SetupFileMenu; virtual; procedure SetupFileMenu; virtual;
procedure SetupEditMenu; virtual; procedure SetupEditMenu; virtual;
@ -252,6 +255,8 @@ type
function DoInitProjectRun: TModalResult; virtual; abstract; function DoInitProjectRun: TModalResult; virtual; abstract;
function DoCheckFilesOnDisk: TModalResult; virtual; abstract; function DoCheckFilesOnDisk: TModalResult; virtual; abstract;
function DoCheckAmbigiousSources(const AFilename: string;
Compiling: boolean): TModalResult;
end; end;
var var
@ -907,5 +912,106 @@ begin
end; end;
end; end;
{-------------------------------------------------------------------------------
function TMainIDEBar.DoCheckAmbigiousSources(const AFilename: string
): TModalResult;
Checks if file exists with same name and similar extension. The compiler
prefers for example .pp to .pas files. So, if we save a .pas file delete .pp
file, so that compiling does what is expected.
-------------------------------------------------------------------------------}
function TMainIDEBar.DoCheckAmbigiousSources(const AFilename: string;
Compiling: boolean): TModalResult;
function DeleteAmbigiousFile(const AmbigiousFilename: string): TModalResult;
begin
if not DeleteFile(AmbigiousFilename) then begin
Result:=MessageDlg('Error deleting file',
'Unable to delete ambigious file "'+AmbigiousFilename+'"',
mtError,[mbOk,mbAbort],0);
end else
Result:=mrOk;
end;
function RenameAmbigiousFile(const AmbigiousFilename: string): TModalResult;
var
NewFilename: string;
begin
NewFilename:=AmbigiousFilename+'.ambigious';
if not RenameFile(AmbigiousFilename,NewFilename) then
begin
Result:=MessageDlg('Error renaming file',
'Unable to rename ambigious file "'+AmbigiousFilename+'"'#13
+'to "'+NewFilename+'"',
mtError,[mbOk,mbAbort],0);
end else
Result:=mrOk;
end;
function AddCompileWarning(const AmbigiousFilename: string): TModalResult;
begin
Result:=mrOk;
if Compiling then begin
TheOutputFilter.ReadLine('Warning: ambigious file found: "'+AmbigiousFilename+'"'
+'. Source file is: "'+AFilename+'"',true);
end;
end;
function CheckFile(const AmbigiousFilename: string): TModalResult;
begin
if not FileExists(AmbigiousFilename) then exit;
if Compiling then begin
Result:=AddCompileWarning(AmbigiousFilename);
exit;
end;
case EnvironmentOptions.AmbigiousFileAction of
afaAsk:
begin
Result:=MessageDlg('Ambigious file found',
'There is a file with the same name and a similar extension ond disk'#13
+'File: '+AFilename+#13
+'Ambigious File: '+AmbigiousFilename+#13
+#13
+'Delete ambigious file?',
mtWarning,[mbYes,mbIgnore,mbAbort],0);
case Result of
mrYes: Result:=DeleteAmbigiousFile(AmbigiousFilename);
mrIgnore: Result:=mrOk;
end;
end;
afaAutoDelete:
Result:=DeleteAmbigiousFile(AmbigiousFilename);
afaAutoRename:
Result:=RenameAmbigiousFile(AmbigiousFilename);
afaWarnOnCompile:
Result:=AddCompileWarning(AmbigiousFilename);
else
Result:=mrOk;
end;
end;
var
Ext, LowExt: string;
begin
Result:=mrOk;
if EnvironmentOptions.AmbigiousFileAction=afaIgnore then exit;
if (EnvironmentOptions.AmbigiousFileAction=afaWarnOnCompile)
and not Compiling then exit;
if FilenameIsPascalUnit(AFilename) then begin
Ext:=ExtractFileExt(AFilename);
LowExt:=lowercase(Ext);
if LowExt='.pp' then
Result:=CheckFile(ChangeFileExt(AFilename,'.pas'))
else if LowExt='.pas' then
Result:=CheckFile(ChangeFileExt(AFilename,'.pp'));
end;
end;
end. end.

View File

@ -106,14 +106,14 @@ type
procedure SetSource(ABuffer: TCodeBuffer); procedure SetSource(ABuffer: TCodeBuffer);
procedure SetUnitName(const NewUnitName:string); procedure SetUnitName(const NewUnitName:string);
protected protected
NextUnitWithEditorIndex: TUnitInfo; fNextUnitWithEditorIndex: TUnitInfo;
PrevUnitWithEditorIndex: TUnitInfo; fPrevUnitWithEditorIndex: TUnitInfo;
NextUnitWithForm: TUnitInfo; fNextUnitWithForm: TUnitInfo;
PrevUnitWithForm: TUnitInfo; fPrevUnitWithForm: TUnitInfo;
NextLoadedUnit: TUnitInfo; fNextLoadedUnit: TUnitInfo;
PrevLoadedUnit: TUnitInfo; fPrevLoadedUnit: TUnitInfo;
NextAutoRevertLockedUnit: TUnitInfo; fNextAutoRevertLockedUnit: TUnitInfo;
PrevAutoRevertLockedUnit: TUnitInfo; fPrevAutoRevertLockedUnit: TUnitInfo;
procedure UpdateEditorIndexList; procedure UpdateEditorIndexList;
procedure UpdateFormList; procedure UpdateFormList;
procedure UpdateLoadedList; procedure UpdateLoadedList;
@ -142,6 +142,16 @@ type
function NeedsSaveToDisk: boolean; function NeedsSaveToDisk: boolean;
{ Properties } { Properties }
public
property NextUnitWithEditorIndex: TUnitInfo read fNextUnitWithEditorIndex;
property PrevUnitWithEditorIndex: TUnitInfo read fPrevUnitWithEditorIndex;
property NextUnitWithForm: TUnitInfo read fNextUnitWithForm;
property PrevUnitWithForm: TUnitInfo read fPrevUnitWithForm;
property NextLoadedUnit: TUnitInfo read fNextLoadedUnit;
property PrevLoadedUnit: TUnitInfo read fPrevLoadedUnit;
property NextAutoRevertLockedUnit: TUnitInfo read fNextAutoRevertLockedUnit;
property PrevAutoRevertLockedUnit: TUnitInfo read fPrevAutoRevertLockedUnit;
public
property Breakpoints: TProjectBreakPointList property Breakpoints: TProjectBreakPointList
read fBreakpoints write fBreakpoints; read fBreakpoints write fBreakpoints;
property CursorPos: TPoint read fCursorPos write fCursorPos; property CursorPos: TPoint read fCursorPos write fCursorPos;
@ -289,6 +299,11 @@ type
property Bookmarks: TProjectBookmarkList read fBookmarks write fBookmarks; property Bookmarks: TProjectBookmarkList read fBookmarks write fBookmarks;
property CompilerOptions: TCompilerOptions property CompilerOptions: TCompilerOptions
read fCompilerOptions write fCompilerOptions; read fCompilerOptions write fCompilerOptions;
property FirstAutoRevertLockedUnit: TUnitInfo read fFirstAutoRevertLockedUnit;
property FirstLoadedUnit: TUnitInfo read fFirstLoadedUnit;
property FirstUnitWithEditorIndex: TUnitInfo read fFirstUnitWithEditorIndex;
property FirstUnitWithForm: TUnitInfo read fFirstUnitWithForm;
property Flags: TProjectFlags read FFlags write SetFlags; property Flags: TProjectFlags read FFlags write SetFlags;
property IconPath: String read fIconPath write fIconPath; property IconPath: String read fIconPath write fIconPath;
property JumpHistory: TProjectJumpHistory property JumpHistory: TProjectJumpHistory
@ -609,8 +624,8 @@ begin
if Project<>nil then begin if Project<>nil then begin
Project.AddToOrRemoveFromEditorWithIndexList(Self); Project.AddToOrRemoveFromEditorWithIndexList(Self);
end else begin end else begin
NextUnitWithEditorIndex:=nil; fNextUnitWithEditorIndex:=nil;
PrevUnitWithEditorIndex:=nil; fPrevUnitWithEditorIndex:=nil;
end; end;
end; end;
@ -619,8 +634,8 @@ begin
if Project<>nil then begin if Project<>nil then begin
Project.AddToOrRemoveFromFormList(Self); Project.AddToOrRemoveFromFormList(Self);
end else begin end else begin
NextUnitWithForm:=nil; fNextUnitWithForm:=nil;
PrevUnitWithForm:=nil; fPrevUnitWithForm:=nil;
end; end;
end; end;
@ -629,8 +644,8 @@ begin
if Project<>nil then begin if Project<>nil then begin
Project.AddToOrRemoveFromLoadedList(Self); Project.AddToOrRemoveFromLoadedList(Self);
end else begin end else begin
NextLoadedUnit:=nil; fNextLoadedUnit:=nil;
PrevLoadedUnit:=nil; fPrevLoadedUnit:=nil;
end; end;
end; end;
@ -639,8 +654,8 @@ begin
if Project<>nil then begin if Project<>nil then begin
Project.AddToOrRemoveFromAutoRevertLockedList(Self); Project.AddToOrRemoveFromAutoRevertLockedList(Self);
end else begin end else begin
NextAutoRevertLockedUnit:=nil; fNextAutoRevertLockedUnit:=nil;
PrevAutoRevertLockedUnit:=nil; fPrevAutoRevertLockedUnit:=nil;
end; end;
end; end;
@ -1439,7 +1454,7 @@ function TProject.UnitWithEditorIndex(Index:integer):TUnitInfo;
begin begin
Result:=fFirstUnitWithEditorIndex; Result:=fFirstUnitWithEditorIndex;
while (Result<>nil) and (Result.EditorIndex<>Index) do begin while (Result<>nil) and (Result.EditorIndex<>Index) do begin
Result:=Result.NextUnitWithEditorIndex; Result:=Result.fNextUnitWithEditorIndex;
end; end;
end; end;
@ -1521,7 +1536,7 @@ var i:integer;
begin begin
AnUnitInfo:=fFirstUnitWithEditorIndex; AnUnitInfo:=fFirstUnitWithEditorIndex;
while AnUnitInfo<>nil do begin while AnUnitInfo<>nil do begin
NextUnitInfo:=AnUnitInfo.NextUnitWithEditorIndex; NextUnitInfo:=AnUnitInfo.fNextUnitWithEditorIndex;
if AnUnitInfo.EditorIndex=EditorIndex then if AnUnitInfo.EditorIndex=EditorIndex then
AnUnitInfo.EditorIndex:=-1 AnUnitInfo.EditorIndex:=-1
else if AnUnitInfo.EditorIndex>EditorIndex then else if AnUnitInfo.EditorIndex>EditorIndex then
@ -1547,7 +1562,7 @@ begin
while AnUnitInfo<>nil do begin while AnUnitInfo<>nil do begin
if AnUnitInfo.EditorIndex>=EditorIndex then if AnUnitInfo.EditorIndex>=EditorIndex then
AnUnitInfo.EditorIndex:=AnUnitInfo.EditorIndex+1; AnUnitInfo.EditorIndex:=AnUnitInfo.EditorIndex+1;
AnUnitInfo:=AnUnitInfo.NextUnitWithEditorIndex; AnUnitInfo:=AnUnitInfo.fNextUnitWithEditorIndex;
end; end;
i:=Bookmarks.Count-1; i:=Bookmarks.Count-1;
while (i>=0) do begin while (i>=0) do begin
@ -1711,7 +1726,7 @@ begin
AnUnitList:=TList.Create; AnUnitList:=TList.Create;
AnUnitList.Add(AnUnitInfo); AnUnitList.Add(AnUnitInfo);
end; end;
AnUnitInfo:=AnUnitInfo.NextAutoRevertLockedUnit; AnUnitInfo:=AnUnitInfo.fNextAutoRevertLockedUnit;
end; end;
end; end;
@ -1760,7 +1775,7 @@ Function TProject.UnitWithForm(AForm : TComponent) : TUnitInfo;
begin begin
Result:=fFirstUnitWithForm; Result:=fFirstUnitWithForm;
while (Result<>nil) and (Result.Form<>AForm) do while (Result<>nil) and (Result.Form<>AForm) do
Result:=Result.NextUnitWithForm; Result:=Result.fNextUnitWithForm;
end; end;
function TProject.IndexOfFilename(const AFilename: string): integer; function TProject.IndexOfFilename(const AFilename: string): integer;
@ -1782,13 +1797,13 @@ procedure TProject.AddToEditorWithIndexList(AnUnitInfo: TUnitInfo);
begin begin
// add to list if AnUnitInfo is not in list // add to list if AnUnitInfo is not in list
if (fFirstUnitWithEditorIndex<>AnUnitInfo) if (fFirstUnitWithEditorIndex<>AnUnitInfo)
and (AnUnitInfo.NextUnitWithEditorIndex=nil) and (AnUnitInfo.fNextUnitWithEditorIndex=nil)
and (AnUnitInfo.PrevUnitWithEditorIndex=nil) then begin and (AnUnitInfo.fPrevUnitWithEditorIndex=nil) then begin
AnUnitInfo.NextUnitWithEditorIndex:=fFirstUnitWithEditorIndex; AnUnitInfo.fNextUnitWithEditorIndex:=fFirstUnitWithEditorIndex;
AnUnitInfo.PrevUnitWithEditorIndex:=nil; AnUnitInfo.fPrevUnitWithEditorIndex:=nil;
fFirstUnitWithEditorIndex:=AnUnitInfo; fFirstUnitWithEditorIndex:=AnUnitInfo;
if AnUnitInfo.NextUnitWithEditorIndex<>nil then if AnUnitInfo.fNextUnitWithEditorIndex<>nil then
AnUnitInfo.NextUnitWithEditorIndex.PrevUnitWithEditorIndex:=AnUnitInfo; AnUnitInfo.fNextUnitWithEditorIndex.fPrevUnitWithEditorIndex:=AnUnitInfo;
end; end;
end; end;
@ -1796,28 +1811,28 @@ procedure TProject.RemoveFromEditorWithIndexList(AnUnitInfo: TUnitInfo);
begin begin
// remove from list if AnUnitInfo is in list // remove from list if AnUnitInfo is in list
if fFirstUnitWithEditorIndex=AnUnitInfo then if fFirstUnitWithEditorIndex=AnUnitInfo then
fFirstUnitWithEditorIndex:=AnUnitInfo.NextUnitWithEditorIndex; fFirstUnitWithEditorIndex:=AnUnitInfo.fNextUnitWithEditorIndex;
if AnUnitInfo.NextUnitWithEditorIndex<>nil then if AnUnitInfo.fNextUnitWithEditorIndex<>nil then
AnUnitInfo.NextUnitWithEditorIndex.PrevUnitWithEditorIndex:= AnUnitInfo.fNextUnitWithEditorIndex.fPrevUnitWithEditorIndex:=
AnUnitInfo.PrevUnitWithEditorIndex; AnUnitInfo.fPrevUnitWithEditorIndex;
if AnUnitInfo.PrevUnitWithEditorIndex<>nil then if AnUnitInfo.fPrevUnitWithEditorIndex<>nil then
AnUnitInfo.PrevUnitWithEditorIndex.NextUnitWithEditorIndex:= AnUnitInfo.fPrevUnitWithEditorIndex.fNextUnitWithEditorIndex:=
AnUnitInfo.NextUnitWithEditorIndex; AnUnitInfo.fNextUnitWithEditorIndex;
AnUnitInfo.NextUnitWithEditorIndex:=nil; AnUnitInfo.fNextUnitWithEditorIndex:=nil;
AnUnitInfo.PrevUnitWithEditorIndex:=nil; AnUnitInfo.fPrevUnitWithEditorIndex:=nil;
end; end;
procedure TProject.AddToFormList(AnUnitInfo: TUnitInfo); procedure TProject.AddToFormList(AnUnitInfo: TUnitInfo);
begin begin
// add to list if AnUnitInfo is not in list // add to list if AnUnitInfo is not in list
if (fFirstUnitWithForm<>AnUnitInfo) if (fFirstUnitWithForm<>AnUnitInfo)
and (AnUnitInfo.NextUnitWithForm=nil) and (AnUnitInfo.fNextUnitWithForm=nil)
and (AnUnitInfo.PrevUnitWithForm=nil) then begin and (AnUnitInfo.fPrevUnitWithForm=nil) then begin
AnUnitInfo.NextUnitWithForm:=fFirstUnitWithForm; AnUnitInfo.fNextUnitWithForm:=fFirstUnitWithForm;
AnUnitInfo.PrevUnitWithForm:=nil; AnUnitInfo.fPrevUnitWithForm:=nil;
fFirstUnitWithForm:=AnUnitInfo; fFirstUnitWithForm:=AnUnitInfo;
if AnUnitInfo.NextUnitWithForm<>nil then if AnUnitInfo.fNextUnitWithForm<>nil then
AnUnitInfo.NextUnitWithForm.PrevUnitWithForm:=AnUnitInfo; AnUnitInfo.fNextUnitWithForm.fPrevUnitWithForm:=AnUnitInfo;
end; end;
end; end;
@ -1825,28 +1840,28 @@ procedure TProject.RemoveFromFormList(AnUnitInfo: TUnitInfo);
begin begin
// remove from list if AnUnitInfo is in list // remove from list if AnUnitInfo is in list
if fFirstUnitWithForm=AnUnitInfo then if fFirstUnitWithForm=AnUnitInfo then
fFirstUnitWithForm:=AnUnitInfo.NextUnitWithForm; fFirstUnitWithForm:=AnUnitInfo.fNextUnitWithForm;
if AnUnitInfo.NextUnitWithForm<>nil then if AnUnitInfo.fNextUnitWithForm<>nil then
AnUnitInfo.NextUnitWithForm.PrevUnitWithForm:= AnUnitInfo.fNextUnitWithForm.fPrevUnitWithForm:=
AnUnitInfo.PrevUnitWithForm; AnUnitInfo.fPrevUnitWithForm;
if AnUnitInfo.PrevUnitWithForm<>nil then if AnUnitInfo.fPrevUnitWithForm<>nil then
AnUnitInfo.PrevUnitWithForm.NextUnitWithForm:= AnUnitInfo.fPrevUnitWithForm.fNextUnitWithForm:=
AnUnitInfo.NextUnitWithForm; AnUnitInfo.fNextUnitWithForm;
AnUnitInfo.NextUnitWithForm:=nil; AnUnitInfo.fNextUnitWithForm:=nil;
AnUnitInfo.PrevUnitWithForm:=nil; AnUnitInfo.fPrevUnitWithForm:=nil;
end; end;
procedure TProject.AddToLoadedList(AnUnitInfo: TUnitInfo); procedure TProject.AddToLoadedList(AnUnitInfo: TUnitInfo);
begin begin
// add to list if AnUnitInfo is not in list // add to list if AnUnitInfo is not in list
if (fFirstLoadedUnit<>AnUnitInfo) if (fFirstLoadedUnit<>AnUnitInfo)
and (AnUnitInfo.NextLoadedUnit=nil) and (AnUnitInfo.fNextLoadedUnit=nil)
and (AnUnitInfo.PrevLoadedUnit=nil) then begin and (AnUnitInfo.fPrevLoadedUnit=nil) then begin
AnUnitInfo.NextLoadedUnit:=fFirstLoadedUnit; AnUnitInfo.fNextLoadedUnit:=fFirstLoadedUnit;
AnUnitInfo.PrevLoadedUnit:=nil; AnUnitInfo.fPrevLoadedUnit:=nil;
fFirstLoadedUnit:=AnUnitInfo; fFirstLoadedUnit:=AnUnitInfo;
if AnUnitInfo.NextLoadedUnit<>nil then if AnUnitInfo.fNextLoadedUnit<>nil then
AnUnitInfo.NextLoadedUnit.PrevLoadedUnit:=AnUnitInfo; AnUnitInfo.fNextLoadedUnit.fPrevLoadedUnit:=AnUnitInfo;
end; end;
end; end;
@ -1854,28 +1869,28 @@ procedure TProject.RemoveFromLoadedList(AnUnitInfo: TUnitInfo);
begin begin
// remove from list if AnUnitInfo is in list // remove from list if AnUnitInfo is in list
if fFirstLoadedUnit=AnUnitInfo then if fFirstLoadedUnit=AnUnitInfo then
fFirstLoadedUnit:=AnUnitInfo.NextUnitWithForm; fFirstLoadedUnit:=AnUnitInfo.fNextUnitWithForm;
if AnUnitInfo.NextLoadedUnit<>nil then if AnUnitInfo.fNextLoadedUnit<>nil then
AnUnitInfo.NextLoadedUnit.PrevLoadedUnit:= AnUnitInfo.fNextLoadedUnit.fPrevLoadedUnit:=
AnUnitInfo.PrevLoadedUnit; AnUnitInfo.fPrevLoadedUnit;
if AnUnitInfo.PrevLoadedUnit<>nil then if AnUnitInfo.fPrevLoadedUnit<>nil then
AnUnitInfo.PrevLoadedUnit.NextLoadedUnit:= AnUnitInfo.fPrevLoadedUnit.fNextLoadedUnit:=
AnUnitInfo.NextLoadedUnit; AnUnitInfo.fNextLoadedUnit;
AnUnitInfo.NextLoadedUnit:=nil; AnUnitInfo.fNextLoadedUnit:=nil;
AnUnitInfo.PrevLoadedUnit:=nil; AnUnitInfo.fPrevLoadedUnit:=nil;
end; end;
procedure TProject.AddToAutoRevertLockedList(AnUnitInfo: TUnitInfo); procedure TProject.AddToAutoRevertLockedList(AnUnitInfo: TUnitInfo);
begin begin
// add to list if AnUnitInfo is not in list // add to list if AnUnitInfo is not in list
if (fFirstAutoRevertLockedUnit<>AnUnitInfo) if (fFirstAutoRevertLockedUnit<>AnUnitInfo)
and (AnUnitInfo.NextAutoRevertLockedUnit=nil) and (AnUnitInfo.fNextAutoRevertLockedUnit=nil)
and (AnUnitInfo.PrevAutoRevertLockedUnit=nil) then begin and (AnUnitInfo.fPrevAutoRevertLockedUnit=nil) then begin
AnUnitInfo.NextAutoRevertLockedUnit:=fFirstAutoRevertLockedUnit; AnUnitInfo.fNextAutoRevertLockedUnit:=fFirstAutoRevertLockedUnit;
AnUnitInfo.PrevAutoRevertLockedUnit:=nil; AnUnitInfo.fPrevAutoRevertLockedUnit:=nil;
fFirstAutoRevertLockedUnit:=AnUnitInfo; fFirstAutoRevertLockedUnit:=AnUnitInfo;
if AnUnitInfo.NextAutoRevertLockedUnit<>nil then if AnUnitInfo.fNextAutoRevertLockedUnit<>nil then
AnUnitInfo.NextAutoRevertLockedUnit.PrevAutoRevertLockedUnit:=AnUnitInfo; AnUnitInfo.fNextAutoRevertLockedUnit.fPrevAutoRevertLockedUnit:=AnUnitInfo;
end; end;
end; end;
@ -1883,15 +1898,15 @@ procedure TProject.RemoveFromAutoRevertLockedList(AnUnitInfo: TUnitInfo);
begin begin
// remove from list if AnUnitInfo is in list // remove from list if AnUnitInfo is in list
if fFirstAutoRevertLockedUnit=AnUnitInfo then if fFirstAutoRevertLockedUnit=AnUnitInfo then
fFirstAutoRevertLockedUnit:=AnUnitInfo.NextAutoRevertLockedUnit; fFirstAutoRevertLockedUnit:=AnUnitInfo.fNextAutoRevertLockedUnit;
if AnUnitInfo.NextAutoRevertLockedUnit<>nil then if AnUnitInfo.fNextAutoRevertLockedUnit<>nil then
AnUnitInfo.NextAutoRevertLockedUnit.PrevAutoRevertLockedUnit:= AnUnitInfo.fNextAutoRevertLockedUnit.fPrevAutoRevertLockedUnit:=
AnUnitInfo.PrevAutoRevertLockedUnit; AnUnitInfo.fPrevAutoRevertLockedUnit;
if AnUnitInfo.PrevAutoRevertLockedUnit<>nil then if AnUnitInfo.fPrevAutoRevertLockedUnit<>nil then
AnUnitInfo.PrevAutoRevertLockedUnit.NextAutoRevertLockedUnit:= AnUnitInfo.fPrevAutoRevertLockedUnit.fNextAutoRevertLockedUnit:=
AnUnitInfo.NextAutoRevertLockedUnit; AnUnitInfo.fNextAutoRevertLockedUnit;
AnUnitInfo.NextAutoRevertLockedUnit:=nil; AnUnitInfo.fNextAutoRevertLockedUnit:=nil;
AnUnitInfo.PrevAutoRevertLockedUnit:=nil; AnUnitInfo.fPrevAutoRevertLockedUnit:=nil;
end; end;
@ -1901,6 +1916,9 @@ end.
{ {
$Log$ $Log$
Revision 1.74 2002/09/05 19:03:36 lazarus
MG: improved handling of ambigious source files
Revision 1.73 2002/08/23 07:05:15 lazarus Revision 1.73 2002/08/23 07:05:15 lazarus
MG: started form renaming MG: started form renaming