mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-21 09:59:32 +02:00
IDE: started fallback define templates
git-svn-id: trunk@26281 -
This commit is contained in:
parent
2bd8a3a414
commit
4abd567ce9
@ -437,6 +437,7 @@ type
|
||||
procedure Add(ADefineTemplate: TDefineTemplate);
|
||||
procedure AddChild(ParentTemplate, NewDefineTemplate: TDefineTemplate);
|
||||
procedure AddFirst(ADefineTemplate: TDefineTemplate);
|
||||
procedure MoveToLast(ADefineTemplate: TDefineTemplate);
|
||||
procedure Assign(SrcDefineTree: TDefineTree);
|
||||
procedure AssignNonAutoCreated(SrcDefineTree: TDefineTree);
|
||||
procedure Clear;
|
||||
@ -3781,6 +3782,14 @@ begin
|
||||
ClearCache;
|
||||
end;
|
||||
|
||||
procedure TDefineTree.MoveToLast(ADefineTemplate: TDefineTemplate);
|
||||
begin
|
||||
if (ADefineTemplate.Next=nil) and (ADefineTemplate.Parent=nil) then exit;
|
||||
ADefineTemplate.Unbind;
|
||||
if FFirstDefineTemplate=ADefineTemplate then FFirstDefineTemplate:=nil;
|
||||
Add(ADefineTemplate);
|
||||
end;
|
||||
|
||||
function TDefineTree.FindDefineTemplateByName(
|
||||
const AName: string; OnlyRoots: boolean): TDefineTemplate;
|
||||
begin
|
||||
|
@ -29,15 +29,18 @@
|
||||
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="2">
|
||||
<RequiredPackages Count="3">
|
||||
<Item1>
|
||||
<PackageName Value="CodeTools"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="AnchorDocking"/>
|
||||
<MinVersion Valid="True"/>
|
||||
<DefaultFilename Value="../anchordocking.lpk"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item3>
|
||||
</RequiredPackages>
|
||||
<Units Count="3">
|
||||
<Unit0>
|
||||
|
@ -7,7 +7,8 @@ interface
|
||||
uses
|
||||
Classes, SysUtils, LCLProc, FileUtil, Forms, Controls, Graphics, Dialogs,
|
||||
Menus, ExtCtrls, Buttons, ComCtrls, SimpleFrm,
|
||||
AnchorDocking, AnchorDockStorage, XMLPropStorage, AnchorDockOptionsDlg;
|
||||
AnchorDocking, AnchorDockStorage, XMLPropStorage, AnchorDockOptionsDlg,
|
||||
DefineTemplates;
|
||||
|
||||
type
|
||||
|
||||
|
@ -39,9 +39,23 @@ uses
|
||||
DefineTemplates, CompilerOptions, TransferMacros, LinkScanner,
|
||||
LazarusIDEStrConsts;
|
||||
|
||||
|
||||
// global
|
||||
function FindRootTemplate(AName: string): TDefineTemplate;
|
||||
procedure SetAdditionalGlobalSrcPathToCodeToolBoss(const SrcPath: string);
|
||||
|
||||
// global defaults
|
||||
function FindNotUsedDirectoryTemplate: TDefineTemplate;
|
||||
function CreateNotUsedDirectoryTemplate: TDefineTemplate;
|
||||
function FindFallBackTemplate: TDefineTemplate;
|
||||
function CreateFallBackTemplate: TDefineTemplate;
|
||||
|
||||
// FPC sources
|
||||
function CreateFPCSourceTemplate(const FPCSrcDir, UnitSearchPath, PPUExt,
|
||||
DefaultTargetOS, DefaultProcessorName: string;
|
||||
UnitLinkListValid: boolean; var UnitLinkList: string;
|
||||
Owner: TObject): TDefineTemplate;
|
||||
|
||||
// projects
|
||||
function FindProjectsTemplate: TDefineTemplate;
|
||||
function FindProjectTemplateWithID(const ProjectID: string): TDefineTemplate;
|
||||
@ -65,6 +79,9 @@ function RemoveAutoGeneratedDefine(ParentTemplate: TDefineTemplate;
|
||||
|
||||
|
||||
const
|
||||
NotUsedDirectoryFlagTemplName = 'DirectoryNotUsed';
|
||||
FallBackTemplName = 'FallBack';
|
||||
|
||||
ProjectDefTemplName = 'Current Project';
|
||||
ProjectDirDefTemplName = 'Current Project Directory';
|
||||
ProjectsDefTemplName = 'Projects';
|
||||
@ -89,11 +106,7 @@ implementation
|
||||
|
||||
function FindPackagesTemplate: TDefineTemplate;
|
||||
begin
|
||||
if (CodeToolBoss<>nil) then
|
||||
Result:=CodeToolBoss.DefineTree.FindDefineTemplateByName(
|
||||
PackagesDefTemplName,true)
|
||||
else
|
||||
Result:=nil;
|
||||
Result:=FindRootTemplate(PackagesDefTemplName);
|
||||
end;
|
||||
|
||||
function FindPackageTemplateWithID(const PkgID: string): TDefineTemplate;
|
||||
@ -107,13 +120,20 @@ begin
|
||||
Result:=PkgTempl.FindChildByName(PkgID);
|
||||
end;
|
||||
|
||||
function CreateFPCSourceTemplate(const FPCSrcDir, UnitSearchPath, PPUExt,
|
||||
DefaultTargetOS, DefaultProcessorName: string; UnitLinkListValid: boolean;
|
||||
var UnitLinkList: string; Owner: TObject): TDefineTemplate;
|
||||
begin
|
||||
Result:=CodeToolBoss.DefinePool.CreateFPCSrcTemplate(FPCSrcDir,
|
||||
UnitSearchPath, PPUExt,
|
||||
DefaultTargetOS, DefaultProcessorName,
|
||||
UnitLinkListValid, UnitLinkList, Owner);
|
||||
|
||||
end;
|
||||
|
||||
function FindProjectsTemplate: TDefineTemplate;
|
||||
begin
|
||||
if (CodeToolBoss<>nil) then
|
||||
Result:=CodeToolBoss.DefineTree.FindDefineTemplateByName(
|
||||
ProjectsDefTemplName,true)
|
||||
else
|
||||
Result:=nil;
|
||||
Result:=FindRootTemplate(ProjectsDefTemplName);
|
||||
end;
|
||||
|
||||
function FindProjectTemplateWithID(const ProjectID: string): TDefineTemplate;
|
||||
@ -136,6 +156,8 @@ begin
|
||||
Result.Flags:=[dtfAutoGenerated];
|
||||
// insert behind all
|
||||
CodeToolBoss.DefineTree.ReplaceRootSameName(Result);
|
||||
// make sure the fallback comes last
|
||||
CreateFallBackTemplate;
|
||||
end;
|
||||
|
||||
function CreateProjectTemplateWithID(const ProjectID: string): TDefineTemplate;
|
||||
@ -159,6 +181,8 @@ begin
|
||||
Result.Flags:=[dtfAutoGenerated];
|
||||
// insert behind all
|
||||
CodeToolBoss.DefineTree.ReplaceRootSameName(Result);
|
||||
// make sure the fallback comes last
|
||||
CreateFallBackTemplate;
|
||||
end;
|
||||
|
||||
function CreatePackageTemplateWithID(const PkgID: string): TDefineTemplate;
|
||||
@ -382,6 +406,14 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function FindRootTemplate(AName: string): TDefineTemplate;
|
||||
begin
|
||||
if (CodeToolBoss<>nil) then
|
||||
Result:=CodeToolBoss.DefineTree.FindDefineTemplateByName(AName,true)
|
||||
else
|
||||
Result:=nil;
|
||||
end;
|
||||
|
||||
procedure SetAdditionalGlobalSrcPathToCodeToolBoss(const SrcPath: string);
|
||||
var DefTempl: TDefineTemplate;
|
||||
begin
|
||||
@ -398,6 +430,43 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function FindNotUsedDirectoryTemplate: TDefineTemplate;
|
||||
begin
|
||||
Result:=FindRootTemplate(NotUsedDirectoryFlagTemplName);
|
||||
end;
|
||||
|
||||
function CreateNotUsedDirectoryTemplate: TDefineTemplate;
|
||||
begin
|
||||
Result:=FindNotUsedDirectoryTemplate;
|
||||
if Result<>nil then exit;
|
||||
Result:=TDefineTemplate.Create(NotUsedDirectoryFlagTemplName, 'Not used directory flag',
|
||||
'', '', da_DefineRecurse);
|
||||
Result.Flags:=[dtfAutoGenerated];
|
||||
// insert in front of all
|
||||
CodeToolBoss.DefineTree.ReplaceRootSameNameAddFirst(Result);
|
||||
end;
|
||||
|
||||
function FindFallBackTemplate: TDefineTemplate;
|
||||
begin
|
||||
Result:=FindRootTemplate(FallBackTemplName);
|
||||
end;
|
||||
|
||||
function CreateFallBackTemplate: TDefineTemplate;
|
||||
begin
|
||||
Result:=FindFallBackTemplate;
|
||||
if Result<>nil then begin
|
||||
// make sure it is at the end
|
||||
if Result.Next<>nil then
|
||||
CodeToolBoss.DefineTree.MoveToLast(Result);
|
||||
exit;
|
||||
end;
|
||||
Result:=TDefineTemplate.Create(FallBackTemplName, 'Definitions for all other directories',
|
||||
'', '', da_Block);
|
||||
Result.Flags:=[dtfAutoGenerated];
|
||||
// insert behind all
|
||||
CodeToolBoss.DefineTree.ReplaceRootSameName(Result);
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
|
||||
|
17
ide/main.pp
17
ide/main.pp
@ -102,10 +102,7 @@ uses
|
||||
SourceEditProcs, MsgQuickFixes, ViewUnit_dlg, FPDocEditWindow,
|
||||
// converter
|
||||
ChgEncodingDlg, ConvertDelphi, MissingPropertiesDlg, LazXMLForms,
|
||||
// rest of the ide
|
||||
Splash, IDEDefs, LazarusIDEStrConsts, LazConf, MsgView, SearchResultView,
|
||||
CodeTemplatesDlg, CodeBrowser, FindUnitDlg, IdeOptionsDlg,
|
||||
// environment options
|
||||
// environment option frames
|
||||
editor_general_options, formed_options, OI_options,
|
||||
files_options, desktop_options, window_options,
|
||||
Backup_Options, naming_options, fpdoc_options,
|
||||
@ -123,16 +120,19 @@ uses
|
||||
codeexplorer_update_options, codeexplorer_categories_options,
|
||||
codeobserver_options,
|
||||
help_general_options,
|
||||
// project options
|
||||
// project option frames
|
||||
project_application_options, project_forms_options, project_lazdoc_options,
|
||||
project_save_options, project_versioninfo_options, project_i18n_options,
|
||||
project_misc_options,
|
||||
// project compiler options
|
||||
// project compiler option frames
|
||||
compiler_path_options, compiler_parsing_options, compiler_codegen_options,
|
||||
compiler_linking_options, compiler_verbosity_options, compiler_messages_options,
|
||||
compiler_other_options, compiler_inherited_options, compiler_compilation_options,
|
||||
BuildModesEditor,
|
||||
|
||||
// rest of the ide
|
||||
Splash, IDEDefs, LazarusIDEStrConsts, LazConf, MsgView, SearchResultView,
|
||||
CodeTemplatesDlg, CodeBrowser, FindUnitDlg, IdeOptionsDlg, EditDefineTree,
|
||||
PublishModule, EnvironmentOpts, TransferMacros, KeyMapping, IDETranslations,
|
||||
IDEProcs, ExtToolDialog, ExtToolEditDlg, OutputFilter, JumpHistoryView,
|
||||
BuildLazDialog, MiscOptions, InputHistory, UnitDependencies, ClipBoardHistory,
|
||||
@ -13365,6 +13365,9 @@ begin
|
||||
MainBuildBoss.GetFPCCompilerParamsForEnvironmentTest(
|
||||
MainBuildBoss.CurDefinesCompilerOptions);
|
||||
//DebugLn('TMainIDE.InitCodeToolBoss CurDefinesCompilerOptions="',CurDefinesCompilerOptions,'"');
|
||||
CreateNotUsedDirectoryTemplate;
|
||||
CreateFallBackTemplate;
|
||||
|
||||
ADefTempl:=CreateFPCTemplate(MainBuildBoss.CurDefinesCompilerFilename,
|
||||
MainBuildBoss.CurDefinesCompilerOptions,
|
||||
CreateCompilerTestPascalFilename,CompilerUnitSearchPath,
|
||||
@ -13383,7 +13386,7 @@ begin
|
||||
CompilerUnitLinks:=InputHistories.FPCConfigCache.GetUnitLinks('');
|
||||
UnitLinksChanged:=InputHistories.LastFPCUnitLinksNeedsUpdate('',
|
||||
CompilerUnitSearchPath,EnvironmentOptions.GetFPCSourceDirectory);
|
||||
ADefTempl:=CreateFPCSrcTemplate(
|
||||
ADefTempl:=CreateFPCSourceTemplate(
|
||||
CodeToolBoss.GlobalValues.Variables[ExternalMacroStart+'FPCSrcDir'],
|
||||
CompilerUnitSearchPath,
|
||||
CodeToolBoss.GetCompiledSrcExtForDirectory(''),
|
||||
|
Loading…
Reference in New Issue
Block a user