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

moosetechnology / VerveineJ / 14665386629

25 Apr 2025 01:09PM UTC coverage: 50.655% (+0.7%) from 49.972%
14665386629

Pull #127

github

web-flow
Merge 9c1f1ce46 into 5207a6c7c
Pull Request #127: New generics implementation

1878 of 3942 branches covered (47.64%)

Branch coverage included in aggregate %.

481 of 1066 new or added lines in 52 files covered. (45.12%)

53 existing lines in 10 files now uncovered.

4267 of 8189 relevant lines covered (52.11%)

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.EntityTyping;
8
import org.moosetechnology.model.famix.famixjavaentities.Exception;
9
import org.moosetechnology.model.famix.famixjavaentities.Method;
10
import org.moosetechnology.model.famix.famixjavaentities.Package;
11
import org.moosetechnology.model.famix.famixtraits.TNamedEntity;
12
import org.moosetechnology.model.famix.famixtraits.TThrowable;
13
import org.moosetechnology.model.famix.famixtraits.TType;
14
import org.moosetechnology.model.famix.famixtraits.TTypedEntity;
15

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

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

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

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

40
        return fmx;
×
41
    }
42

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

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

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

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

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

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

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

119
        return false;
2✔
120
    }
121

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

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