mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-10-01 07:09:18 +02:00
MG: fixed project codetool variable
git-svn-id: trunk@535 -
This commit is contained in:
parent
746f33a85e
commit
9a99f03e56
@ -1071,8 +1071,11 @@ begin
|
|||||||
Result:=nil;
|
Result:=nil;
|
||||||
if Code=nil then exit;
|
if Code=nil then exit;
|
||||||
//DefineTree.WriteDebugReport;
|
//DefineTree.WriteDebugReport;
|
||||||
Result:=DefineTree.GetDefinesForDirectory(
|
if not TCodeBuffer(Code).IsVirtual then
|
||||||
ExtractFilePath(TCodeBuffer(Code).Filename));
|
Result:=DefineTree.GetDefinesForDirectory(
|
||||||
|
ExtractFilePath(TCodeBuffer(Code).Filename))
|
||||||
|
else
|
||||||
|
Result:=DefineTree.GetDefinesForVirtualDirectory;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCodeToolManager.OnDefineTreeReadValue(Sender: TObject;
|
procedure TCodeToolManager.OnDefineTreeReadValue(Sender: TObject;
|
||||||
|
@ -69,7 +69,10 @@ const
|
|||||||
StdDefTemplFPCSrc = 'Free Pascal Sources';
|
StdDefTemplFPCSrc = 'Free Pascal Sources';
|
||||||
StdDefTemplLazarusSources = 'Lazarus Sources';
|
StdDefTemplLazarusSources = 'Lazarus Sources';
|
||||||
StdDefTemplLCLProject = 'LCL Project';
|
StdDefTemplLCLProject = 'LCL Project';
|
||||||
|
|
||||||
|
// virtual directory
|
||||||
|
VirtualDirectory='VIRTUALDIRECTORY';
|
||||||
|
|
||||||
// FPC operating systems and processor types
|
// FPC operating systems and processor types
|
||||||
FPCOperatingSystemNames: array[1..11] of shortstring =(
|
FPCOperatingSystemNames: array[1..11] of shortstring =(
|
||||||
'linux', 'freebsd', 'win32', 'go32v1', 'go32v2', 'beos', 'os2', 'amiga',
|
'linux', 'freebsd', 'win32', 'go32v1', 'go32v2', 'beos', 'os2', 'amiga',
|
||||||
@ -144,6 +147,7 @@ type
|
|||||||
private
|
private
|
||||||
FFirstDefineTemplate: TDefineTemplate;
|
FFirstDefineTemplate: TDefineTemplate;
|
||||||
FCache: TAVLTree; // tree of TDirectoryDefines
|
FCache: TAVLTree; // tree of TDirectoryDefines
|
||||||
|
FVirtualDirCache: TDirectoryDefines;
|
||||||
FOnReadValue: TOnReadValue;
|
FOnReadValue: TOnReadValue;
|
||||||
FErrorTemplate: TDefineTemplate;
|
FErrorTemplate: TDefineTemplate;
|
||||||
FErrorDescription: string;
|
FErrorDescription: string;
|
||||||
@ -151,6 +155,7 @@ type
|
|||||||
function Calculate(DirDef: TDirectoryDefines): boolean;
|
function Calculate(DirDef: TDirectoryDefines): boolean;
|
||||||
public
|
public
|
||||||
function GetDefinesForDirectory(const Path: string): TExpressionEvaluator;
|
function GetDefinesForDirectory(const Path: string): TExpressionEvaluator;
|
||||||
|
function GetDefinesForVirtualDirectory: TExpressionEvaluator;
|
||||||
property RootTemplate: TDefineTemplate
|
property RootTemplate: TDefineTemplate
|
||||||
read FFirstDefineTemplate write FFirstDefineTemplate;
|
read FFirstDefineTemplate write FFirstDefineTemplate;
|
||||||
procedure Add(ADefineTemplate: TDefineTemplate);
|
procedure Add(ADefineTemplate: TDefineTemplate);
|
||||||
@ -649,6 +654,8 @@ end;
|
|||||||
procedure TDefineTree.ClearCache;
|
procedure TDefineTree.ClearCache;
|
||||||
begin
|
begin
|
||||||
FCache.FreeAndClear;
|
FCache.FreeAndClear;
|
||||||
|
FVirtualDirCache.Free;
|
||||||
|
FVirtualDirCache:=nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TDefineTree.Create;
|
constructor TDefineTree.Create;
|
||||||
@ -712,6 +719,25 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TDefineTree.GetDefinesForVirtualDirectory: TExpressionEvaluator;
|
||||||
|
begin
|
||||||
|
if FVirtualDirCache<>nil then
|
||||||
|
Result:=FVirtualDirCache.Values
|
||||||
|
else begin
|
||||||
|
writeln('################');
|
||||||
|
FVirtualDirCache:=TDirectoryDefines.Create;
|
||||||
|
FVirtualDirCache.Path:=VirtualDirectory;
|
||||||
|
if Calculate(FVirtualDirCache) then begin
|
||||||
|
Result:=FVirtualDirCache.Values;
|
||||||
|
writeln(Result.AsString);
|
||||||
|
end else begin
|
||||||
|
FVirtualDirCache.Free;
|
||||||
|
FVirtualDirCache:=nil;
|
||||||
|
Result:=nil;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TDefineTree.Calculate(DirDef: TDirectoryDefines): boolean;
|
function TDefineTree.Calculate(DirDef: TDirectoryDefines): boolean;
|
||||||
// calculates the values for a single directory
|
// calculates the values for a single directory
|
||||||
// returns false on error
|
// returns false on error
|
||||||
@ -915,7 +941,10 @@ begin
|
|||||||
//writeln('[TDefineTree.Calculate] "',DirDef.Path,'"');
|
//writeln('[TDefineTree.Calculate] "',DirDef.Path,'"');
|
||||||
Result:=true;
|
Result:=true;
|
||||||
FErrorTemplate:=nil;
|
FErrorTemplate:=nil;
|
||||||
ExpandedDirectory:=ReadValue(DirDef.Path);
|
if DirDef.Path<>VirtualDirectory then
|
||||||
|
ExpandedDirectory:=ReadValue(DirDef.Path)
|
||||||
|
else
|
||||||
|
ExpandedDirectory:=DirDef.Path;
|
||||||
DirDef.Values.Clear;
|
DirDef.Values.Clear;
|
||||||
// compute the result of all matching DefineTemplates
|
// compute the result of all matching DefineTemplates
|
||||||
CalculateTemplate(FFirstDefineTemplate,'');
|
CalculateTemplate(FFirstDefineTemplate,'');
|
||||||
|
@ -192,14 +192,21 @@ writeln('TFindDeclarationTool.FindUnitSource.LoadFile ',ExpandedFilename);
|
|||||||
|
|
||||||
function SearchUnitFileInPath(const APath, TheUnitName: string): TCodeBuffer;
|
function SearchUnitFileInPath(const APath, TheUnitName: string): TCodeBuffer;
|
||||||
var PathStart, PathEnd: integer;
|
var PathStart, PathEnd: integer;
|
||||||
|
ADir: string;
|
||||||
begin
|
begin
|
||||||
|
writeln('--------------------------------------');
|
||||||
|
writeln(APath,' ',TheUnitName);
|
||||||
|
writeln('--------------------------------------');
|
||||||
PathStart:=1;
|
PathStart:=1;
|
||||||
while PathStart<=length(APath) do begin
|
while PathStart<=length(APath) do begin
|
||||||
PathEnd:=PathStart;
|
PathEnd:=PathStart;
|
||||||
while (PathEnd<=length(APath)) and (APath[PathEnd]<>';') do inc(PathEnd);
|
while (PathEnd<=length(APath)) and (APath[PathEnd]<>';') do inc(PathEnd);
|
||||||
if PathEnd>PathStart then begin
|
if PathEnd>PathStart then begin
|
||||||
Result:=SearchUnitFileInDir(copy(APath,PathStart,PathEnd-PathStart),
|
ADir:=copy(APath,PathStart,PathEnd-PathStart);
|
||||||
TheUnitName);
|
if (ADir<>'') and (ADir[length(ADir)]<>OSDirSeparator) then
|
||||||
|
ADir:=ADir+OSDirSeparator;
|
||||||
|
writeln('B ',ADir);
|
||||||
|
Result:=SearchUnitFileInDir(ADir,TheUnitName);
|
||||||
if Result<>nil then exit;
|
if Result<>nil then exit;
|
||||||
end;
|
end;
|
||||||
PathStart:=PathEnd+1;
|
PathStart:=PathEnd+1;
|
||||||
|
13
ide/main.pp
13
ide/main.pp
@ -3192,7 +3192,7 @@ writeln('TMainIDE.DoNewProject A');
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
CodeToolBoss.GlobalValues.Variables[ExternalMacroStart+'ProjectDir']:=
|
CodeToolBoss.GlobalValues.Variables[ExternalMacroStart+'ProjectDir']:=
|
||||||
'(unknown Project Directory)';
|
VirtualDirectory;
|
||||||
|
|
||||||
Project:=TProject.Create(NewProjectType);
|
Project:=TProject.Create(NewProjectType);
|
||||||
Project.OnFileBackup:=@DoBackupFile;
|
Project.OnFileBackup:=@DoBackupFile;
|
||||||
@ -3358,6 +3358,9 @@ writeln('AnUnitInfo.Filename=',AnUnitInfo.Filename);
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
Project.ProjectFile:=NewFilename;
|
Project.ProjectFile:=NewFilename;
|
||||||
|
CodeToolBoss.GlobalValues.Variables[ExternalMacroStart+'ProjectDir']:=
|
||||||
|
ExtractFilePath(Project.ProjectFile);
|
||||||
|
CodeToolBoss.DefineTree.ClearCache;
|
||||||
EnvironmentOptions.AddToRecentProjectFiles(NewFilename);
|
EnvironmentOptions.AddToRecentProjectFiles(NewFilename);
|
||||||
if (MainUnitInfo<>nil) then begin
|
if (MainUnitInfo<>nil) then begin
|
||||||
// switch MainUnitInfo to new code
|
// switch MainUnitInfo to new code
|
||||||
@ -3514,6 +3517,9 @@ CheckHeap(IntToStr(GetMem_Cnt));
|
|||||||
LPIFilename:=ChangeFileExt(AFilename,'.lpi');
|
LPIFilename:=ChangeFileExt(AFilename,'.lpi');
|
||||||
Project:=TProject.Create(ptProgram);
|
Project:=TProject.Create(ptProgram);
|
||||||
Project.ReadProject(LPIFilename);
|
Project.ReadProject(LPIFilename);
|
||||||
|
CodeToolBoss.GlobalValues.Variables[ExternalMacroStart+'ProjectDir']:=
|
||||||
|
ExtractFilePath(Project.ProjectFile);
|
||||||
|
CodeToolBoss.DefineTree.ClearCache;
|
||||||
writeln('TMainIDE.DoOpenProjectFile B2');
|
writeln('TMainIDE.DoOpenProjectFile B2');
|
||||||
if Project.MainUnit>=0 then begin
|
if Project.MainUnit>=0 then begin
|
||||||
// read MainUnit Source
|
// read MainUnit Source
|
||||||
@ -4831,7 +4837,7 @@ begin
|
|||||||
Variables[ExternalMacroStart+'FPCSrcDir']:=
|
Variables[ExternalMacroStart+'FPCSrcDir']:=
|
||||||
EnvironmentOptions.FPCSourceDirectory;
|
EnvironmentOptions.FPCSourceDirectory;
|
||||||
Variables[ExternalMacroStart+'LCLWidgetType']:='gtk';
|
Variables[ExternalMacroStart+'LCLWidgetType']:='gtk';
|
||||||
Variables[ExternalMacroStart+'ProjectDir']:='';
|
Variables[ExternalMacroStart+'ProjectDir']:=VirtualDirectory;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// build DefinePool and Define Tree
|
// build DefinePool and Define Tree
|
||||||
@ -5375,6 +5381,9 @@ end.
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.184 2001/12/16 12:55:57 lazarus
|
||||||
|
MG: fixed project codetool variable
|
||||||
|
|
||||||
Revision 1.183 2001/12/16 11:20:26 lazarus
|
Revision 1.183 2001/12/16 11:20:26 lazarus
|
||||||
MG: find declaration for uses sections
|
MG: find declaration for uses sections
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user