Skip to content

Disable indexing for restricted binary files - #5284

Draft
trancexpress wants to merge 1 commit into
eclipse-jdt:masterfrom
trancexpress:gh4970
Draft

Disable indexing for restricted binary files#5284
trancexpress wants to merge 1 commit into
eclipse-jdt:masterfrom
trancexpress:gh4970

Conversation

@trancexpress

Copy link
Copy Markdown
Contributor

Indexing for restricted files is so far disabled only for sources, not for binary files. This change ensures also restricted binary files are not indexed.

Fixes: #4970

Indexing for restricted files is so far disabled only for sources, not
for binary files. This change ensures also restricted binary files are
not indexed.

Fixes: eclipse-jdt#4970
String binaryIndexerMessage = "Could not index empty /IndexProject/src/p/TestBroken.class";
List<IStatus> logs = this.logListener.getLogs();
boolean unexpectedLog = logs.stream().map(IStatus::getMessage).anyMatch(m -> binaryIndexerMessage.equals(m));
assertFalse("Expected no log from binary indexer", unexpectedLog);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not the best and definitely not the most robust way to test this... but its simple. I can try to come up with something else, but it won't be simple getting a class file that has the expected matches.


private boolean disabledForFile() {
if (JavaModelManager.disableRestrictedFileIndexing()) {
IFile file = getDocumentFile(this.document);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For binary indexer, in most cases the IFile will not exist, so on every file from a jar or jre it will throw exception, which is not OK.

@iloveeclipse

Copy link
Copy Markdown
Member

Ideally we only check at places which indexer has "IFile" in hand, like:

  • org.eclipse.jdt.internal.core.search.indexing.IndexManager.addSource(IFile, IPath, SourceElementParser)
  • org.eclipse.jdt.internal.core.search.indexing.IndexManager.addBinary(IFile, IPath)

So we don't need to reconstruct the IFile from some path which was never IFile.

@trancexpress
trancexpress marked this pull request as draft August 13, 2026 12:15
@trancexpress

Copy link
Copy Markdown
Contributor Author

Ideally we only check at places which indexer has "IFile" in hand, like:

* `org.eclipse.jdt.internal.core.search.indexing.IndexManager.addSource(IFile, IPath, SourceElementParser)`
* `org.eclipse.jdt.internal.core.search.indexing.IndexManager.addBinary(IFile, IPath)`

So we don't need to reconstruct the IFile from some path which was never IFile.

My main reason for putting code directly in SourceIndexer with the first PR was to ensure we always check the session property, regardless of who the caller is.

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.

Add preference for disabling indexing of specific files

2 participants