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

moosetechnology / VerveineJ / 19990566308

06 Dec 2025 03:32PM UTC coverage: 50.991% (+0.02%) from 50.975%
19990566308

Pull #177

github

web-flow
Merge cb09790bc into 67bcff346
Pull Request #177: Fix object inheriting from object if parsing the JDK

1924 of 3986 branches covered (48.27%)

Branch coverage included in aggregate %.

4 of 5 new or added lines in 1 file covered. (80.0%)

4303 of 8226 relevant lines covered (52.31%)

2.11 hits per line

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

78.49
/app/src/main/java/fr/inria/verveine/extractor/java/visitors/refvisitors/VisitorInheritanceRef.java
1
package fr.inria.verveine.extractor.java.visitors.refvisitors;
2

3
import fr.inria.verveine.extractor.java.EntityDictionary;
4
import fr.inria.verveine.extractor.java.VerveineJOptions;
5
import fr.inria.verveine.extractor.java.utils.StubBinding;
6
import fr.inria.verveine.extractor.java.utils.Util;
7
import fr.inria.verveine.extractor.java.visitors.GetVisitedEntityAbstractVisitor;
8
import org.eclipse.jdt.core.dom.*;
9
import org.moosetechnology.model.famix.famixjavaentities.ContainerEntity;
10
import org.moosetechnology.model.famix.famixjavaentities.Package;
11
import org.moosetechnology.model.famix.famixtraits.TAssociation;
12
import org.moosetechnology.model.famix.famixtraits.TType;
13
import org.moosetechnology.model.famix.famixtraits.TWithInheritances;
14
import org.moosetechnology.model.famix.famixtraits.TWithTypes;
15

16
/** A visitor to record inheritance relationships.<br>
17
 * It is simpler than the other ref visitors
18
 * @author anquetil
19
 */
20
public class VisitorInheritanceRef extends GetVisitedEntityAbstractVisitor {
21

22
        public VisitorInheritanceRef(EntityDictionary dico, VerveineJOptions options) {
23
                super(dico, options);
4✔
24
        }
1✔
25

26
        public boolean visit(TypeDeclaration node) {
27
                TWithInheritances fmx = (TWithInheritances) visitTypeDeclaration(node);
5✔
28
                ITypeBinding bnd = node.resolveBinding();
3✔
29
                if ((fmx != null) && (bnd != null)) {
4!
30
                        ensureInheritances(bnd, fmx);
4✔
31

32
                        return super.visit(node);
4✔
33
                } else {
34
                        return false;
×
35
                }
36
        }
37

38
        public void endVisit(TypeDeclaration node) {
39
                endVisitTypeDeclaration(node);
3✔
40
                super.endVisit(node);
3✔
41
        }
1✔
42

43
        public boolean visit(ClassInstanceCreation node) {
44
                // used to get the name of the super type of the anonymous class
45
                possiblyAnonymousClassDeclaration(node);
3✔
46
                return super.visit(node);
4✔
47
        }
48

49
        public boolean visit(AnonymousClassDeclaration node) {
50

51
                // ITypeBinding bnd = node.resolveBinding();
52
                ITypeBinding bnd = (ITypeBinding) StubBinding.getDeclarationBinding(node);
4✔
53
                org.moosetechnology.model.famix.famixjavaentities.Class fmx = this.dico.getFamixClass(bnd, Util.stringForAnonymousName(getAnonymousSuperTypeName(), context), /*owner*/(ContainerEntity) context.top());
14✔
54

55
                if ((fmx != null) && (bnd != null)) {
4!
56
                        ensureInheritances(bnd, fmx);
4✔
57

58
                        this.context.pushType(fmx);
4✔
59
                        return super.visit(node);
4✔
60
                } else {
61
                        return false;
×
62
                }
63
        }
64

65
        public void endVisit(AnonymousClassDeclaration node) {
66
                visitAnonymousClassDeclaration(node);
4✔
67
                super.endVisit(node);
3✔
68
        }
1✔
69

70
        public boolean visit(EnumDeclaration node) {
71
                ITypeBinding bnd = node.resolveBinding();
3✔
72
                org.moosetechnology.model.famix.famixjavaentities.Enum fmx = dico.getFamixEnum(bnd, node.getName().getIdentifier(), (TWithTypes) context.top());
12✔
73

74
                if ((fmx != null) && (bnd != null)) {
4!
75
                        // --------------- implicit superclass java.lang.Enum<> cannot use ensureInheritances(bnd,fmx)
76
                        TType superclass;
77
                        ITypeBinding supbnd = null;
2✔
78
                        supbnd = bnd.getSuperclass();
3✔
79
                        if (supbnd != null) {
2!
80
                                superclass = dico.ensureFamixType(supbnd);
6✔
81
                        } else {
82
                                Package javaLang = dico.ensureFamixPackageJavaLang(null);
×
83
                                superclass = dico.ensureFamixClass(/*bnd*/null, /*name*/"Enum", /*owner*/javaLang, /*isGeneric*/true, /*modifiers*/Modifier.ABSTRACT & Modifier.PUBLIC);
×
84
                        }
85
                        dico.ensureFamixInheritance((TWithInheritances) superclass, fmx, /*lastInheritance*/null, supbnd);
9✔
86

87
                        this.context.pushType(fmx);
4✔
88
                        return super.visit(node);
4✔
89
                }
90
                else {
91
                        return false;
×
92
                }
93
        }
94

95
        public void endVisit(EnumDeclaration node) {
96
                endVisitEnumDeclaration( node);
3✔
97
                super.endVisit(node);
3✔
98
        }
1✔
99

100
        public boolean visit(AnnotationTypeDeclaration node) {
101
                if (visitAnnotationTypeDeclaration( node) != null) {
4!
102
                        return super.visit(node);
4✔
103
                }
104
                else {
105
                        return false;
×
106
                }
107
        }
108

109
        public void endVisit(AnnotationTypeDeclaration node) {
110
                endVisitAnnotationTypeDeclaration( node);
3✔
111
                super.endVisit(node);
3✔
112
        }
1✔
113

114
        public boolean visit(MethodDeclaration node) {
115
                if (visitMethodDeclaration( node) != null) {
4!
116
                        return super.visit(node);
4✔
117
                } else {
118
                        return false;
×
119
                }
120
        }
121

122
        @Override
123
        public void endVisit(MethodDeclaration node) {
124
                endVisitMethodDeclaration(node);
3✔
125
        }
1✔
126

127
        @Override
128
        public boolean visit(Initializer node) {
129
                if (visitInitializer(node) != null) {
4!
130
                        return super.visit(node);
4✔
131
                }
132
                else {
133
                        return false;
×
134
                }
135
        }
136

137
        @Override
138
        public void endVisit(Initializer node) {
139
                endVisitInitializer(node);
3✔
140
        }
1✔
141

142
        // UTILITY METHODS
143

144
        protected void ensureInheritances(ITypeBinding bnd, TWithInheritances fmx) {
145
                TAssociation lastInheritance = null;
2✔
146

147
                if (bnd.isInterface()) {
3✔
148
                        return;
1✔
149
                }
150

151
                // --------------- superclass
152
                ITypeBinding supbnd = bnd.getSuperclass();
3✔
153
        TType type;
154
                if (supbnd != null) {
2✔
155
                        type = dico.ensureFamixType(supbnd);
6✔
156
                } else {
157

158
            if(bnd.getQualifiedName().equals("java.lang.Object")){
5!
159
                // Edge case: If we are parsing java.lang.Object, then we should not have an inheritance at all
NEW
160
                return;
×
161
            }
162

163
                        type = dico.ensureFamixClassObject(null);
5✔
164
                }
165
                lastInheritance = dico.ensureFamixInheritance((TWithInheritances) type, fmx, lastInheritance, supbnd);
9✔
166

167
                // --------------- interfaces
168
                dico.ensureImplementedInterfaces(bnd, (TType)fmx, null, lastInheritance);
8✔
169
        }
1✔
170
}
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