The bug I'm trying to solve here is this race condition: project initializes, we begin to findUsages asynchronously, the editors come up, the line markers are collected -- but at this time the event class names are not in the event class set -- so no line markers are created. Then the async scan finishes, we optimize index, but its too late.  

If I launch it with debugging enabled it works fine and my "already open" MyEvent editor shows the line marker after the whole thing starts up. However, if I launch it without debugging the marker doesn't show up. After adding some additional logging, I see that there must be some kind of race condition between starting up the projects and doing the FindUsages scan. Launching it normally (without debugging) the first time I do the scan it finds no usages of the Subscribe method and so no event classes are created and obviously no line markers are there. I looked around inside of FindUsagesManager but couldn't see any obvious culprits, nor obvious conditions to check for. I don't really know enough about IDEAs apis to know if there is any kind of "delayed execution" -- so in the meantime I just added a check so after the initial scan if you find no usages of Subscribe, schedule another scan later. Do this up to five times. I found in my testing that on the second time, it always finds the usages correctly. This seems pretty hacky, so if you guys have any better insight that would be great.