Add support for generic constraints to CodeTools
Original Reporter info from Mantis: PascalDragon @PascalDragon
-
Reporter name: Sven Barth
Original Reporter info from Mantis: PascalDragon @PascalDragon
- Reporter name: Sven Barth
Description:
Free Pascal now supports constraints for generics, so Lazarus should support these as well.
Support for such constraints contains two steps:
* correctly parse the constraint syntax (see Additional Information)
* handle type parameters correctly (e.g. if a type parameter has a constraint for a specific class the class' methods should be listed in the completion list)
Additional information:
The syntax for type constraints looks as follows:
type
generic TSomeGeneric<T1, T2: "Constraints"; T3; T4: "Constraints"> = class
end;
where "Constraints" currently is:
- "record" keyword (mutually exclusive to other constraints)
- "class" keyword (mutually exclusive to "record")
- "constructor" keyword (Delphi mode only; mutually exclusive to "record")
- class identifier (mutually exclusive to "record" and "class")
- interface identifier (mutually exclusive to "record")
Multiple interface identifiers can be given together with the "class" or "constructor" keywords as well as a class identifier; the of the constraints is not important.
The "constructor" constraint behaves the same as the "class" constraint.
For further examples please take a look at $fpcdir/tests/test/ugenconstraints.pas (from FPC revision 23158 on).
Mantis conversion info:
- Mantis ID: 23496
- Fixed in revision: 39822 (#f4f57577)