diff --git a/.gitbook/assets/ai-code-search.gif b/.gitbook/assets/ai-code-search.gif new file mode 100644 index 00000000..5dfb9a57 Binary files /dev/null and b/.gitbook/assets/ai-code-search.gif differ diff --git a/user-documentation/moderne-platform/how-to-guides/how-to-find-method-invocations-based-on-a-pattern.md b/user-documentation/moderne-platform/how-to-guides/how-to-find-method-invocations-based-on-a-pattern.md index 9586b62c..4b3248fe 100644 --- a/user-documentation/moderne-platform/how-to-guides/how-to-find-method-invocations-based-on-a-pattern.md +++ b/user-documentation/moderne-platform/how-to-guides/how-to-find-method-invocations-based-on-a-pattern.md @@ -4,6 +4,8 @@ Searching for methods across a code base can not only help you learn more about In this guide, we'll give you some background on each of these recipes and then walk through the different ways you might use them. +
+ ## Recipes that search for methods The Moderne marketplace has two key recipes that can help you find method invocations throughout your codebases: @@ -13,9 +15,9 @@ The Moderne marketplace has two key recipes that can help you find method invoca The first recipe, find method usages, uses [method patterns](https://docs.openrewrite.org/reference/method-patterns) to identify a method. If you know the exact method name you're looking for, then this is recipe you should use. -The second recipe, which is backed by AI, is a better candidate for situations where you are looking for multiple method invocations, without knowing the name or even the library it comes from. +The second recipe, which is backed by AI, is a better candidate for situations where you are looking for multiple method invocations, without knowing the name or even the library it comes from. -Imagine, for instance, that you wanted to change how you authorize HTTP requests across all over your services. To begin, you'd want to figure out which libraries you use. Do you use Spring's WebClient? OkHttp3? Spring's HttpHeaders? Something else? Rather than needing to know exactly what methods you use and how those methods are defined, you could use this recipe to search for something as simple as `HTTP requests with an authorization header`. +Imagine, for instance, that you wanted to change how you authorize HTTP requests across all over your services. To begin, you'd want to figure out which libraries you use. Do you use Spring's WebClient? OkHttp3? Spring's HttpHeaders? Something else? Rather than needing to know exactly what methods you use and how those methods are defined, you could use this recipe to search for something as simple as `HTTP requests with an authorization header`. Please note, though, that this AI recipe is designed to find results even if they are somewhat ambiguous, rather than rejecting them like a normal recipe might. @@ -24,7 +26,7 @@ Please note, though, that this AI recipe is designed to find results even if the ### Find method usages 1. Navigate to the [find method usages recipe in Moderne](https://app.moderne.io/recipes/org.openrewrite.java.search.FindMethods). -2. Either enter a [method pattern](https://docs.openrewrite.org/reference/method-patterns) directly into the method pattern text box, or click on the wand icon next to it to open a tool to help you build a method pattern. +2. Either enter a [method pattern](https://docs.openrewrite.org/reference/method-patterns) directly into the method pattern text box, or click on the wand icon next to it to open a tool to help you build a method pattern. 3. Press `Dry Run` to kick off the recipe. 4. On the recipe results page, you can click on any repository to see the code that matches the method you specified. For instance, if you searched for `Java.util.List add(..)` – you might see results like: @@ -41,21 +43,21 @@ Please note, though, that this AI recipe is designed to find results even if the * Parses XML or JSON {% hint style="info" %} -The AI search is aware of the arguments inside the method invocation. If you are looking for a specific way a method is used, consider adding that information inside of the query. For instance, instead of saying `HTTP request`, consider specifying `HTTP request with an authorization header`. +The AI search is aware of the arguments inside the method invocation. If you are looking for a specific way a method is used, consider adding that information inside of the query. For instance, instead of saying `HTTP request`, consider specifying `HTTP request with an authorization header`. {% endhint %} -3. In the `Top-K` field, you can customize the types of results you'll receive. A higher value means the AI search will find more results and take a longer period of time to run. A lower value means the AI search will find less results, but run more quickly. For best results, we'd recommend keeping this value in the 5-10 range. +3. In the `Top-K` field, you can customize the types of results you'll receive. A higher value means the AI search will find more results and take a longer period of time to run. A lower value means the AI search will find less results, but run more quickly. For best results, we'd recommend keeping this value in the 5-10 range. * Keep in mind that recipes have a time-out of 8 minutes, so if you enter too high of a value, the recipe will not return any results as it will time out. 4. With those two options specified, press `Dry Run` to kick off the recipe. 5. On the recipe results page, you can click on any repository to see the code that matches the method you described. For instance, if you searched for `HTTP Request` - you might see results like: -
Find method invocations that resemble a pattern results
+

Find method invocations that resemble a pattern results

## Gain insight from the results After running each of these recipes, you may want to view the results in a different way or learn more about why certain results were or were not included. To assist with this goal, Moderne offers a few data tables and visualizations you can run with the recipe results. Let's take a look at a few of them. You can find these by clicking on the `Visualization` or `Data tables` tab at the top of the recipe results page: -
Click on the visualizations or data tables tab
+
### Find uses of method in code @@ -73,7 +75,7 @@ This visualization uses AI to return method patterns found in your code that mat
-You could then take this method pattern and plug it in to the [find method usages recipe](https://app.moderne.io/recipes/org.openrewrite.java.search.FindMethods) to find results that match just that pattern. Or, if you wanted to create a recipe that will find _all_ of the results that match the method patterns returned here, [we provide a visualization to assist with that](how-to-find-method-invocations-based-on-a-pattern.md#generate-a-search-recipe-from-the-ai-results). +You could then take this method pattern and plug it in to the [find method usages recipe](https://app.moderne.io/recipes/org.openrewrite.java.search.FindMethods) to find results that match just that pattern. Or, if you wanted to create a recipe that will find _all_ of the results that match the method patterns returned here, [we provide a visualization to assist with that](how-to-find-method-invocations-based-on-a-pattern.md#generate-a-search-recipe-from-the-ai-results). {% hint style="info" %} Regardless of which option you pick, please note that you may want to modify the method pattern to meet your needs as the method pattern does not include argument matching. @@ -81,7 +83,7 @@ Regardless of which option you pick, please note that you may want to modify the ### Generate a search recipe from the AI results -This visualization takes the method patterns generated by the AI and creates a declarative YAML recipe that will find methods that match said patterns. You can then directly run that recipe - or you can take it over to the [recipe builder](recipe-builder.md) and modify it to meet your needs. +This visualization takes the method patterns generated by the AI and creates a declarative YAML recipe that will find methods that match said patterns. You can then directly run that recipe - or you can take it over to the [recipe builder](recipe-builder.md) and modify it to meet your needs.
@@ -91,6 +93,6 @@ This visualization takes the method patterns generated by the AI and creates a d Another feature Moderne offers is the ability to download an extremely detailed file that contains all of the results from the recipe or all of the details about the AI search. To download these tables, go to the `Data tables` tab and then select the type of file you'd like to receive (CSV, XLS, or JSON). -![Find method usages data table](/.gitbook/assets/method-usage-data-table.png) +![Find method usages data table](../../../.gitbook/assets/method-usage-data-table.png) -![Find method invocations that resemble a pattern data tables](/.gitbook/assets/ai-data-tables.png) \ No newline at end of file +![Find method invocations that resemble a pattern data tables](../../../.gitbook/assets/ai-data-tables.png)