dsh-ris-ide 1.8.3 → 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.
- package/README.md +1 -1
- package/lib/client-codemirror.js +516 -11
- package/lib/client.js +832 -57
- package/lib/index.js +533 -48
- package/lib/risd/server.js +12 -3
- package/lib/standalone/window.html +10 -0
- package/package.json +2 -2
- package/test/client-build.test.mjs +3 -0
- package/test/client-viewer.test.mjs +227 -7
- package/test/dsh-window-refresh.test.mjs +45 -5
- package/test/helpers/cmd.mjs +2 -0
- package/test/host-tail.test.mjs +18 -1
- package/test/risd-api.test.mjs +22 -0
package/lib/risd/server.js
CHANGED
|
@@ -118,9 +118,18 @@ function dshSidebarRows(sidebar, windows, origin) {
|
|
|
118
118
|
const window = remembered.get(cwd)
|
|
119
119
|
if (window !== undefined) remembered.delete(cwd)
|
|
120
120
|
const title = typeof entry.title === 'string' ? entry.title : ''
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
// Which Session should the IDE bind to? The sidebar mirror names the session
|
|
122
|
+
// DSH associates with the workspace, but a remembered window row names the
|
|
123
|
+
// session that actually refreshed this workspace LAST — validated by the
|
|
124
|
+
// plugin (its header.cwd === row.cwd, else the row is dropped). Preferring
|
|
125
|
+
// the live window session keeps the row's sessionId stable while the page is
|
|
126
|
+
// open: mixing the two ids across `/v1/dsh` polls made the maintenance page
|
|
127
|
+
// rewrite the iframe URL (cwd|sessionId signature) and reload the IDE — the
|
|
128
|
+
// "切换工作区加载错误 / 内容窜" symptom (m00001-2). The sidebar value stays as
|
|
129
|
+
// the fallback for a workspace nobody opened yet.
|
|
130
|
+
const sessionId = window !== undefined && typeof window.sessionId === 'string' && window.sessionId !== ''
|
|
131
|
+
? window.sessionId
|
|
132
|
+
: (typeof entry.sessionId === 'string' ? entry.sessionId : '')
|
|
124
133
|
rows.push({
|
|
125
134
|
cwd,
|
|
126
135
|
title: title !== '' ? title : (window === undefined ? '' : window.title),
|
|
@@ -175,6 +175,16 @@
|
|
|
175
175
|
else if (data.type === 'close') closeForOpener()
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
|
+
// INSIDE an iframe (the maintenance page's IDE tab) the one-window rule is
|
|
179
|
+
// already enforced by the single reused <iframe>: it navigates THIS document
|
|
180
|
+
// away instead of stacking a second one. Claiming the lock there only races
|
|
181
|
+
// the previous document's release — the fresh document failed its claim and
|
|
182
|
+
// painted "RIS-IDE 已在另一个窗口打开" instead of the IDE, which is what made
|
|
183
|
+
// a workspace switch in risd-ui look like a load error (m00001-2). Embedded
|
|
184
|
+
// windows boot directly; standalone popups keep the lock.
|
|
185
|
+
var embeddedBoot = false
|
|
186
|
+
try { embeddedBoot = window.self !== window.top } catch (error) { embeddedBoot = false }
|
|
187
|
+
if (embeddedBoot) { becomeHolder(); resolveClaim(true); return }
|
|
178
188
|
var locks = typeof navigator !== 'undefined' ? navigator.locks : undefined
|
|
179
189
|
if (locks && typeof locks.request === 'function') {
|
|
180
190
|
var attempt = 0
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-ris-ide",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.5",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"description": "RIS-IDE local dev panel for the DSH web GUI: live log tail, one-click start/stop of workspace programs, JDWP debugging, file tree + editor, and a standalone IDE window that carries no session history.
|
|
5
|
+
"description": "RIS-IDE local dev panel for the DSH web GUI: live log tail, one-click start/stop of workspace programs, JDWP debugging, file tree + editor, and a standalone IDE window that carries no session history. \u00b7 DSH \u53f3\u4fa7\u680f\u672c\u5730\u5f00\u53d1\u9762\u677f\uff1a\u65e5\u5fd7\u5b9e\u65f6\u8ddf\u968f\u3001\u4e00\u952e\u542f\u505c\u672c\u5730\u7a0b\u5e8f\u3001Java \u65ad\u70b9\u8c03\u8bd5\u3001\u6587\u4ef6\u6811\u4e0e\u7f16\u8f91\u5668\u3001\u72ec\u7acb IDE \u7a97\u53e3\u3002",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"dsh",
|
|
8
8
|
"dsh-plugin",
|
|
@@ -107,6 +107,9 @@ test('a stale page offers a refresh and never reloads itself', () => {
|
|
|
107
107
|
test('the stale-build bar carries a refresh button', () => {
|
|
108
108
|
const source = readFileSync(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
109
109
|
const notice = source.slice(source.indexOf('function showStaleBuildNotice'), source.indexOf('function watchClientBuild'))
|
|
110
|
+
// m06203: dsh端取消 —— the DSH page hosts this panel in its right sidebar, and the
|
|
111
|
+
// banner's only action is a full-page reload there, so it is standalone-only.
|
|
112
|
+
assert.match(notice, /if \(!inStandaloneIdeWindow\(\)\) return/)
|
|
110
113
|
assert.match(notice, /textContent = '刷新'/)
|
|
111
114
|
assert.match(notice, /location\.reload\(\)/, 'the reload happens only when the user clicks it')
|
|
112
115
|
assert.match(notice, /staleNoticeDismissedFor = staleNoticeBuild/)
|
|
@@ -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')
|
|
@@ -3516,6 +3610,54 @@ test('only a FRONTEND row offers the browser button, and only a yds project prom
|
|
|
3516
3610
|
assert.doesNotMatch(source, /yds 项目会自动注入 YYCToken/, 'the old unconditional yds wording is gone')
|
|
3517
3611
|
})
|
|
3518
3612
|
|
|
3613
|
+
test('the IDE console is wired to the owning panel\'s openSite (m00982)', async () => {
|
|
3614
|
+
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
3615
|
+
// The button RESOLVES nothing itself: ProgramsPanel owns the fetch and the
|
|
3616
|
+
// one-tab guard, and hands both down (m04354: a backend has no page to open).
|
|
3617
|
+
assert.match(source, /onOpenSite: openSite,/)
|
|
3618
|
+
assert.match(source, /siteBusyId: busySiteId,/)
|
|
3619
|
+
assert.match(source, /ydsProject: ydsProject,/)
|
|
3620
|
+
// `button()` turns `action` into `data-action` in the DOM.
|
|
3621
|
+
assert.match(source, /action: 'console-open-site'/)
|
|
3622
|
+
assert.match(source, /var onOpenSite = typeof props\.onOpenSite === 'function' \? props\.onOpenSite : null/)
|
|
3623
|
+
assert.match(source, /if \(onOpenSite !== null\) onOpenSite\(program\)/)
|
|
3624
|
+
})
|
|
3625
|
+
|
|
3626
|
+
test('the IDE console opens a frontend page with the same 🌐 as the sidebar (m00982)', { skip: !reactIsReal ? 'React unavailable for SSR' : false }, () => {
|
|
3627
|
+
const markup = renderWorkbench({
|
|
3628
|
+
programs: [
|
|
3629
|
+
{ id: 'frontend:ui#dev', name: 'ris-ui-3', kind: 'frontend', logPath: '/w/logs/ui.log', running: { alive: true } },
|
|
3630
|
+
{ id: 'spring:a#A', name: 'a-biz', kind: 'spring', logPath: '/w/logs/a.log', running: { alive: true } },
|
|
3631
|
+
],
|
|
3632
|
+
})
|
|
3633
|
+
assert.equal((markup.match(/data-action="console-open-site"/g) || []).length, 1, 'frontend rows only: the spring row has no page')
|
|
3634
|
+
const buttonTag = ((markup.match(/<button[^>]*>/g) || []).filter((tag) => tag.includes('data-action="console-open-site"'))[0]) || ''
|
|
3635
|
+
assert.match(buttonTag, /width:25px/, 'same fixed width as the other console icons')
|
|
3636
|
+
assert.match(buttonTag, /在系统浏览器打开 ris-ui-3 的页面/)
|
|
3637
|
+
|
|
3638
|
+
// No frontend → no button at all (a workspace of backends must not show one).
|
|
3639
|
+
const springOnly = renderWorkbench({
|
|
3640
|
+
programs: [{ id: 'spring:a#A', name: 'a-biz', kind: 'spring', logPath: '/w/logs/a.log', running: { alive: false } }],
|
|
3641
|
+
})
|
|
3642
|
+
assert.doesNotMatch(springOnly, /console-open-site/, 'backend-only workspaces get no browser button')
|
|
3643
|
+
|
|
3644
|
+
// In flight: the row shows progress and cannot launch a second tab.
|
|
3645
|
+
const busy = renderWorkbench({
|
|
3646
|
+
siteBusyId: 'frontend:ui#dev',
|
|
3647
|
+
programs: [{ id: 'frontend:ui#dev', name: 'ris-ui-3', kind: 'frontend', logPath: '/w/logs/ui.log', running: { alive: true } }],
|
|
3648
|
+
})
|
|
3649
|
+
const busyTag = ((busy.match(/<button[^>]*>/g) || []).filter((tag) => tag.includes('data-action="console-open-site"'))[0]) || ''
|
|
3650
|
+
assert.match(busyTag, /disabled=""/)
|
|
3651
|
+
assert.match(busy, /…<\/button>/)
|
|
3652
|
+
|
|
3653
|
+
// The token sentence only appears for a yds workspace (m04354).
|
|
3654
|
+
const yds = renderWorkbench({
|
|
3655
|
+
ydsProject: true,
|
|
3656
|
+
programs: [{ id: 'frontend:ui#dev', name: 'ris-ui-3', kind: 'frontend', logPath: '/w/logs/ui.log', running: { alive: true } }],
|
|
3657
|
+
})
|
|
3658
|
+
assert.match(yds, /yds 项目:请求自动带上登录 token,免登录/)
|
|
3659
|
+
})
|
|
3660
|
+
|
|
3519
3661
|
test('the tab strip shows ⟳ while the buffer is clean and ± once it is dirty (m00388/m00808)', { skip: !reactIsReal ? 'React unavailable for SSR' : false }, () => {
|
|
3520
3662
|
const markup = renderWorkbenchWithFile('/w/README.md')
|
|
3521
3663
|
const tag = (markup.match(/<button[^>]*data-action="reload-file"[^>]*>/) || [''])[0]
|
|
@@ -4462,8 +4604,28 @@ test('a frame without source in the workspace is ignored quietly', async () => {
|
|
|
4462
4604
|
assert.doesNotMatch(source, /源码不在工作区/)
|
|
4463
4605
|
assert.match(source, /'data-missing-source': '1'/)
|
|
4464
4606
|
assert.match(source, /'无源码 · '/)
|
|
4465
|
-
//
|
|
4466
|
-
|
|
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\)/)
|
|
4467
4629
|
})
|
|
4468
4630
|
|
|
4469
4631
|
test('a debug start, stop or resume re-reads the log pane', async () => {
|
|
@@ -4553,9 +4715,9 @@ test('a start switches to that program log before waiting for the spawn', async
|
|
|
4553
4715
|
// block for START_WAIT_MS, and Maven compile prints nothing for tens of seconds.
|
|
4554
4716
|
assert.match(source, /async function consoleStart\(program\) \{\n\s*\/\/[\s\S]*?\n\s*selectProgram\(program\)[\s\S]*?setConsoleBusy\(program\.id\)[\s\S]*?requestStart\(program\.id, scopeRef\.current\)/)
|
|
4555
4717
|
// The sidebar rows do the same before awaiting requestStart.
|
|
4556
|
-
assert.match(source, /if \(boots\) \{ setActive\(program\); broadcastLogFocus\(program\.logPath\); setCompactLogNonce/)
|
|
4718
|
+
assert.match(source, /if \(boots\) \{ setActive\(program\); broadcastLogFocus\(program\.logPath, sessionId, cwd\); setCompactLogNonce/)
|
|
4557
4719
|
// …and every window watching another log is moved by the same broadcast.
|
|
4558
|
-
assert.match(source, /function broadcastLogFocus\(logPath\)/)
|
|
4720
|
+
assert.match(source, /function broadcastLogFocus\(logPath, sessionId, cwd\)/)
|
|
4559
4721
|
})
|
|
4560
4722
|
|
|
4561
4723
|
test('the debug pane has a visual settings dialog for dependency sources', { skip: !reactIsReal ? 'React unavailable for SSR' : false }, async () => {
|
|
@@ -4614,7 +4776,7 @@ test('debug start switches the log pane first, and the variable caret is borderl
|
|
|
4614
4776
|
assert.match(slice, /setLogNonce\(function \(value\) \{ return value \+ 1 \}\)/)
|
|
4615
4777
|
// The switch follows the user into other windows, and the tail is re-read the
|
|
4616
4778
|
// moment the restarted service prints its first byte (Maven is quiet).
|
|
4617
|
-
assert.match(slice, /broadcastLogFocus\(logPath\)/)
|
|
4779
|
+
assert.match(slice, /broadcastLogFocus\(logPath, sessionId, cwd\)/)
|
|
4618
4780
|
assert.match(slice, /watchLogOutput\(logPath, baseline\)/)
|
|
4619
4781
|
// Tree caret: glyph only, no bordered button box.
|
|
4620
4782
|
assert.match(source, /var caretStyle = \{[\s\S]{0,400}?border: 'none'/)
|
|
@@ -5006,7 +5168,7 @@ test('the editor scrollbars are visible and a start re-reads its log', async ()
|
|
|
5006
5168
|
assert.match(source, /SELECTION_CSS \+ SCROLLBAR_CSS \+ SEARCH_PANEL_CSS \+ TOAST_CSS/, 'injected with the panel styles')
|
|
5007
5169
|
assert.doesNotMatch(source, /SCROLLBAR_CSS[\s\S]{0,800}?scrollbar-gutter/, 'no empty gutter on files that do not overflow')
|
|
5008
5170
|
// BUG6: a start records a size baseline and watches for its first new byte …
|
|
5009
|
-
assert.match(source, /async function consoleStart\(program\) \{[\s\S]{0,
|
|
5171
|
+
assert.match(source, /async function consoleStart\(program\) \{[\s\S]{0,900}?await logSizeOf\(logPath\)/, 'the start records a size baseline')
|
|
5010
5172
|
assert.match(source, /async function consoleStart\(program\) \{[\s\S]{0,2400}?watchLogOutput\(logPath, baseline\)/, 'and watches the first new byte')
|
|
5011
5173
|
// … a pane mounting on an already-open socket reads its tail once …
|
|
5012
5174
|
assert.match(source, /if \(typeof EventSource !== 'function'\) return\n\s*void refresh\(\)/, 'first paint reads the tail')
|
|
@@ -5014,7 +5176,7 @@ test('the editor scrollbars are visible and a start re-reads its log', async ()
|
|
|
5014
5176
|
// polls instead of waiting on someone else's stream.
|
|
5015
5177
|
assert.match(source, /var servedTail = ''/, 'the connection remembers its tail path')
|
|
5016
5178
|
assert.match(source, /notifyOpen\(\)/)
|
|
5017
|
-
assert.match(source, /setStreamOk\(served === '' \|\| served === path\)/, 'a pane the socket does not carry falls back to polling')
|
|
5179
|
+
assert.match(source, /setStreamOk\(mismatch !== true && \(served === '' \|\| served === path\)\)/, 'a pane the socket does not carry (or another scope) falls back to polling')
|
|
5018
5180
|
assert.match(source, /setCompactLogNonce\(function \(value\) \{ return value \+ 1 \}\)/, 'the sidebar pane re-reads after start/stop')
|
|
5019
5181
|
// … and the host never drops a delta without re-snapshotting.
|
|
5020
5182
|
const host = await readFile(new URL('../lib/index.js', import.meta.url), 'utf8')
|
|
@@ -5330,3 +5492,61 @@ test('the workbench reads its saved blob once per mount and remounts per workspa
|
|
|
5330
5492
|
// The compact panel layout is a machine-wide preference on purpose.
|
|
5331
5493
|
assert.match(source, /Deliberately NOT workspace-scoped/)
|
|
5332
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 {
|
|
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("
|
|
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
|
|
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:
|
|
79
|
-
assert.
|
|
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', () => {
|
package/test/helpers/cmd.mjs
CHANGED
|
@@ -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) {
|
package/test/host-tail.test.mjs
CHANGED
|
@@ -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 }) => {
|
package/test/risd-api.test.mjs
CHANGED
|
@@ -409,6 +409,28 @@ test('/v1/dsh drops unusable `at` values and counts them (review A3-P2-6)', asyn
|
|
|
409
409
|
assert.equal(body.dropped, 3, 'every unusable timestamp is reported, not silently pruned')
|
|
410
410
|
})
|
|
411
411
|
|
|
412
|
+
test('/v1/dsh names a workspace by the Session that refreshed its window row (m00001-2)', async (t) => {
|
|
413
|
+
// The sidebar mirror names the session DSH associates with each workspace; the
|
|
414
|
+
// remembered window row names the session that most recently opened that
|
|
415
|
+
// workspace. They can differ, and mixing them per poll made the maintenance page
|
|
416
|
+
// rewrite (and reload) the IDE iframe every few seconds. The live window row wins.
|
|
417
|
+
const { home, state } = await startFixture(t)
|
|
418
|
+
const now = new Date().toISOString()
|
|
419
|
+
writeFileSync(join(home, 'dsh-window.json'), `${JSON.stringify({
|
|
420
|
+
windows: [{ url: 'http://127.0.0.1:3080', sessionId: 'win-session', cwd: '/tmp/ws-window', title: 'window', at: now }],
|
|
421
|
+
workspaces: [
|
|
422
|
+
{ cwd: '/tmp/ws-window', title: 'window', sessionId: 'sidebar-session', active: true },
|
|
423
|
+
{ cwd: '/tmp/ws-sidebar', title: 'sidebar', sessionId: 'sidebar-only', active: true },
|
|
424
|
+
],
|
|
425
|
+
at: now,
|
|
426
|
+
})}\n`)
|
|
427
|
+
const body = await (await call(state, '/v1/dsh')).json()
|
|
428
|
+
assert.equal(body.available, true)
|
|
429
|
+
const rows = new Map(body.windows.map((row) => [row.cwd, row]))
|
|
430
|
+
assert.equal(rows.get('/tmp/ws-window').sessionId, 'win-session', 'the window row session wins')
|
|
431
|
+
assert.equal(rows.get('/tmp/ws-sidebar').sessionId, 'sidebar-only', 'a workspace nobody opened keeps the sidebar session')
|
|
432
|
+
})
|
|
433
|
+
|
|
412
434
|
test('/v1/dsh probes a live host when no usable snapshot exists (m00186)', async (t) => {
|
|
413
435
|
// The daemon cannot read dsh's own API (its launch token lives in dsh's memory), so
|
|
414
436
|
// the plugin advertises one `instances/dsh-<pid>.json` per running host. When the
|