mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-23 01:19:37 +02:00
SynEdit: PascalHighlighter, improve detecting hint modifiers
This commit is contained in:
parent
e9538adea1
commit
439016e4f6
@ -2770,23 +2770,31 @@ begin
|
||||
end;
|
||||
|
||||
function TSynPasSyn.Func85: TtkTokenKind;
|
||||
var
|
||||
tfb: TPascalCodeFoldBlockType;
|
||||
begin
|
||||
tfb := TopPascalCodeFoldBlockType;
|
||||
if (PasCodeFoldRange.BracketNestLevel = 0) and
|
||||
(fRange * [rsInProcHeader, rsProperty, rsAfterEqualOrColon, rsWasInProcHeader] = [rsWasInProcHeader]) and
|
||||
(TopPascalCodeFoldBlockType in ProcModifierAllowedNoVar-[cfbtClass, cfbtClassSection]) and
|
||||
(tfb in ProcModifierAllowedNoVar-[cfbtClass, cfbtClassSection]) and
|
||||
KeyComp('Forward')
|
||||
then begin
|
||||
Result := tkModifier;
|
||||
if TopPascalCodeFoldBlockType = cfbtProcedure then begin
|
||||
if tfb = cfbtProcedure then begin
|
||||
EndPascalCodeFoldBlock(True);
|
||||
end;
|
||||
end
|
||||
else
|
||||
if KeyComp('Library') then begin
|
||||
fRange := fRange - [rsInterface] + [rsImplementation];
|
||||
if TopPascalCodeFoldBlockType=cfbtNone then
|
||||
StartPascalCodeFoldBlock(cfbtProgram);
|
||||
Result := tkKey
|
||||
if KeyCompU('LIBRARY') then begin
|
||||
if IsHintModifier(tfb) then begin
|
||||
Result := DoHintModifier;
|
||||
end
|
||||
else begin
|
||||
fRange := fRange - [rsInterface] + [rsImplementation];
|
||||
if tfb=cfbtNone then
|
||||
StartPascalCodeFoldBlock(cfbtProgram);
|
||||
Result := tkKey;
|
||||
end;
|
||||
end
|
||||
else
|
||||
Result := tkIdentifier;
|
||||
@ -3637,15 +3645,28 @@ begin
|
||||
(PasCodeFoldRange.BracketNestLevel = 0) and
|
||||
( ( (tfb in cfbtVarConstType) and
|
||||
(FTokenState <> tsAfterAbsolute) and
|
||||
(fRange * [rsVarTypeInSpecification, rsAfterEqualOrColon] = [rsVarTypeInSpecification]) ) or
|
||||
( (fRange * [rsVarTypeInSpecification, rsAfterEqualOrColon] = [rsVarTypeInSpecification]) or
|
||||
( (tfb in [cfbtTypeBlock, cfbtLocalTypeBlock]) and
|
||||
(rsWasInProcHeader in fRange) and
|
||||
(FTokenState in [tsAtBeginOfStatement])
|
||||
)
|
||||
)
|
||||
) or
|
||||
( (tfb in [cfbtClass, cfbtClassSection, cfbtRecord, cfbtRecordCase, cfbtRecordCaseSection, cfbtClassConstBlock, cfbtClassTypeBlock]) and
|
||||
( (fRange * [rsAfterClassMembers, rsInProcHeader] = [rsAfterClassMembers]) or
|
||||
(fRange * [rsAfterClassMembers, rsAfterEqualOrColon, rsVarTypeInSpecification] = [rsVarTypeInSpecification])
|
||||
) ) or
|
||||
(fRange * [rsAfterClassMembers, rsAfterEqualOrColon, rsVarTypeInSpecification] = [rsVarTypeInSpecification]) or
|
||||
( (tfb = cfbtClassTypeBlock) and
|
||||
(rsWasInProcHeader in fRange) and
|
||||
(FTokenState in [tsAtBeginOfStatement])
|
||||
)
|
||||
)
|
||||
) or
|
||||
( (tfb in [cfbtUnitSection, cfbtProgram, cfbtProcedure]) and
|
||||
(fRange * [rsInProcHeader] = []) ) or
|
||||
(fRange * [rsInProcHeader] = [])
|
||||
) or
|
||||
( (tfb in [cfbtUnit, cfbtNone]) and
|
||||
(fRange * [rsInProcHeader] = []) and (FTokenState = tsAfterProcName) )
|
||||
(fRange * [rsInProcHeader] = []) and (FTokenState = tsAfterProcName)
|
||||
)
|
||||
)
|
||||
then
|
||||
Result := True
|
||||
|
@ -1985,15 +1985,17 @@ procedure TTestHighlighterPas.TestContextForDeprecated;
|
||||
s+'= array [1..2] of '+s+' '+s+';', // nameDEPRECATED=array of typeDEPRECATED deprecated;
|
||||
s+'= set of '+s+' '+s+';', // nameDEPRECATED=set of typeDEPRECATED deprecated;
|
||||
s+'= class of '+s+' '+s+';', // nameDEPRECATED=class of typeDEPRECATED deprecated;
|
||||
s+'= procedure '+s+';',
|
||||
s+'= procedure of object '+s+';',
|
||||
s+'= procedure(a:'+s+') '+s+';',
|
||||
s+'= procedure(a:'+s+') of object '+s+';',
|
||||
s+'= function:'+s+' '+s+';',
|
||||
s+'= function:'+s+' of object '+s+';',
|
||||
s+'= function(a:'+s+'):'+s+' '+s+';',
|
||||
s+'= function(a:'+s+'):'+s+' of object '+s+';',
|
||||
s+'= record end '+s+';', // nameDEPRECATED=packed record deprecated;
|
||||
s+'= procedure '+s+';', // 8
|
||||
'f= procedure; '+s+';', // 9
|
||||
'f= procedure '+s+';'+s+';', // 10
|
||||
'f= procedure of object '+s+';',
|
||||
'f= procedure(a:'+s+') '+s+';',
|
||||
'f= procedure(a:'+s+') of object '+s+';',
|
||||
'f= function:'+s+' '+s+';',
|
||||
'f= function:'+s+' of object '+s+';',
|
||||
'f= function(a:'+s+'):'+s+' '+s+';',
|
||||
'f= function(a:'+s+'):'+s+' of object '+s+';',
|
||||
'f= record end '+s+';', // nameDEPRECATED=packed record deprecated;
|
||||
s+'= packed record end '+s+';', // nameDEPRECATED=packed record deprecated;
|
||||
'end',
|
||||
''
|
||||
@ -2010,35 +2012,41 @@ procedure TTestHighlighterPas.TestContextForDeprecated;
|
||||
[tkIdentifier, tkSymbol, tkSpace, tkKey, tkSpace, tkKey {"of"}, tkSpace, tkIdentifier, tkSpace, tkModifier {the one and only}, tkSymbol]);
|
||||
CheckTokensForLine('class of', 7,
|
||||
[tkIdentifier, tkSymbol, tkSpace, tkKey, tkSpace, tkKey {"of"}, tkSpace, tkIdentifier, tkSpace, tkModifier {the one and only}, tkSymbol]);
|
||||
|
||||
CheckTokensForLine('procedure ', 8,
|
||||
[tkIdentifier, tkSymbol, tkSpace, tkKey, tkSpace, tkModifier {the one and only}, tkSymbol]);
|
||||
CheckTokensForLine('procedure of object ', 9,
|
||||
CheckTokensForLine('procedure ', 9,
|
||||
[tkIdentifier, tkSymbol, tkSpace, tkKey, TK_Semi, tkSpace, tkModifier {the one and only}, tkSymbol]);
|
||||
CheckTokensForLine('procedure ', 10,
|
||||
[tkIdentifier, tkSymbol, tkSpace, tkKey, tkSpace, tkModifier, TK_Semi, tkModifier, tkSymbol]);
|
||||
|
||||
CheckTokensForLine('procedure of object ', 11,
|
||||
[tkIdentifier, tkSymbol, tkSpace, tkKey, tkSpace, tkKey {"of"}, tkSpace, tkKey, tkSpace, tkModifier {the one and only}, tkSymbol]);
|
||||
CheckTokensForLine('procedure(a:s) ', 10,
|
||||
CheckTokensForLine('procedure(a:s) ', 12,
|
||||
[tkIdentifier, tkSymbol, tkSpace, tkKey,
|
||||
TK_Bracket, tkIdentifier, TK_Colon, tkIdentifier, TK_Bracket,
|
||||
tkSpace, tkModifier {the one and only}, tkSymbol]);
|
||||
CheckTokensForLine('procedure(a:s) of object ', 11,
|
||||
CheckTokensForLine('procedure(a:s) of object ', 13,
|
||||
[tkIdentifier, tkSymbol, tkSpace, tkKey,
|
||||
TK_Bracket, tkIdentifier, TK_Colon, tkIdentifier, TK_Bracket,
|
||||
tkSpace, tkKey {"of"}, tkSpace, tkKey, tkSpace, tkModifier {the one and only}, tkSymbol]);
|
||||
CheckTokensForLine('function', 12,
|
||||
CheckTokensForLine('function', 14,
|
||||
[tkIdentifier, tkSymbol, tkSpace, tkKey, TK_Colon, tkIdentifier, tkSpace, tkModifier {the one and only}, tkSymbol]);
|
||||
CheckTokensForLine('function of object ', 13,
|
||||
CheckTokensForLine('function of object ', 15,
|
||||
[tkIdentifier, tkSymbol, tkSpace, tkKey, TK_Colon, tkIdentifier, tkSpace, tkKey {"of"}, tkSpace, tkKey, tkSpace, tkModifier {the one and only}, tkSymbol]);
|
||||
CheckTokensForLine('function(a:s)', 14,
|
||||
CheckTokensForLine('function(a:s)', 16,
|
||||
[tkIdentifier, tkSymbol, tkSpace, tkKey,
|
||||
TK_Bracket, tkIdentifier, TK_Colon, tkIdentifier, TK_Bracket,
|
||||
TK_Colon, tkIdentifier,
|
||||
tkSpace, tkModifier {the one and only}, tkSymbol]);
|
||||
CheckTokensForLine('function(a:s) of object ', 15,
|
||||
CheckTokensForLine('function(a:s) of object ', 17,
|
||||
[tkIdentifier, tkSymbol, tkSpace, tkKey,
|
||||
TK_Bracket, tkIdentifier, TK_Colon, tkIdentifier, TK_Bracket,
|
||||
TK_Colon, tkIdentifier,
|
||||
tkSpace, tkKey {"of"}, tkSpace, tkKey, tkSpace, tkModifier {the one and only}, tkSymbol]);
|
||||
CheckTokensForLine('record end', 16,
|
||||
CheckTokensForLine('record end', 18,
|
||||
[tkIdentifier, tkSymbol, tkSpace, tkKey, tkSpace, tkKey {"end"}, tkSpace, tkModifier {the one and only}, tkSymbol]);
|
||||
CheckTokensForLine('packed record end', 17,
|
||||
CheckTokensForLine('packed record end', 19,
|
||||
[tkIdentifier, tkSymbol, tkSpace, tkKey, tkSpace, tkKey, tkSpace, tkKey {"end"}, tkSpace, tkModifier {the one and only}, tkSymbol]);
|
||||
|
||||
if (struct = 'record') or (struct = 'byte;') then
|
||||
|
Loading…
Reference in New Issue
Block a user