Class FieldClassifier
java.lang.Object
org.ek9lang.compiler.phase5.FieldClassifier
Classifies fields in an aggregate as service-type (abstract/interface) or data-type (concrete).
Also tracks which fields are used in 'by' delegation.
Service-type fields are those whose type is an abstract/behavior contract:
- A trait (SymbolGenus.CLASS_TRAIT) - behavior contract
- An abstract class (isMarkedAbstract()) - behavior contract
- An abstract function (SymbolGenus.FUNCTION_TRAIT) - behavior contract
Data-type fields are concrete types:
- Records (SymbolGenus.RECORD) - pure data
- Text constructs (SymbolGenus.TEXT) - pure data
- Concrete classes (String, Dimension, user-defined) - values with behavior
- Concrete functions - specific implementation, not a contract
For parameterized types (List, Dict, Optional), the classification is based on the type argument, not the container. For example:
List of Repository(trait) → SERVICE (holds behavior contracts)List of String(concrete) → DATA (holds concrete values)Dict of String, UserRecord(record) → DATA (value type determines)
This classification helps detect the construct misuse anti-patterns:
- E11022: Class with many service fields and no data = should be component
- E11024: Class with 'by' delegation + many service fields = hybrid, should split
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final recordResult of field classification for an aggregate. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) FieldClassifier.FieldCountsclassify(IAggregateSymbol aggregate, EK9Parser.TraitsListContext traitsListContext) Classify all fields of an aggregate.
-
Constructor Details
-
FieldClassifier
FieldClassifier()
-
-
Method Details
-
classify
FieldClassifier.FieldCounts classify(IAggregateSymbol aggregate, EK9Parser.TraitsListContext traitsListContext) Classify all fields of an aggregate.- Parameters:
aggregate- The aggregate to analyzetraitsListContext- Optional parse tree context for detecting 'by' delegation- Returns:
- Classification counts and field lists
-