Skip to content

Commit

Permalink
Replace invoc towith invoc target.
Browse files Browse the repository at this point in the history
+ Deal with empty source anchors. Not sure the default 0 value is correct.
  • Loading branch information
ClotildeToullec committed Oct 10, 2024
1 parent bf62482 commit ddef008
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions src/Carrefour-FastAndBindingGenerator/CRFBinderVisitor.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -279,17 +279,24 @@ CRFBinderVisitor >> visitFASTJavaMethodEntity: aFASTJavaMethodEntity [

{ #category : 'visitor' }
CRFBinderVisitor >> visitFASTJavaMethodInvocation: aFASTJavaMethodInvocation [
(self sourceFamixEntity queryAllOutgoingInvocations
select: [ :invoc |
(invoc hasSourceAnchor
ifTrue: [ | sourceStartPos |
sourceStartPos := self sourceFamixEntityStartPo.
invoc sourceAnchor startPos - sourceStartPos >= (aFASTJavaMethodInvocation startPos - 1)
and: [ invoc sourceAnchor endPos - sourceStartPos <= (aFASTJavaMethodInvocation endPos + 1) ] ]
ifFalse: [ invoc to first name beginsWith: aFASTJavaMethodInvocation name ]) ])
ifNotEmpty: [ :collectionOfPotentialInvoc |
(collectionOfPotentialInvoc sorted: [ :invoc1 :invoc2 | invoc1 sourceAnchor intervalAsCharPos size > invoc2 sourceAnchor intervalAsCharPos size ]) first
fast: aFASTJavaMethodInvocation ].

(self sourceFamixEntity queryAllOutgoingInvocations select: [ :invoc |
invoc hasSourceAnchor
ifTrue: [
| sourceStartPos |
sourceStartPos := self sourceFamixEntityStartPo.
invoc sourceAnchor startPos - sourceStartPos
>= (aFASTJavaMethodInvocation startPos - 1) and: [
invoc sourceAnchor endPos - sourceStartPos
<= (aFASTJavaMethodInvocation endPos + 1) ] ]
ifFalse: [
invoc target first name beginsWith: aFASTJavaMethodInvocation name ] ])
ifNotEmpty: [ :collectionOfPotentialInvoc |
(collectionOfPotentialInvoc sorted: [ :invoc |
invoc sourceAnchor
ifNil: [ 0 ]
ifNotNil: [ :sourceAnchor | sourceAnchor intervalAsCharPos size ] ]
descending) first fast: aFASTJavaMethodInvocation ].
super visitFASTJavaMethodInvocation: aFASTJavaMethodInvocation
]

Expand Down

0 comments on commit ddef008

Please sign in to comment.