mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-13 14:39:09 +02:00
codetools: auto indent: round brackets
git-svn-id: trunk@22314 -
This commit is contained in:
parent
5cf79cb15b
commit
5cde48e398
@ -104,13 +104,15 @@ type
|
|||||||
bbtClass,
|
bbtClass,
|
||||||
bbtClassInterface,
|
bbtClassInterface,
|
||||||
bbtClassSection, // public, private, protected, published
|
bbtClassSection, // public, private, protected, published
|
||||||
|
bbtTypeRoundBracket,
|
||||||
// statement blocks
|
// statement blocks
|
||||||
bbtProcedure, // procedure, constructor, destructor
|
bbtProcedure, // procedure, constructor, destructor
|
||||||
bbtFunction,
|
bbtFunction,
|
||||||
bbtMainBegin,
|
bbtProcedureParamList,
|
||||||
bbtCommentaryBegin, // begin without any need
|
|
||||||
bbtRepeat,
|
|
||||||
bbtProcedureBegin,
|
bbtProcedureBegin,
|
||||||
|
bbtMainBegin,
|
||||||
|
bbtFreeBegin, // begin without need (e.g. without if-then)
|
||||||
|
bbtRepeat,
|
||||||
bbtCase,
|
bbtCase,
|
||||||
bbtCaseOf, // child of bbtCase
|
bbtCaseOf, // child of bbtCase
|
||||||
bbtCaseColon, // child of bbtCase
|
bbtCaseColon, // child of bbtCase
|
||||||
@ -122,7 +124,8 @@ type
|
|||||||
bbtIf,
|
bbtIf,
|
||||||
bbtIfThen, // child of bbtIf
|
bbtIfThen, // child of bbtIf
|
||||||
bbtIfElse, // child of bbtIf
|
bbtIfElse, // child of bbtIf
|
||||||
bbtIfBegin // child of bbtIfThen or bbtIfElse
|
bbtIfBegin, // child of bbtIfThen or bbtIfElse
|
||||||
|
bbtStatementRoundBracket
|
||||||
);
|
);
|
||||||
TFABBlockTypes = set of TFABBlockType;
|
TFABBlockTypes = set of TFABBlockType;
|
||||||
|
|
||||||
@ -131,10 +134,54 @@ const
|
|||||||
bbtResourceStringSection,bbtLabelSection];
|
bbtResourceStringSection,bbtLabelSection];
|
||||||
bbtAllCodeSections = [bbtInterface,bbtImplementation,bbtInitialization,
|
bbtAllCodeSections = [bbtInterface,bbtImplementation,bbtInitialization,
|
||||||
bbtFinalization];
|
bbtFinalization];
|
||||||
bbtAllStatements = [bbtMainBegin,bbtCommentaryBegin,bbtRepeat,bbtProcedureBegin,
|
bbtAllStatements = [bbtMainBegin,bbtFreeBegin,bbtRepeat,bbtProcedureBegin,
|
||||||
bbtCaseColon,bbtCaseBegin,bbtCaseElse,
|
bbtCaseColon,bbtCaseBegin,bbtCaseElse,
|
||||||
bbtTry,bbtFinally,bbtExcept,
|
bbtTry,bbtFinally,bbtExcept,
|
||||||
bbtIfThen,bbtIfElse,bbtIfBegin];
|
bbtIfThen,bbtIfElse,bbtIfBegin,bbtStatementRoundBracket];
|
||||||
|
const
|
||||||
|
FABBlockTypeNames: array[TFABBlockType] of string = (
|
||||||
|
'bbtNone',
|
||||||
|
// code sections
|
||||||
|
'bbtInterface',
|
||||||
|
'bbtImplementation',
|
||||||
|
'bbtInitialization',
|
||||||
|
'bbtFinalization',
|
||||||
|
// identifier sections
|
||||||
|
'bbtUsesSection',
|
||||||
|
'bbtTypeSection',
|
||||||
|
'bbtConstSection',
|
||||||
|
'bbtVarSection',
|
||||||
|
'bbtResourceStringSection',
|
||||||
|
'bbtLabelSection',
|
||||||
|
// type blocks
|
||||||
|
'bbtRecord',
|
||||||
|
'bbtClass',
|
||||||
|
'bbtClassInterface',
|
||||||
|
'bbtClassSection',
|
||||||
|
'bbtTypeRoundBracket',
|
||||||
|
// statement blocks
|
||||||
|
'bbtProcedure',
|
||||||
|
'bbtFunction',
|
||||||
|
'bbtProcedureParamList',
|
||||||
|
'bbtProcedureBegin',
|
||||||
|
'bbtMainBegin',
|
||||||
|
'bbtFreeBegin',
|
||||||
|
'bbtRepeat',
|
||||||
|
'bbtCase',
|
||||||
|
'bbtCaseOf',
|
||||||
|
'bbtCaseColon',
|
||||||
|
'bbtCaseBegin',
|
||||||
|
'bbtCaseElse',
|
||||||
|
'bbtTry',
|
||||||
|
'bbtFinally',
|
||||||
|
'bbtExcept',
|
||||||
|
'bbtIf',
|
||||||
|
'bbtIfThen',
|
||||||
|
'bbtIfElse',
|
||||||
|
'bbtIfBegin',
|
||||||
|
'bbtStatementRoundBracket'
|
||||||
|
);
|
||||||
|
|
||||||
type
|
type
|
||||||
TOnGetFABExamples = procedure(Sender: TObject; Code: TCodeBuffer;
|
TOnGetFABExamples = procedure(Sender: TObject; Code: TCodeBuffer;
|
||||||
Step: integer; // starting at 0
|
Step: integer; // starting at 0
|
||||||
@ -258,47 +305,6 @@ type
|
|||||||
property OnLoadFile: TOnGetFABFile read FOnLoadFile write FOnLoadFile;
|
property OnLoadFile: TOnGetFABFile read FOnLoadFile write FOnLoadFile;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
const
|
|
||||||
FABBlockTypeNames: array[TFABBlockType] of string = (
|
|
||||||
'bbtNone',
|
|
||||||
// code sections
|
|
||||||
'bbtInterface',
|
|
||||||
'bbtImplementation',
|
|
||||||
'bbtInitialization',
|
|
||||||
'bbtFinalization',
|
|
||||||
// identifier sections
|
|
||||||
'bbtUsesSection',
|
|
||||||
'bbtTypeSection',
|
|
||||||
'bbtConstSection',
|
|
||||||
'bbtVarSection',
|
|
||||||
'bbtResourceStringSection',
|
|
||||||
'bbtLabelSection',
|
|
||||||
// type blocks
|
|
||||||
'bbtRecord',
|
|
||||||
'bbtClass',
|
|
||||||
'bbtClassInterface',
|
|
||||||
'bbtClassSection',
|
|
||||||
// statement blocks
|
|
||||||
'bbtProcedure',
|
|
||||||
'bbtFunction',
|
|
||||||
'bbtMainBegin',
|
|
||||||
'bbtCommentaryBegin',
|
|
||||||
'bbtRepeat',
|
|
||||||
'bbtProcedureBegin',
|
|
||||||
'bbtCase',
|
|
||||||
'bbtCaseOf',
|
|
||||||
'bbtCaseColon',
|
|
||||||
'bbtCaseBegin',
|
|
||||||
'bbtCaseElse',
|
|
||||||
'bbtTry',
|
|
||||||
'bbtFinally',
|
|
||||||
'bbtExcept',
|
|
||||||
'bbtIf',
|
|
||||||
'bbtIfThen',
|
|
||||||
'bbtIfElse',
|
|
||||||
'bbtIfBegin'
|
|
||||||
);
|
|
||||||
|
|
||||||
function CompareFABPoliciesWithCode(Data1, Data2: Pointer): integer;
|
function CompareFABPoliciesWithCode(Data1, Data2: Pointer): integer;
|
||||||
function CompareCodeWithFABPolicy(Key, Data: Pointer): integer;
|
function CompareCodeWithFABPolicy(Key, Data: Pointer): integer;
|
||||||
|
|
||||||
@ -566,6 +572,27 @@ begin
|
|||||||
|
|
||||||
r:=@Src[AtomStart];
|
r:=@Src[AtomStart];
|
||||||
case UpChars[r^] of
|
case UpChars[r^] of
|
||||||
|
'(':
|
||||||
|
if p-AtomStart=1 then begin
|
||||||
|
// round bracket open
|
||||||
|
case Stack.TopType of
|
||||||
|
bbtProcedure,bbtFunction:
|
||||||
|
BeginBlock(bbtProcedureParamList);
|
||||||
|
else
|
||||||
|
if Stack.TopType in bbtAllStatements then
|
||||||
|
BeginBlock(bbtStatementRoundBracket)
|
||||||
|
else
|
||||||
|
BeginBlock(bbtTypeRoundBracket);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
')':
|
||||||
|
if p-AtomStart=1 then begin
|
||||||
|
// round bracket close
|
||||||
|
case Stack.TopType of
|
||||||
|
bbtProcedureParamList,bbtTypeRoundBracket,bbtStatementRoundBracket:
|
||||||
|
EndBlock;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
'B':
|
'B':
|
||||||
if CompareIdentifiers('BEGIN',r)=0 then begin
|
if CompareIdentifiers('BEGIN',r)=0 then begin
|
||||||
while Stack.TopType in (bbtAllIdentifierSections+bbtAllCodeSections) do
|
while Stack.TopType in (bbtAllIdentifierSections+bbtAllCodeSections) do
|
||||||
@ -576,7 +603,7 @@ begin
|
|||||||
bbtProcedure,bbtFunction:
|
bbtProcedure,bbtFunction:
|
||||||
BeginBlock(bbtProcedureBegin);
|
BeginBlock(bbtProcedureBegin);
|
||||||
bbtMainBegin,bbtProcedureBegin:
|
bbtMainBegin,bbtProcedureBegin:
|
||||||
BeginBlock(bbtCommentaryBegin);
|
BeginBlock(bbtFreeBegin);
|
||||||
bbtCaseElse,bbtCaseColon:
|
bbtCaseElse,bbtCaseColon:
|
||||||
BeginBlock(bbtCaseBegin);
|
BeginBlock(bbtCaseBegin);
|
||||||
bbtIfThen,bbtIfElse:
|
bbtIfThen,bbtIfElse:
|
||||||
@ -624,7 +651,7 @@ begin
|
|||||||
EndBlock;
|
EndBlock;
|
||||||
|
|
||||||
case Stack.TopType of
|
case Stack.TopType of
|
||||||
bbtMainBegin,bbtCommentaryBegin,
|
bbtMainBegin,bbtFreeBegin,
|
||||||
bbtRecord,bbtClass,bbtClassInterface,bbtTry,bbtFinally,bbtExcept,
|
bbtRecord,bbtClass,bbtClassInterface,bbtTry,bbtFinally,bbtExcept,
|
||||||
bbtCase,bbtCaseBegin,bbtIfBegin:
|
bbtCase,bbtCaseBegin,bbtIfBegin:
|
||||||
EndBlock;
|
EndBlock;
|
||||||
@ -1137,7 +1164,7 @@ begin
|
|||||||
bbtRecord,
|
bbtRecord,
|
||||||
bbtClassSection,
|
bbtClassSection,
|
||||||
bbtMainBegin,
|
bbtMainBegin,
|
||||||
bbtCommentaryBegin,
|
bbtFreeBegin,
|
||||||
bbtRepeat,
|
bbtRepeat,
|
||||||
bbtProcedureBegin,
|
bbtProcedureBegin,
|
||||||
bbtCaseColon,
|
bbtCaseColon,
|
||||||
|
Loading…
Reference in New Issue
Block a user