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

moosetechnology / VerveineJ / 20993219095

14 Jan 2026 11:56AM UTC coverage: 51.4% (+0.2%) from 51.203%
20993219095

Pull #190

github

web-flow
Merge 06681983b into c134c85f9
Pull Request #190: fix #186, rolling back some of the changes in #184

1931 of 3948 branches covered (48.91%)

Branch coverage included in aggregate %.

13 of 14 new or added lines in 4 files covered. (92.86%)

2 existing lines in 2 files now uncovered.

4294 of 8163 relevant lines covered (52.6%)

2.12 hits per line

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

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

3
import fr.inria.verveine.extractor.java.EntityDictionary;
4
import fr.inria.verveine.extractor.java.VerveineJOptions;
5
import fr.inria.verveine.extractor.java.utils.ImplicitVarBinding;
6
import fr.inria.verveine.extractor.java.utils.NodeTypeChecker;
7

8
import org.eclipse.jdt.core.dom.ASTNode;
9
import org.eclipse.jdt.core.dom.AnnotationTypeDeclaration;
10
import org.eclipse.jdt.core.dom.AnnotationTypeMemberDeclaration;
11
import org.eclipse.jdt.core.dom.AnonymousClassDeclaration;
12
import org.eclipse.jdt.core.dom.ArrayAccess;
13
import org.eclipse.jdt.core.dom.AssertStatement;
14
import org.eclipse.jdt.core.dom.Assignment;
15
import org.eclipse.jdt.core.dom.ClassInstanceCreation;
16
import org.eclipse.jdt.core.dom.CompilationUnit;
17
import org.eclipse.jdt.core.dom.DoStatement;
18
import org.eclipse.jdt.core.dom.EnhancedForStatement;
19
import org.eclipse.jdt.core.dom.EnumConstantDeclaration;
20
import org.eclipse.jdt.core.dom.EnumDeclaration;
21
import org.eclipse.jdt.core.dom.Expression;
22
import org.eclipse.jdt.core.dom.FieldAccess;
23
import org.eclipse.jdt.core.dom.FieldDeclaration;
24
import org.eclipse.jdt.core.dom.ForStatement;
25
import org.eclipse.jdt.core.dom.IBinding;
26
import org.eclipse.jdt.core.dom.IVariableBinding;
27
import org.eclipse.jdt.core.dom.IfStatement;
28
import org.eclipse.jdt.core.dom.InfixExpression;
29
import org.eclipse.jdt.core.dom.Initializer;
30
import org.eclipse.jdt.core.dom.LambdaExpression;
31
import org.eclipse.jdt.core.dom.MethodDeclaration;
32
import org.eclipse.jdt.core.dom.MethodInvocation;
33
import org.eclipse.jdt.core.dom.PostfixExpression;
34
import org.eclipse.jdt.core.dom.PrefixExpression;
35
import org.eclipse.jdt.core.dom.QualifiedName;
36
import org.eclipse.jdt.core.dom.ReturnStatement;
37
import org.eclipse.jdt.core.dom.SimpleName;
38
import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
39
import org.eclipse.jdt.core.dom.SwitchCase;
40
import org.eclipse.jdt.core.dom.SwitchStatement;
41
import org.eclipse.jdt.core.dom.SynchronizedStatement;
42
import org.eclipse.jdt.core.dom.ThisExpression;
43
import org.eclipse.jdt.core.dom.ThrowStatement;
44
import org.eclipse.jdt.core.dom.TypeDeclaration;
45
import org.eclipse.jdt.core.dom.TypeLiteral;
46
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
47
import org.eclipse.jdt.core.dom.WhileStatement;
48
import org.moosetechnology.model.famix.famixjavaentities.Attribute;
49
import org.moosetechnology.model.famix.famixjavaentities.ContainerEntity;
50
import org.moosetechnology.model.famix.famixjavaentities.Enum;
51
import org.moosetechnology.model.famix.famixjavaentities.EnumValue;
52
import org.moosetechnology.model.famix.famixjavaentities.ImplicitVariable;
53
import org.moosetechnology.model.famix.famixjavaentities.LocalVariable;
54
import org.moosetechnology.model.famix.famixjavaentities.Method;
55
import org.moosetechnology.model.famix.famixjavaentities.Parameter;
56
import org.moosetechnology.model.famix.famixtraits.TAccess;
57
import org.moosetechnology.model.famix.famixtraits.TMethod;
58
import org.moosetechnology.model.famix.famixtraits.TNamedEntity;
59
import org.moosetechnology.model.famix.famixtraits.TStructuralEntity;
60
import org.moosetechnology.model.famix.famixtraits.TWithAttributes;
61

62
import java.util.List;
63

64
/**
65
 * A visitor that extracts accesses to variables.
66
 * One difficulty is that variable are often SimpleName nodes
67
 * But many other things are also SimpleName nodes (ex: name of an invoked method)
68
 * So we need to differentiate them. The choice has been made to do this in the parent nodes of the SimpleName nodes
69
 */
70
public class VisitorAccessRef extends AbstractRefVisitor {
71

72
        /**
73
         * Whether a variable access is lhs (write) or not
74
         */
75
        protected boolean inAssignmentLHS = false;
3✔
76

77
        /**
78
         * Counts in how many nested lambdas we are
79
         * This is needed because Lambdas parameters are currently considered as local variables whereas JDT (rightly) reports them as parameters
80
         */
81
        private int inLambda = 0;
3✔
82

83
        public VisitorAccessRef(EntityDictionary dico, VerveineJOptions options) {
84
                super(dico, options);
4✔
85
                this.inLambda = 0;
3✔
86
        }
1✔
87

88
        // VISITOR METHODS
89

90
        @Override
91
        public boolean visit(CompilationUnit node) {
92
                visitCompilationUnit(node);
4✔
93
                return super.visit(node);
4✔
94
        }
95

96
        @Override
97
        public void endVisit(CompilationUnit node) {
98
                endVisitCompilationUnit(node);
3✔
99
        }
1✔
100

101
        @SuppressWarnings("unchecked")
102
        @Override
103
        public boolean visit(TypeDeclaration node) {
104
                if (visitTypeDeclaration( node) != null) {
4!
105
            visitNodeList(node.bodyDeclarations());
4✔
106
                }
107
                return false;
2✔
108
        }
109

110
        @Override
111
        public void endVisit(TypeDeclaration node) {
112
                endVisitTypeDeclaration(node);
3✔
113
        }
1✔
114

115
        @Override
116
        public boolean visit(ClassInstanceCreation node) {
117
                possiblyAnonymousClassDeclaration( node);
3✔
118
        visitIfNotNull(node.getExpression());
4✔
119
        for (Object arg : node.arguments()) {
10✔
120
            if (NodeTypeChecker.isSimpleName((ASTNode) arg)) {
4✔
121
                visitIfNotNull((ASTNode) arg);
5✔
122
            }
123
            else {
124
                    ((ASTNode) arg).accept(this);
4✔
125
                        }
126
        }
1✔
127
        if (node.getAnonymousClassDeclaration() != null) {
3✔
128
            node.getAnonymousClassDeclaration().accept(this);
4✔
129
        }
130
                return false;
2✔
131
        }
132

133
        @SuppressWarnings("unchecked")
134
        @Override
135
        public boolean visit(AnonymousClassDeclaration node) {
136
                if (visitAnonymousClassDeclaration( node) != null) {
4!
137
            visitNodeList(node.bodyDeclarations());
4✔
138
        }
139

140
                        return false;
2✔
141

142
        }
143

144
        @Override
145
        public void endVisit(AnonymousClassDeclaration node) {
146
                endVisitAnonymousClassDeclaration( node);
3✔
147
        }
1✔
148

149
        @SuppressWarnings("unchecked")
150
        @Override
151
        public boolean visit(EnumDeclaration node) {
152
                if (visitEnumDeclaration( node) != null) {
4!
153
            // no need to visit node.enumConstants() in this visitor
154
            visitNodeList(node.bodyDeclarations());
4✔
155
        }
156
                return false;
2✔
157
        }
158

159
    @Override
160
        public void endVisit(EnumDeclaration node) {
161
                endVisitEnumDeclaration( node);
3✔
162
        }
1✔
163

164
        @Override
165
        public boolean visit(AnnotationTypeDeclaration node) {
166
                if (visitAnnotationTypeDeclaration( node) != null) {
4!
167
                        return super.visit(node);
4✔
168
                }
169
                else {
170
                        return false;
×
171
                }
172
        }
173

174
        @Override
175
        public void endVisit(AnnotationTypeDeclaration node) {
176
                endVisitAnnotationTypeDeclaration(node);
3✔
177
        }
1✔
178

179
        public boolean visit(AnnotationTypeMemberDeclaration node) {
180
                if (visitAnnotationTypeMemberDeclaration( node) != null) {
4!
181
            visitIfNotNull(node.getDefault());
4✔
182
        }
183
                return false;
2✔
184
        }
185

186
        public void endVisit(AnnotationTypeMemberDeclaration node) {
187
                this.context.popAnnotationMember();
4✔
188
                super.endVisit(node);
3✔
189
        }
1✔
190

191
        public boolean visit(MethodDeclaration node) {
192
                Method fmx = visitMethodDeclaration( node);
4✔
193

194
                if (fmx != null) {
2!
195
                        if (node.getBody() != null) {
3✔
196
                                context.setLastAccess(null);
4✔
197
                node.getBody().accept(this);
4✔
198
                        }
199
        }
200
        return false;
2✔
201
        }
202

203
        @Override
204
        public void endVisit(MethodDeclaration node) {
205
                endVisitMethodDeclaration(node);
3✔
206
        }
1✔
207

208
        @Override
209
        public boolean visit(Initializer node) {
210
                if (visitInitializer(node) != null) {
4!
211
                        node.getBody().accept(this);
4✔
212
                }
213
                return false;
2✔
214
        }
215

216
        @Override
217
        public void endVisit(Initializer node) {
218
                endVisitInitializer(node);
3✔
219
        }
1✔
220

221
    /**
222
         * <pre>
223
         * {@code
224
     * MethodInvocation ::=
225
     *      [ Expression . ]
226
     *          [ < Type { , Type } > ]
227
     *          Identifier ( [ Expression { , Expression } ] )
228
     * }
229
         * </pre>
230
         **/
231
        @Override
232
        public boolean visit(MethodInvocation node) {
233
        visitIfNotNull( node.getExpression());
4✔
234
        for (Object arg : node.arguments()) {
10✔
235
            visitIfNotNull((ASTNode) arg);
4✔
236
        }
1✔
237
                return false;  // already visited the interesting children
2✔
238
        }
239

240
        /**
241
         * Currently not defining lambdas. Only parse their body and consider their parameters as local variables
242
         * of the parent method
243
         *<pre>
244
         * {@code
245
         *  LambdaExpression:
246
         *     Identifier -> Body
247
         *     ( [ Identifier { , Identifier } ] ) -> Body
248
         *     ( [ FormalParameter { , FormalParameter } ] ) -> Body
249
         * }
250
         * </pre>
251
         */
252
        @Override
253
        public boolean visit(LambdaExpression node) {
254
                inLambda++;
6✔
255
                node.getBody().accept(this);
4✔
256
                inLambda--;
6✔
257
                return false;  // only visit body of lambda
2✔
258
        }
259

260
        /**
261
         *  FieldDeclaration ::=
262
         *     [Javadoc] { ExtendedModifier } Type VariableDeclarationFragment
263
         *          { , VariableDeclarationFragment } ;
264
         */
265
        @SuppressWarnings("unchecked")
266
        @Override
267
        public boolean visit(FieldDeclaration node) {
268
            if (hasInitBlock(node)) {   // true if hasInitializer + recovers EntityDictionary.INIT_BLOCK_NAME method
4✔
269
            visitNodeList(node.fragments());
4✔
270
        }
271
        return false;
2✔
272
        }
273

274
        @Override
275
        public void endVisit(FieldDeclaration node) {
276
                endVisitFieldDeclaration(node);
3✔
277
        }
1✔
278

279
        public boolean visit(EnumConstantDeclaration node) {
NEW
280
        return visitEnumConstantDeclaration(node);
×
281
        }
282

283
        public void endVisit(EnumConstantDeclaration node) {
284
                endVisitEnumConstantDeclaration(node);
×
285
        }
×
286

287
        public boolean visit(FieldAccess node) {
288
            visitIfNotNull(node.getExpression());
4✔
289
                TMethod accessor = this.context.topMethod();
4✔
290
                IVariableBinding bnd = node.resolveFieldBinding();
3✔
291
                // FIXME if bnd == null we have a problem
292
                ensureAccessedStructEntity(bnd, node.getName().getIdentifier(), /*typ*/null, /*owner*/null, accessor);
10✔
293
                TAccess lastAccess = context.getLastAccess();
4✔
294
                if ( (options.withAnchors(VerveineJOptions.AnchorOptions.assoc))
8!
295
                                // check that lastAccess corresponds to current one
296
                                && (lastAccess != null) && (lastAccess.getAccessor() == accessor)
4!
297
                                && ((TNamedEntity) (lastAccess.getCandidates().iterator().next())).getName().equals(node.getName().getIdentifier())) {
10✔
298
                        dico.addSourceAnchor(lastAccess, node);
6✔
299
                }
300
                return false;
2✔
301
        }
302

303
        /*
304
         * Could be a FieldAccess (see JDT javadoc: class FieldAccess) 
305
         */
306
        public boolean visit(QualifiedName node) {
307
                IBinding bnd = node.resolveBinding();
3✔
308
                if ( (bnd != null) && (bnd.getKind() == IBinding.VARIABLE) ) {
6✔
309
                        // could be a field or an enumValue
310
                        TMethod accessor = this.context.topMethod();
4✔
311
                        ensureAccessedStructEntity((IVariableBinding) bnd, node.getName().getIdentifier(), /*typ*/null,
11✔
312
                                        /*owner*/null, accessor);
313
                        TAccess lastAccess = context.getLastAccess();
4✔
314
                        if ( (options.withAnchors(VerveineJOptions.AnchorOptions.assoc))
8!
315
                                        // check that lastAccess corresponds to current one
316
                                        && (lastAccess != null) && (lastAccess.getAccessor() == accessor)
4!
317
                                        && (((TNamedEntity) (lastAccess.getCandidates().iterator().next())).getName().equals(node.getName().getIdentifier()))) {
10!
318
                                dico.addSourceAnchor(lastAccess, node);
6✔
319
                        }
320
                }
321
                return false;
2✔
322
        }
323

324
    @SuppressWarnings("unchecked")
325
    public boolean visit(InfixExpression node) {
326
        visitIfNotNull( node.getLeftOperand());
4✔
327
        visitIfNotNull( node.getRightOperand());
4✔
328
        if (node.hasExtendedOperands()) {
3✔
329
            for (Expression op : (List<Expression>) node.extendedOperands()) {
11✔
330
                visitIfNotNull( op);
3✔
331
            }
1✔
332
        }
333
        return false;
2✔
334
    }
335

336
    @Override
337
    public boolean visit(PrefixExpression node) {
338
        visitIfNotNull( node.getOperand());
4✔
339
        return false;
2✔
340
    }
341

342
    @Override
343
    public boolean visit(PostfixExpression node) {
344
        visitIfNotNull( node.getOperand());
4✔
345
        return false;
2✔
346
    }
347

348
        // "SomeClass.class"
349
        public boolean visit(TypeLiteral node) {
350
                Attribute accessed = dico.getFamixAttribute(null, "class", dico.getFamixMetaClass(null));
10✔
351
                if (accessed != null) {
2!
352
                        createAccess(/*accessor*/context.topMethod(), accessed, inAssignmentLHS);
8✔
353
                }
354

355
                return super.visit(node);
4✔
356
        }
357

358
        public boolean visit(AssertStatement node) {
359
        visitIfNotNull( node.getExpression());
×
360
        visitIfNotNull( node.getMessage());
×
361
                return false;
×
362
        }
363

364
        public boolean visit(Assignment node) {
365
        visitAssignment(node.getLeftHandSide(), node.getRightHandSide());
6✔
366
                return false;
2✔
367
        }
368

369
    public boolean visit(ArrayAccess node) {
370
                // an array might be accessed in writing (see visit(Assignment node) ),
371
                // but it's index is accessed in reading
372
                boolean tmp = inAssignmentLHS;
3✔
373

374
                node.getArray().accept(this);
4✔
375

376
                inAssignmentLHS = false;  // array index is not lhs of an assignement
3✔
377
        visitIfNotNull( node.getIndex());
4✔
378
                inAssignmentLHS = tmp;
3✔
379

380
                return false;
2✔
381
        }
382

383
        public boolean visit(DoStatement node) {
384
        visitIfNotNull( node.getExpression());
×
385
        node.getBody().accept(this);
×
386
                return false;
×
387
        }
388

389
        public boolean visit(EnhancedForStatement node) {
390
        visitIfNotNull( node.getExpression());
4✔
391
        node.getBody().accept(this);
4✔
392
        return false;
2✔
393
        }
394

395
        @SuppressWarnings("unchecked")
396
        public boolean visit(ForStatement node) {
397
        visitNodeList(node.initializers());
4✔
398
        visitIfNotNull( node.getExpression());
4✔
399
        visitNodeList(node.updaters());
4✔
400
        node.getBody().accept(this);
4✔
401
        return false;
2✔
402
    }
403

404
        public boolean visit(IfStatement node) {
405
        visitIfNotNull( node.getExpression());
4✔
406
        node.getThenStatement().accept(this);
4✔
407
        if (node.getElseStatement() != null) {
3✔
408
            node.getElseStatement().accept(this);
4✔
409
        }
410
        return false;
2✔
411
    }
412

413
        public boolean visit(ReturnStatement node) {
414
        visitIfNotNull( node.getExpression());
4✔
415
        return false;
2✔
416
        }
417

418
        public boolean visit(SwitchCase node) {
419
        visitIfNotNull( node.getExpression());
4✔
420
        return false;
2✔
421
        }
422

423
        @SuppressWarnings("unchecked")
424
        public boolean visit(SwitchStatement node) {
425
        visitIfNotNull( node.getExpression());
4✔
426
        visitNodeList(node.statements());
4✔
427
        return false;
2✔
428
        }
429

430
        public boolean visit(SynchronizedStatement node) {
431
        visitIfNotNull(node.getExpression());
×
432
        node.getBody().accept(this);
×
433
        return false;
×
434
        }
435

436
        public boolean visit(WhileStatement node) {
437
        visitIfNotNull(node.getExpression());
4✔
438
        node.getBody().accept(this);
4✔
439
        return false;
2✔
440
        }
441

442
        @Override
443
        public boolean visit(ThrowStatement node) {
444
                visitIfNotNull( node.getExpression());
4✔
445
                return false;
2✔
446
        }
447

448
        @Override
449
        public boolean visit(ThisExpression node) {
450
                IBinding bnd = ImplicitVarBinding.getInstance(context.topMethod(), EntityDictionary.THIS_NAME);
6✔
451
                ImplicitVariable fmx = dico.ensureFamixImplicitVariable(
8✔
452
                                bnd, 
453
                                EntityDictionary.THIS_NAME,
454
                                this.context.topType(), 
3✔
455
                                context.topMethod());
1✔
456
                if (fmx != null) {
2!
457
                        TMethod accessor = this.context.topMethod();
4✔
458

459
                        createAccess(accessor, fmx, inAssignmentLHS);
6✔
460

461
                        TAccess lastAccess = context.getLastAccess();
4✔
462
                        if ( (options.withAnchors(VerveineJOptions.AnchorOptions.assoc)) && (lastAccess != null) ) {
7!
463
                                dico.addSourceAnchor(lastAccess, node.getParent());
7✔
464
                        }
465
                }
466

467
                return false;
2✔
468
        }
469

470
        @Override
471
        public boolean visit(SingleVariableDeclaration node) {
472
                if (node.getInitializer() != null) {
3!
473
            visitAssignment(node.getName(), node.getInitializer());
×
474
                }
475
                return false;
2✔
476
        }
477

478
        @Override
479
        public boolean visit(VariableDeclarationFragment node) {
480
                if (node.getInitializer() != null) {
3✔
481
            visitAssignment(node.getName(), node.getInitializer());
6✔
482
                }
483
                return false;
2✔
484
        }
485

486
        @Override
487
        public boolean visit(SimpleName node) {
488
        //System.err.println("visit(SimpleName)");
489
        IBinding bnd = node.resolveBinding();
3✔
490
        if ( (bnd != null) && (bnd.getKind() == IBinding.VARIABLE) && (context.topMethod() != null) ) {
10!
491
            // could be a variable, a field, an enumValue, ...
492
            TMethod accessor = this.context.topMethod();
4✔
493
            ensureAccessedStructEntity((IVariableBinding) bnd, node.getIdentifier(), /*typ*/null, /*owner*/null,
10✔
494
                    accessor);
495
            TAccess lastAccess = context.getLastAccess();
4✔
496
            if ( options.withAnchors(VerveineJOptions.AnchorOptions.assoc)
8✔
497
                    // check that lastAccess corresponds to current one
498
                    && (lastAccess != null) && (lastAccess.getAccessor() == accessor)
4!
499
                    && (((TNamedEntity) (lastAccess.getCandidates().iterator().next())).getName().equals(node.getIdentifier()))) {
9✔
500
                dico.addSourceAnchor(lastAccess, node);
6✔
501
            }
502
        }
503
                return false;
2✔
504
        }
505

506
        // UTILITY METHODS
507

508
        private void visitIfNotNull(ASTNode node) {
509
                if (node != null) {
2✔
510
                        node.accept(this);
3✔
511
                }
512
        }
1✔
513

514
        private void visitAssignment(Expression lhs, Expression rhs) {
515
                inAssignmentLHS = true;
3✔
516
                visitIfNotNull(lhs);
3✔
517
                inAssignmentLHS = false;
3✔
518

519
                visitIfNotNull(rhs);
3✔
520
        }
1✔
521

522
        private TStructuralEntity ensureAccessedStructEntity(IVariableBinding bnd, String name,
523
                                                                                                                 org.moosetechnology.model.famix.famixjavaentities.Type typ, ContainerEntity owner, TMethod accessor) {
524
                TStructuralEntity accessed = null;
2✔
525

526
                if (bnd == null) {
2✔
527
                        // no way to know if it should be an attribute, EnumValue, variable, ...
528
                        return null;
2✔
529
                } else {
530
                        bnd = bnd.getVariableDeclaration();
3✔
531
                }
532

533
                // could also test: "owner instanceof Enum" in case bnd == null
534
                if (bnd.isEnumConstant()) {
3✔
535
                        accessed = dico.ensureFamixEnumValue(bnd, name, (Enum) owner);
9✔
536
                } else if (bnd.isField()) {
3✔
537
                        accessed = dico.ensureFamixAttribute(bnd, name, typ, (TWithAttributes) owner);
9✔
538
                        if ((accessed != null) && (((Attribute) accessed).getParentType() == null)
6!
539
                                        && (((Attribute) accessed).getName().equals("length"))) {
×
540
                                // special case: length attribute of arrays in Java
541
                                ((Attribute) accessed).setParentType(dico.ensureFamixClassArray());
×
542
                        }
543
                } else if (bnd.isParameter() && notInALambda()) {
6✔
544
                        accessed = dico.ensureFamixParameter(bnd, name, typ, (Method) owner);
10✔
545
                } else {
546
                        // it seems it is a variable.
547
                        // if it is not already defined, we assume we are not interested
548
                        accessed = (TStructuralEntity) dico.getEntityByKey(bnd);
6✔
549
                }
550

551
                createAccess(accessor, accessed, inAssignmentLHS);
6✔
552

553
                return accessed;
2✔
554
        }
555

556
        /**
557
         * Creates a FamixAccess between an accessor and an accessed. Checks before that we are not in a local access to ignore.
558
         *
559
         * @param accessor -- the method accessing
560
         * @param accessed -- the variable accessed
561
         * @param isLHS    -- whether the access occurs on the LeftHandSide of an assignement (and therefore is a write access)
562
         */
563
        private void createAccess(TMethod accessor, TStructuralEntity accessed, boolean isLHS) {
564
                // create local accesses?
565
                if ((accessed != null) && (accessor != null)) {
4✔
566
                        if (options.withLocals() || (! localVariable(accessed, accessor)) ) {
9✔
567
                                context.setLastAccess(
10✔
568
                                                dico.addFamixAccess(accessor, (TStructuralEntity) accessed, /*isWrite*/isLHS, context.getLastAccess()));
2✔
569
                        }
570
                }
571
        }
1✔
572

573
        private boolean localVariable(TStructuralEntity accessed, TMethod accessor) {
574
                // TODO see issue 11 (https://github.com/NicolasAnquetil/VerveineJ/issues/11)
575

576
                // This is ugly.. but it allows us to not rewrite method in generated code
577
                if (accessed instanceof ImplicitVariable) {
3✔
578
                        return false;
2✔
579
                } else if (accessed instanceof Attribute && ((Attribute) accessed).getParentType() == accessor) {
8!
580
                        return true;
×
581
                } else if (accessed instanceof EnumValue && ((EnumValue) accessed).getParentEnum() == accessor) {
8!
582
                        return true;
×
583
                } 
584
                // Benoit Verhaeghe: Has been removed between VerveineJ 3.0.0 and VerveineJ 3.0.1
585
                // else if (accessed instanceof GlobalVariable && ((GlobalVariable) accessed).getParentScope() == accessor) {
586
                //         return true;
587
                // } 
588
                else if (accessed instanceof ImplicitVariable && ((ImplicitVariable) accessed).getParentBehaviouralEntity() == accessor) {
3!
589
                        return true;
×
590
                } else if (accessed instanceof LocalVariable && ((LocalVariable) accessed).getParentBehaviouralEntity() == accessor) {
8!
591
                        return true;
2✔
592
                } else if (accessed instanceof Parameter && ((Parameter) accessed).getParentBehaviouralEntity() == accessor) {
8!
593
                        return true;
2✔
594
                }
595
                if (((TNamedEntity) accessor.getParentType()).getName().startsWith(EntityDictionary.ANONYMOUS_NAME_PREFIX)) {
7✔
596
                        return localVariable(accessed, ((Method) ((org.moosetechnology.model.famix.famixjavaentities.Type) accessor.getParentType()).getTypeContainer()));
9✔
597
                }
598
                return false;
2✔
599
        }
600

601
        protected boolean notInALambda() {
602
                return (inLambda == 0);
7✔
603
        }
604

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