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

moosetechnology / VerveineJ / 42893019655

10 Nov 2026 08:12PM UTC coverage: 55.582% (+2.6%) from 52.984%
42893019655

Pull #275

github

web-flow
Merge cd2f95be4 into ec7f62630
Pull Request #275: Setup mooseci on every PR

2253 of 4218 branches covered (53.41%)

Branch coverage included in aggregate %.

4891 of 8635 relevant lines covered (56.64%)

2.34 hits per line

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

75.95
/app/src/main/java/fr/inria/verveine/extractor/java/utils/Util.java
1
package fr.inria.verveine.extractor.java.utils;
2

3
import ch.akuhn.fame.MetaRepository;
4
import ch.akuhn.fame.fm3.MetaDescription;
5
import ch.akuhn.fame.fm3.PropertyDescription;
6
import ch.akuhn.fame.internal.RepositoryVisitor.UnknownElementError;
7
import fr.inria.verveine.extractor.java.EntityDictionary;
8
import org.eclipse.jdt.core.dom.ArrayType;
9
import org.eclipse.jdt.core.dom.NameQualifiedType;
10
import org.eclipse.jdt.core.dom.QualifiedType;
11
import org.eclipse.jdt.core.dom.SimpleType;
12
import org.moosetechnology.model.famix.famixtraits.TCanBeStub;
13
import org.moosetechnology.model.famix.famixtraits.TNamedEntity;
14

15
import java.io.File;
16
import java.lang.reflect.InvocationTargetException;
17
import java.util.Collection;
18
import java.util.stream.Collectors;
19

20
public class Util {
×
21

22
        public static MetaRepository metamodel;
23

24
        /**
25
         * helper to "normalize" an anonymous type name
26
         */
27
        public static String stringForAnonymousName(String anonymousSuperTypeName, EntityStack context) {
28
                String anonSuperTypeName = (anonymousSuperTypeName != null) ? anonymousSuperTypeName : context.topType().getName();
8 ✔
29
                return EntityDictionary.ANONYMOUS_NAME_PREFIX + "(" +anonSuperTypeName+")";
3 ✔
30
        }
31

32
        /**
33
         * Helper to compute the name of a JDT Type
34
         */
35
        public static String jdtTypeName(org.eclipse.jdt.core.dom.Type jdtType) {
36
                if (jdtType == null) {
2 !
37
                        return null;
×
38
                }
39

40
                if (jdtType.isPrimitiveType()) {
3 ✔
41
                        return jdtType.toString();
3 ✔
42
                } else if (jdtType.isSimpleType()) {
3 ✔
43
                        return ((SimpleType) jdtType).getName().getFullyQualifiedName();
5 ✔
44
                } else if (jdtType.isQualifiedType()) {
3 !
45
                        return ((QualifiedType) jdtType).getName().getIdentifier();
×
46
                } else if (jdtType.isNameQualifiedType()) {
3 ✔
47
                        return ((NameQualifiedType) jdtType).getName().getIdentifier();
5 ✔
48
                } else if (jdtType.isArrayType()) {
3 ✔
49
                        return jdtTypeName(((ArrayType) jdtType).getElementType());
5 ✔
50
                } else if (jdtType.isParameterizedType()) {
3 !
51
                        return jdtTypeName(((org.eclipse.jdt.core.dom.ParameterizedType) jdtType).getType());
5 ✔
52
                } else { // it is a WildCardType
53
                        if (((org.eclipse.jdt.core.dom.WildcardType) jdtType).isUpperBound()) {
×
54
                                return jdtTypeName(((org.eclipse.jdt.core.dom.WildcardType) jdtType).getBound());
×
55
                        } else {
56
                                return EntityDictionary.OBJECT_NAME;
×
57
                        }
58
                }
59
        }
60

61
        /**
62
         * sets <code>fmx</code> isStub property to <code>isStub</code> and goes up recusively to all parent entities
63
         */
64
        public static  <T extends TCanBeStub & TNamedEntity> void recursivelySetIsStub(T fmx, boolean isStub) {
65
                TCanBeStub owner;
66
                fmx.setIsStub(isStub);
4 ✔
67
                owner = getOwner(fmx);
4 ✔
68
                if ((owner != null) && (owner.getIsStub() != isStub)) {
7 ✔
69
                        recursivelySetIsStub((T) owner, isStub);
3 ✔
70
                }
71

72
        }
1 ✔
73

74
        public static <T extends TNamedEntity, X extends TNamedEntity> X getOwner(T entity) {
75
                Collection<PropertyDescription> propertyDescriptions = ((MetaDescription) metamodel.getDescription(entity.getClass())).allProperties()
6 ✔
76
                                .stream().filter(PropertyDescription::isContainer).collect(Collectors.toList());
7 ✔
77
                for (PropertyDescription propertyDescription : propertyDescriptions) {
10 ✔
78
                        try {
79
                                java.lang.reflect.Method method = entity.getClass().getMethod("get" + capitalizeString(propertyDescription.getName()));
10 ✔
80
                                T containerEntity = (T) method.invoke(entity);
7 ✔
81
                                if (containerEntity != null) {
2 ✔
82
                                        return (X) containerEntity;
2 ✔
83
                                }
84
                        } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
×
85
                                e.printStackTrace();
×
86
                        }
1 ✔
87
                }
1 ✔
88
                return null;
2 ✔
89
        }
90

91
        /**
92
         * The name of an implicitly declared class is not written in the source. The
93
         * JLS gives it the name of its compilation unit, which is also what the
94
         * compiler uses for the class file.
95
         */
96
        public static String typeNameFromSourceFile(String sourceFileName) {
97
                if (sourceFileName == null) {
2 !
98
                        return "";
×
99
                }
100
                String name = new File(sourceFileName).getName();
6 ✔
101
                int extension = name.lastIndexOf('.');
4 ✔
102
                return extension < 0 ? name : name.substring(0, extension);
7 !
103
        }
104

105
        public static String capitalizeString(String str) {
106
                String retStr = str;
2 ✔
107
                try {
108
                        retStr = str.substring(0, 1).toUpperCase() + str.substring(1);
10 ✔
109
                } catch (Exception ignored) {
×
110
                }
1 ✔
111
                return retStr;
2 ✔
112
        }
113

114
        public static void traceUnknownElementError(UnknownElementError err) {
115
                err.printStackTrace(); // repo.all(org.moosetechnology.model.famix.famixjavaentities.Method.class).size()
×
116
        }
×
117
}
118

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc