Completion Helpers via TypeScript
For example, in the above use of
underscore.js, ReSharper is not able to infer the properties of the
_ (underscore) symbol, and thus the developer has to pick from all identifiers. In addition, function parameter information is not available.
After the addition of the strongly typed definitions from the
*.d.ts file, ReSharper shows the members that are permitted for the
_ symbol in bold, and proceeds to offer those members by default. This reduces the risk of error.
Also, ReSharper is able to provide information about function parameters:
So let’s start with a simple example of searching for a declaration of objects with a single property assignment:
The above pattern uses the Name placeholder to locate anything that can be considered a variable or property name. The Find Results window then gives you a listing of all the locations code matching the pattern has been found.
Of course, finding things is only half of what you can do, because you can also perform replacements. For example, say you wanted to replace explicit
Array declarations with square-brace syntax. Here’s how you would define such a pattern:
This pattern uses yet another placeholder which allows
$args$ to represent any number of arguments to a function.
It’s important to note that SSR mechanisms are semantically aware. Here’s an example: searching for a condition
$x$ > 100 will correspondingly match
if (100 >= x):
Similarly, prefix and postfix operators are matched interchangeably, assuming, of course, that no assignments are made:
Also note that SSR ignores non-significant tokens such as curly or round braces or semicolons:
And finally, it’s possible to generate search patterns directly from code:
File Structure Window Improvements
First of all, function names are inferred either from declarations or variable names:
ReSharper is also able to determine element names from documentation when they are not available explicitly:
The file structure window uses an ellipsis … to indicate additional arguments. Consider the
varArgsFunction below; it sees that the
arguments value is being used:
Some function call expressions actually represent higher-level constructs called modules. ReSharper attempts to recognize these structures and present both their private and exported members. Note that, for a constructor, we try to present its fields, too:
Smart Usage Search
That’s It (For Now)