mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-27 09:37:25 +01:00
MG: improved handling of ambigious source files
git-svn-id: trunk@2758 -
This commit is contained in:
parent
0562becea2
commit
f2d117e8f3
@ -100,7 +100,7 @@ begin
|
|||||||
if AProject.IsVirtual then
|
if AProject.IsVirtual then
|
||||||
ProjectFilename:=DefaultFilename
|
ProjectFilename:=DefaultFilename
|
||||||
else
|
else
|
||||||
ProjectFilename:=AProject.Units[AProject.MainUnit].Filename;
|
ProjectFilename:=AProject.MainUnitInfo.Filename;
|
||||||
if ProjectFilename='' then exit;
|
if ProjectFilename='' then exit;
|
||||||
ProjectDir:=ExtractFilePath(ProjectFilename);
|
ProjectDir:=ExtractFilePath(ProjectFilename);
|
||||||
if not SetCurrentDir(ProjectDir) then exit;
|
if not SetCurrentDir(ProjectDir) then exit;
|
||||||
@ -189,6 +189,9 @@ end.
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.33 2002/09/05 19:03:34 lazarus
|
||||||
|
MG: improved handling of ambigious source files
|
||||||
|
|
||||||
Revision 1.32 2002/07/05 12:34:08 lazarus
|
Revision 1.32 2002/07/05 12:34:08 lazarus
|
||||||
MG: assembler errors are now shown in output
|
MG: assembler errors are now shown in output
|
||||||
|
|
||||||
|
|||||||
96
ide/main.pp
96
ide/main.pp
@ -253,8 +253,6 @@ type
|
|||||||
FOpenEditorsOnCodeToolChange: boolean;
|
FOpenEditorsOnCodeToolChange: boolean;
|
||||||
|
|
||||||
FRunProcess: TProcess; // temp solution, will be replaced by dummydebugger
|
FRunProcess: TProcess; // temp solution, will be replaced by dummydebugger
|
||||||
TheCompiler: TCompiler;
|
|
||||||
TheOutputFilter: TOutputFilter;
|
|
||||||
|
|
||||||
CustomExtToolMenuSeparator: TMenuItem;
|
CustomExtToolMenuSeparator: TMenuItem;
|
||||||
|
|
||||||
@ -311,7 +309,6 @@ type
|
|||||||
var ResourceCode: TCodeBuffer): TModalResult;
|
var ResourceCode: TCodeBuffer): TModalResult;
|
||||||
function DoSaveFileResources(AnUnitInfo: TUnitInfo;
|
function DoSaveFileResources(AnUnitInfo: TUnitInfo;
|
||||||
ResourceCode, LFMCode: TCodeBuffer; Flags: TSaveFlags): TModalResult;
|
ResourceCode, LFMCode: TCodeBuffer; Flags: TSaveFlags): TModalResult;
|
||||||
function DoDeleteAmbigiousSources(const AFilename: string): TModalResult;
|
|
||||||
|
|
||||||
// methods for 'open unit' and 'open main unit'
|
// methods for 'open unit' and 'open main unit'
|
||||||
function DoOpenNotExistingFile(const AFileName:string;
|
function DoOpenNotExistingFile(const AFileName:string;
|
||||||
@ -363,6 +360,7 @@ type
|
|||||||
function DoOpenProjectFile(AFileName:string):TModalResult;
|
function DoOpenProjectFile(AFileName:string):TModalResult;
|
||||||
function DoAddActiveUnitToProject: TModalResult;
|
function DoAddActiveUnitToProject: TModalResult;
|
||||||
function DoRemoveFromProjectDialog: TModalResult;
|
function DoRemoveFromProjectDialog: TModalResult;
|
||||||
|
procedure DoWarnAmbigiousFiles;
|
||||||
function DoBuildProject(BuildAll: boolean): TModalResult;
|
function DoBuildProject(BuildAll: boolean): TModalResult;
|
||||||
function DoInitProjectRun: TModalResult; override;
|
function DoInitProjectRun: TModalResult; override;
|
||||||
function DoRunProject: TModalResult;
|
function DoRunProject: TModalResult;
|
||||||
@ -444,6 +442,7 @@ type
|
|||||||
function GetProjectTargetFilename: string;
|
function GetProjectTargetFilename: string;
|
||||||
function GetTestProjectFilename: string;
|
function GetTestProjectFilename: string;
|
||||||
function GetTestUnitFilename(AnUnitInfo: TUnitInfo): string; override;
|
function GetTestUnitFilename(AnUnitInfo: TUnitInfo): string; override;
|
||||||
|
function GetTargetUnitFilename(AnUnitInfo: TUnitInfo): string;
|
||||||
function IsTestUnitFilename(const AFilename: string): boolean; override;
|
function IsTestUnitFilename(const AFilename: string): boolean; override;
|
||||||
function GetRunCommandLine: string; override;
|
function GetRunCommandLine: string; override;
|
||||||
procedure OnMacroSubstitution(TheMacro: TTransferMacro; var s:string;
|
procedure OnMacroSubstitution(TheMacro: TTransferMacro; var s:string;
|
||||||
@ -1492,13 +1491,14 @@ end;
|
|||||||
procedure TMainIDE.mnuSaveClicked(Sender : TObject);
|
procedure TMainIDE.mnuSaveClicked(Sender : TObject);
|
||||||
begin
|
begin
|
||||||
if SourceNoteBook.NoteBook=nil then exit;
|
if SourceNoteBook.NoteBook=nil then exit;
|
||||||
DoSaveEditorFile(SourceNoteBook.NoteBook.PageIndex,[]);
|
DoSaveEditorFile(SourceNoteBook.NoteBook.PageIndex,[sfCheckAmbigiousFiles]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMainIDE.mnuSaveAsClicked(Sender : TObject);
|
procedure TMainIDE.mnuSaveAsClicked(Sender : TObject);
|
||||||
begin
|
begin
|
||||||
if SourceNoteBook.NoteBook=nil then exit;
|
if SourceNoteBook.NoteBook=nil then exit;
|
||||||
DoSaveEditorFile(SourceNoteBook.NoteBook.PageIndex,[sfSaveAs]);
|
DoSaveEditorFile(SourceNoteBook.NoteBook.PageIndex,
|
||||||
|
[sfSaveAs,sfCheckAmbigiousFiles]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMainIDE.mnuSaveAllClicked(Sender : TObject);
|
procedure TMainIDE.mnuSaveAllClicked(Sender : TObject);
|
||||||
@ -2801,40 +2801,6 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{-------------------------------------------------------------------------------
|
|
||||||
function TMainIDE.DoDeleteAmbigiousSources(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 TMainIDE.DoDeleteAmbigiousSources(const AFilename: string
|
|
||||||
): TModalResult;
|
|
||||||
|
|
||||||
function DeleteFileIfExists(const DelFilename: string): boolean;
|
|
||||||
begin
|
|
||||||
if FileExists(DelFilename) then
|
|
||||||
Result:=DeleteFile(DelFilename)
|
|
||||||
else
|
|
||||||
Result:=true;
|
|
||||||
end;
|
|
||||||
|
|
||||||
var
|
|
||||||
Ext, LowExt: string;
|
|
||||||
begin
|
|
||||||
Result:=mrOk;
|
|
||||||
if not EnvironmentOptions.AutoDeleteAmbigiousSources then exit;
|
|
||||||
if FilenameIsPascalUnit(AFilename) then begin
|
|
||||||
Ext:=ExtractFileExt(AFilename);
|
|
||||||
LowExt:=lowercase(Ext);
|
|
||||||
if LowExt='.pp' then
|
|
||||||
DeleteFileIfExists(ChangeFileExt(AFilename,'.pas'))
|
|
||||||
else if LowExt='.pas' then
|
|
||||||
DeleteFileIfExists(ChangeFileExt(AFilename,'.pp'));
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TMainIDE.DoOpenNotExistingFile(const AFileName: string;
|
function TMainIDE.DoOpenNotExistingFile(const AFileName: string;
|
||||||
Flags: TOpenFlags): TModalResult;
|
Flags: TOpenFlags): TModalResult;
|
||||||
begin
|
begin
|
||||||
@ -3541,7 +3507,8 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
DoDeleteAmbigiousSources(DestFilename);
|
if sfCheckAmbigiousFiles in Flags then
|
||||||
|
DoCheckAmbigiousSources(DestFilename,false);
|
||||||
|
|
||||||
{$IFDEF IDE_DEBUG}
|
{$IFDEF IDE_DEBUG}
|
||||||
writeln('*** HasResources=',ActiveUnitInfo.HasResources);
|
writeln('*** HasResources=',ActiveUnitInfo.HasResources);
|
||||||
@ -3602,7 +3569,7 @@ begin
|
|||||||
ACaption:='Source modified';
|
ACaption:='Source modified';
|
||||||
if Messagedlg(ACaption, AText, mtConfirmation, [mbYes, mbNo], 0)=mrYes then
|
if Messagedlg(ACaption, AText, mtConfirmation, [mbYes, mbNo], 0)=mrYes then
|
||||||
begin
|
begin
|
||||||
Result:=DoSaveEditorFile(PageIndex,[]);
|
Result:=DoSaveEditorFile(PageIndex,[sfCheckAmbigiousFiles]);
|
||||||
if Result=mrAbort then exit;
|
if Result=mrAbort then exit;
|
||||||
end;
|
end;
|
||||||
Result:=mrOk;
|
Result:=mrOk;
|
||||||
@ -4555,6 +4522,21 @@ Begin
|
|||||||
Result:=mrOk;
|
Result:=mrOk;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TMainIDE.DoWarnAmbigiousFiles;
|
||||||
|
var
|
||||||
|
AnUnitInfo: TUnitInfo;
|
||||||
|
i: integer;
|
||||||
|
DestFilename: string;
|
||||||
|
begin
|
||||||
|
for i:=0 to Project1.UnitCount-1 do begin
|
||||||
|
AnUnitInfo:=Project1.Units[i];
|
||||||
|
if (AnUnitInfo.IsPartOfProject) and (not AnUnitInfo.IsVirtual) then begin
|
||||||
|
DestFilename:=GetTargetUnitFilename(AnUnitInfo);
|
||||||
|
DoCheckAmbigiousSources(DestFilename,true);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TMainIDE.DoSaveProjectToTestDirectory: TModalResult;
|
function TMainIDE.DoSaveProjectToTestDirectory: TModalResult;
|
||||||
begin
|
begin
|
||||||
Result:=mrCancel;
|
Result:=mrCancel;
|
||||||
@ -4576,7 +4558,7 @@ begin
|
|||||||
Result:=DoSaveAll([sfCheckAmbigiousFiles]);
|
Result:=DoSaveAll([sfCheckAmbigiousFiles]);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
Result:=DoSaveProject([sfSaveToTestDir]);
|
Result:=DoSaveProject([sfSaveToTestDir,sfCheckAmbigiousFiles]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TMainIDE.DoBuildProject(BuildAll: boolean): TModalResult;
|
function TMainIDE.DoBuildProject(BuildAll: boolean): TModalResult;
|
||||||
@ -4618,9 +4600,12 @@ begin
|
|||||||
// show messages
|
// show messages
|
||||||
MessagesView.Clear;
|
MessagesView.Clear;
|
||||||
DoArrangeSourceEditorAndMessageView;
|
DoArrangeSourceEditorAndMessageView;
|
||||||
|
TheOutputFilter.OnOutputString:=@MessagesView.Add;
|
||||||
|
|
||||||
|
// warn ambigious files
|
||||||
|
DoWarnAmbigiousFiles;
|
||||||
|
|
||||||
// compile
|
// compile
|
||||||
TheOutputFilter.OnOutputString:=@MessagesView.Add;
|
|
||||||
Result:=TheCompiler.Compile(Project1,BuildAll,DefaultFilename);
|
Result:=TheCompiler.Compile(Project1,BuildAll,DefaultFilename);
|
||||||
if Result=mrOk then begin
|
if Result=mrOk then begin
|
||||||
MessagesView.MessageView.Items.Add(
|
MessagesView.MessageView.Items.Add(
|
||||||
@ -5255,7 +5240,8 @@ begin
|
|||||||
if MacroName='save' then begin
|
if MacroName='save' then begin
|
||||||
Handled:=true;
|
Handled:=true;
|
||||||
if SourceNoteBook.NoteBook<>nil then
|
if SourceNoteBook.NoteBook<>nil then
|
||||||
Abort:=(DoSaveEditorFile(SourceNoteBook.NoteBook.PageIndex,[])<>mrOk);
|
Abort:=(DoSaveEditorFile(SourceNoteBook.NoteBook.PageIndex,
|
||||||
|
[sfCheckAmbigiousFiles])<>mrOk);
|
||||||
s:='';
|
s:='';
|
||||||
end else if MacroName='saveall' then begin
|
end else if MacroName='saveall' then begin
|
||||||
Handled:=true;
|
Handled:=true;
|
||||||
@ -5485,6 +5471,14 @@ begin
|
|||||||
Result:=TestDir+Result;
|
Result:=TestDir+Result;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TMainIDE.GetTargetUnitFilename(AnUnitInfo: TUnitInfo): string;
|
||||||
|
begin
|
||||||
|
if Project1.IsVirtual then
|
||||||
|
Result:=GetTestUnitFilename(AnUnitInfo)
|
||||||
|
else
|
||||||
|
Result:=AnUnitInfo.Filename;
|
||||||
|
end;
|
||||||
|
|
||||||
function TMainIDE.IsTestUnitFilename(const AFilename: string): boolean;
|
function TMainIDE.IsTestUnitFilename(const AFilename: string): boolean;
|
||||||
var
|
var
|
||||||
TestDir: string;
|
TestDir: string;
|
||||||
@ -5498,9 +5492,10 @@ end;
|
|||||||
|
|
||||||
function TMainIDE.GetRunCommandLine: string;
|
function TMainIDE.GetRunCommandLine: string;
|
||||||
begin
|
begin
|
||||||
if Project1.RunParameterOptions.UseLaunchingApplication
|
if Project1.RunParameterOptions.UseLaunchingApplication then
|
||||||
then Result := Project1.RunParameterOptions.LaunchingApplicationPathPlusParams
|
Result := Project1.RunParameterOptions.LaunchingApplicationPathPlusParams
|
||||||
else Result := '';
|
else
|
||||||
|
Result := '';
|
||||||
|
|
||||||
if Result=''
|
if Result=''
|
||||||
then begin
|
then begin
|
||||||
@ -6467,7 +6462,6 @@ end;
|
|||||||
|
|
||||||
procedure TMainIDE.OnExtToolNeedsOutputFilter(var OutputFilter: TOutputFilter;
|
procedure TMainIDE.OnExtToolNeedsOutputFilter(var OutputFilter: TOutputFilter;
|
||||||
var Abort: boolean);
|
var Abort: boolean);
|
||||||
var ActiveSrcEdit: TSourceEditor;
|
|
||||||
begin
|
begin
|
||||||
OutputFilter:=TheOutputFilter;
|
OutputFilter:=TheOutputFilter;
|
||||||
OutputFilter.Project:=Project1;
|
OutputFilter.Project:=Project1;
|
||||||
@ -6475,8 +6469,7 @@ begin
|
|||||||
Abort:=true;
|
Abort:=true;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
ActiveSrcEdit:=SourceNotebook.GetActiveSE;
|
SourceNotebook.ClearErrorLines;
|
||||||
if ActiveSrcEdit<>nil then ActiveSrcEdit.ErrorLine:=-1;
|
|
||||||
|
|
||||||
ToolStatus:=itBuilder;
|
ToolStatus:=itBuilder;
|
||||||
MessagesView.Clear;
|
MessagesView.Clear;
|
||||||
@ -6818,6 +6811,9 @@ end.
|
|||||||
|
|
||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.363 2002/09/05 19:03:34 lazarus
|
||||||
|
MG: improved handling of ambigious source files
|
||||||
|
|
||||||
Revision 1.362 2002/09/05 15:24:26 lazarus
|
Revision 1.362 2002/09/05 15:24:26 lazarus
|
||||||
MG: added auto deleting of ambigious source files
|
MG: added auto deleting of ambigious source files
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user