IDE: check for unit forms implies using interfaces

git-svn-id: trunk@36480 -
This commit is contained in:
mattias 2012-03-31 12:30:57 +00:00
parent d9645f4278
commit 69f2bc9bd7
3 changed files with 55 additions and 49 deletions

View File

@ -2090,8 +2090,8 @@ resourcestring
lisTheContainsANotExistingDirectory = 'The %s contains a not existing ' lisTheContainsANotExistingDirectory = 'The %s contains a not existing '
+'directory:%s%s'; +'directory:%s%s';
lisTheProjectDoesNotUseTheLCLUnitInterfacesButItSeems = 'The project does ' lisTheProjectDoesNotUseTheLCLUnitInterfacesButItSeems = 'The project does '
+'not use the LCL unit interfaces, but it seems it needs it.%sYou will ' +'not use the LCL unit interfaces, which is required by LCLBase.%sYou will '
+'get strange linker errors if you use the LCL forms without interfaces.'; +'get strange linker errors if you use the LCL without interfaces.';
lisAddUnitInterfaces = 'Add unit interfaces'; lisAddUnitInterfaces = 'Add unit interfaces';
lisCCODatesDiffer = 'The dates of the .ppu files of FPC' lisCCODatesDiffer = 'The dates of the .ppu files of FPC'
+' differ more than one hour.%s' +' differ more than one hour.%s'

View File

@ -11797,10 +11797,10 @@ begin
MainUnitInfo:=Project1.MainUnitInfo; MainUnitInfo:=Project1.MainUnitInfo;
if (MainUnitInfo=nil) or (MainUnitInfo.Source=nil) then exit; if (MainUnitInfo=nil) or (MainUnitInfo.Source=nil) then exit;
if PackageGraph.FindDependencyRecursively(Project1.FirstRequiredDependency, if PackageGraph.FindDependencyRecursively(Project1.FirstRequiredDependency,
PackageGraph.LCLPackage)=nil PackageGraph.LCLBasePackage)=nil
then then
exit; // project does not use LCL exit; // project does not use LCLBase
// project uses LCL // project uses LCLBase
MainUsesSection:=nil; MainUsesSection:=nil;
ImplementationUsesSection:=nil; ImplementationUsesSection:=nil;
try try

View File

@ -323,6 +323,55 @@ procedure TQuickFixUnitNotFoundPosition.Execute(const Msg: TIDEMessageLine;
end; end;
end; end;
procedure CheckUnitUsedByIDE(MissingUnitname: string;
var PPUFilename, PkgName: string);
var
i, j: Integer;
Pkg: TIDEPackage;
PkgFile: TLazPackageFile;
DirCache: TCTDirectoryCache;
UnitOutDir: String;
begin
// search ppu in installed packages
if PPUFilename='' then begin
for i:=0 to PackageEditingInterface.GetPackageCount-1 do begin
Pkg:=PackageEditingInterface.GetPackages(i);
if Pkg.AutoInstall=pitNope then continue;
UnitOutDir:=Pkg.LazCompilerOptions.GetUnitOutputDirectory(false);
//debugln(['TQuickFixUnitNotFoundPosition.Execute ',Pkg.Name,' UnitOutDir=',UnitOutDir]);
if FilenameIsAbsolute(UnitOutDir) then begin
DirCache:=CodeToolBoss.DirectoryCachePool.GetCache(UnitOutDir,true,false);
PPUFilename:=DirCache.FindFile(MissingUnitname+'.ppu',ctsfcLoUpCase);
//debugln(['TQuickFixUnitNotFoundPosition.Execute ShortPPU=',PPUFilename]);
if PPUFilename<>'' then begin
PkgName:=Pkg.Name;
PPUFilename:=AppendPathDelim(DirCache.Directory)+PPUFilename;
break;
end;
end;
end;
end;
if PkgName='' then begin
// search unit in installed packages
for i:=0 to PackageEditingInterface.GetPackageCount-1 do begin
Pkg:=PackageEditingInterface.GetPackages(i);
if Pkg.AutoInstall=pitNope then continue;
if CompareTextCT(Pkg.Name,MissingUnitname)=0 then begin
PkgName:=Pkg.Name;
break;
end;
for j:=0 to Pkg.FileCount-1 do begin
PkgFile:=Pkg.Files[j];
if not FilenameIsPascalUnit(PkgFile.Filename) then continue;
if CompareTextCT(ExtractFileNameOnly(PkgFile.Filename),MissingUnitname)<>0
then continue;
PkgName:=Pkg.Name;
break;
end;
end;
end;
end;
var var
CodeBuf: TCodeBuffer; CodeBuf: TCodeBuffer;
MissingUnitname: String; MissingUnitname: String;
@ -331,16 +380,10 @@ var
Dir: String; Dir: String;
PPUFilename: String; PPUFilename: String;
s: String; s: String;
i: Integer;
Pkg: TIDEPackage;
UnitOutDir: String;
Filename: string; Filename: string;
Line: integer; Line: integer;
Col: integer; Col: integer;
DirCache: TCTDirectoryCache;
PkgName: String; PkgName: String;
PkgFile: TLazPackageFile;
j: Integer;
begin begin
if Step<>imqfoImproveMessage then exit; if Step<>imqfoImproveMessage then exit;
//DebugLn('QuickFixUnitNotFoundPosition '); //DebugLn('QuickFixUnitNotFoundPosition ');
@ -413,44 +456,7 @@ begin
//debugln(['TQuickFixUnitNotFoundPosition.Execute AAA1 PPUFilename=',PPUFilename,' IsFileInIDESrcDir=',IsFileInIDESrcDir(Dir+'test')]); //debugln(['TQuickFixUnitNotFoundPosition.Execute AAA1 PPUFilename=',PPUFilename,' IsFileInIDESrcDir=',IsFileInIDESrcDir(Dir+'test')]);
PkgName:=''; PkgName:='';
if IsFileInIDESrcDir(Dir+'test') then begin if IsFileInIDESrcDir(Dir+'test') then begin
// search ppu in installed packages CheckUnitUsedByIDE(MissingUnitname,PPUFilename,PkgName);
if PPUFilename='' then begin
for i:=0 to PackageEditingInterface.GetPackageCount-1 do begin
Pkg:=PackageEditingInterface.GetPackages(i);
if Pkg.AutoInstall=pitNope then continue;
UnitOutDir:=Pkg.LazCompilerOptions.GetUnitOutputDirectory(false);
//debugln(['TQuickFixUnitNotFoundPosition.Execute ',Pkg.Name,' UnitOutDir=',UnitOutDir]);
if FilenameIsAbsolute(UnitOutDir) then begin
DirCache:=CodeToolBoss.DirectoryCachePool.GetCache(UnitOutDir,true,false);
PPUFilename:=DirCache.FindFile(MissingUnitname+'.ppu',ctsfcLoUpCase);
//debugln(['TQuickFixUnitNotFoundPosition.Execute ShortPPU=',PPUFilename]);
if PPUFilename<>'' then begin
PkgName:=Pkg.Name;
PPUFilename:=AppendPathDelim(DirCache.Directory)+PPUFilename;
break;
end;
end;
end;
end;
if PkgName='' then begin
// search unit in installed packages
for i:=0 to PackageEditingInterface.GetPackageCount-1 do begin
Pkg:=PackageEditingInterface.GetPackages(i);
if Pkg.AutoInstall=pitNope then continue;
if CompareTextCT(Pkg.Name,MissingUnitname)=0 then begin
PkgName:=Pkg.Name;
break;
end;
for j:=0 to Pkg.FileCount-1 do begin
PkgFile:=Pkg.Files[j];
if not FilenameIsPascalUnit(PkgFile.Filename) then continue;
if CompareTextCT(ExtractFileNameOnly(PkgFile.Filename),MissingUnitname)<>0
then continue;
PkgName:=Pkg.Name;
break;
end;
end;
end;
end; end;
if PPUFilename<>'' then begin if PPUFilename<>'' then begin