• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

moosetechnology / Famix-Value / 15827198882

23 Jun 2025 02:34PM UTC coverage: 22.949% (+0.2%) from 22.717%
15827198882

push

github

Gabriel-Darbord
Exporter: Enhance constructor discovery

811 of 3534 relevant lines covered (22.95%)

0.23 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

73.53
/src/Famix-Value-Exporter/FASTJavaBuilder.class.st
1
"
2
I am used to handle Java type references and imports.
3
"
4
Class {
5
        #name : 'FASTJavaBuilder',
6
        #superclass : 'FASTBuilder',
7
        #instVars : [
8
                'typeNameDictionary'
9
        ],
10
        #category : 'Famix-Value-Exporter-Helpers',
11
        #package : 'Famix-Value-Exporter',
12
        #tag : 'Helpers'
13
}
14

15
{ #category : 'processing' }
16
FASTJavaBuilder >> canReferType: aFamixType [
1✔
17
        "Does the code model have the necessary information to import the type?"
1✔
18

1✔
19
        ^ aFamixType needsJavaImport not or: [ "Is the type definition in the model?"
1✔
20
                  aFamixType isStub not or: [ "Is it part of the JDK?"
1✔
21
                          aFamixType mooseName beginsWithAnyOf:
1✔
22
                                  #( 'java.' 'javax.' 'jdk.' ) ] ]
1✔
23
]
1✔
24

25
{ #category : 'initialization' }
26
FASTJavaBuilder >> initialize [
1✔
27

1✔
28
        typeNameDictionary := Dictionary new
1✔
29
]
1✔
30

31
{ #category : 'ast' }
32
FASTJavaBuilder >> makeImportDeclaration: aFamixType [
×
33

×
34
        ^ self model newImportDeclaration qualifiedName:
×
35
                  (aFamixType fullyQualifiedNameOn: self model)
×
36
]
×
37

38
{ #category : 'ast' }
39
FASTJavaBuilder >> makeImportDeclarations [
×
40
        "Make an import declaration for each type processed by this builder."
×
41

×
42
        ^ typeNameDictionary values collect: [ :type |
×
43
                  self makeImportDeclaration: type ]
×
44
]
×
45

46
{ #category : 'ast' }
47
FASTJavaBuilder >> makeImportDeclarations: anEntity [
×
48
        "Make import declarations for all types related to the given entity."
×
49

×
50
        ^ (anEntity allTypes select: [ :type | type needsJavaImport ])
×
51
                  collect: [ :type | self makeImportDeclaration: type ]
×
52
                  as: OrderedCollection
×
53
]
×
54

55
{ #category : 'processing' }
56
FASTJavaBuilder >> processType: aFamixType [
1✔
57
        "Process the given type and its related types, for example if it has concrete type parameters.
1✔
58
        This lets the builder know how to refer to the type.
1✔
59
        If the type is in the typeNameDict, it will be imported, so it can be referenced by its unqualified name."
1✔
60

1✔
61
        | type |
1✔
62
        (self canReferType: aFamixType) ifFalse: [
1✔
63
                FamixValueExporterError signal:
1✔
64
                        'Cannot import type: ' , aFamixType mooseName ].
1✔
65

1✔
66
        type := aFamixType isParametricEntity
1✔
67
                        ifTrue: [
1✔
68
                                aFamixType concreteParameters do: [ :parameter |
1✔
69
                                        self processType: parameter ].
1✔
70
                                aFamixType genericEntity ]
1✔
71
                        ifFalse: [ aFamixType ].
1✔
72
        type needsJavaImport ifTrue: [
1✔
73
                typeNameDictionary at: type name ifAbsentPut: type ]
1✔
74
]
1✔
75

76
{ #category : 'processing' }
77
FASTJavaBuilder >> referType: aFamixType [
1✔
78
        "Process a type and return a FAST expression to reference it.
1✔
79
        Use its unqualified name when importing the type, otherwise use its fully qualified name."
1✔
80

1✔
81
        | registeredType |
1✔
82
        self processType: aFamixType.
1✔
83
        registeredType := typeNameDictionary
1✔
84
                                  at: aFamixType name
1✔
85
                                  ifAbsent: nil.
1✔
86
        ^ self model newClassTypeExpression typeName:
1✔
87
                  ((registeredType == aFamixType or: [
1✔
88
                            aFamixType needsJavaImport not or: [
1✔
89
                                    aFamixType isParametricEntity and: [
1✔
90
                                            registeredType == aFamixType genericEntity ] ] ])
1✔
91
                           ifTrue: [ "has import"
1✔
92
                           model newTypeName name: aFamixType baseName ]
1✔
93
                           ifFalse: [ "no import"
1✔
94
                           aFamixType fullyQualifiedTypeNameOn: self model ])
1✔
95
]
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc