mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-08 09:20:49 +02:00
SynEdit: PasHighLighter, fix parsing "=" after "generic foo<_A>" (without spaces, looks like ">=")
This commit is contained in:
parent
3d0e418a24
commit
9db0c4e54e
@ -1803,7 +1803,9 @@ begin
|
|||||||
if (PasCodeFoldRange.BracketNestLevel = 0)
|
if (PasCodeFoldRange.BracketNestLevel = 0)
|
||||||
and (TopPascalCodeFoldBlockType in
|
and (TopPascalCodeFoldBlockType in
|
||||||
[cfbtVarType, cfbtLocalVarType, cfbtNone, cfbtProcedure, cfbtAnonymousProcedure, cfbtProgram,
|
[cfbtVarType, cfbtLocalVarType, cfbtNone, cfbtProcedure, cfbtAnonymousProcedure, cfbtProgram,
|
||||||
cfbtUnit, cfbtUnitSection])
|
cfbtUnit, cfbtUnitSection,
|
||||||
|
cfbtClass, cfbtClassSection, cfbtRecord // if inside a type section in class/record
|
||||||
|
])
|
||||||
then begin
|
then begin
|
||||||
if (rsAfterEqualOrColon in fRange) then begin
|
if (rsAfterEqualOrColon in fRange) then begin
|
||||||
if TypeHelpers then
|
if TypeHelpers then
|
||||||
@ -3483,8 +3485,11 @@ procedure TSynPasSyn.GreaterProc;
|
|||||||
begin
|
begin
|
||||||
fTokenID := tkSymbol;
|
fTokenID := tkSymbol;
|
||||||
inc(Run);
|
inc(Run);
|
||||||
if fLine[Run] = '=' then
|
if fLine[Run] = '=' then begin
|
||||||
inc(Run);
|
inc(Run);
|
||||||
|
if (rsInTypeBlock in fRange) then // generic TFoo<..>= // no space between > and =
|
||||||
|
fRange := fRange + [rsAfterEqual, rsAfterEqualOrColon];
|
||||||
|
end;
|
||||||
if fRange * [rsProperty, rsVarTypeInSpecification] = [rsProperty] then
|
if fRange * [rsProperty, rsVarTypeInSpecification] = [rsProperty] then
|
||||||
fRange := fRange + [rsAtPropertyOrReadWrite];
|
fRange := fRange + [rsAtPropertyOrReadWrite];
|
||||||
end;
|
end;
|
||||||
|
@ -61,6 +61,7 @@ type
|
|||||||
procedure TestContextForProcedureNameAttr;
|
procedure TestContextForProcedureNameAttr;
|
||||||
procedure TestContextForInterface;
|
procedure TestContextForInterface;
|
||||||
procedure TestContextForDeprecated;
|
procedure TestContextForDeprecated;
|
||||||
|
procedure TestContextForClassObjRecHelp;
|
||||||
procedure TestContextForClassSection;
|
procedure TestContextForClassSection;
|
||||||
procedure TestContextForClassModifier; // Sealed abstract
|
procedure TestContextForClassModifier; // Sealed abstract
|
||||||
procedure TestContextForClassHelper;
|
procedure TestContextForClassHelper;
|
||||||
@ -1460,6 +1461,104 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TTestHighlighterPas.TestContextForClassObjRecHelp;
|
||||||
|
var
|
||||||
|
i0, i1, i2, i3, i4: Integer;
|
||||||
|
s0, s1, s2: String;
|
||||||
|
begin
|
||||||
|
ReCreateEdit;
|
||||||
|
EnableFolds([cfbtClass, cfbtRecord], []);
|
||||||
|
|
||||||
|
for i0 := 0 to 9 do
|
||||||
|
for i1 := 0 to 5 do
|
||||||
|
for i2 := 0 to 1 do
|
||||||
|
for i3 := 0 to 1 do
|
||||||
|
for i4 := 0 to 3 do
|
||||||
|
begin
|
||||||
|
if (i1 = 3) and (i2 = 1) then // type type helper
|
||||||
|
continue;
|
||||||
|
|
||||||
|
case i0 of
|
||||||
|
0: s0 := '';
|
||||||
|
1: s0 := 'TSome = class type';
|
||||||
|
2: s0 := 'TSome = class public type';
|
||||||
|
3: s0 := 'TSome = class var a: integer; type';
|
||||||
|
4: s0 := 'TSome = object type';
|
||||||
|
5: s0 := 'TSome = object public type';
|
||||||
|
6: s0 := 'TSome = object var a: integer; type';
|
||||||
|
7: s0 := 'TSome = record type';
|
||||||
|
8: s0 := 'TSome = record public type';
|
||||||
|
9: s0 := 'TSome = record var a: integer; type';
|
||||||
|
// TODO: nested in record-case
|
||||||
|
//10: s0 := 'TSome = record case integer of 1: ( a: record b: integer; type'; // BracketNestLevel inside record-case
|
||||||
|
end;
|
||||||
|
|
||||||
|
case i4 of
|
||||||
|
0: s1 := 'TFoo = ';
|
||||||
|
1: s1 := 'TFoo=';
|
||||||
|
2: s1 := 'generic TFoo<A> = ';
|
||||||
|
3: s1 := 'generic TFoo<A>=';
|
||||||
|
end;
|
||||||
|
|
||||||
|
case i1 of
|
||||||
|
0: s2 := 'class';
|
||||||
|
1: s2 := 'record';
|
||||||
|
2: s2 := 'object';
|
||||||
|
3: s2 := 'type helper for integer';
|
||||||
|
4: s2 := 'class helper for TFoo';
|
||||||
|
5: s2 := 'record helper for TBar';
|
||||||
|
end;
|
||||||
|
if i2 = 1 then s2 := 'type '+s2;
|
||||||
|
if i3 = 1 then s2 := ' '+s2; // leading space
|
||||||
|
|
||||||
|
SetLines
|
||||||
|
([ 'Unit A; interface {$modeswitch advancedrecords}{$modeswitch typehelpers}', // 0
|
||||||
|
'type',
|
||||||
|
s0,
|
||||||
|
'',
|
||||||
|
s1,
|
||||||
|
s2, // 5
|
||||||
|
'public',
|
||||||
|
'end;',
|
||||||
|
''
|
||||||
|
]);
|
||||||
|
|
||||||
|
AssertEquals(1, FTheHighLighter.FoldOpenCount(5)); // fold opens for class/record/...
|
||||||
|
AssertEquals(7, FTheHighLighter.FoldEndLine(5, 0)); // fold end for class/record/...
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for i2 := 0 to 1 do
|
||||||
|
for i3 := 0 to 1 do
|
||||||
|
for i4 := 0 to 1 do
|
||||||
|
begin
|
||||||
|
|
||||||
|
case i4 of
|
||||||
|
0: s1 := 'TFoo : ';
|
||||||
|
1: s1 := 'TFoo:';
|
||||||
|
end;
|
||||||
|
|
||||||
|
s2 := 'record';
|
||||||
|
if i2 = 1 then s2 := 'type '+s2;
|
||||||
|
if i3 = 1 then s2 := ' '+s2; // leading space
|
||||||
|
SetLines
|
||||||
|
([ 'Unit A; interface {$modeswitch advancedrecords}{$modeswitch typehelpers}', // 0
|
||||||
|
'var',
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
s1,
|
||||||
|
s2, // 5
|
||||||
|
'public',
|
||||||
|
'end;',
|
||||||
|
''
|
||||||
|
]);
|
||||||
|
|
||||||
|
AssertEquals(1, FTheHighLighter.FoldOpenCount(5)); // fold opens for class/record/...
|
||||||
|
AssertEquals(7, FTheHighLighter.FoldEndLine(5, 0)); // fold end for class/record/...
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TTestHighlighterPas.TestContextForClassSection;
|
procedure TTestHighlighterPas.TestContextForClassSection;
|
||||||
var
|
var
|
||||||
ty, rc, lead1, lead2, cm, s1, s2, v: string;
|
ty, rc, lead1, lead2, cm, s1, s2, v: string;
|
||||||
|
Loading…
Reference in New Issue
Block a user