mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-30 00:30:25 +02:00
IDE: improve fpc message Cant find unit: search used by in directory
git-svn-id: trunk@36411 -
This commit is contained in:
parent
3cd59126ec
commit
fa2a8293d3
@ -274,6 +274,9 @@ end;
|
||||
|
||||
procedure TQuickFixUnitNotFoundPosition.Execute(const Msg: TIDEMessageLine;
|
||||
Step: TIMQuickFixStep);
|
||||
// for example:
|
||||
// Fatal: Can't find unit Unit12 used by testunit1
|
||||
// /home/user/laz/main.pp(1,1) Fatal: Can't find unit lazreport used by lazarus
|
||||
var
|
||||
CodeBuf: TCodeBuffer;
|
||||
MissingUnitname: String;
|
||||
@ -286,22 +289,33 @@ begin
|
||||
if Step<>imqfoImproveMessage then exit;
|
||||
//DebugLn('QuickFixUnitNotFoundPosition ');
|
||||
|
||||
if not REMatches(Msg.Msg,'Can''t find unit ([a-z_0-9]+)','I') then begin
|
||||
//DebugLn('QuickFixUnitNotFoundPosition invalid message ',Msg.Msg);
|
||||
if not REMatches(Msg.Msg,'Can''t find unit ([a-z_.0-9]+) used by ','I') then begin
|
||||
DebugLn('QuickFixUnitNotFoundPosition invalid message ',Msg.Msg);
|
||||
exit;
|
||||
end;
|
||||
MissingUnitname:=REVar(1);
|
||||
if REMatches(Msg.Msg,'Can''t find unit ([a-z_0-9]+) used by ([a-z_0-9]+)','I')
|
||||
if REMatches(Msg.Msg,'Can''t find unit ([a-z_.0-9]+) used by ([a-z_.0-9]+)','I')
|
||||
then begin
|
||||
UsedByUnit:=REVar(2);
|
||||
//debugln(['TQuickFixUnitNotFoundPosition.Execute Missing="',MissingUnitname,'" used by "',UsedByUnit,'"']);
|
||||
if SysUtils.CompareText(UsedByUnit,MissingUnitname)<>0 then
|
||||
begin
|
||||
// the message belongs to another unit
|
||||
NewFilename:=LazarusIDE.FindUnitFile(UsedByUnit);
|
||||
NewFilename:='';
|
||||
if FilenameIsAbsolute(Msg.Directory) then
|
||||
begin
|
||||
// For example: /path/laz/main.pp(1,1) Fatal: Can't find unit lazreport used by lazarus
|
||||
// => search source lazarus in directory
|
||||
NewFilename:=CodeToolBoss.DirectoryCachePool.FindUnitInDirectory(
|
||||
Msg.Directory,UsedByUnit,true);
|
||||
end;
|
||||
if NewFilename='' then begin
|
||||
DebugLn('QuickFixUnitNotFoundPosition unit not found: ',UsedByUnit);
|
||||
//ShowError('QuickFix: UnitNotFoundPosition unit not found: '+UsedByUnit);
|
||||
exit;
|
||||
NewFilename:=LazarusIDE.FindUnitFile(UsedByUnit);
|
||||
if NewFilename='' then begin
|
||||
DebugLn('QuickFixUnitNotFoundPosition unit not found: ',UsedByUnit);
|
||||
//ShowError('QuickFix: UnitNotFoundPosition unit not found: '+UsedByUnit);
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
CodeBuf:=CodeToolBoss.LoadFile(NewFilename,false,false);
|
||||
if CodeBuf=nil then begin
|
||||
|
@ -814,10 +814,11 @@ var i, j, FilenameEndPos: integer;
|
||||
if fLastErrorType in [etPanic,etFatal] then begin
|
||||
// fatal and panic errors are not very informative
|
||||
// -> prepend current file
|
||||
if CompStr(UnableToOpen, NewLine, 1) then
|
||||
if CompStr(UnableToOpen, NewLine, 1) then begin
|
||||
CurrentMessageParts.Values['Filename']:=
|
||||
TrimFilename(SetDirSeparators(Copy(NewLine,Length(UnableToOpen)+1,Length(NewLine))))
|
||||
else if (fCompilingHistory<>nil) and (fCompilingHistory.Count>0) then begin
|
||||
end else if (fCompilingHistory<>nil) and (fCompilingHistory.Count>0)
|
||||
then begin
|
||||
LastFile:=fCompilingHistory[fCompilingHistory.Count-1];
|
||||
if not FilenameIsAbsolute(LastFile) then
|
||||
FullFilename:=TrimFilename(fCurrentDirectory+LastFile)
|
||||
|
Loading…
Reference in New Issue
Block a user