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

moosetechnology / VerveineJ / 20030831789

08 Dec 2025 02:05PM UTC coverage: 50.923% (-0.07%) from 50.991%
20030831789

Pull #178

github

web-flow
Merge 6433323b6 into ccd766c89
Pull Request #178: Some cleanings

1898 of 3934 branches covered (48.25%)

Branch coverage included in aggregate %.

90 of 105 new or added lines in 7 files covered. (85.71%)

2 existing lines in 2 files now uncovered.

4255 of 8149 relevant lines covered (52.21%)

2.11 hits per line

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

75.76
/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.QualifiedType;
10
import org.eclipse.jdt.core.dom.SimpleType;
11
import org.moosetechnology.model.famix.famixtraits.TCanBeStub;
12
import org.moosetechnology.model.famix.famixtraits.TNamedEntity;
13

14
import java.lang.reflect.InvocationTargetException;
15
import java.util.Collection;
16
import java.util.stream.Collectors;
17

18
public class Util {
×
19

20
        public static MetaRepository metamodel;
21

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

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

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

57
        public static  <T extends TCanBeStub & TNamedEntity> void recursivelySetIsStub(T fmx, boolean b) {
58
                TCanBeStub owner;
59
                fmx.setIsStub(b);
4✔
60
                owner = getOwner(fmx);
4✔
61
                if ((owner != null) && (owner.getIsStub() != b)) {
7✔
62
                        recursivelySetIsStub((T) owner, b);
3✔
63
                }
64

65
        }
1✔
66

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

84
        public static String capitalizeString(String str) {
85
                String retStr = str;
2✔
86
                try {
87
                        retStr = str.substring(0, 1).toUpperCase() + str.substring(1);
10✔
NEW
88
                } catch (Exception ignored) {
×
89
                }
1✔
90
                return retStr;
2✔
91
        }
92

93
        public static void traceUnknownElementError(UnknownElementError err) {
94
                err.printStackTrace(); // repo.all(org.moosetechnology.model.famix.famixjavaentities.Method.class).size()
×
95
        }
×
96
}
97

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

© 2025 Coveralls, Inc