mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-01 21:40:25 +02:00
IDE: mode matrix: hint for macro syntax error
git-svn-id: trunk@41317 -
This commit is contained in:
parent
52766063ca
commit
e64b63d9a5
@ -19,13 +19,13 @@
|
|||||||
***************************************************************************
|
***************************************************************************
|
||||||
|
|
||||||
ToDo:
|
ToDo:
|
||||||
- show ide macro errors in hint
|
|
||||||
- mark target errors red
|
- mark target errors red
|
||||||
- show target errors in hint
|
- show target errors in hint
|
||||||
- ide macro
|
- ide macro
|
||||||
- load old build macro values into matrix
|
- load old build macro values into matrix
|
||||||
- save matrix options for old build macro values
|
- save matrix options for old build macro values
|
||||||
- wiki
|
- wiki
|
||||||
|
- undo: combine changes while editing a cell
|
||||||
- remove old frame
|
- remove old frame
|
||||||
- remove old macro value classes
|
- remove old macro value classes
|
||||||
- resourcestring for value types?
|
- resourcestring for value types?
|
||||||
@ -127,6 +127,9 @@ type
|
|||||||
property LazProject: TProject read FProject;
|
property LazProject: TProject read FProject;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
EMMMacroSyntaxException = class(Exception)
|
||||||
|
end;
|
||||||
|
|
||||||
// assign
|
// assign
|
||||||
function IsEqual(Options: TBuildMatrixOptions; StorageGroup: TGroupedMatrixGroup): boolean;
|
function IsEqual(Options: TBuildMatrixOptions; StorageGroup: TGroupedMatrixGroup): boolean;
|
||||||
procedure AssignBuildMatrixOptionsToGroup(Options: TBuildMatrixOptions;
|
procedure AssignBuildMatrixOptionsToGroup(Options: TBuildMatrixOptions;
|
||||||
@ -134,9 +137,10 @@ procedure AssignBuildMatrixOptionsToGroup(Options: TBuildMatrixOptions;
|
|||||||
procedure AssignBuildMatrixGroupToOptions(StorageGroup: TGroupedMatrixGroup;
|
procedure AssignBuildMatrixGroupToOptions(StorageGroup: TGroupedMatrixGroup;
|
||||||
Options: TBuildMatrixOptions; InvalidateCompOpts: boolean);
|
Options: TBuildMatrixOptions; InvalidateCompOpts: boolean);
|
||||||
|
|
||||||
// target
|
// targets, see BuildMatrixTargetFits
|
||||||
function TargetsPrefix: string;
|
function TargetsPrefix: string;
|
||||||
function AddMatrixTarget(Matrix: TGroupedMatrix; StorageGroup: TGroupedMatrixGroup): TGroupedMatrixGroup;
|
function AddMatrixTarget(Matrix: TGroupedMatrix; StorageGroup: TGroupedMatrixGroup): TGroupedMatrixGroup;
|
||||||
|
function BuildMatrixTargetsAsHint(const Targets: String): String;
|
||||||
|
|
||||||
// type
|
// type
|
||||||
function BuildMatrixOptionTypeCaption(Typ: TBuildMatrixOptionType): string;
|
function BuildMatrixOptionTypeCaption(Typ: TBuildMatrixOptionType): string;
|
||||||
@ -311,12 +315,80 @@ begin
|
|||||||
Result.Writable:=true;
|
Result.Writable:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function BuildMatrixTargetsAsHint(const Targets: String): String;
|
||||||
|
var
|
||||||
|
ExcludeProject: Boolean;
|
||||||
|
IncludeProject: Boolean;
|
||||||
|
All: Boolean;
|
||||||
|
Includes: String;
|
||||||
|
Excludes: String;
|
||||||
|
Target: String;
|
||||||
|
StartP: Integer;
|
||||||
|
p: Integer;
|
||||||
|
begin
|
||||||
|
Result:=CheckBuildMatrixTargetsSyntax(Targets);
|
||||||
|
if Result<>'' then begin
|
||||||
|
Result:='Warning: '+Result;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
p:=1;
|
||||||
|
Excludes:='';
|
||||||
|
Includes:='';
|
||||||
|
All:=false;
|
||||||
|
IncludeProject:=false;
|
||||||
|
ExcludeProject:=false;
|
||||||
|
while (p<=length(Targets)) do begin
|
||||||
|
StartP:=p;
|
||||||
|
while (p<=length(Targets)) and (Targets[p]<>',') do inc(p);
|
||||||
|
Target:=copy(Targets,StartP,p-StartP);
|
||||||
|
if Target<>'' then begin
|
||||||
|
if Target[1]='-' then begin
|
||||||
|
system.Delete(Target,1,1);
|
||||||
|
if Target<>'' then begin
|
||||||
|
if Target=BuildMatrixProjectName then
|
||||||
|
ExcludeProject:=true
|
||||||
|
else begin
|
||||||
|
if Excludes<>'' then Excludes+=',';
|
||||||
|
Excludes+=Target;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end else begin
|
||||||
|
if Target='*' then
|
||||||
|
All:=true
|
||||||
|
else if Target=BuildMatrixProjectName then
|
||||||
|
IncludeProject:=true
|
||||||
|
else begin
|
||||||
|
if Includes<>'' then Includes+=',';
|
||||||
|
Includes+=Target;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
inc(p);
|
||||||
|
end;
|
||||||
|
if ExcludeProject then
|
||||||
|
IncludeProject:=false;
|
||||||
|
if All then begin
|
||||||
|
if ExcludeProject then
|
||||||
|
Result+=lisMMApplyToAllPackages+LineEnding
|
||||||
|
else
|
||||||
|
Result+=lisMMApplyToAllPackagesAndProjects+LineEnding;
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
if IncludeProject then
|
||||||
|
Result+=lisMMApplyToProject+LineEnding;
|
||||||
|
if Includes<>'' then
|
||||||
|
Result+=Format(lisMMApplyToAllPackagesMatching, [Includes])+LineEnding;
|
||||||
|
end;
|
||||||
|
if Excludes<>'' then
|
||||||
|
Result+=Format(lisMMExcludeAllPackagesMatching, [Excludes])+LineEnding;
|
||||||
|
end;
|
||||||
|
|
||||||
function SplitMatrixMacro(MacroAssignment: string; out MacroName,
|
function SplitMatrixMacro(MacroAssignment: string; out MacroName,
|
||||||
MacroValue: string; ExceptionOnError: boolean): boolean;
|
MacroValue: string; ExceptionOnError: boolean): boolean;
|
||||||
|
|
||||||
procedure E(Msg: string);
|
procedure E(Msg: string);
|
||||||
begin
|
begin
|
||||||
raise Exception.Create(Msg);
|
raise EMMMacroSyntaxException.Create(Msg);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -342,17 +414,12 @@ begin
|
|||||||
inc(p);
|
inc(p);
|
||||||
until not IsIdentChar[p^];
|
until not IsIdentChar[p^];
|
||||||
MacroName:=copy(MacroAssignment,1,p-StartP);
|
MacroName:=copy(MacroAssignment,1,p-StartP);
|
||||||
if p^<>':' then begin
|
if (p^<>':') or (p[1]<>'=') then begin
|
||||||
if ExceptionOnError then
|
if ExceptionOnError then
|
||||||
E(Format(lisMMExpectedButFound, [dbgstr(p^)]));
|
E(Format(lisMMExpectedAfterMacroNameButFound, [dbgstr(p^)]));
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
inc(p);
|
|
||||||
if p^<>'=' then begin
|
|
||||||
if ExceptionOnError then
|
|
||||||
E(Format(lisMMExpectedButFound2, [dbgstr(p^)]));
|
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
inc(p,2);
|
||||||
repeat
|
repeat
|
||||||
if (p^=#0) and (p-PChar(MacroAssignment)=length(MacroAssignment)) then break;
|
if (p^=#0) and (p-PChar(MacroAssignment)=length(MacroAssignment)) then break;
|
||||||
if p^ in [#0..#31,#127] then begin
|
if p^ in [#0..#31,#127] then begin
|
||||||
@ -407,16 +474,11 @@ var
|
|||||||
aRow: Longint;
|
aRow: Longint;
|
||||||
MatRow: TGroupedMatrixRow;
|
MatRow: TGroupedMatrixRow;
|
||||||
h: String;
|
h: String;
|
||||||
p: Integer;
|
|
||||||
GroupRow: TGroupedMatrixGroup;
|
GroupRow: TGroupedMatrixGroup;
|
||||||
Targets: String;
|
Targets: String;
|
||||||
StartP: Integer;
|
ValueRow: TGroupedMatrixValue;
|
||||||
Target: String;
|
MacroName: string;
|
||||||
Excludes: String;
|
MacroValue: string;
|
||||||
Includes: String;
|
|
||||||
All: Boolean;
|
|
||||||
IncludeProject: Boolean;
|
|
||||||
ExcludeProject: Boolean;
|
|
||||||
begin
|
begin
|
||||||
aCol:=0;
|
aCol:=0;
|
||||||
aRow:=0;
|
aRow:=0;
|
||||||
@ -429,56 +491,19 @@ begin
|
|||||||
if GroupRow.Group<>nil then begin
|
if GroupRow.Group<>nil then begin
|
||||||
// a target group
|
// a target group
|
||||||
Targets:=GroupRow.Value;
|
Targets:=GroupRow.Value;
|
||||||
p:=1;
|
h:=BuildMatrixTargetsAsHint(Targets);
|
||||||
Excludes:='';
|
end;
|
||||||
Includes:='';
|
end else if MatRow is TGroupedMatrixValue then begin
|
||||||
All:=false;
|
ValueRow:=TGroupedMatrixValue(MatRow);
|
||||||
IncludeProject:=false;
|
if ValueRow.Typ=BuildMatrixOptionTypeCaption(bmotIDEMacro) then begin
|
||||||
ExcludeProject:=false;
|
h:='';
|
||||||
while (p<=length(Targets)) do begin
|
try
|
||||||
StartP:=p;
|
SplitMatrixMacro(ValueRow.Value,MacroName,MacroValue,true);
|
||||||
while (p<=length(Targets)) and (Targets[p]<>',') do inc(p);
|
except
|
||||||
Target:=copy(Targets,StartP,p-StartP);
|
on E: EMMMacroSyntaxException do begin
|
||||||
if Target<>'' then begin
|
h:='Error: '+E.Message;
|
||||||
if Target[1]='-' then begin
|
|
||||||
system.Delete(Target,1,1);
|
|
||||||
if Target<>'' then begin
|
|
||||||
if Target=BuildMatrixProjectName then
|
|
||||||
ExcludeProject:=true
|
|
||||||
else begin
|
|
||||||
if Excludes<>'' then Excludes+=',';
|
|
||||||
Excludes+=Target;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end else begin
|
|
||||||
if Target='*' then
|
|
||||||
All:=true
|
|
||||||
else if Target=BuildMatrixProjectName then
|
|
||||||
IncludeProject:=true
|
|
||||||
else begin
|
|
||||||
if Includes<>'' then Includes+=',';
|
|
||||||
Includes+=Target;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
inc(p);
|
|
||||||
end;
|
|
||||||
if ExcludeProject then
|
|
||||||
IncludeProject:=false;
|
|
||||||
if All then begin
|
|
||||||
if ExcludeProject then
|
|
||||||
h+=lisMMApplyToAllPackages+LineEnding
|
|
||||||
else
|
|
||||||
h+=lisMMApplyToAllPackagesAndProjects+LineEnding;
|
|
||||||
end
|
|
||||||
else begin
|
|
||||||
if IncludeProject then
|
|
||||||
h+=lisMMApplyToProject+LineEnding;
|
|
||||||
if Includes<>'' then
|
|
||||||
h+=Format(lisMMApplyToAllPackagesMatching, [Includes])+LineEnding;
|
|
||||||
end;
|
|
||||||
if Excludes<>'' then
|
|
||||||
h+=Format(lisMMExcludeAllPackagesMatching, [Excludes])+LineEnding;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
HintInfo^.HintStr:=h;
|
HintInfo^.HintStr:=h;
|
||||||
|
@ -5683,15 +5683,15 @@ resourcestring
|
|||||||
lisMMSetAnIDEMacroEGLCLWidgetTypeWin32 = 'Set an IDE macro, e.g.: '
|
lisMMSetAnIDEMacroEGLCLWidgetTypeWin32 = 'Set an IDE macro, e.g.: '
|
||||||
+'LCLWidgetType:=win32';
|
+'LCLWidgetType:=win32';
|
||||||
lisMMMissingMacroName = 'missing macro name';
|
lisMMMissingMacroName = 'missing macro name';
|
||||||
lisMMExpectedMacroNameButFound = 'expected macro name, but found %s';
|
lisMMExpectedMacroNameButFound = 'expected macro name, but found "%s"';
|
||||||
lisMMExpectedButFound = 'expected :, but found %s';
|
lisMMInvalidCharacterInMacroValue = 'invalid character in macro value "%s"';
|
||||||
lisMMExpectedButFound2 = 'expected =, but found %s';
|
lisMMExpectedAfterMacroNameButFound = 'expected ":=" after macro name, but '
|
||||||
lisMMInvalidCharacterInMacroValue = 'invalid character in macro value %s';
|
+'found "%s"';
|
||||||
lisMMApplyToAllPackages = 'Apply to all packages.';
|
lisMMApplyToAllPackages = 'Apply to all packages.';
|
||||||
lisMMApplyToAllPackagesAndProjects = 'Apply to all packages and projects.';
|
lisMMApplyToAllPackagesAndProjects = 'Apply to all packages and projects.';
|
||||||
lisMMApplyToProject = 'Apply to project.';
|
lisMMApplyToProject = 'Apply to project.';
|
||||||
lisMMApplyToAllPackagesMatching = 'Apply to all packages matching %s';
|
lisMMApplyToAllPackagesMatching = 'Apply to all packages matching name "%s"';
|
||||||
lisMMExcludeAllPackagesMatching = 'Exclude all packages matching %s';
|
lisMMExcludeAllPackagesMatching = 'Exclude all packages matching name "%s"';
|
||||||
lisMMStoredInIDEEnvironmentoptionsXml = 'Stored in IDE (environmentoptions.'
|
lisMMStoredInIDEEnvironmentoptionsXml = 'Stored in IDE (environmentoptions.'
|
||||||
+'xml)';
|
+'xml)';
|
||||||
lisMMStoredInProjectLpi = 'Stored in project (.lpi)';
|
lisMMStoredInProjectLpi = 'Stored in project (.lpi)';
|
||||||
|
@ -139,6 +139,7 @@ type
|
|||||||
|
|
||||||
function BuildMatrixTargetFits(Target, Targets: string): boolean;
|
function BuildMatrixTargetFits(Target, Targets: string): boolean;
|
||||||
function BuildMatrixTargetFitsPattern(Target, Pattern: PChar): boolean;
|
function BuildMatrixTargetFitsPattern(Target, Pattern: PChar): boolean;
|
||||||
|
function CheckBuildMatrixTargetsSyntax(const Targets: String): String;
|
||||||
function BuildMatrixModeFits(Mode, ModesSeparatedByLineBreaks: string): boolean;
|
function BuildMatrixModeFits(Mode, ModesSeparatedByLineBreaks: string): boolean;
|
||||||
function Str2BuildMatrixOptionType(const s: string): TBuildMatrixOptionType;
|
function Str2BuildMatrixOptionType(const s: string): TBuildMatrixOptionType;
|
||||||
|
|
||||||
@ -240,6 +241,38 @@ begin
|
|||||||
until false;
|
until false;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function CheckBuildMatrixTargetsSyntax(const Targets: String): String;
|
||||||
|
var
|
||||||
|
p: PChar;
|
||||||
|
|
||||||
|
procedure WarnInvalidChar;
|
||||||
|
begin
|
||||||
|
Result:='invalid character "'+dbgstr(p^)+'" at '+IntToStr(p-PChar(Targets)+1);
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:='';
|
||||||
|
if Targets='' then exit;
|
||||||
|
p:=PChar(Targets);
|
||||||
|
repeat
|
||||||
|
case p^ of
|
||||||
|
#0:
|
||||||
|
if p-PChar(Targets)=length(Targets) then
|
||||||
|
break
|
||||||
|
else begin
|
||||||
|
WarnInvalidChar;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
#1..#32,#127:
|
||||||
|
begin
|
||||||
|
WarnInvalidChar;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
inc(p);
|
||||||
|
until false;
|
||||||
|
end;
|
||||||
|
|
||||||
function BuildMatrixModeFits(Mode, ModesSeparatedByLineBreaks: string): boolean;
|
function BuildMatrixModeFits(Mode, ModesSeparatedByLineBreaks: string): boolean;
|
||||||
var
|
var
|
||||||
p: PChar;
|
p: PChar;
|
||||||
|
Loading…
Reference in New Issue
Block a user