IDE: fpc msg parser: improve cant find unit when an indirectly used unit has no ppu in project and package

git-svn-id: trunk@47656 -
This commit is contained in:
mattias 2015-02-09 16:38:53 +00:00
parent 7feade1dc9
commit d868b219ae
3 changed files with 22 additions and 8 deletions

View File

@ -2188,14 +2188,18 @@ end;
function TMessageLine.GetToolData: TIDEExternalToolData;
var
View: TExtToolView;
Tool: TAbstractExternalTool;
begin
Result:=nil;
if Lines=nil then exit;
View:=TExtToolView(Lines.Owner);
if not (View is TExtToolView) then exit;
if View.Tool=nil then exit;
Result:=TIDEExternalToolData(View.Tool.Data);
if Lines.Owner is TAbstractExternalTool then
Tool:=TAbstractExternalTool(Lines.Owner)
else if Lines.Owner is TExtToolView then begin
Tool:=TExtToolView(Lines.Owner).Tool;
if Tool=nil then exit;
end else
exit;
Result:=TIDEExternalToolData(Tool.Data);
if not (Result is TIDEExternalToolData) then
Result:=nil;
end;

View File

@ -1796,6 +1796,7 @@ var
i: Integer;
DepOwner: TObject;
PkgFile: TLazPackageFile;
TheOwner: TObject;
begin
if MsgLine.Urgency<mluError then exit;
if not IsMsgID(MsgLine,FPCMsgIDCantFindUnitUsedBy,fMsgItemCantFindUnitUsedBy)
@ -1811,6 +1812,8 @@ begin
etpspAfterSync: exit;
end;
// in main thread
if not GetFPCMsgValues(MsgLine,MissingUnitName,UsedByUnit) then
exit;
MsgLine.Attribute[FPCMsgAttrMissingUnit]:=MissingUnitName;
@ -1844,7 +1847,12 @@ begin
ExtractFilePath(Filename),UsedByUnit,true);
end;
if NewFilename='' then begin
NewFilename:=LazarusIDE.FindUnitFile(UsedByUnit);
if Tool.Data is TIDEExternalToolData then
TheOwner:=ExternalToolList.GetIDEObject(TIDEExternalToolData(Tool.Data))
else if Tool.Data=nil then begin
debugln(['TIDEFPCParser.ImproveMsgUnitNotFound Tool.Data=nil, ProcDir=',Tool.Process.CurrentDirectory]);
end;
NewFilename:=LazarusIDE.FindUnitFile(UsedByUnit,TheOwner);
if NewFilename='' then begin
{$IFDEF VerboseFPCMsgUnitNotFound}
debugln(['TIDEFPCParser.ImproveMsgUnitNotFound unit not found: ',UsedByUnit]);

View File

@ -187,6 +187,7 @@ var
UsedByUnit: string;
CodeBuf: TCodeBuffer;
Dlg: TFindUnitDialog;
StartFilename: String;
begin
// get unitname
if not IsApplicable(Msg,MissingUnit,UsedByUnit) then exit;
@ -202,9 +203,10 @@ begin
exit;
end;
CodeBuf:=CodeToolBoss.LoadFile(Msg.GetFullFilename,true,false);
StartFilename:=Msg.GetFullFilename;
CodeBuf:=CodeToolBoss.LoadFile(StartFilename,true,false);
if CodeBuf=nil then begin
debugln(['TQuickFixUnitNotFound_Search.QuickFix can not open file "',Msg.GetFullFilename,'"']);
debugln(['TQuickFixUnitNotFound_Search.QuickFix cannot open file "',StartFilename,'", Msg="',Msg.Line,'"']);
exit;
end;