Implementing Autocompletion by using indexed values Follow
I have an issue with my plugin. I have implement a ReferenceProvider for autocompletion and reference check in XML Files.
My problem is that the references and autocompletion does not work. In order to make the loading of the ids from other files efficent I try to load the required files by indexing them. Therefore I am also creating a GlobalSearchScope for the directories where I am trying to locate the references.
Via the method `FileBasedIndex.getInstance().getContainingFiles(...)` I am trying to find the indexed files by given key.
But for some reason I don't understand why my index key has no values. But it should have some.
But when I invalidate the cache and start intellij again, I can see that the Index is working.After starting the project later it does not work until I invalidate the cache again and restart intellij
Here is a sample of my code and the test project for the plugin.
Upload id: 2022_10_20_5Y4NEx5PTHq4BspJATxitz (files: plugin_code.zip, completionTest.zip)
Please sign in to leave a comment.
I opened your project, and I'm getting NullPointerExceptions at the IDE start when the index is being built:
It may be the cause, so please fix it (I guess simple null checks should do the job) and check if it solves the issues.
Thats confusing because I do not have this kind of NullpointerException.
But I found some other issues which I uploaded.
Here the updated Project Upload id: 2022_10_21_APnaheusqYRJsyRGFz5WPA (file: plugin_code.zip)
Did you start the plugin via "Run Plugin" or did you build a plugin and install it?
It seems that NPE is thrown because `rule-base/mappings/mapping.xml` root tag doesn't have `noNamespaceSchemaLocation` attribute (if I understand the code correctly). It is thrown only on the first run or after invalidating caches.
I used "Run Plugin".
Please also clarify how to reproduce the issue. Which file should I open, and what should I do to reproduce it?
thanks for your answer I did not strip enough from the old code. I will fix this and upload a new version of the code.
To reproduce the error you just need to start the project and go into the file `rule-base/mappings/mapping.xml` there you should see a lot of errors for all XML Attributes `parameter` and `variable`. You also should not have any suggestions for completion.
You also should see in the file `objects/assemblies/some_object.xml` should have genereate the index for reference after the change but not in the `mapping.xml` file.
See the image:
Here the updated version of my code. I hope I have strip everything which is unnecessary from the code.
Upload id: 2022_10_21_279GtaTzKRt7s67tDNMtL7 (files: test_plugin_project.zip, plugin_code_fixed.zip)
com.example.demo.index.MasterIdToConfigurationIdKeyValuedoesn’t implement equals() and hashCode() and entries cannot be found in the index. I generated the methods, and all work correctly.
I do not think that the equals() and hashCode() will solve my Problem. In my actual Project I am using the @Value Annotation from Lombok. But nevertheless I did generate the equals() and hashCode() and it doesn't change anything as you can see.
It only works when I clean the cash before but I want that it works all the time. Did I forget any trigger or something?
You are right - it didn't fix the issue. I must have accidentally cleaned the cache when closing the project.
I still didn't find the issue, and looking at the code, I couldn't spot anything suspicious. I'll try to get back to it later this week.
In the meantime, I suggest debugging the serialization code. Maybe there is an issue with storing values on disk or reading them back.
EDIT: I noticed that you override com.intellij.util.indexing.FileBasedIndexExtension#traceKeyHashToVirtualFileMapping() to return true which affects the index content after re-runnig the application. I asked the responsible developer about it and will get back to you when I know more.
To keep you updated: Initially, it looks like a bug, but the developer who is familiar with this part of indexing is off and will be back the next week.
Please be patient, and sorry for the inconvenience.
Thanks for the information. I will wait patiently for a fix or more information regarding the indexing.
Do you have a ticket for me were I can track the state of this issue?
I didn't create an issue yet as it's not confirmed that it is a bug. Let's wait for the confirmation.
Please follow: https://youtrack.jetbrains.com/issue/IDEA-305136/FileBasedIndexExtensiontraceKeyHashToVirtualFileMapping-affects-the-index-content
thank you! I will follow it patiently!