3030import java .util .stream .Collectors ;
3131
3232import static org .digma .intellij .plugin .idea .psi .java .Constants .SPAN_BUILDER_FQN ;
33- import static org .digma .intellij .plugin .idea .psi .java .SpanDiscoveryUtils .filterNonRelevantMethodsForSpanDiscovery ;
34- import static org .digma .intellij .plugin .idea .psi .java .SpanDiscoveryUtils .filterNonRelevantReferencesForSpanDiscovery ;
33+ import static org .digma .intellij .plugin .idea .psi .java .JavaSpanDiscoveryUtils .filterNonRelevantMethodsForSpanDiscovery ;
34+ import static org .digma .intellij .plugin .idea .psi .java .JavaSpanDiscoveryUtils .filterNonRelevantReferencesForSpanDiscovery ;
3535
3636@ SuppressWarnings ("UnstableApiUsage" )
3737public class JavaSpanNavigationProvider implements Disposable {
@@ -111,7 +111,7 @@ private void buildStartSpanMethodCall() {
111111 startSpanReferences = filterNonRelevantReferencesForSpanDiscovery (startSpanReferences );
112112
113113 startSpanReferences .forEach (psiReference -> {
114- SpanInfo spanInfo = SpanDiscoveryUtils .getSpanInfoFromStartSpanMethodReference (project , psiReference );
114+ SpanInfo spanInfo = JavaSpanDiscoveryUtils .getSpanInfoFromStartSpanMethodReference (project , psiReference );
115115 if (spanInfo != null ) {
116116 int lineNumber = psiReference .getElement ().getTextOffset ();
117117 var location = new SpanLocation (spanInfo .getContainingFileUri (), lineNumber );
@@ -129,11 +129,14 @@ private void buildWithSpanAnnotation() {
129129 Query <PsiMethod > psiMethods = AnnotatedElementsSearch .searchPsiMethods (withSpanClass , GlobalSearchScope .projectScope (project ));
130130 psiMethods = filterNonRelevantMethodsForSpanDiscovery (psiMethods );
131131 psiMethods .forEach (psiMethod -> {
132- SpanInfo spanInfo = SpanDiscoveryUtils .getSpanInfoFromWithSpanAnnotatedMethod (psiMethod );
133- if (spanInfo != null ) {
134- int offset = psiMethod .getTextOffset ();
135- var location = new SpanLocation (spanInfo .getContainingFileUri (), offset );
136- spanLocations .put (spanInfo .getId (), location );
132+ List <SpanInfo > spanInfos = JavaSpanDiscoveryUtils .getSpanInfoFromWithSpanAnnotatedMethod (psiMethod );
133+ if (spanInfos != null ) {
134+ spanInfos .forEach (spanInfo -> {
135+ Log .log (LOGGER ::debug , "Found span info {} for method {}" ,spanInfo .getId (),spanInfo .getContainingMethod ());
136+ int offset = psiMethod .getTextOffset ();
137+ var location = new SpanLocation (spanInfo .getContainingFileUri (), offset );
138+ spanLocations .put (spanInfo .getId (), location );
139+ });
137140 }
138141 });
139142 }
@@ -209,8 +212,9 @@ private void buildStartSpanMethodCall(VirtualFile virtualFile) {
209212 startSpanReferences = filterNonRelevantReferencesForSpanDiscovery (startSpanReferences );
210213
211214 startSpanReferences .forEach (psiReference -> {
212- SpanInfo spanInfo = SpanDiscoveryUtils .getSpanInfoFromStartSpanMethodReference (project , psiReference );
215+ SpanInfo spanInfo = JavaSpanDiscoveryUtils .getSpanInfoFromStartSpanMethodReference (project , psiReference );
213216 if (spanInfo != null ) {
217+ Log .log (LOGGER ::debug , "Found span info {} in method {}" ,spanInfo .getId (),spanInfo .getContainingMethod ());
214218 int lineNumber = psiReference .getElement ().getTextOffset ();
215219 var location = new SpanLocation (spanInfo .getContainingFileUri (), lineNumber );
216220 spanLocations .put (spanInfo .getId (), location );
@@ -228,11 +232,14 @@ private void buildWithSpanAnnotation(VirtualFile virtualFile) {
228232 Query <PsiMethod > psiMethods = AnnotatedElementsSearch .searchPsiMethods (withSpanClass , GlobalSearchScope .fileScope (project , virtualFile ));
229233 psiMethods = filterNonRelevantMethodsForSpanDiscovery (psiMethods );
230234 psiMethods .forEach (psiMethod -> {
231- SpanInfo spanInfo = SpanDiscoveryUtils .getSpanInfoFromWithSpanAnnotatedMethod (psiMethod );
232- if (spanInfo != null ) {
233- int offset = psiMethod .getTextOffset ();
234- var location = new SpanLocation (spanInfo .getContainingFileUri (), offset );
235- spanLocations .put (spanInfo .getId (), location );
235+ List <SpanInfo > spanInfos = JavaSpanDiscoveryUtils .getSpanInfoFromWithSpanAnnotatedMethod (psiMethod );
236+ if (spanInfos != null ) {
237+ spanInfos .forEach (spanInfo -> {
238+ Log .log (LOGGER ::debug , "Found span info {} for method {}" ,spanInfo .getId (),spanInfo .getContainingMethod ());
239+ int offset = psiMethod .getTextOffset ();
240+ var location = new SpanLocation (spanInfo .getContainingFileUri (), offset );
241+ spanLocations .put (spanInfo .getId (), location );
242+ });
236243 }
237244 });
238245 }
0 commit comments