dsh-ris-ide 1.8.4 → 1.8.5

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.
@@ -1643,6 +1643,100 @@ test('the selected range is highlighted stronger than the other matches', async
1643
1643
  assert.match(chunk, /dsh-ris-ide-has-selection/, 'the editor marks itself while a selection exists')
1644
1644
  })
1645
1645
 
1646
+ // 2026-11-16: Ctrl/Cmd-hover underlines every occurrence of the identifier and
1647
+ // Ctrl/Cmd+click goes to the declaration — Tier 0 of the no-index plan (the
1648
+ // file's own text plus package/import mapping; no repository scan, no compile).
1649
+ test('Ctrl+click jumps to declarations without an index', async () => {
1650
+ const { readFile } = await import('node:fs/promises')
1651
+ const chunk = await readFile(new URL('../lib/client-codemirror.js', import.meta.url), 'utf8')
1652
+ assert.match(chunk, /cm-symbol-hit/, 'hovered identifiers are underlined')
1653
+ assert.match(chunk, /symbolHighlightEffect/, 'the highlight is a state effect (clears on modifier release)')
1654
+ assert.match(chunk, /revealSymbol/, 'the handle can reveal a declaration by name')
1655
+ assert.match(chunk, /annotationContextAt\(view, pos, word\)/, 'the editor recognises annotation attributes')
1656
+ assert.match(chunk, /findAnnotationMemberDeclaration\(view, member\)/, 'annotation attribute declarations are locatable')
1657
+ assert.match(chunk, /revealLine/, 'the handle can reveal a line/column')
1658
+ const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
1659
+ assert.match(source, /onSymbolJump: jumpToSymbolInProject/, 'cross-file type jumps reach the workbench')
1660
+ assert.match(source, /function javaTypeCandidates\(cwd, fromPath, text, name\)/, 'package/import → path mapping')
1661
+ assert.match(source, /controls\.revealSymbol\(name, member === '' \? undefined : member\)/, 'the opened file reveals the type declaration (or the annotation attribute)')
1662
+ assert.match(source, /'\/src\/main\/java\/'/, 'Maven/Gradle source roots win over the workspace root (m04067)')
1663
+ })
1664
+
1665
+ test('cross-project and dependency symbols resolve by their last name segment (m04476)', async () => {
1666
+ const { readFile } = await import('node:fs/promises')
1667
+ const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
1668
+ assert.match(source, /function javaPackagePath\(text\)/, 'the package path is shared by the candidates and the fallback search')
1669
+ assert.match(source, /fsSearch\(scopeRef\.current, name \+ '\.java'\)/, 'an imported name is located by its last segment anywhere in the workspace')
1670
+ assert.match(source, /function javaTypeFqn\(text, name\)/, 'the click resolves a fully-qualified name before asking the host')
1671
+ assert.match(source, /fsDependencySource\(scopeRef\.current, fqn, logPath\)/, 'a jar class falls back to the debugger source pipeline by its FQN')
1672
+ assert.match(source, /var knownDependencyDoc = docsRef\.current\[dependencyPath\]/, 'an already-open dependency tab is noticed')
1673
+ assert.match(source, /reloadPath\(dependencyPath\)/, 'a new dependency jar version must re-read the cached file instead of showing the old text')
1674
+ assert.match(source, /remembered\.indexOf\('\/\.dsh-ris-ide\/cache\/'\)/, 'a remembered dependency source is re-resolved so an upgraded jar is noticed')
1675
+ const host = await readFile(new URL('../lib/index.js', import.meta.url), 'utf8')
1676
+ assert.match(host, /const DECOMPILE_TIMEOUT_MS = 30 \* 1000/, 'a wedged decompiler jar cannot hang /debug/source forever')
1677
+ assert.match(host, /const JAVAP_TIMEOUT_MS = 15 \* 1000/, 'javap is bounded too')
1678
+ assert.match(host, /child\.kill\('SIGKILL'\)/, 'the timed-out child is actually killed')
1679
+ assert.match(host, /timedOut: true/, 'the caller can tell a timeout from a failure')
1680
+ assert.match(host, /const CLASS_JAR_CACHE = new Map\(\)/, 'repeated dependency jumps do not rescan every classpath jar')
1681
+ const chunk = await readFile(new URL('../lib/client-codemirror.js', import.meta.url), 'utf8')
1682
+ assert.ok(chunk.includes(String.raw`[\\w$]+\\.`), 'javap FQN headers still count as the type declaration')
1683
+ })
1684
+
1685
+ test('a class outside every program log still resolves: workspace classpath, then the JDK (m05797)', async () => {
1686
+ const { readFile } = await import('node:fs/promises')
1687
+ const host = await readFile(new URL('../lib/index.js', import.meta.url), 'utf8')
1688
+ assert.match(host, /async function resolveDependencySourceIn\(cwd, dirs, className\)/, 'every workspace classpath file is tried for a class clicked outside a started program')
1689
+ assert.match(host, /async function findDependencyJarIn\(dirs, className\)/, 'the background sources job still knows which jar was clicked')
1690
+ assert.match(host, /async function resolveJdkSource\(cwd, className\)/, 'platform classes fall back to the JDK itself')
1691
+ assert.match(host, /function jdkSourcesArchives\(/, 'the JDK src.zip is preferred when the distribution ships one')
1692
+ assert.match(host, /runCapture\('javap', \['-p', '-c', '-l', className\]/, 'javap without a classpath reads the running module path')
1693
+ // Only the JDWP debug routes still require a program log; both dependency
1694
+ // routes accept a missing `path` (a class clicked in a module never started).
1695
+ assert.equal((host.match(/path \(the program log path\) is required/g) ?? []).length, 2, 'the dependency routes no longer require a program log')
1696
+ const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
1697
+ assert.match(source, /var logPath = dependencyLogPath\(fromPath\)\n\s+var fqn = javaTypeFqn\(text, name\)/, 'a missing log path does not abort the dependency route')
1698
+ assert.match(source, /statusNote\('正在解析 ' \+ fqn/, 'the note no longer claims the workspace search gave up')
1699
+ // Symbol-navigation messages belong in the bottom status bar, not toasts (m05950):
1700
+ // the transient area sits right after the "文件 x/20" counter and statusNote()
1701
+ // replaces the previous message and clears itself after a few seconds.
1702
+ assert.doesNotMatch(source, /note\('正在解析/, 'resolving a dependency never pops a toast')
1703
+ assert.doesNotMatch(source, /note\('找不到 ' \+ name/, 'a search miss never pops a toast')
1704
+ assert.ok(source.includes("statusNote('找不到 ' + name + ' 的声明'"), 'a search miss lands in the status bar instead')
1705
+ const fileCounter = source.indexOf("' · 文件 ' + openFiles.length")
1706
+ const statusArea = source.indexOf("'data-ide-status-text'")
1707
+ assert.ok(fileCounter >= 0 && statusArea > fileCounter && statusArea - fileCounter < 900, 'the transient status area follows the file counter')
1708
+ const chunk = await readFile(new URL('../lib/client-codemirror.js', import.meta.url), 'utf8')
1709
+ assert.match(chunk, /function symbolDrillWord\(view, pos\)/, 'a package line is not a symbol and only the last import segment is drillable')
1710
+ assert.match(chunk, /trimmed\.startsWith\(["']package["']\)/, 'package lines never highlight or jump')
1711
+ assert.match(source, /function symbolNavigationPath\(path\)/, 'symbol navigation is decided per document path')
1712
+ assert.match(source, /symbolNavigation: symbolNavigationPath\(/, 'only java/class tabs turn the feature on')
1713
+ assert.match(chunk, /options\.symbolNavigation === false/, 'a non-java tab never attaches the hover plugin or the click handler')
1714
+ })
1715
+
1716
+ test('a missing sources jar is fetched in the background while the decompiled text opens (m05238)', async () => {
1717
+ const { readFile } = await import('node:fs/promises')
1718
+ const host = await readFile(new URL('../lib/index.js', import.meta.url), 'utf8')
1719
+ assert.match(host, /const DEBUG_SOURCE_STATUS_PATH = /, 'the editor can poll for the downloaded sources')
1720
+ assert.match(host, /payload\.sourcePending = true/, 'the decompiled answer carries sourcePending')
1721
+ assert.match(host, /'dependency:sources'/, 'Maven is the download mechanism (the workspace pom decides the repository)')
1722
+ assert.match(host, /-DincludeArtifactIds=/, 'only the artifact that was actually clicked is fetched')
1723
+ assert.match(host, /const SOURCE_FETCH_TIMEOUT_MS = 120 \* 1000/, 'a wedged mvn cannot hang the background job forever')
1724
+ assert.match(host, /function startSourceFetch\(cwd, programDir, jarPath\)/, 'one background job per jar')
1725
+ assert.match(host, /const mvnDir = nearestPomDir\(programDir\)/, 'Maven resolves the clicked dependency from the module POM, so the version is the one this build uses')
1726
+ assert.match(host, /async function serveDebugSourceStatus\(/, 'the status route exists')
1727
+ const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
1728
+ assert.match(source, /if \(resolved\.sourcePending === true\) pollDependencySources\(/, 'a pending source starts the poller')
1729
+ assert.match(source, /routeUrl\('dsh-ris-ide\/debug\/source-status'\)/, 'the poller hits the status route')
1730
+ assert.match(source, /'data-source-upgrade': '1'/, 'the banner is rendered above the editor')
1731
+ assert.match(source, /payload\.member/, 'the click payload carries the annotation attribute')
1732
+ assert.match(source, /switchToDependencySource\(upgrade\)/, 'clicking the banner switches to the real sources')
1733
+ assert.match(source, /activePathRef\.current === decompiledPath/, 'the decompiled view switches by itself once the sources land')
1734
+ assert.match(source, /closePath\(upgrade\.decompiledPath\)/, 'the decompiled fallback tab is closed after switching')
1735
+ assert.match(source, /docsRef\.current\[decompiledPath\] === undefined/, 'a closed decompiled tab stops the fetch poller silently')
1736
+ assert.match(source, /sourceUpgrade\.decompiledPath === path\) setSourceUpgrade\(null\)/, 'closing the fallback tab drops its stale banner')
1737
+ assert.match(source, /sourcePending: parsed\.sourcePending === true/, 'the host flag survives the client parser')
1738
+ })
1739
+
1646
1740
  test('the tree clipboard keys only fire while the tree owns the focus', async () => {
1647
1741
  const { readFile } = await import('node:fs/promises')
1648
1742
  const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
@@ -4510,8 +4604,28 @@ test('a frame without source in the workspace is ignored quietly', async () => {
4510
4604
  assert.doesNotMatch(source, /源码不在工作区/)
4511
4605
  assert.match(source, /'data-missing-source': '1'/)
4512
4606
  assert.match(source, /'无源码 · '/)
4513
- // The miss stays cached so a step storm never re-scans the workspace.
4514
- assert.match(source, /sourcePathRef\.current\[cleaned\] = found === undefined \? null : found/)
4607
+ // A miss is cached for a minute only: `mvn` may still be fetching the sources
4608
+ // jar in the background, so the lookup has to run again later (m06100).
4609
+ assert.match(source, /var sourceMissRef = useRef\(\{\}\)/)
4610
+ assert.match(source, /var SOURCE_MISS_TTL_MS = 60 \* 1000/)
4611
+ assert.match(source, /Date\.now\(\) - missedAt < SOURCE_MISS_TTL_MS/)
4612
+ assert.match(source, /sourceMissRef\.current\[cleaned\] = Date\.now\(\)/)
4613
+ assert.match(source, /sourcePathRef\.current\[cleaned\] = found\n/)
4614
+ assert.doesNotMatch(source, /sourcePathRef\.current\[cleaned\] = found === undefined \? null : found/)
4615
+ })
4616
+
4617
+ test('the debugger shares the click-to-declaration dependency pipeline (m06100)', async () => {
4618
+ const { readFile } = await import('node:fs/promises')
4619
+ const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
4620
+
4621
+ // Same host route, same pending-sources poller and banner as Ctrl/Cmd+click:
4622
+ // the poller lives at workbench scope so both entry points can call it.
4623
+ assert.match(source, /^ function pollDependencySources\(displayName, fqn, logPath, decompiledPath\) \{/m)
4624
+ assert.match(source, /^ function switchToDependencySource\(upgrade\) \{/m)
4625
+ assert.match(source, /var resolved = await fsDependencySource\(scopeRef\.current, cleaned, debugLogPath\)/)
4626
+ assert.match(source, /found = resolved\.path/)
4627
+ assert.match(source, /if \(resolved\.sourcePending === true\) \{/)
4628
+ assert.match(source, /pollDependencySources\(cleaned\.split\('\.'\)\.pop\(\), cleaned, debugLogPath, found\)/)
4515
4629
  })
4516
4630
 
4517
4631
  test('a debug start, stop or resume re-reads the log pane', async () => {
@@ -5378,3 +5492,61 @@ test('the workbench reads its saved blob once per mount and remounts per workspa
5378
5492
  // The compact panel layout is a machine-wide preference on purpose.
5379
5493
  assert.match(source, /Deliberately NOT workspace-scoped/)
5380
5494
  })
5495
+
5496
+ test('member access is classified and inherited members walk the extends chain (m06015)', async () => {
5497
+ const chunk = await readFile(new URL('../lib/client-codemirror.js', import.meta.url), 'utf8')
5498
+ const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
5499
+ // Chunk side: `Receiver.Member` is parsed from the click position and handed to
5500
+ // the core, which knows about imports, parents and dependency sources.
5501
+ assert.match(chunk, /function memberAccessAt\(view, pos\)/, 'Receiver.Member is parsed at the click position')
5502
+ assert.match(chunk, /function jumpToMember\(view, access, options\)/, 'member clicks are handed to the core')
5503
+ assert.match(chunk, /receiver: access\.receiver,/, 'the receiver travels with the member')
5504
+ // Core side: classification + resolution.
5505
+ assert.match(source, /function memberDeclarationIn\(source, member\)/, 'member declarations are classified')
5506
+ assert.match(source, /function javaVariableType\(source, name\)/, 'a variable receiver resolves through its declared type')
5507
+ assert.match(source, /function javaSuperClass\(source\)/, 'the extends chain is followed for inherited fields')
5508
+ assert.match(source, /var receiver = typeof payload\.receiver === 'string'/, 'member payloads take the member route')
5509
+ assert.match(source, /jumpToMemberInProject\(receiver, member, fromPath, text\)/)
5510
+ assert.match(source, /'父类 ' \+ parent/, 'inherited members say which parent declared them')
5511
+ assert.match(source, /label \+ ' · ' \+ describeMember\(decl\)/, 'the status bar states the member kind')
5512
+ assert.match(source, /decl\.static \? '静态方法' : '方法'/, 'static methods are labelled')
5513
+ assert.match(source, /decl\.constant \? '静态常量' : '静态字段'/, 'static final uppercase fields are constants')
5514
+ assert.match(source, /receiver === 'this' \|\| receiver === 'super'/, 'this/super start at the current type')
5515
+
5516
+ // Behaviour: extract the three text helpers and check a small Java sample.
5517
+ function sliceFunction(name) {
5518
+ const start = source.indexOf('function ' + name + '(')
5519
+ assert.ok(start >= 0, name + ' exists')
5520
+ const end = source.indexOf('\n }', start)
5521
+ return source.slice(start, end + 6)
5522
+ }
5523
+ const helpers = new Function(
5524
+ sliceFunction('memberDeclarationIn') + '\n' + sliceFunction('javaVariableType') + '\n' + sliceFunction('javaSuperClass') +
5525
+ '\nreturn { memberDeclarationIn, javaVariableType, javaSuperClass }',
5526
+ )()
5527
+ const sample = [
5528
+ 'package a.b;',
5529
+ 'public class SqlMethod {',
5530
+ ' public static final SqlMethod INSERT_ONE = new SqlMethod();',
5531
+ ' private final Class<?> entityClass;',
5532
+ ' public static boolean retBool(long n) { return n > 0; }',
5533
+ '}',
5534
+ 'class SqlHelper { static boolean retBool(long n) { return true; } }',
5535
+ 'class Base { protected Class<?> entityClass; }',
5536
+ 'class Sub extends Base { private String name; }',
5537
+ ].join('\n')
5538
+ const constant = helpers.memberDeclarationIn(sample, 'INSERT_ONE')
5539
+ assert.equal(constant.kind, 'field')
5540
+ assert.equal(constant.static, true)
5541
+ assert.equal(constant.constant, true, 'static final uppercase field is a constant')
5542
+ assert.equal(constant.line, 3)
5543
+ const field = helpers.memberDeclarationIn(sample, 'entityClass')
5544
+ assert.equal(field.kind, 'field')
5545
+ assert.equal(field.static, false)
5546
+ const method = helpers.memberDeclarationIn(sample, 'retBool')
5547
+ assert.equal(method.kind, 'method')
5548
+ assert.equal(method.static, true)
5549
+ assert.equal(helpers.javaVariableType('private final Class<?> entityClass;', 'entityClass'), 'Class')
5550
+ assert.equal(helpers.javaVariableType('private String name = "x";', 'name'), 'String')
5551
+ assert.equal(helpers.javaSuperClass('class Sub extends Base { }'), 'Base')
5552
+ })
@@ -4,7 +4,8 @@
4
4
  // inside the freshness window.
5
5
  import assert from 'node:assert/strict'
6
6
  import { createServer, request } from 'node:http'
7
- import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
7
+ import { spawn } from 'node:child_process'
8
+ import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
8
9
  import { tmpdir } from 'node:os'
9
10
  import { join } from 'node:path'
10
11
  import { after, before, test } from 'node:test'
@@ -12,14 +13,20 @@ import { __test, handleRequest } from '../lib/index.js'
12
13
 
13
14
  let home
14
15
 
16
+ // The refresh tick drops a row whose workspace directory no longer exists (m14800),
17
+ // so the fixture workspaces these tests talk about must really exist on disk.
18
+ const FIXTURE_DIRS = ['/tmp/ws-a', '/tmp/ws-b', '/tmp/ws-c', '/tmp/ws-garbage', '/tmp/ws-moved', '/tmp/ws-new', '/tmp/ws-other']
19
+
15
20
  before(() => {
16
21
  home = mkdtempSync(join(tmpdir(), 'dsh-window-refresh-'))
17
22
  process.env.DSH_RIS_IDE_PROXY_HOME = home
23
+ for (const dir of FIXTURE_DIRS) mkdirSync(dir, { recursive: true })
18
24
  })
19
25
 
20
26
  after(() => {
21
27
  delete process.env.DSH_RIS_IDE_PROXY_HOME
22
28
  rmSync(home, { recursive: true, force: true })
29
+ for (const dir of FIXTURE_DIRS) rmSync(dir, { recursive: true, force: true })
23
30
  })
24
31
 
25
32
  function writeWindows(windows) {
@@ -67,16 +74,49 @@ test('a missing window list is a no-op', () => {
67
74
  assert.deepEqual(__test.refreshDshWindows({ sessions: { get: () => ({}) } }), { changed: 0, windows: 0, dropped: 0 })
68
75
  })
69
76
 
70
- test("another dsh instance's rows are left alone", () => {
77
+ test("a live dsh instance's rows are left alone", async () => {
71
78
  // The home is machine-wide: two dsh processes share dsh-window.json, and each may
72
79
  // only vouch for sessions IT knows. A row stamped with a foreign ownerPid must
73
- // survive even though this process cannot resolve its sessionId (review C2-P2-2).
80
+ // survive while that process runs, even though this process cannot resolve its
81
+ // sessionId (review C2-P2-2) — but it can never be pruned by anyone once that
82
+ // process exits (m14800), so the liveness check has to be real.
83
+ const peer = spawn(process.execPath, ['-e', 'setInterval(function () {}, 1000)'], { stdio: 'ignore' })
84
+ try {
85
+ const old = new Date(Date.now() - 10 * 60_000).toISOString()
86
+ writeWindows([
87
+ { url: 'http://127.0.0.1:3080', cwd: '/tmp/ws-other', sessionId: 's-foreign', ownerPid: peer.pid, at: old },
88
+ ])
89
+ assert.deepEqual(__test.refreshDshWindows({ sessions: { get: () => null } }), { changed: 0, windows: 1, dropped: 0 })
90
+ assert.equal(readWindows()[0].sessionId, 's-foreign')
91
+ } finally {
92
+ peer.kill()
93
+ }
94
+ })
95
+
96
+ test('a row whose dsh process exited is dropped (m14800)', () => {
97
+ // Nothing else could ever retire the row: its owner is gone, and the daemon keeps
98
+ // rows for seven days. The workspace used to sit in the IDE list for days.
74
99
  const old = new Date(Date.now() - 10 * 60_000).toISOString()
75
100
  writeWindows([
76
101
  { url: 'http://127.0.0.1:3080', cwd: '/tmp/ws-other', sessionId: 's-foreign', ownerPid: 999999, at: old },
77
102
  ])
78
- assert.deepEqual(__test.refreshDshWindows({ sessions: { get: () => null } }), { changed: 0, windows: 1, dropped: 0 })
79
- assert.equal(readWindows()[0].sessionId, 's-foreign')
103
+ assert.deepEqual(__test.refreshDshWindows({ sessions: { get: () => null } }), { changed: 0, windows: 0, dropped: 1 })
104
+ assert.deepEqual(readWindows(), [])
105
+ })
106
+
107
+ test('a row for a deleted workspace directory is dropped (m14800)', () => {
108
+ // Deleting a workspace while a session still points at it used to keep the row
109
+ // alive: the session resolved, so the refresh only re-stamped `at`. The IDE then
110
+ // advertised a workspace that cannot be opened.
111
+ const old = new Date(Date.now() - 10 * 60_000).toISOString()
112
+ writeWindows([
113
+ { url: 'http://127.0.0.1:3080', cwd: '/tmp/ws-deleted-14800', sessionId: 's-live', at: old },
114
+ ])
115
+ const result = __test.refreshDshWindows({
116
+ sessions: { get: (id) => (id === 's-live' ? { header: { cwd: '/tmp/ws-deleted-14800' } } : null) },
117
+ })
118
+ assert.deepEqual(result, { changed: 0, windows: 0, dropped: 1 })
119
+ assert.deepEqual(readWindows(), [])
80
120
  })
81
121
 
82
122
  test('a garbage ownerPid makes the row ours, not somebody else\'s', () => {
@@ -22,6 +22,8 @@ export const HAS_GIT = hasCommand('git')
22
22
  export const HAS_BASH = hasCommand('bash', ['-c', 'true'])
23
23
  /** WSL 上把 Linux 路径翻成 Windows 形式要靠它;普通 Linux 用 lib 的测试接缝替代。 */
24
24
  export const HAS_WSLPATH = hasCommand('wslpath', ['-w', '/tmp'])
25
+ /** javap ships with the JDK; platform-class fallback needs it (m05797). */
26
+ export const HAS_JAVAP = hasCommand('javap', ['-version'])
25
27
 
26
28
  /** node:test `skip` value: false when available, else the reason string. */
27
29
  export function skipWithout(available, label) {
@@ -17,7 +17,7 @@ import { dirname, join, resolve } from 'node:path'
17
17
  import { fileURLToPath } from 'node:url'
18
18
 
19
19
  import { __test } from '../lib/index.js'
20
- import { HAS_BASH, HAS_GIT, skipWithout } from './helpers/cmd.mjs'
20
+ import { HAS_BASH, HAS_GIT, HAS_JAVAP, skipWithout } from './helpers/cmd.mjs'
21
21
 
22
22
  const {
23
23
  resolvePath, isLoopbackRequest, readTail, clampBytes, serveTail, serveStop, handleRequest,
@@ -669,6 +669,23 @@ test('the programs route scans over HTTP and the start route refuses bad input',
669
669
  }, undefined, root)
670
670
  })
671
671
 
672
+ test('platform classes resolve from the JDK itself when no jar carries them (m05797)', { skip: skipWithout(HAS_JAVAP, 'javap') }, async () => {
673
+ const workspace = await mkdtemp(join(tmpdir(), 'dsh-ris-ide-jdk-'))
674
+ try {
675
+ const resolved = await __test.resolveJdkSource(workspace, 'java.lang.annotation.ElementType')
676
+ assert.ok(resolved !== undefined, 'javap (or a JDK src.zip) answers for a platform class')
677
+ const text = await readFile(resolved.path, 'utf8')
678
+ assert.match(text, /java\.lang\.annotation\.ElementType/, 'the cached text carries the class')
679
+ // The same path without any module directory (a class clicked in a module that
680
+ // was never started through the IDE has no program log to name).
681
+ const viaEmptyDirs = await __test.resolveDependencySourceIn(workspace, [], 'java.lang.annotation.ElementType')
682
+ assert.ok(viaEmptyDirs !== undefined)
683
+ assert.equal(viaEmptyDirs.kind, resolved.kind)
684
+ } finally {
685
+ await rm(workspace, { recursive: true, force: true })
686
+ }
687
+ })
688
+
672
689
  test('the open-target route resolves a program by id and never invents a URL (m03945)', async () => {
673
690
  const { root } = await makeProgramFixture()
674
691
  await withServer(async ({ base }) => {