Update type aware search doc to use recipe-examples

Previously, the doc was using examples that I found in random
repositories. However, as people change code over time, that could
mean that the tutorials go out of date. I created a recipe-examples
repository to store code in that I can use to highlight examples
in these tutorials.

On top of that, I switched the example from `createFile` to
`createTempFile` to lead in to another tutorial where we'll use
a security recipe to update the file.
This commit is contained in:
Mike Sol
2022-10-25 11:43:06 -07:00
parent e9c45d0e49
commit 1f18e6380b
5 changed files with 7 additions and 6 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 169 KiB

After

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

After

Width:  |  Height:  |  Size: 62 KiB

1
.gitignore vendored
View File

@@ -1 +1,2 @@
.idea/
.vscode/

View File

@@ -10,7 +10,7 @@ To help you get accustomed to Moderne's search capabilities, in this guide, we w
## Using a search recipe
As an example, let's say you are wanting to find all of the places that use the `createFile` method from `java.nio.file.Files` in your code base. To begin this search:
As an example, let's say that you are wanting to find all of the places where your team is using the `createTempFile` method from `java.io.File`. If you searched for `createTempFile` in GitHub, you might end up with a ton of irrelevant results as this is a fairly common method name. To find results that match the method name _and_ are from the correct library please follow these steps:
* From the [Java Search](https://public.moderne.io/catalog/org.openrewrite.java.search) page, scroll down and click on `Find method usages`. You will see this:
@@ -20,23 +20,23 @@ As an example, let's say you are wanting to find all of the places that use the
* Click on `Select Repositories`.
* Press `Add Filter`.
* Select what you want to filter on such as `Organization`.
* Type the text you want to search for such as `eclipse`. You should see the repositories filter down as desired.
* Type the text you want to search for such as `openrewrite`. You should see the repositories filter down as desired.
* Press the `>>` button to select all of the filtered repositories.
* Click out of the modal to confirm your choices.
* Enter the fully qualified class name of `java.nio.file.Files` in the receiver type field.
* Enter the method name of `createFile` in the method name field.
* Enter the fully qualified class name of `java.io.File` in the receiver type field.
* Enter the method name of `createTempFile` in the method name field.
* Enter `..` in the argument type field to denote that we want to search for any amount of arguments.
* Select `none` for the flow.
* Your window should look like:
![](../.gitbook/assets/find-method-usage-eclipse.png)
![](../.gitbook/assets/find-method-usage-openrewrite.png)
* Press `Dry Run` to begin the search. You will be redirected to a page that looks like:
![](../.gitbook/assets/find-method-usage-results.png)
* If you click on one of the repository names such as `eclipse/jkube`, you'll be taken into the code for that repository. Lines that match the search will be underlined and marked with a magnifying glass icon. These lines match the type that was specified in the search. This means that if any other `createFile` method was invoked, you wouldn't see those results here. Instead, you will see:
* If you click on one of the repository names such as `openrewrite/recipe-examples`, you'll be taken into the code for that repository. Lines that match the search will be underlined and marked with a magnifying glass icon. These lines match the type that was specified in the search. This means that if any other `createTempFile` method was invoked, you wouldn't see those results here. Instead, you will see:
![](../.gitbook/assets/find-method-usage-result.png)