wuwuxin 28 Posted March 5, 2021 (edited) MMX would wrap code line (that exceeds the set max columns), but sometimes the wrapping is not very optimal, for example, function MyFooFooFunction(const AParam1: string; const AParam2: TObject; const AParam3: IInterface): TObject would be wrapped up as function MyFooFooFunction(const AParam1: string; const AParam2: TObject; const AParam3: IInterface): TObject or wrapped up as function MyFooFooFunction(const AParam1: string; const AParam2 : TObject; const AParam3: IInterface): TObject Ideally, I want to keep the parameter declaration intact, i.e., const AParam3: IInterface doesn't get "cut off" at const, or at ":". How can I do that? Edited March 5, 2021 by wuwuxin improve Share this post Link to post
Uwe Raabe 2064 Posted March 5, 2021 4 hours ago, wuwuxin said: How can I do that? Unfortunately, you cannot. The wrapping algorithm is based on a tokenizer with some checks for line comments and special delimiters (like comma, semicolon and opening brackets) which are kept with the following token. Currently there is nothing implemented to detect complete declarations. You can file a feature request here: support@mmx-delphi.de (best accompanied by a set of examples to help me create some unit tests). Share this post Link to post
wuwuxin 28 Posted June 1, 2021 It seems the latest MMX improves the wrapping algorithm. But still it doesn't seem to be able to wrap generic param correctly: for example: ATables: TArray<TSQLRecordClass> can be wrapped as at the left bracket: ATables: TArray< TSQLRecordClass> Share this post Link to post
Uwe Raabe 2064 Posted June 1, 2021 Well, I am thankful for every test case. The test case should have: the complete line with leading spaces the expected length of the first line after wrapping the wrap margin to use (default = 80) the indent for the wrapped lines (default = 4) Share this post Link to post
wuwuxin 28 Posted June 2, 2021 1. The implementation of the function is wrapped wrongly: class function TMormotOrmFactory.CreateMormotOrm(const AParams: TMormotOrmParams; const ATables: TArray< TSQLRecordClass>; const ASchema: String; const AObsoleteSchemas: TArray<String>; const ACreateIndexProc: TMormotCreateIndexProc; const AStartupScript: String = ''): IMormotOrmFramework; 2. Not sure what it means. 3. Wrap margin is 118 4. Indent = 2 Share this post Link to post
Uwe Raabe 2064 Posted June 2, 2021 I just realized that this is far more complex than I anticipated. The current implementation takes one or more lines and splits them each independently. If a line break is inserted, the remaining text is also handled as if it were independent. Unfortunately that will not work reliable when semantics come into play and some state has to be carried on. Seems I have to re-design the whole approach before it can be used in production. Share this post Link to post