Skip to content

Conversation

@yasmramos
Copy link

Summary

This PR fixes Bug #9033 by enhancing the Java file detection in the Find in Projects feature.

Problem

Java files were not automatically detected in Find in Projects functionality, creating a regression in NetBeans 28.

Solution

Enhanced the isPrimaryFile() method in VisibilityFilter.java with a three-tier detection strategy:

  1. DataObject primary file check: Original logic preserved
  2. MIME type verification: Check for text/x-java MIME type
  3. File extension validation: Verify .java extension

Changes Made

  • Modified: platform/api.search/src/org/netbeans/spi/search/impl/VisibilityFilter.java
  • Enhanced isPrimaryFile() method with robust detection logic
  • Maintains backward compatibility

Testing

  • Java files are now correctly detected in Find in Projects
  • Existing functionality remains unchanged
  • No regression in other file type detection

References

Problem: Java files not automatically detected in Find in Projects
Solution: Enhanced isPrimaryFile() with three-tier detection:
1. DataObject primary file check (original logic)
2. MIME type verification (text/x-java)
3. File extension validation (.java)

This resolves the regression in NetBeans 28 where Java files
were not properly included in search results.
@matthiasblaesing
Copy link
Contributor

As already stated in the issue the problem is not reproducible for me. I started with a download of NB 28, without a present userdir. Opened a java project, searched for "import" with and without file mask (file mask being "*.java"). Both searches yielded the expected results.

Without a reproducible case, I don't see this going in.

@lahodaj
Copy link
Contributor

lahodaj commented Nov 28, 2025

I am sorry, but:

  • hardcoding knowledge specifically of Java into the platform is weird at least. I think that would need a very good reason. Why hardcode specifically Java?
  • looking at the original logic, I fail to see the issue. I think the filter is supposed to only filter out "secondary" files, like .form. Offhand, I don't recall about any case where .java would be a secondary file of a DataObject. Were there any non-standard 3rd party modules installed? If yes, which ones?

Overall, I think I would suggest to investigate why are the .java files filtered out. One possible way would be to put a breakpoint at the line with DataObject.find(file), and observe what happens (in particular, what is the instance of the DataObject, and why the .java is not its primary file).

FTR, I tried a search on my personal build from mainline from today, and it also was able to find occurrences in my .java files.

@mbien
Copy link
Member

mbien commented Nov 29, 2025

I too can't reproduce the original issue.

this does also read like generated text to me (including the patch) - assuming I talk to a human and you can reproduce it, please post a reproducer there. closing this for now.

@mbien mbien closed this Nov 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants