Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Unreasonable matches for pattern search
Unreasonable matches for pattern search [message #1807530] Sat, 01 June 2019 13:36 Go to next message
Eclipse UserFriend
Hello,

I am using JDT's search engine to search for annotation references inside a builder:

// search the project my builder was invoked on, including referenced libraries...
IJavaSearchScope scope = SearchEngine.createJavaSearchScope(false,
  new IJavaElement[] { javaProject },
  IJavaSearchScope.SOURCES | IJavaSearchScope.APPLICATION_LIBRARIES);

// search for references to annotation from a specific package prefix:
searchEngine.search(SearchPattern.createPattern("my.test.prefix.**", //
	IJavaSearchConstants.ANNOTATION_TYPE, IJavaSearchConstants.ANNOTATION_TYPE_REFERENCE,
	SearchPattern.R_PATTERN_MATCH),
	new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() },
	scope, requestor, monitor);


The project that has spring in its classpath and I get a lot of unrelated matches with accuracy 1. For example I get a match with (this is output from the requestor's "acceptSearchMatch(SearchMatch match)" method logging the result:

In my-project-with-spring / exact:true, accuracy:1 found: void onWebSocketConnect(org.eclipse.jetty.websocket.api.Session) {key=Lorg/springframework/web/reactive/socket/adapter/JettyWebSocketHandlerAdapter;.onWebSocketConnect(LSession;)V} [in JettyWebSocketHandlerAdapter [in JettyWebSocketHandlerAdapter.class [in org.springframework.web.reactive.socket.adapter [in /Users/myuser/.m2/repository/org/springframework/spring-webflux/5.1.6.RELEASE/spring-webflux-5.1.6.RELEASE.jar]]]] 
     ANNOS: [@org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect [in onWebSocketConnect(org.eclipse.jetty.websocket.api.Session) [in JettyWebSocketHandlerAdapter [in JettyWebSocketHandlerAdapter.class [in org.springframework.web.reactive.socket.adapter [in /Users/myuser/.m2/repository/org/springframework/spring-webflux/5.1.6.RELEASE/spring-webflux-5.1.6.RELEASE.jar]]]]]]


The code for the method suggested as an inaccurate result is:

	@OnWebSocketConnect
	public void onWebSocketConnect(Session session) {
		this.delegateSession = this.sessionFactory.apply(session);
		this.delegateHandler.handle(this.delegateSession).subscribe(this.delegateSession);
	}


The annotation has absolutely no relation to package "my.test.prefix" that I asked for. Its fully qualified name is: org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose

Why is it being reported? There are no compilation errors in the workspace so it should be pretty straight-forward to exclude this result...

[Updated on: Sat, 01 June 2019 13:39] by Moderator

Re: Unreasonable matches for pattern search [message #1807945 is a reply to message #1807530] Thu, 13 June 2019 00:43 Go to previous message
Eclipse UserFriend
Hi,

Can you please attach a sample project where we can reproduce this scenario?

Thanks
Previous Topic:JVM.dll ignores -Xss argument
Next Topic:Old ERP system on Java 11 classpath only
Goto Forum:
  


Current Time: Sun Jul 20 12:58:00 EDT 2025

Powered by FUDForum. Page generated in 0.05535 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top