@@ -3,12 +3,11 @@ package org.combinators.ep.approach.oo /*DI:LI:AD*/
3
3
import org .combinators .ep .domain .abstractions .{DataTypeCase , Operation , TestCase , TypeRep }
4
4
import org .combinators .ep .domain .{GenericModel , abstractions }
5
5
import org .combinators .ep .generator .Command .Generator
6
- import org .combinators .ep .generator .communication .{ReceivedRequest , Request }
7
6
import org .combinators .ep .generator .paradigm .AnyParadigm .syntax .forEach
8
- import org .combinators .ep .generator .{AbstractSyntax , ApproachImplementationProvider , Command , EvolutionImplementationProvider , NameProvider , TestImplementationProvider , Understands , communication }
7
+ import org .combinators .ep .generator .{AbstractSyntax , Command , EvolutionImplementationProvider , NameProvider , TestImplementationProvider , Understands , communication }
9
8
import org .combinators .ep .generator .paradigm .{AddImport , AnyParadigm , Apply , FindClass , Generics , ObjectOriented , ParametricPolymorphism , ResolveImport , AddTypeLookup }
10
9
11
- trait CoCoClean extends ApproachImplementationProvider {
10
+ trait CoCoClean extends SharedOO {
12
11
val paradigm : AnyParadigm
13
12
val ooParadigm : ObjectOriented .WithBase [paradigm.type ]
14
13
val polymorphics : ParametricPolymorphism .WithBase [paradigm.type ]
@@ -22,10 +21,6 @@ trait CoCoClean extends ApproachImplementationProvider {
22
21
val finalizedTypeParameter : paradigm.syntax.Name = names.mangle(" FT" )
23
22
val finalizedPackage : paradigm.syntax.Name = names.mangle(" finalized" )
24
23
val getSelfMethod : paradigm.syntax.Name = names.mangle(" getSelf" )
25
-
26
- def getter (attribute : abstractions.Attribute ): paradigm.syntax.Name = {
27
- names.addPrefix(" get" , names.mangle(names.conceptNameOf(attribute)))
28
- }
29
24
}
30
25
31
26
/**
@@ -464,41 +459,18 @@ trait CoCoClean extends ApproachImplementationProvider {
464
459
import paradigm .methodBodyCapabilities ._
465
460
import ooParadigm .methodBodyCapabilities ._
466
461
467
- val properModel = latestModelDefiningNewFactoryType(domain) // not Exp but the Factory!
468
- .later(domain.findTypeCase(dataTypeCase).get)
469
-
470
462
for {
471
463
_ <- setOperationMethodSignature(domain, finalizedType, operation)
472
464
_ <- if (domain.operationsPresentEarlier(dataTypeCase).contains(operation)) {
473
465
setOverride()
474
466
} else {
475
467
Command .skip[paradigm.MethodBodyContext ]
476
468
}
477
- arguments <- getArguments()
478
- self <- selfReference()
479
- attributes <- forEach(dataTypeCase.attributes) { attribute =>
480
- for {
481
- getterMethod <- getMember(self, ComponentNames .getter(attribute))
482
- getterCall <- apply(getterMethod, Seq .empty)
483
- } yield (attribute, getterCall)
484
- }
485
- receivedRequest =
486
- ReceivedRequest (
487
- onType = domain.baseDataType,
488
- tpeCase = dataTypeCase,
489
- selfReference = self,
490
- attributes = attributes.toMap,
491
- request = Request (
492
- op = operation,
493
- arguments = operation.parameters.zip(arguments.map(argument => argument._3)).toMap
494
- ),
495
- model = Some (properModel)
496
- )
497
- result <- domainSpecific.logic(this )(receivedRequest)
469
+
470
+ result <- completeImplementation(domain.baseDataType, dataTypeCase, operation, domain, domainSpecific, attributeAccess= attributeGetterAccess)
498
471
} yield result
499
472
}
500
473
501
-
502
474
def addDataTypeCaseInterfaces (domain : GenericModel , domainSpecific : EvolutionImplementationProvider [this .type ]): Generator [paradigm.ProjectContext , Unit ] = {
503
475
val _newDataTypeCasesWithNewOperations = newDataTypeCasesWithNewOperations(domain)
504
476
@@ -554,7 +526,7 @@ trait CoCoClean extends ApproachImplementationProvider {
554
526
555
527
// Add abstract getters if defined here
556
528
_ <- forEach(if (domain.typeCases.contains(newDataTypeCase)) newDataTypeCase.attributes else List .empty) { attribute =>
557
- addAbstractMethod(ComponentNames .getter (attribute), setAttributeGetterSignature(domain, finalizedType, attribute))
529
+ addAbstractMethod(getterName (attribute), setAttributeGetterSignature(domain, finalizedType, attribute))
558
530
}
559
531
560
532
// Add methods for new operations
@@ -852,7 +824,7 @@ trait CoCoClean extends ApproachImplementationProvider {
852
824
} else Command .lift[ooParadigm.ClassContext , paradigm.syntax.Type ](baseTypeInterface)
853
825
854
826
_ <- addField(names.mangle(names.instanceNameOf(attribute)), attributeType)
855
- _ <- addMethod(ComponentNames .getter (attribute), makeAttributeGetter(domain, finalizedType, attribute))
827
+ _ <- addMethod(getterName (attribute), makeAttributeGetter(domain, finalizedType, attribute))
856
828
} yield ()
857
829
}
858
830
0 commit comments