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

moosetechnology / VerveineJ / 23642838101

27 Mar 2026 10:52AM UTC coverage: 51.994% (-0.05%) from 52.039%
23642838101

Pull #205

github

web-flow
Merge 4adac8808 into d564a6404
Pull Request #205: Add support for primitive types in generics

1973 of 3970 branches covered (49.7%)

Branch coverage included in aggregate %.

12 of 35 new or added lines in 4 files covered. (34.29%)

234 existing lines in 2 files now uncovered.

4362 of 8214 relevant lines covered (53.1%)

2.15 hits per line

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

62.2
/app/src/main/java/fr/inria/verveine/extractor/java/FamixRequestor.java
1
package fr.inria.verveine.extractor.java;
2

3
import java.io.File;
4
import java.util.HashMap;
5
import java.util.Map;
6

7
import fr.inria.verveine.extractor.java.visitors.refvisitors.*;
8
import org.eclipse.jdt.core.dom.CompilationUnit;
9
import org.eclipse.jdt.core.dom.FileASTRequestor;
10

11
import ch.akuhn.fame.Repository;
12
import fr.inria.verveine.extractor.java.visitors.defvisitors.VisitorClassMethodDef;
13
import fr.inria.verveine.extractor.java.visitors.defvisitors.VisitorComments;
14
import fr.inria.verveine.extractor.java.visitors.defvisitors.VisitorPackageDef;
15
import fr.inria.verveine.extractor.java.visitors.defvisitors.VisitorVarsDef;
16

17
public class FamixRequestor extends FileASTRequestor {
18

19
        protected EntityDictionary famixDictionnary;
20

21
        protected VerveineJOptions options;
22
        
23
        /**
24
         * Maps the arguments (file names or dir names) to their absolute path (well actually it is the other way around)
25
         */
26
        protected Map<String, String> dirMap;
27
        protected Map<String, String> fileMap;
28

29
        public FamixRequestor(Repository famixRepo, VerveineJOptions options) {
30
                super();
2✔
31

32
                this.options = options;
3✔
33
                initFileMaps(options);
3✔
34
                this.famixDictionnary = new EntityDictionary(famixRepo);
6✔
35
        }
1✔
36

37
        protected void initFileMaps(VerveineJOptions options) {
38
                this.fileMap = new HashMap<String, String>();
5✔
39
                // initialization of the Map with the absolute paths
40
                for (String tempArgFile : options.argFiles)
11✔
41
                        this.fileMap.put(new File(tempArgFile).getAbsolutePath(), tempArgFile);
11✔
42

43
                this.dirMap = new HashMap<String, String>();
5✔
44
                // initialization of the Map with the absolute paths
45
                for (String tempArgDir : options.argPath) {
11✔
46
                        this.dirMap.put(new File(tempArgDir).getAbsolutePath(), tempArgDir);
10✔
47
                }
1✔
48
        }
1✔
49

50
        public void acceptAST(String sourceFilePath, CompilationUnit ast) {
51
                String path = relativePath(sourceFilePath);
4✔
52
                System.out.println("Processing file: " + path);
4✔
53

54
                ast.setProperty(EntityDictionary.SOURCE_FILENAME_PROPERTY, path);
4✔
55
                try {
56
                        ast.accept(new VisitorPackageDef(famixDictionnary, options));
9✔
57
                        ast.accept(new VisitorClassMethodDef(famixDictionnary, options));
9✔
58
                        
59
                        ast.accept(new VisitorVarsDef(famixDictionnary, options));
9✔
60
                        ast.accept(new VisitorComments(famixDictionnary, options));
9✔
61

62
                        ast.accept(new VisitorInheritanceRef(famixDictionnary, options));
9✔
63
                        ast.accept(new VisitorTypeRefRef(famixDictionnary, options));
9✔
64
                        ast.accept(new VisitorAccessRef(famixDictionnary, options));
9✔
65
                        ast.accept(new VisitorInvocRef(famixDictionnary, options));
9✔
66
                        ast.accept(new VisitorAnnotationRef(famixDictionnary, options));
9✔
67
                        ast.accept(new VisitorExceptionRef(famixDictionnary, options));
9✔
68

69
                } catch (Exception err) {
×
70
                        
NEW
71
                        if (options.isStrict())
×
72
                        {
NEW
73
                                throw err;
×
74
                        }
75
                        
76
                        err.printStackTrace();
×
77
                        System.err.println("*** " + getVisitorName(err, path) + " got exception: '" + err + "' while processing file: " + path);
×
78
                }
1✔
79
        }
1✔
80

81
        private String getVisitorName(Exception err, String path) {
82
                String visitorName = "";
×
83
                StackTraceElement[] stack = err.getStackTrace();
×
84
                if (stack.length == 0) {
×
85
                        return "Unknown Class";
×
86
                }
87

88
                for (int i = 0; (! visitorName.startsWith("Visitor")) && (i < stack.length); i++) {
×
89
                        visitorName = stack[i].getClassName() + ":" + stack[i].getLineNumber();
×
90
                        int dot = visitorName.lastIndexOf('.');
×
91
                        if (dot > 0) {
×
92
                                visitorName = visitorName.substring(dot + 1);
×
93
                        }
94

95
                }
96
                if (visitorName.startsWith("Visitor")) {
×
97
                        return visitorName;
×
98
                }
99
                else {
100
                        return stack[0].getClassName();  // did not find the Visitor in the stack, return the top frame
×
101
                }
102
        }
103

104
        /**
105
         * Search in the program args the corresponding path of the provided fileAbsolutePath
106
         * @param fileAbsolutePath the absolute path of a parsed file
107
         * @return the path of the same file relative to the appropriate verveinej argument
108
         */
109
        private String relativePath(String fileAbsolutePath) {
110
                File file = new File(fileAbsolutePath);
5✔
111
                String fullPath = file.getAbsolutePath();
3✔
112

113
                if (this.fileMap.containsKey(fullPath)) {
5✔
114
                        // parsed file was an argument of verveinej, return the path that was given as argument
115
                        return this.fileMap.get(fullPath);
6✔
116
                }
117

118
                // file belongs to a directory that was a verveinej arg
119
                // need to find back this arg
120
                while (file != null) {
2!
121
                        String key = file.getAbsolutePath();
3✔
122

123
                        if (this.dirMap.containsKey(key)) {
5✔
124
                                // relative path = verveineJ arg + local-path-to-the-file
125
                                if (!this.dirMap.get(key).endsWith(File.separator))
8✔
126
                                        return this.dirMap.get(key) + "/" + fullPath.substring(key.length() + 1);
13✔
127
                                else
128
                                        return this.dirMap.get(key) + fullPath.substring(key.length() + 1);
13✔
129
                        } else
130
                                file = file.getParentFile();
3✔
131
                }
1✔
132
                return fullPath;
×
133
        }
134
}
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