Community
Participate
Working Groups
Its seems that after a rename of performed from the all references UI, the editor and tools are in different states. heres some steps: 1. using the minesweeper-demo example find all refs to main in main.js 2. rename to main2 3. select main2 in the editor - occurrences only marks ‘main’ of main2 4. run find refs again on main2 - notice the search still says it looked for ‘main' 5. reload the page and everything works fine I wonder if there is a problem with all of the *Changed events being sent out when the rename is performed. If this was a problem it would explain the tooling bad state, since the ASTManager uses those events to know when to flush a cached AST.
I debugged this a bit and confirmed the AST manager is holding the old (pre-refactor) AST
So the problem is no onModelChanged events being sent for files that are changed but are not the file your are currently working in. Steps (using the minesweeper-demo project): 1. open index.html 2. open main.js 3. back in index.html, rename 'main' to 'main2', click in the editor to force it to update 4. at this point we get an onModelChanged for index.html (GOOD), but we do not get one for main.js (BAD) - so we don't know to flush the cache for its AST. Then when we navigate to main.js and try to use the tools, they are all working against the original main.js AST (with 'main' in it).
(In reply to Michael Rennie from comment #2) > So the problem is no onModelChanged events being sent for files that are > changed but are not the file your are currently working in. > > Steps (using the minesweeper-demo project): > 1. open index.html > 2. open main.js > 3. back in index.html, rename 'main' to 'main2', click in the editor to > force it to update > 4. at this point we get an onModelChanged for index.html (GOOD), but we do > not get one for main.js (BAD) - so we don't know to flush the cache for its > AST. Then when we navigate to main.js and try to use the tools, they are all > working against the original main.js AST (with 'main' in it). So in steps 3, I assume that you used "replace selected" feature in the search panel to rename. The "replace selected" feature is a silent "write" action against all the files related, where there is no editor context. I think the best way to notify the AST manager in this case is to send out an event with a list file URIs attached. The AST manager then needs to flush the cache on theses files, if any.
Talked to SSQ, ideally we should have sort of workspace resource eventing system so that any resource changes will be notified to client. But for the "replace selected" feature in the search, we do not need that heavy duty thing. As we are using fileClient.write() to change all the file contents, we may end up dispatching a change event from fileClient. Because the javaScript plugin and orion client side share the same file client now(thanks SSQ's improvement), you can listen the change event on the plugin side to tell AST what to do.
(In reply to libing wang from comment #4) > Talked to SSQ, ideally we should have sort of workspace resource eventing > system so that any resource changes will be notified to client. But for the > "replace selected" feature in the search, we do not need that heavy duty > thing. > As we are using fileClient.write() to change all the file contents, we may > end up dispatching a change event from fileClient. Because the javaScript > plugin and orion client side share the same file client now(thanks SSQ's > improvement), you can listen the change event on the plugin side to tell AST > what to do. Perfect, so I assume we will end up with something like: addListener(id, callback) removeListener(id) in fileClient, and will get events like: ADDED | file metadata REMOVED | file metadata CHANGED | file metadata
Pushed the dispatchEvent changes form the search pane and file client. http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=4cd5f0760268e6ffe774eaa557e4367e3d89a304
Second commit to use Object.create(null) to create event. http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=fc387e5eafbfa50d4c769b388dc2fe20754b4c9a
Opened bug 488582 for a generic solution.
Mike, my changes are in now. I put a piece of code(commented out) at the end of javascriptPlugin.js and verified the listener got the event. Please remove that code after you are done.
I pushed all the glue on the plugin side: http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=d09ad4a73ad4c615cfa7d191dc8a8e3b6af1c6a2