From ddef008c707c9c54071ea1e15d5eacbc0531ff49 Mon Sep 17 00:00:00 2001 From: ClotildeToullec Date: Thu, 10 Oct 2024 18:33:55 +0200 Subject: [PATCH] Replace `invoc to`with `invoc target`. + Deal with empty source anchors. Not sure the default 0 value is correct. --- .../CRFBinderVisitor.class.st | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/Carrefour-FastAndBindingGenerator/CRFBinderVisitor.class.st b/src/Carrefour-FastAndBindingGenerator/CRFBinderVisitor.class.st index 350054f..ece6937 100644 --- a/src/Carrefour-FastAndBindingGenerator/CRFBinderVisitor.class.st +++ b/src/Carrefour-FastAndBindingGenerator/CRFBinderVisitor.class.st @@ -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 ]