@kaluchi/jdtbridge 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -32,20 +32,20 @@ Run `jdt help <command>` for detailed flags and examples. Most commands have sho
32
32
  ```bash
33
33
  jdt projects # list workspace projects
34
34
  jdt project-info <name> [--lines N] # (alias: pi) project overview
35
- jdt find <Name> [--source-only] # find type declarations (* wildcards)
36
- jdt references <FQN> [method] [--field <name>] # (alias: refs) references to type/method/field
35
+ jdt find <Name|package> [--source-only] # find types by name, wildcard, or package
36
+ jdt references <FQMN> [--field <name>] # (alias: refs) references to type/method/field
37
37
  jdt subtypes <FQN> # (alias: subt) all subtypes/implementors
38
38
  jdt hierarchy <FQN> # (alias: hier) supers + interfaces + subtypes
39
- jdt implementors <FQN> <method> [--arity N] # (alias: impl) implementations of interface method
39
+ jdt implementors <FQMN> # (alias: impl) implementations of interface method
40
40
  jdt type-info <FQN> # (alias: ti) class overview (fields, methods)
41
- jdt source <FQN> [method] [--arity N] # (alias: src) source code (project + libraries)
41
+ jdt source <FQMN> # (alias: src) source code (project + libraries)
42
42
  ```
43
43
 
44
44
  ### Testing & building
45
45
 
46
46
  ```bash
47
47
  jdt build [--project <name>] [--clean] # (alias: b) build project
48
- jdt test <FQN> [method] [--timeout N] # run JUnit test class or method
48
+ jdt test <FQMN> [--timeout N] # run JUnit test class or method
49
49
  jdt test --project <name> [--package <pkg>] # run tests in project/package
50
50
  ```
51
51
 
@@ -66,7 +66,7 @@ File paths are workspace-relative: `my-app/src/main/java/.../Foo.java`.
66
66
  jdt organize-imports <file> # (alias: oi) organize imports
67
67
  jdt format <file> # (alias: fmt) format code (Eclipse settings)
68
68
  jdt rename <FQN> <newName> # rename type
69
- jdt rename <FQN> <newName> --method <old> # rename method
69
+ jdt rename <FQMN> <newName> # rename method (FQMN includes method)
70
70
  jdt rename <FQN> <newName> --field <old> # rename field
71
71
  jdt move <FQN> <target.package> # move type to another package
72
72
  ```
@@ -75,7 +75,7 @@ jdt move <FQN> <target.package> # move type to another pa
75
75
 
76
76
  ```bash
77
77
  jdt active-editor # (alias: ae) current file and cursor line
78
- jdt open <FQN> [method] [--arity N] # open in Eclipse editor
78
+ jdt open <FQMN> # open in Eclipse editor
79
79
  ```
80
80
 
81
81
  ## Instance discovery
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaluchi/jdtbridge",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "CLI for Eclipse JDT Bridge — semantic Java analysis via Eclipse JDT SearchEngine",
5
5
  "type": "module",
6
6
  "bin": {
package/src/args.mjs CHANGED
@@ -35,3 +35,73 @@ export function extractPositional(args) {
35
35
  }
36
36
  return result;
37
37
  }
38
+
39
+ /**
40
+ * Parse a Fully Qualified Method Name (FQMN) string.
41
+ *
42
+ * Supported formats:
43
+ * "pkg.Class#method(Type, Type)" — javadoc / surefire style
44
+ * "pkg.Class#method" — method without signature
45
+ * "pkg.Class.method(Type, Type)" — Eclipse Copy Qualified Name style
46
+ * "pkg.Class" — plain FQN (no method)
47
+ *
48
+ * Returns { className, method, paramTypes } where paramTypes is:
49
+ * null — no signature specified (any overload)
50
+ * [] — empty parens, i.e. zero-arg method
51
+ * ["String", "int[]", ...] — explicit parameter types
52
+ */
53
+ export function parseFqmn(input) {
54
+ if (!input) return { className: null, method: null, paramTypes: null };
55
+
56
+ // Javadoc style: Class#method or Class#method(params)
57
+ const hashIdx = input.indexOf("#");
58
+ if (hashIdx >= 0) {
59
+ return parseMethodPart(input.substring(0, hashIdx), input.substring(hashIdx + 1));
60
+ }
61
+
62
+ // Eclipse Copy Qualified Name: only when parentheses are present
63
+ const parenIdx = input.indexOf("(");
64
+ if (parenIdx >= 0) {
65
+ const dotIdx = input.lastIndexOf(".", parenIdx);
66
+ if (dotIdx >= 0) {
67
+ return parseMethodPart(input.substring(0, dotIdx), input.substring(dotIdx + 1));
68
+ }
69
+ }
70
+
71
+ // Plain FQN — no method
72
+ return { className: input, method: null, paramTypes: null };
73
+ }
74
+
75
+ function parseMethodPart(className, rest) {
76
+ const parenIdx = rest.indexOf("(");
77
+ if (parenIdx < 0) {
78
+ return { className, method: rest || null, paramTypes: null };
79
+ }
80
+
81
+ const method = rest.substring(0, parenIdx);
82
+ const closeIdx = rest.lastIndexOf(")");
83
+ const paramsStr = rest.substring(parenIdx + 1, closeIdx >= 0 ? closeIdx : rest.length);
84
+
85
+ if (paramsStr.trim() === "") {
86
+ return { className, method, paramTypes: [] };
87
+ }
88
+
89
+ return { className, method, paramTypes: splitParams(paramsStr) };
90
+ }
91
+
92
+ function splitParams(str) {
93
+ const params = [];
94
+ let depth = 0;
95
+ let start = 0;
96
+ for (let i = 0; i < str.length; i++) {
97
+ if (str[i] === "<") depth++;
98
+ else if (str[i] === ">") depth--;
99
+ else if (str[i] === "," && depth === 0) {
100
+ params.push(str.substring(start, i).trim());
101
+ start = i + 1;
102
+ }
103
+ }
104
+ const last = str.substring(start).trim();
105
+ if (last) params.push(last);
106
+ return params;
107
+ }
package/src/cli.mjs CHANGED
@@ -98,17 +98,17 @@ Requires: Eclipse running with the jdtbridge plugin.
98
98
  Search & navigation:
99
99
  projects list workspace projects
100
100
  project-info${fmtAliases("project-info")} <name> [--lines N] project overview (adaptive detail)
101
- find <Name|*Pattern*> [--source-only] find type declarations
102
- references${fmtAliases("references")} <FQN> [method] [--field <name>] references to type/method/field
101
+ find <Name|*Pattern*|pkg> [--source-only] find types by name, wildcard, or package
102
+ references${fmtAliases("references")} <FQMN> [--field <name>] references to type/method/field
103
103
  subtypes${fmtAliases("subtypes")} <FQN> all subtypes/implementors
104
104
  hierarchy${fmtAliases("hierarchy")} <FQN> full hierarchy (supers + interfaces + subtypes)
105
- implementors${fmtAliases("implementors")} <FQN> <method> [--arity n] implementations of interface method
105
+ implementors${fmtAliases("implementors")} <FQMN> implementations of interface method
106
106
  type-info${fmtAliases("type-info")} <FQN> class overview (fields, methods, line numbers)
107
- source${fmtAliases("source")} <FQN> [method] [--arity n] type or method source code (project and libraries)
107
+ source${fmtAliases("source")} <FQMN> type or method source code (project and libraries)
108
108
 
109
109
  Testing & building:
110
110
  build${fmtAliases("build")} [--project <name>] [--clean] build project (incremental or clean)
111
- test <FQN> [method] run JUnit test class or method
111
+ test <FQMN> run JUnit test class or method
112
112
  test --project <name> [--package <pkg>] run tests in project/package
113
113
 
114
114
  Diagnostics:
@@ -117,12 +117,12 @@ Diagnostics:
117
117
  Refactoring:
118
118
  organize-imports${fmtAliases("organize-imports")} <file> organize imports
119
119
  format${fmtAliases("format")} <file> format with Eclipse project settings
120
- rename <FQN> <newName> [--method|--field] rename type/method/field
120
+ rename <FQMN> <newName> [--field <old>] rename type/method/field
121
121
  move <FQN> <target.package> move type to another package
122
122
 
123
123
  Editor:
124
124
  active-editor${fmtAliases("active-editor")} current file and cursor line
125
- open <FQN> [method] open in Eclipse editor
125
+ open <FQMN> open in Eclipse editor
126
126
 
127
127
  Setup:
128
128
  setup [--check|--remove] install/check/remove Eclipse plugin
@@ -1,5 +1,5 @@
1
1
  import { get } from "../client.mjs";
2
- import { extractPositional, parseFlags } from "../args.mjs";
2
+ import { extractPositional, parseFlags, parseFqmn } from "../args.mjs";
3
3
  import { stripProject } from "../paths.mjs";
4
4
 
5
5
  export async function activeEditor() {
@@ -18,16 +18,18 @@ export async function activeEditor() {
18
18
  export async function open(args) {
19
19
  const pos = extractPositional(args);
20
20
  const flags = parseFlags(args);
21
- const fqn = pos[0];
22
- const method = pos[1];
21
+ const parsed = parseFqmn(pos[0]);
22
+ const fqn = parsed.className;
23
+ const method = parsed.method || pos[1];
23
24
  if (!fqn) {
24
- console.error("Usage: open <FQN> [method] [--arity n]");
25
+ console.error("Usage: open <FQN>[#method[(param types)]]");
25
26
  process.exit(1);
26
27
  }
27
28
  let url = `/open?class=${encodeURIComponent(fqn)}`;
28
29
  if (method) url += `&method=${encodeURIComponent(method)}`;
29
- if (flags.arity !== undefined && flags.arity !== true)
30
- url += `&arity=${flags.arity}`;
30
+ if (parsed.paramTypes) {
31
+ url += `&paramTypes=${encodeURIComponent(parsed.paramTypes.join(","))}`;
32
+ }
31
33
  const result = await get(url);
32
34
  if (result.error) {
33
35
  console.error(result.error);
@@ -42,8 +44,9 @@ Usage: jdt active-editor`;
42
44
 
43
45
  export const openHelp = `Open a type or method in the Eclipse editor.
44
46
 
45
- Usage: jdt open <FQN> [method] [--arity n]
47
+ Usage: jdt open <FQN>[#method[(param types)]]
46
48
 
47
49
  Examples:
48
50
  jdt open app.m8.dao.StaffDaoImpl
49
- jdt open app.m8.dao.StaffDaoImpl getStaff`;
51
+ jdt open app.m8.dao.StaffDaoImpl#getStaff
52
+ jdt open "app.m8.dao.StaffDaoImpl#save(Order)"`;
@@ -25,17 +25,20 @@ export async function find(args) {
25
25
  }
26
26
  }
27
27
 
28
- export const help = `Find type declarations by name or wildcard pattern.
28
+ export const help = `Find type declarations by name, wildcard, or package.
29
29
 
30
- Usage: jdt find <Name|*Pattern*> [--source-only]
30
+ Usage: jdt find <Name|*Pattern*|package.name> [--source-only]
31
31
 
32
32
  Arguments:
33
- Name exact type name (e.g. DataSourceUtils)
34
- *Pattern* wildcard pattern (e.g. *Controller*, Find*)
33
+ Name exact type name (e.g. DataSourceUtils)
34
+ *Pattern* wildcard pattern (e.g. *Controller*, Find*)
35
+ package.name dotted package name — lists all types in the package
35
36
 
36
37
  Flags:
37
38
  --source-only exclude binary/library types, show only workspace sources
38
39
 
39
40
  Examples:
40
41
  jdt find DataSourceUtils
41
- jdt find *Controller* --source-only`;
42
+ jdt find *Controller* --source-only
43
+ jdt find com.example.service
44
+ jdt find com.example.service.`;
@@ -1,18 +1,21 @@
1
1
  import { get } from "../client.mjs";
2
- import { extractPositional, parseFlags } from "../args.mjs";
2
+ import { extractPositional, parseFlags, parseFqmn } from "../args.mjs";
3
3
  import { stripProject } from "../paths.mjs";
4
4
 
5
5
  export async function implementors(args) {
6
6
  const pos = extractPositional(args);
7
7
  const flags = parseFlags(args);
8
- const [fqn, method] = pos;
8
+ const parsed = parseFqmn(pos[0]);
9
+ const fqn = parsed.className;
10
+ const method = parsed.method || pos[1];
9
11
  if (!fqn || !method) {
10
- console.error("Usage: implementors <FQN> <method> [--arity n]");
12
+ console.error("Usage: implementors <FQN>#<method>[(param types)]");
11
13
  process.exit(1);
12
14
  }
13
15
  let url = `/implementors?class=${encodeURIComponent(fqn)}&method=${encodeURIComponent(method)}`;
14
- if (flags.arity !== undefined && flags.arity !== true)
15
- url += `&arity=${flags.arity}`;
16
+ if (parsed.paramTypes) {
17
+ url += `&paramTypes=${encodeURIComponent(parsed.paramTypes.join(","))}`;
18
+ }
16
19
  const results = await get(url, 30_000);
17
20
  if (results.error) {
18
21
  console.error(results.error);
@@ -29,6 +32,7 @@ export async function implementors(args) {
29
32
 
30
33
  export const help = `Find implementations of an interface method across all implementing classes.
31
34
 
32
- Usage: jdt implementors <FQN> <method> [--arity <n>]
35
+ Usage: jdt implementors <FQN>#<method>[(param types)]
33
36
 
34
- Example: jdt implementors app.m8.web.shared.core.HasId getId`;
37
+ Examples:
38
+ jdt implementors app.m8.web.shared.core.HasId#getId`;
@@ -1,5 +1,5 @@
1
1
  import { get } from "../client.mjs";
2
- import { extractPositional, parseFlags } from "../args.mjs";
2
+ import { extractPositional, parseFlags, parseFqmn } from "../args.mjs";
3
3
  import { toWsPath } from "../paths.mjs";
4
4
  import { green, yellow } from "../color.mjs";
5
5
 
@@ -46,19 +46,21 @@ export async function format(args) {
46
46
  export async function rename(args) {
47
47
  const pos = extractPositional(args);
48
48
  const flags = parseFlags(args);
49
- const fqn = pos[0];
49
+ const parsed = parseFqmn(pos[0]);
50
+ const fqn = parsed.className;
50
51
  const newName = pos[1];
51
52
  if (!fqn || !newName) {
52
53
  console.error(
53
- "Usage: rename <FQN> <newName> [--field name] [--method name] [--arity n]",
54
+ "Usage: rename <FQN>[#method[(param types)]] <newName> [--field name]",
54
55
  );
55
56
  process.exit(1);
56
57
  }
57
58
  let url = `/rename?class=${encodeURIComponent(fqn)}&newName=${encodeURIComponent(newName)}`;
58
59
  if (flags.field) url += `&field=${encodeURIComponent(flags.field)}`;
59
- if (flags.method) url += `&method=${encodeURIComponent(flags.method)}`;
60
- if (flags.arity !== undefined && flags.arity !== true)
61
- url += `&arity=${flags.arity}`;
60
+ if (parsed.method) url += `&method=${encodeURIComponent(parsed.method)}`;
61
+ if (parsed.paramTypes) {
62
+ url += `&paramTypes=${encodeURIComponent(parsed.paramTypes.join(","))}`;
63
+ }
62
64
  const result = await get(url, 30_000);
63
65
  if (result.error) {
64
66
  console.error(result.error);
@@ -103,11 +105,12 @@ Example: jdt format m8-server/src/main/java/.../Foo.java`;
103
105
 
104
106
  export const renameHelp = `Rename a type, method, or field (updates all references).
105
107
 
106
- Usage: jdt rename <FQN> <newName> [--method <old>] [--field <old>] [--arity <n>]
108
+ Usage: jdt rename <FQN>[#method[(param types)]] <newName>
109
+ jdt rename <FQN> <newName> [--field <old>]
107
110
 
108
111
  Examples:
109
112
  jdt rename app.m8.dto.Foo Bar
110
- jdt rename app.m8.dto.Foo getBar --method getFoo`;
113
+ jdt rename app.m8.dto.Foo#getFoo getBar`;
111
114
 
112
115
  export const moveHelp = `Move a type to another package (updates all references).
113
116
 
@@ -1,24 +1,26 @@
1
1
  import { get } from "../client.mjs";
2
- import { extractPositional, parseFlags } from "../args.mjs";
2
+ import { extractPositional, parseFlags, parseFqmn } from "../args.mjs";
3
3
  import { formatReferences } from "../format/references.mjs";
4
4
 
5
5
  export async function references(args) {
6
6
  const pos = extractPositional(args);
7
7
  const flags = parseFlags(args);
8
- const fqn = pos[0];
8
+ const parsed = parseFqmn(pos[0]);
9
+ const fqn = parsed.className;
9
10
  if (!fqn) {
10
- console.error("Usage: references <FQN> [method] [--field name] [--arity n]");
11
+ console.error("Usage: references <FQN>[#method[(param types)]] [--field name]");
11
12
  process.exit(1);
12
13
  }
13
14
  let url = `/references?class=${encodeURIComponent(fqn)}`;
14
15
  if (flags.field) {
15
16
  url += `&field=${encodeURIComponent(flags.field)}`;
16
17
  } else {
17
- const method = pos[1];
18
+ const method = parsed.method || pos[1];
18
19
  if (method) url += `&method=${encodeURIComponent(method)}`;
20
+ if (parsed.paramTypes) {
21
+ url += `&paramTypes=${encodeURIComponent(parsed.paramTypes.join(","))}`;
22
+ }
19
23
  }
20
- if (flags.arity !== undefined && flags.arity !== true)
21
- url += `&arity=${flags.arity}`;
22
24
  const results = await get(url, 30_000);
23
25
  if (results.error) {
24
26
  console.error(results.error);
@@ -33,19 +35,20 @@ export async function references(args) {
33
35
 
34
36
  export const help = `Find all references to a type, method, or field across the workspace.
35
37
 
36
- Usage: jdt references <FQN> [method]
38
+ Usage: jdt references <FQN>[#method[(param types)]]
37
39
  jdt references <FQN> --field <name>
38
- jdt references <FQN> [method] --arity <n>
39
40
 
40
- Arguments:
41
- FQN fully qualified class name
42
- method method name (optional)
41
+ FQMN formats (Fully Qualified Method Name):
42
+ pkg.Class#method any overload
43
+ pkg.Class#method() zero-arg overload
44
+ pkg.Class#method(String) specific signature
45
+ pkg.Class.method(String) Eclipse Copy Qualified Name style
43
46
 
44
47
  Flags:
45
48
  --field <name> find references to a field
46
- --arity <n> disambiguate overloaded methods by parameter count
47
49
 
48
50
  Examples:
49
51
  jdt references app.m8.dto.web.core.IdOrgRoot
50
- jdt references app.m8.dao.StaffDaoImpl getStaff
52
+ jdt references app.m8.dao.StaffDaoImpl#getStaff
53
+ jdt references "app.m8.dao.StaffDaoImpl#save(Order)"
51
54
  jdt references app.m8.dao.StaffDaoImpl --field staffCache`;
@@ -1,19 +1,22 @@
1
1
  import { getRaw } from "../client.mjs";
2
- import { extractPositional, parseFlags } from "../args.mjs";
2
+ import { extractPositional, parseFlags, parseFqmn } from "../args.mjs";
3
3
  import { stripProject } from "../paths.mjs";
4
4
 
5
5
  export async function source(args) {
6
6
  const pos = extractPositional(args);
7
7
  const flags = parseFlags(args);
8
- const [fqn, method] = pos;
8
+ const parsed = parseFqmn(pos[0]);
9
+ const fqn = parsed.className;
9
10
  if (!fqn) {
10
- console.error("Usage: source <FQN> [method] [--arity n]");
11
+ console.error("Usage: source <FQN>[#method[(param types)]]");
11
12
  process.exit(1);
12
13
  }
14
+ const method = parsed.method || pos[1];
13
15
  let url = `/source?class=${encodeURIComponent(fqn)}`;
14
16
  if (method) url += `&method=${encodeURIComponent(method)}`;
15
- if (flags.arity !== undefined && flags.arity !== true)
16
- url += `&arity=${flags.arity}`;
17
+ if (parsed.paramTypes) {
18
+ url += `&paramTypes=${encodeURIComponent(parsed.paramTypes.join(","))}`;
19
+ }
17
20
  const result = await getRaw(url, 30_000);
18
21
  const file = result.headers["x-file"] || "?";
19
22
  const startLine = result.headers["x-start-line"] || "?";
@@ -35,9 +38,9 @@ export async function source(args) {
35
38
 
36
39
  export const help = `Print source code of a type or method.
37
40
 
38
- Usage: jdt source <FQN> [method] [--arity <n>]
41
+ Usage: jdt source <FQN>[#method[(param types)]]
39
42
 
40
43
  Examples:
41
44
  jdt source app.m8.dao.StaffDaoImpl
42
- jdt source app.m8.dao.StaffDaoImpl getStaff
43
- jdt source app.m8.dao.StaffDaoImpl save --arity 2`;
45
+ jdt source app.m8.dao.StaffDaoImpl#getStaff
46
+ jdt source "app.m8.dao.StaffDaoImpl#save(Order)"`;
@@ -1,15 +1,16 @@
1
1
  import { get } from "../client.mjs";
2
- import { extractPositional, parseFlags } from "../args.mjs";
2
+ import { extractPositional, parseFlags, parseFqmn } from "../args.mjs";
3
3
  import { formatTestResults } from "../format/test-results.mjs";
4
4
 
5
5
  export async function test(args) {
6
6
  const pos = extractPositional(args);
7
7
  const flags = parseFlags(args);
8
8
  let url = "/test?";
9
- const fqn = pos[0];
9
+ const parsed = parseFqmn(pos[0]);
10
+ const fqn = parsed.className;
10
11
  if (fqn) {
11
12
  url += `class=${encodeURIComponent(fqn)}`;
12
- const method = pos[1];
13
+ const method = parsed.method || pos[1];
13
14
  if (method) url += `&method=${encodeURIComponent(method)}`;
14
15
  } else if (flags.project) {
15
16
  url += `project=${encodeURIComponent(flags.project)}`;
@@ -33,7 +34,7 @@ export async function test(args) {
33
34
 
34
35
  export const help = `Run JUnit tests via Eclipse's built-in test runner.
35
36
 
36
- Usage: jdt test <FQN> [method]
37
+ Usage: jdt test <FQN>[#method]
37
38
  jdt test --project <name> [--package <pkg>]
38
39
 
39
40
  Flags:
@@ -43,5 +44,5 @@ Flags:
43
44
 
44
45
  Examples:
45
46
  jdt test app.m8ws.utils.ObjectMapperTest
46
- jdt test app.m8ws.utils.ObjectMapperTest testSerialize
47
+ jdt test app.m8ws.utils.ObjectMapperTest#testSerialize
47
48
  jdt test --project m8-server`;