Community
Participate
Working Groups
Consider the following snippet: var Baz = { one: function() { return 'one'; }, two: function() { return this.one(); }, three: function() { return this.one(); } }; var Bar.one = Baz.one; If you place the carat in 'one:' I would expect the two uses of 'this.one' to be marked. For bonus points if would be awesome if the use of Baz.one could be marked also.
(In reply to Michael Rennie from comment #0) > For bonus points if would be awesome if the use of Baz.one > could be marked also. This should actually be simple-ish (in this case anyway) since we can look ahead when we hit the VariableDeclarator to compose the member expression name and match it. Although that might introduce a performance hit, since we have code to short-circuit when we leave the defining scope.
Created attachment 244019 [details] Work in progress This patch adds support for object properties and some tests, but it comes with a few caveats: - Treats object property selection separately similar to 'this' selection - To determine whether an object property is selected, we have to use findNode() instead of findToken(), possible performance impact - There appears to be a bug in the findNode() with parents option that when selecting object property values returns the node itself as its own parent. i.e. {c: c}, select the right hand side c, it's parent is also the identifier c. The patch gets around this most of the time by asking for the node's direct parent, not searching the array of parents. Unless there is a major concern with the performance issue, I suggest cleaning up the work and pushing it next week as it is very helpful when working on Orion files.
Created attachment 244090 [details] updated This patch is an update with the latest changes from master merged in.
Created attachment 244096 [details] another refresh Another refresh to merge WhileStatement changes
Created attachment 244099 [details] Update to handle nested object expressions This patch includes a change to fix occurrences with nested object expressions (with properties of the same name). We need to skip object expressions that don't enclose the selection and we need to not stop looking for occurrences just because we have found a matching property definition (a nested scope may redefine). Even when working with large files, the performance impact was not noticeable. However, the use of findNode causes a much bigger problem. The node range will always include everything up until the next node. As punctuators aren't included in the AST, selecting whitespace, semicolons, etc. will still mark occurrences of the closest node.
Created attachment 244165 [details] Patch for nested contents and ignored punctuators This patch tweaks the fix for nested object expressions and fixes the problem of not recognizing punctuators by getting both the ast node and the token. The patch also adds tests for all these scenarios. Unfortunately, the fix makes the performance impact noticeable. While not substantial (maybe a half second loss at the end of the 27k line js file), it can be noticed. A fix for Bug 436191 could eliminate this cost.
(In reply to Curtis Windatt from comment #6) > Unfortunately, the fix makes the performance impact noticeable. While not > substantial (maybe a half second loss at the end of the 27k line js file), > it can be noticed. A fix for Bug 436191 could eliminate this cost. I overstated the performance impact. After some minor tweaking, I can no longer tell a noticeable difference in occurrence calculation with my changes. On a 27k long file, occurrences still take time to show up, but this change does not make it noticeably longer. I also found a bug in the findNode function where it does not remove the found node from the parents list if it was the last node in the ast. This is only evident in the tests as the ast nodes have a correct parent node when in the editor (I used the parent node if available, otherwise checking the parents array). http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=e415f79293d7909205b7af309565b82f77624757 Pushed the final changes to master.