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

moosetechnology / Famix-Value / 11557114099

28 Oct 2024 03:20PM UTC coverage: 24.281% (-0.9%) from 25.209%
11557114099

push

github

Gabriel-Darbord
Major Java update
Model:
- rename relation TType's relation to ValueEntity from `values` to `valueInstances`, to avoid clash with TTypedEntity's relation to ValueEntity (because of FamixJavaParameterType which uses both)

Importer:
- handle class references
- handle enums
- do not remove @type and @id keys when iterating over raw values (that made debugging difficult)
- handle field descriptors with anonymous classes (using `$` as separator instead of a dot)
- search for attributes on parametric classes by asking the generic superclass
- infer using concrete parameter types
- read declared type array dimensions
- implicit switch from int to long when out of bounds

Exporter:
- handle class references
- throw error when reaching broken state instead of persevering and generating uncompilable code
- correctly export qualified names of any class using dispatch (there were problems with inner classes)
- when finding accessed attributes in a method, handle case where variable is the receiver
- add `withSubHierarchy` to also find interface implementors
- work around VerveineJ problems by adding nil checks where they should normally never occur
- better exception handling when using reflection
- more polymorphism on UnknownType
- add explicit cast to disambiguate between int and long when calling helpers
- WIP handling of exceptions thrown by constructors and accessors

Types:
- handle `java.util.Calendar`

13 of 207 new or added lines in 11 files covered. (6.28%)

3 existing lines in 2 files now uncovered.

760 of 3130 relevant lines covered (24.28%)

0.24 hits per line

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

51.35
/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 : 'ast' }
16
FASTJavaBuilder >> fullyQualifiedPackageNameFor: aFamixJavaPackage [
×
17

×
18
        ^ aFamixJavaPackage parentPackage
×
19
                  ifNil: [ self model newTypeName name: aFamixJavaPackage name ]
×
20
                  ifNotNil: [ :parentPackage |
×
21
                          self model newQualifiedTypeName
×
22
                                  name: aFamixJavaPackage name;
×
23
                                  namespace: (self fullyQualifiedPackageNameFor: parentPackage) ]
×
24
]
×
25

26
{ #category : 'ast' }
27
FASTJavaBuilder >> fullyQualifiedTypeNameFor: aFamixJavaType [
×
NEW
28
        "A type can be in another type or a package"
×
29

×
30
        ^ self model newQualifiedTypeName
×
31
                  name: aFamixJavaType baseName;
×
32
                  namespace:
×
NEW
33
                          (aFamixJavaType typeContainer fullyQualifiedTypeNameOn:
×
NEW
34
                                           self model)
×
UNCOV
35
]
×
36

37
{ #category : 'initialization' }
38
FASTJavaBuilder >> initialize [
1✔
39

1✔
40
        typeNameDictionary := Dictionary new
1✔
41
]
1✔
42

43
{ #category : 'ast' }
44
FASTJavaBuilder >> makeImportDeclaration: aFamixType [
×
45

×
46
        ^ self model newImportDeclaration qualifiedName:
×
NEW
47
                  (aFamixType fullyQualifiedNameOn: self model)
×
48
]
×
49

50
{ #category : 'ast' }
51
FASTJavaBuilder >> makeImportDeclarations [
×
52
        "Make an import declaration for each type processed by this builder."
×
53

×
54
        ^ typeNameDictionary values collect: [ :type |
×
55
                  self makeImportDeclaration: type ]
×
56
]
×
57

58
{ #category : 'ast' }
59
FASTJavaBuilder >> makeImportDeclarations: anEntity [
×
60
        "Make import declarations for all types related to the given entity."
×
61

×
62
        ^ (anEntity allTypes select: [ :type | type needsJavaImport ])
×
63
                  collect: [ :type | self makeImportDeclaration: type ]
×
64
                  as: OrderedCollection
×
65
]
×
66

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

1✔
73
        | type |
1✔
74
        type := aFamixType isParametricEntity
1✔
75
                        ifTrue: [
1✔
76
                                aFamixType concreteParameters do: [ :parameter |
1✔
77
                                        self processType: parameter ].
1✔
78
                                aFamixType genericEntity ]
1✔
79
                        ifFalse: [ aFamixType ].
1✔
80
        type needsJavaImport ifTrue: [
1✔
81
                typeNameDictionary at: type name ifAbsentPut: type ]
1✔
82
]
1✔
83

84
{ #category : 'processing' }
85
FASTJavaBuilder >> referType: aFamixType [
1✔
86
        "Process a type and return a FAST expression to reference it.
1✔
87
        Use its unqualified name when importing the type, otherwise use its fully qualified name."
1✔
88

1✔
89
        | registeredType |
1✔
90
        self processType: aFamixType.
1✔
91
        registeredType := typeNameDictionary
1✔
92
                                  at: aFamixType name
1✔
93
                                  ifAbsent: nil.
1✔
94
        ^ self model newClassTypeExpression typeName:
1✔
95
                  ((registeredType == aFamixType or: [
1✔
96
                            aFamixType needsJavaImport not or: [
1✔
97
                                    aFamixType isParametricEntity and: [
1✔
98
                                            registeredType == aFamixType genericEntity ] ] ])
1✔
99
                           ifTrue: [ "has import"
1✔
100
                           model newTypeName name: aFamixType baseName ]
1✔
101
                           ifFalse: [ "no import"
1✔
102
                           self fullyQualifiedTypeNameFor: aFamixType ])
1✔
103
]
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