diff --git a/src/hover-values.ts b/src/hover-values.ts index ee7709a..37df821 100644 --- a/src/hover-values.ts +++ b/src/hover-values.ts @@ -2,7 +2,7 @@ import * as vscode from 'vscode'; import type { NodeId } from '@eagleoutice/flowr/r-bridge/lang-4.x/ast/model/processing/node-id'; import { getFlowrSession } from './extension'; import { makeSlicingCriteriaForPositions } from './flowr/utils'; -import { Bottom, Top } from '@eagleoutice/flowr/abstract-interpretation/domains/lattice'; +import { Bottom, BottomSymbol, Top, TopSymbol } from '@eagleoutice/flowr/abstract-interpretation/domains/lattice'; import { isTop, stringifyValue } from '@eagleoutice/flowr/dataflow/eval/values/r-value'; import { getConfig, Settings } from './settings'; import { ConfigurableRefresher, RefreshType } from './configurable-refresher'; @@ -116,14 +116,12 @@ class FlowrHoverProvider implements vscode.HoverProvider { if(shape) { values.push({ value: shape, - textRep: `Dataframe Shape: -| | | -|----|----| -| Rows: | ${intLift2Str(shape.rows.value)} | -| Cols: | ${intLift2Str(shape.cols.value)} | - -Known Columns: ${setString(shape.colnames.value)} + textRep: ` +Dataframe Shape: +*Columns*: ${formatSetRange(shape.colnames.value)}\\ +*Cols*: ${shape.cols.toString()}\\ +*Rows*: ${shape.rows.toString()} `.trim(), criteria: criteria }); @@ -135,28 +133,27 @@ Known Columns: ${setString(shape.colnames.value)} } } -function setString(set: { readonly min: ReadonlySet, readonly range: ReadonlySet | typeof Top } | typeof Top | typeof Bottom): string { +function formatSetRange(set: { readonly min: ReadonlySet, readonly range: ReadonlySet | typeof Top } | typeof Top | typeof Bottom): string { if(set === Bottom) { - return '⊥'; + return BottomSymbol; + } else if(set === Top || (set.min.size === 0 && set.range === Top)) { + return TopSymbol; } - if(set === Top) { - return '⊤'; + let txt: string | undefined; + + if(set.min.size === 0) { + txt = '*\\*'; + } else { + txt = `${set.min.values().toArray().map(entry => '`' + entry + '`').join(', ')}`; } - let txt = `${[...set.min].map(f => `\`${f}\``).join(', ')} - `; if(set.range === Top) { - txt += '(Potential: ⊤)'; + txt += ' (Potential: ' + TopSymbol + ')'; } else if(set.range.size > 0) { - txt += '(Potential: ' + [...set.range].map(f => `\`${f}\``).join(', ') + ')'; + txt += ' (Potential: ' + set.range.values().toArray().map(entry => '`' + entry + '`').join(', ') + ')'; } return txt; } -function intLift2Str(val: readonly [number, number] | typeof Bottom): string { - if(val === Bottom) { - return '⊥'; - } - return `[${val[0]}, ${val[1]}]`; -} + function valueToHint(cached: ValueInfo[]): vscode.Hover | undefined { if(cached.length === 0) { return undefined; diff --git a/src/test/hover-values.test.ts b/src/test/hover-values.test.ts index 9ab2de9..7460df7 100644 --- a/src/test/hover-values.test.ts +++ b/src/test/hover-values.test.ts @@ -29,13 +29,13 @@ suite('hover values', () => { }); test('shows inferred value for dataframe', async() => { - const df = `Dataframe Shape: -| | | -|----|----| -| Rows: | [3, 3] | -| Cols: | [2, 2] | + const df = ` +Dataframe Shape: -Known Columns: \`id\`, \`label\``; +*Columns*: \`id\`, \`label\`\\ +*Cols*: [2, 2]\\ +*Rows*: [3, 3] + `.trim(); await tc(new vscode.Position(2, 1), df); }); });