mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-30 21:10:36 +02:00
IDE: quick-fix-msg: unit1(): fatal: can not find unit2 used by unit3
git-svn-id: trunk@17565 -
This commit is contained in:
parent
6e2e2c1ff2
commit
e159a63692
@ -11213,8 +11213,9 @@ end;
|
|||||||
|
|
||||||
function TMainIDE.FindUnitFile(const AFilename: string): string;
|
function TMainIDE.FindUnitFile(const AFilename: string): string;
|
||||||
var
|
var
|
||||||
SearchPath, ProjectDir: string;
|
ProjectDir: string;
|
||||||
AnUnitInfo: TUnitInfo;
|
AnUnitInfo: TUnitInfo;
|
||||||
|
AnUnitName: String;
|
||||||
begin
|
begin
|
||||||
if FilenameIsAbsolute(AFilename) then begin
|
if FilenameIsAbsolute(AFilename) then begin
|
||||||
Result:=AFilename;
|
Result:=AFilename;
|
||||||
@ -11229,11 +11230,11 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
// search in search path
|
// search in search path
|
||||||
|
AnUnitName:=ExtractFileNameOnly(AFilename);
|
||||||
if not Project1.IsVirtual then begin
|
if not Project1.IsVirtual then begin
|
||||||
// ToDo: use the CodeTools way to find the pascal source
|
// use the CodeTools way to find the pascal source
|
||||||
ProjectDir:=Project1.ProjectDirectory;
|
ProjectDir:=Project1.ProjectDirectory;
|
||||||
SearchPath:=CodeToolBoss.GetCompleteSrcPathForDirectory(ProjectDir);
|
Result:=CodeToolBoss.DirectoryCachePool.FindUnitInDirectory(ProjectDir,AnUnitName,true);
|
||||||
Result:=SearchFileInPath(AFilename,ProjectDir,SearchPath,';',[]);
|
|
||||||
if Result<>'' then exit;
|
if Result<>'' then exit;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -190,6 +190,8 @@ var
|
|||||||
MissingUnitname: String;
|
MissingUnitname: String;
|
||||||
NamePos, InPos: Integer;
|
NamePos, InPos: Integer;
|
||||||
Line, Col: Integer;
|
Line, Col: Integer;
|
||||||
|
UsedByUnit: String;
|
||||||
|
NewFilename: String;
|
||||||
begin
|
begin
|
||||||
if Step<>imqfoImproveMessage then exit;
|
if Step<>imqfoImproveMessage then exit;
|
||||||
//DebugLn('QuickFixUnitNotFoundPosition ');
|
//DebugLn('QuickFixUnitNotFoundPosition ');
|
||||||
@ -200,18 +202,38 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
MissingUnitname:=REVar(1);
|
MissingUnitname:=REVar(1);
|
||||||
|
if REMatches(Msg.Msg,'Can''t find unit ([a-z_0-9]+) used by ([a-z_0-9]+)','I') then begin
|
||||||
|
UsedByUnit:=REVar(2);
|
||||||
|
if SysUtils.CompareText(UsedByUnit,ExtractFileNameOnly(CodeBuf.Filename))<>0 then
|
||||||
|
begin
|
||||||
|
// the message belongs to another unit
|
||||||
|
NewFilename:=LazarusIDE.FindUnitFile(UsedByUnit);
|
||||||
|
if NewFilename='' then begin
|
||||||
|
DebugLn('QuickFixUnitNotFoundPosition unit not found: ',UsedByUnit);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
CodeBuf:=CodeToolBoss.LoadFile(NewFilename,false,false);
|
||||||
|
if CodeBuf=nil then begin
|
||||||
|
DebugLn('QuickFixUnitNotFoundPosition unable to load unit: ',NewFilename);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
LazarusIDE.SaveSourceEditorChangesToCodeCache(-1);
|
LazarusIDE.SaveSourceEditorChangesToCodeCache(-1);
|
||||||
if not CodeToolBoss.FindUnitInAllUsesSections(CodeBuf,MissingUnitname,
|
if not CodeToolBoss.FindUnitInAllUsesSections(CodeBuf,MissingUnitname,
|
||||||
NamePos,InPos)
|
NamePos,InPos)
|
||||||
then begin
|
then begin
|
||||||
DebugLn('QuickFixUnitNotFoundPosition failed due to syntax errors');
|
DebugLn('QuickFixUnitNotFoundPosition failed due to syntax errors or '+MissingUnitname+' is not used in '+CodeBuf.Filename);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
if InPos=0 then ;
|
if InPos=0 then ;
|
||||||
CodeBuf.AbsoluteToLineCol(NamePos,Line,Col);
|
CodeBuf.AbsoluteToLineCol(NamePos,Line,Col);
|
||||||
if (Line>0) and (Col>0) then begin
|
if (Line>0) and (Col>0) then begin
|
||||||
//DebugLn('QuickFixUnitNotFoundPosition Line=',dbgs(Line),' Col=',dbgs(Col));
|
//DebugLn('QuickFixUnitNotFoundPosition Line=',dbgs(Line),' Col=',dbgs(Col));
|
||||||
Msg.SetSourcePosition('',Line,Col);
|
NewFilename:=CodeBuf.Filename;
|
||||||
|
if (Msg.Directory<>'') and (FilenameIsAbsolute(Msg.Directory)) then
|
||||||
|
NewFilename:=CreateRelativePath(NewFilename,Msg.Directory);
|
||||||
|
Msg.SetSourcePosition(NewFilename,Line,Col);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user