during stub-ast switch, expose PSI to other threads only after it points to AST (could explain some of EA-96572 - failedToBindStubToAst)

This commit is contained in:
peter
2017-02-11 15:05:27 +01:00
parent f09f20a63c
commit c175718dbf
@@ -87,8 +87,10 @@ class AstPathPsiMap {
@NotNull
StubBasedPsiElementBase<?> cachePsi(@NotNull AstPath key, @NotNull StubBasedPsiElementBase psi) {
myQueue.cleanupStaleReferences();
myMap.put(key, new MyReference(psi, key, myQueue));
// ensure PSI will use AST path before making it available to other threads
// otherwise another thread could invoke StubRef.getNode and fail since file's AST isn't set yet
psi.setSubstrateRef(key);
myMap.put(key, new MyReference(psi, key, myQueue));
return psi;
}