Test case for rename across multiple files



I’m implementing rename support in YouCompleteMe’s tern completer, and I have it all working, except for renames where the chunks are split across multiple files. Embarrassingly, the reason I haven’t got this working is that I haven’t been able to construct a test case where a rename returns chunks in different files. This is mostly, I assume due to my ignorance of JavaScript :).

I wonder if someone could give me a hint. I have tried with the node and requireJs plugins, but in both cases, the returned value from require is an object, whose members can’t be renamed (tern only renames variables, not members).

So simply put: how can I construct 2 javascript files with the same variable in them, so that I can rename it?

Many thanks,


If you don’t load a module plugin, and just use JavaScript’s default global scope for all files, you can rename global variables and their uses across files.