@@ -96,64 +96,41 @@ public List<LocationLink> getDefinitions(CancelChecker cancelToken, IJavaProject
96
96
if (n instanceof StringLiteral ) {
97
97
StringLiteral valueNode = (StringLiteral ) n ;
98
98
ASTNode parent = ASTUtils .getNearestAnnotationParent (valueNode );
99
-
100
99
if (parent != null && parent instanceof Annotation ) {
100
+ List <LocationLink > locationLink = new ArrayList <>();
101
101
Annotation a = (Annotation ) parent ;
102
102
IAnnotationBinding binding = a .resolveAnnotationBinding ();
103
103
if (binding != null && binding .getAnnotationType () != null
104
104
&& Annotations .VALUE .equals (binding .getAnnotationType ().getQualifiedName ())) {
105
- return parseSpelAndFetchLocation (cancelToken , project , cu , offset );
105
+ Arrays .stream (spelExtractors ).map (e -> {
106
+ if (a instanceof SingleMemberAnnotation )
107
+ return e .getSpelRegion ((SingleMemberAnnotation ) a );
108
+ else if (a instanceof NormalAnnotation )
109
+ return e .getSpelRegion ((NormalAnnotation ) a );
110
+ return Optional .<Snippet >empty ();
111
+ }).filter (o -> o .isPresent ()).map (o -> o .get ())
112
+ .filter (snippet -> {
113
+ int tokenEndIndex = snippet .offset () + snippet .text ().length ();
114
+ return snippet .offset () <= (offset ) && (offset ) <= tokenEndIndex ;
115
+ }).forEach (snippet -> {
116
+ List <TokenData > beanReferenceTokens = computeTokens (snippet , offset );
117
+ if (beanReferenceTokens != null && beanReferenceTokens .size () > 0 ) {
118
+ locationLink .addAll (findLocationLinksForBeanRef (project , offset , beanReferenceTokens ));
119
+ }
120
+
121
+ Optional <Tuple2 <String , String >> result = parseAndExtractMethodClassPairFromSpel (snippet ,
122
+ offset );
123
+ result .ifPresent (tuple -> {
124
+ locationLink .addAll (findLocationLinksForMethodRef (tuple .getT1 (), tuple .getT2 (), project ));
125
+ });
126
+ });
127
+ return locationLink ;
106
128
}
107
129
}
108
130
}
109
131
return Collections .emptyList ();
110
132
}
111
133
112
- private List <LocationLink > parseSpelAndFetchLocation (CancelChecker cancelToken , IJavaProject project ,
113
- CompilationUnit cu , int offset ) {
114
- List <LocationLink > locationLink = new ArrayList <>();
115
- cu .accept (new ASTVisitor () {
116
- @ Override
117
- public boolean visit (SingleMemberAnnotation node ) {
118
- Arrays .stream (spelExtractors ).map (e -> e .getSpelRegion (node )).filter (o -> o .isPresent ())
119
- .map (o -> o .get ()).forEach (snippet -> {
120
- List <TokenData > beanReferenceTokens = computeTokens (snippet , offset );
121
- if (beanReferenceTokens != null && beanReferenceTokens .size () > 0 ) {
122
- locationLink .addAll (findLocationLinksForBeanRef (project , offset , beanReferenceTokens ));
123
- }
124
-
125
- Optional <Tuple2 <String , String >> result = parseAndExtractMethodClassPairFromSpel (snippet ,
126
- offset );
127
- result .ifPresent (tuple -> {
128
- locationLink .addAll (findLocationLinksForMethodRef (tuple .getT1 (), tuple .getT2 (), project ));
129
- });
130
- });
131
- return super .visit (node );
132
- }
133
-
134
- @ Override
135
- public boolean visit (NormalAnnotation node ) {
136
- Arrays .stream (spelExtractors ).map (e -> e .getSpelRegion (node )).filter (o -> o .isPresent ())
137
- .map (o -> o .get ()).forEach (snippet -> {
138
- List <TokenData > beanReferenceTokens = computeTokens (snippet , offset );
139
- if (beanReferenceTokens != null && beanReferenceTokens .size () > 0 ) {
140
- locationLink .addAll (findLocationLinksForBeanRef (project , offset , beanReferenceTokens ));
141
- }
142
- parseAndExtractMethodClassPairFromSpel (snippet , offset );
143
- Optional <Tuple2 <String , String >> result = parseAndExtractMethodClassPairFromSpel (snippet ,
144
- offset );
145
- result .ifPresent (tuple -> {
146
- locationLink .addAll (findLocationLinksForMethodRef (tuple .getT1 (), tuple .getT2 (), project ));
147
- });
148
- });
149
-
150
- return super .visit (node );
151
- }
152
-
153
- });
154
- return locationLink ;
155
- }
156
-
157
134
private List <LocationLink > findLocationLinksForBeanRef (IJavaProject project , int offset ,
158
135
List <TokenData > beanReferenceTokens ) {
159
136
return beanReferenceTokens .stream ().flatMap (t -> findBeansWithName (project , t .text ()).stream ())
@@ -168,7 +145,6 @@ private List<LocationLink> findLocationLinksForMethodRef(String methodName, Stri
168
145
String classFqName = className .substring (2 , className .length () - 1 );
169
146
Optional <URL > sourceUrl = SourceLinks .source (project , classFqName );
170
147
if (sourceUrl .isPresent ()) {
171
-
172
148
docUri = sourceUrl .get ().toURI ();
173
149
}
174
150
} else if (className .startsWith ("@" )) {
0 commit comments