# jdx samples

IDE equivalent: Real call sites as usage examples

Show real call sites as usage examples, ranked by exemplariness (non-test before test, non-generated before generated, fuller overloads first): one row per calling method with its enclosing-method source when paired sources exist, snippet-less otherwise. --limit caps the ranked rows (default 3); --prefer-sources ranks callers from sources-paired artifacts first; --in/--exclude filter rows by artifact label (jar file, JDK module or class-dir name). Type refs match calls to any member; field refs exit 3 (examples need a call site: jdx usages shows reads and writes). Exits 1 when the symbol is unknown or unsampled, 2 on an ambiguous short name.

## Usage

```text
jdx samples [<options>] <ref>
```

## Example

```console
$ jdx samples 'com.google.gson.JsonParser#parseString(String)' --coord com.google.code.gson:gson:2.14.0
samples of 'com.google.gson.JsonParser#parseString(String)'
  example com.google.gson.JsonParser#parse(java.lang.String)  gson-2.14.0.jar
    com/google/gson/JsonParser.java:155-159
      @Deprecated
      @InlineMe(replacement = "JsonParser.parseString(json)", imports = "com.google.gson.JsonParser")
      public JsonElement parse(String json) throws JsonSyntaxException {
        return parseString(json);
      }
warning MULTI_RELEASE_VARIANT: multi-release gson-2.14.0.jar serves version-specific variants for this JDK (21)
```

## Options

| Option | Description |
|---|---|
| `--limit=<int>` | Maximum examples shown (default 3); the rest become a truncation footer. |
| `--in=<text>` | Only examples whose artifact label matches this glob (jar file name, JDK module or class-dir name). |
| `--exclude=<text>` | Skip examples whose artifact label matches this glob. |
| `--prefer-sources` | Rank examples from sources-paired artifacts (rendered with snippets) ahead of snippet-less ones. |
| `--jars=<text>` | Binary roots: jar files, class directories or globs (repeatable). Merge in front of the selected workspace's roots. |
| `-w, --workspace=<text>` | Use a named workspace (see jdx ws). Explicit --jars merge in front of it. |
| `--no-jdk` | Do not include the running JDK's stdlib (included by default). |
| `--coord=<text>` | Maven coordinate root group:artifact:version (repeatable). Resolved from ~/.gradle/caches and ~/.m2 first; with --fetch, downloaded from Maven repositories into <cache-dir>/m2 with checksum verification. Merges in front of the workspace. |
| `--repo=<text>` | Maven repository base URL for --coord fetches (repeatable, e.g. --repo https://repo.example.com/maven2). Tried in flag order before Maven Central, which stays last as the fallback. Must be an http(s) URL. |
| `--fetch` | Allow downloading --coord artifacts (and their -sources.jar) from Maven repositories (Central by default, --repo to add mirrors). Without it, coordinates resolve from the local caches only. |
| `--json` | Emit machine-readable JSON instead of human-readable text (same information, D-007). |
| `--no-color` | Disable ANSI colors even on a TTY (piped output is always plain). |
| `--no-daemon` | Force in-process execution: do not forward this query to the background daemon even when its socket answers (PROPOSAL.md §14.1). |
| `-h, --help` | Show this message and exit |

## Arguments

| Argument | Description |
|---|---|
| `<ref>` | Type or member reference to show usage examples of (full or short form). |

## Full help text

```console
$ jdx samples --help
Usage: jdx samples [<options>] <ref>

  Show real call sites as usage examples, ranked by exemplariness (non-test before test, non-generated before generated, fuller overloads first): one row per calling method with its enclosing-method source when paired sources exist, snippet-less otherwise. --limit caps the ranked rows (default 3); --prefer-sources ranks callers from sources-paired artifacts first; --in/--exclude filter rows by artifact label (jar file, JDK module or class-dir name). Type refs match calls to any member; field refs exit 3 (examples need a call site: jdx usages shows reads and writes). Exits 1 when the symbol is unknown or unsampled, 2 on an ambiguous short name.

Options:
  --limit=<int>           Maximum examples shown (default 3); the rest become a truncation footer.
  --in=<text>             Only examples whose artifact label matches this glob (jar file name, JDK module or class-dir name).
  --exclude=<text>        Skip examples whose artifact label matches this glob.
  --prefer-sources        Rank examples from sources-paired artifacts (rendered with snippets) ahead of snippet-less ones.
  --jars=<text>           Binary roots: jar files, class directories or globs (repeatable). Merge in front of the selected workspace's roots.
  -w, --workspace=<text>  Use a named workspace (see jdx ws). Explicit --jars merge in front of it.
  --no-jdk                Do not include the running JDK's stdlib (included by default).
  --coord=<text>          Maven coordinate root group:artifact:version (repeatable). Resolved from ~/.gradle/caches and ~/.m2 first; with --fetch, downloaded from Maven repositories into <cache-dir>/m2 with checksum verification. Merges in front of the workspace.
  --repo=<text>           Maven repository base URL for --coord fetches (repeatable, e.g. --repo https://repo.example.com/maven2). Tried in flag order before Maven Central, which stays last as the fallback. Must be an http(s) URL.
  --fetch                 Allow downloading --coord artifacts (and their -sources.jar) from Maven repositories (Central by default, --repo to add mirrors). Without it, coordinates resolve from the local caches only.
  --json                  Emit machine-readable JSON instead of human-readable text (same information, D-007).
  --no-color              Disable ANSI colors even on a TTY (piped output is always plain).
  --no-daemon             Force in-process execution: do not forward this query to the background daemon even when its socket answers (PROPOSAL.md §14.1).
  -h, --help              Show this message and exit

Arguments:
  <ref>  Type or member reference to show usage examples of (full or short form).
```

## Learn more

Guide: [Usages, hierarchy & calls](https://mohammadmd1383.github.io/jdx/docs/navigating-code/) · [All commands](https://mohammadmd1383.github.io/jdx/docs/reference/)
