StubIndex persisting between test runs leading to incorrect completions Follow
I'm testing references and completion and the completion results are failing based on the order of the tests because the LightPlatformCodeInsightFixtureTestCase reuses the project (and I guess the index). I tried overriding getProjectDescriptor as suggested in http://www.jetbrains.org/intellij/sdk/docs/basics/indexing_and_psi_stubs/stub_indexes.html, but my completion results were still populated with stale index entries (I know it's stale because the name didn't exist in the test path files or the configured files. The only thing that fixed the cross-test pollution was deleting the sandbox home ($HOME/Library/Caches/IntelliJIdea2016.1/plugins-sandbox). Is there a better way to ensure a new project is used between the test suites? The same project can be used for the same Test class, but I need a different one for different Test classes. Or is there a way to ask the stub index to be cleared, an equivalent of Invalidate Caches and Restart for tests?
Please sign in to leave a comment.
Could you please post the code, how do you query the index to get the completion variants?
I get all the variants from outside the file with `StubIndex.getInstance().getAllKeys(AllName.KEY, project)` here
I see. The thing is, for performance reasons those keys are a superset of actual keys in the actual project, but not exactly the same set. So, I'd suggest for each key to query stub index values with some project scope, and add it to completion only if you get any values from the index. Sorry for confusing API.
I also use that pattern in my GotoSymbolContributor.getNames too. Should I be checking the names exists for GoToSymbols too? If I should be checking the names too, it would also be a bug in intellij-erlang also because I based that on it's code.
In Goto Symbol the pattern is OK, because it first retrieves all possible names, sorts them, and then checks which symbols are actually present for each separate name. Code completion should probably use the same way.