IDE, main: Clean up. Inverted "if NOT ... then ... else .." blocks

git-svn-id: trunk@33436 -
This commit is contained in:
martin 2011-11-09 15:13:44 +00:00
parent 1eb940ef83
commit 3a74265653

View File

@ -9344,19 +9344,7 @@ begin
end; end;
// check if the project knows this file // check if the project knows this file
if (not (ofRevert in Flags)) then begin if (ofRevert in Flags) then begin
UnitIndex:=Project1.IndexOfFilename(AFilename);
UnknownFile := (UnitIndex < 0);
if not UnknownFile then begin
NewUnitInfo:=Project1.Units[UnitIndex];
if AEditorInfo <> nil then
NewEditorInfo := AEditorInfo
else if (ofProjectLoading in Flags) then
NewEditorInfo := NewUnitInfo.GetClosedOrNewEditorInfo
else
NewEditorInfo := NewUnitInfo.EditorInfo[0];
end;
end else begin
// revert // revert
UnknownFile := False; UnknownFile := False;
NewEditorInfo := Project1.EditorInfoWithEditorComponent( NewEditorInfo := Project1.EditorInfoWithEditorComponent(
@ -9373,6 +9361,18 @@ begin
Result:=mrCancel; Result:=mrCancel;
exit; exit;
end; end;
end else begin
UnitIndex:=Project1.IndexOfFilename(AFilename);
UnknownFile := (UnitIndex < 0);
if not UnknownFile then begin
NewUnitInfo:=Project1.Units[UnitIndex];
if AEditorInfo <> nil then
NewEditorInfo := AEditorInfo
else if (ofProjectLoading in Flags) then
NewEditorInfo := NewUnitInfo.GetClosedOrNewEditorInfo
else
NewEditorInfo := NewUnitInfo.EditorInfo[0];
end;
end; end;
if (ofAddToProject in Flags) and (not NewUnitInfo.IsPartOfProject) then if (ofAddToProject in Flags) and (not NewUnitInfo.IsPartOfProject) then
@ -9420,7 +9420,20 @@ begin
end; end;
// load the source // load the source
if not UnknownFile then begin if UnknownFile then begin
// open unknown file // Never happens if ofRevert
Handled:=false;
Result:=DoOpenUnknownFile(AFilename,Flags,NewUnitInfo,Handled);
if (Result<>mrOk) or Handled then exit;
// the file was previously unknown, use the default EditorInfo
if AEditorInfo <> nil then
NewEditorInfo := AEditorInfo
else
if NewUnitInfo <> nil then
NewEditorInfo := NewUnitInfo.GetClosedOrNewEditorInfo
else
NewEditorInfo := nil;
end else begin
// project knows this file => all the meta data is known // project knows this file => all the meta data is known
// -> just load the source // -> just load the source
NewUnitInfo:=Project1.Units[UnitIndex]; NewUnitInfo:=Project1.Units[UnitIndex];
@ -9441,20 +9454,6 @@ begin
if FilenameIsPascalUnit(NewUnitInfo.Filename) then if FilenameIsPascalUnit(NewUnitInfo.Filename) then
NewUnitInfo.ReadUnitNameFromSource(false); NewUnitInfo.ReadUnitNameFromSource(false);
NewUnitInfo.Modified:=NewUnitInfo.Source.FileOnDiskNeedsUpdate; NewUnitInfo.Modified:=NewUnitInfo.Source.FileOnDiskNeedsUpdate;
end else begin
// open unknown file
// Never happens if ofRevert
Handled:=false;
Result:=DoOpenUnknownFile(AFilename,Flags,NewUnitInfo,Handled);
if (Result<>mrOk) or Handled then exit;
// the file was previously unknown, use the default EditorInfo
if AEditorInfo <> nil then
NewEditorInfo := AEditorInfo
else
if NewUnitInfo <> nil then
NewEditorInfo := NewUnitInfo.GetClosedOrNewEditorInfo
else
NewEditorInfo := nil;
end; end;
// check readonly // check readonly