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

moosetechnology / VerveineJ / 15191557690

22 May 2025 04:10PM UTC coverage: 50.616% (+0.6%) from 49.972%
15191557690

push

github

web-flow
Merge pull request #127 from moosetechnology/new-generics-implementation

New generics implementation

1884 of 3956 branches covered (47.62%)

Branch coverage included in aggregate %.

513 of 1119 new or added lines in 53 files covered. (45.84%)

53 existing lines in 10 files now uncovered.

4277 of 8216 relevant lines covered (52.06%)

2.08 hits per line

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

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

3
import java.util.List;
4

5
import org.eclipse.jdt.core.dom.*;
6
import org.moosetechnology.model.famix.famixjavaentities.ContainerEntity;
7
import org.moosetechnology.model.famix.famixjavaentities.Exception;
8
import org.moosetechnology.model.famix.famixjavaentities.Method;
9
import org.moosetechnology.model.famix.famixjavaentities.Package;
10
import org.moosetechnology.model.famix.famixtraits.TNamedEntity;
11
import org.moosetechnology.model.famix.famixtraits.TThrowable;
12
import org.moosetechnology.model.famix.famixtraits.TType;
13
import org.moosetechnology.model.famix.famixtraits.TTypedEntity;
14

15
import fr.inria.verveine.extractor.java.EntityDictionary;
16
import fr.inria.verveine.extractor.java.VerveineJOptions;
17
import fr.inria.verveine.extractor.java.utils.NodeTypeChecker;
18

19
/** A visitor to record exceptions declared/thrown/caught.<br>
20
 * It is simpler than the other ref visitors because we only need to worry about methods
21
 * @author anquetil
22
 */
23
public class VisitorExceptionRef extends AbstractRefVisitor {
24

25
    public VisitorExceptionRef(EntityDictionary dico, VerveineJOptions options) {
26
        super(dico, options);
4✔
27
    }
1✔
28

29
    protected Package visitCompilationUnit(CompilationUnit node) {
UNCOV
30
        Package fmx = null;
×
31
        PackageDeclaration pckg = node.getPackage();
×
32
        if (pckg == null) {
×
33
            fmx = dico.getFamixPackageDefault();
×
34
        } else {
35
            fmx = (Package) dico.getEntityByKey(pckg.resolveBinding());
×
36
        }
37
        this.context.pushPckg(fmx);
×
38

39
        return fmx;
×
40
    }
41

42
    protected void endVisitCompilationUnit(CompilationUnit node) {
43
        this.context.popPckg();
×
44
        super.endVisit(node);
×
45
    }
×
46

47
    @Override
48
    public boolean visit(TypeDeclaration node) {
49
        if (visitTypeDeclaration( node) != null) {
4!
50
            return super.visit(node);
4✔
51
        } else {
52
            return false;
×
53
        }
54
    }
55

56
    @Override
57
    public void endVisit(TypeDeclaration node) {
58
        endVisitTypeDeclaration(node);
3✔
59
    }
1✔
60

61
        public boolean visit(MethodDeclaration node) {
62
                Method fmx = visitMethodDeclaration(node);
4✔
63
                if (fmx != null) {
2!
64
                    for (Type excep : (List<Type>) node.thrownExceptionTypes()) {
11✔
65
                            TThrowable excepFmx =  dico.asException(this.referredType(excep, (ContainerEntity) context.topType(), true, true));
13✔
66
                            dico.createFamixDeclaredException(fmx,excepFmx);
6✔
67
            }
1✔
68
                        return super.visit(node);
4✔
69
                } else {
70
                        return false;
×
71
                }
72
        }
73

74
        @Override
75
        public void endVisit(MethodDeclaration node) {
76
                endVisitMethodDeclaration(node);
3✔
77
        }
1✔
78

79
    @Override
80
    public boolean visit(ThrowStatement node) {
81
        Method meth = (Method) this.context.topMethod();
5✔
82
        TType thrownExceptionType = this.referredType(node.getExpression().resolveTypeBinding(), (TNamedEntity) context.topType(), true);
10✔
83
        TThrowable excepFmx;
84
        if (thrownExceptionType == null) {
2✔
85
            excepFmx = dico.ensureFamixException(null, "Throwable", null, false, EntityDictionary.UNKNOWN_MODIFIERS) ;
10✔
86
        }
87
        else {
88
        excepFmx = dico.asException( thrownExceptionType);}
5✔
89
        if (excepFmx != null) {
2!
90
                dico.createFamixThrownException(meth, excepFmx);
6✔
91
        }
92
        return super.visit(node);
4✔
93
    }
94

95
    /**
96
     *  CatchClause ::=
97
     *                catch ( FormalParameter ) Block
98
          *        The FormalParameter is represented by a SingleVariableDeclaration
99
          *
100
          * We set the type of the catchClause variable here because it would be more difficult in VisitorTypeRefRef
101
     */
102
    @Override
103
    public boolean visit(CatchClause node) {
104
        Method meth = (Method) this.context.topMethod();
5✔
105
        Type excepClass = node.getException().getType();
4✔
106
        if (meth != null) {
2✔
107
            TThrowable excepFmx = null;
2✔
108
            if ( NodeTypeChecker.isSimpleType(excepClass) || NodeTypeChecker.isQualifiedType(excepClass) ) {
3!
109
                excepFmx = dico.asException(referredType(excepClass, meth, true, true));
10✔
110
            }
111
            if (excepFmx != null) {
2!
112
                    dico.createFamixCaughtException(meth, excepFmx);
6✔
113
                    setVariableDeclaredType(node.getException(), (Exception)excepFmx);
6✔
114
            }
115
        }
116
            node.getBody().accept(this);
4✔
117

118
        return false;
2✔
119
    }
120

121
        public void setVariableDeclaredType(SingleVariableDeclaration varDecl, Exception fmxException) {
122
        IVariableBinding bnd = varDecl.resolveBinding();
3✔
123
                TTypedEntity fmx = (TTypedEntity) dico.getEntityByKey(bnd);
6✔
124
                if (fmx != null) {
2!
125
            ITypeBinding declaredTypeBinding = (bnd == null) ? null : bnd.getType();
5!
126
            dico.ensureFamixEntityTyping(declaredTypeBinding, fmx, fmxException);
7✔
127
                }
128
        }
1✔
129

130
}
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