Skip to content

Commit a389bc5

Browse files
Merge branch 'mr/1622-misc-change-on-Show-Graph' into 'master'
Misc changes in Graph Visualizers See merge request eng/ide/ada_language_server!2084
2 parents 820a6e9 + 9408e61 commit a389bc5

File tree

6 files changed

+50
-14
lines changed

6 files changed

+50
-14
lines changed

integration/vscode/ada/src/alsVisualizerProvider/CPPVisualizerHandler.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import * as vscode from 'vscode';
22
import { VisualizerHandler } from '../alsVisualizerProvider';
3+
import { Hierarchy } from '../visualizerTypes';
4+
import * as fs from 'fs';
35

46
/**
57
* Specialization of the Generic Visualizer Handler for C/CPP language.
@@ -22,4 +24,18 @@ export class CPPVisualizerHandler extends VisualizerHandler {
2224
label = label.split('(')[0];
2325
return super.getParentSymbolWholeRange(symbol, label, location);
2426
}
27+
28+
async getBodyLocation(location: vscode.Location, hierarchy: Hierarchy) {
29+
if (!fs.existsSync(location.uri.fsPath)) return null;
30+
if (hierarchy === Hierarchy.TYPE) return [location];
31+
32+
// The Go To Implementation is not implemented in Clangd so we use the
33+
// Go To Definition.
34+
const implementations = await vscode.commands.executeCommand<
35+
(vscode.Location | vscode.LocationLink)[]
36+
>('vscode.executeDefinitionProvider', location.uri, location.range.start);
37+
38+
if (implementations.length > 0) return implementations;
39+
return null;
40+
}
2541
}

integration/vscode/ada/src/visualizing/App.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ function handleReveal(response: RevealReferencesResponse) {
294294
if (referencesPickerMenu)
295295
setReferencesPickerMenu({ ...referencesPickerMenu, locationsMap: locationsMap });
296296
else if (nodeContextMenu) {
297-
setNodeContextMenu({ ...nodeContextMenu, locationsMap: locationsMap });
297+
setNodeContextMenu({ ...nodeContextMenu, locationsMap: locationsMap, receivedData: true });
298298
}
299299
}
300300

@@ -689,6 +689,7 @@ export default function App() {
689689
? pane.height - event.clientY
690690
: undefined,
691691
locationsMap: new Map(),
692+
receivedData: false,
692693
pane: pane,
693694
onContextClose: onNodeContextClose,
694695
deleteNodes: deleteNodes,
@@ -859,6 +860,7 @@ export default function App() {
859860
onFocus={onFocus}
860861
maxZoom={maxZoom}
861862
minZoom={minZoom}
863+
deleteKeyCode={[]}
862864
nodeTypes={nodeTypes}
863865
edgeTypes={edgeTypes}
864866
onKeyDown={onKeyDown}
@@ -881,7 +883,7 @@ export default function App() {
881883
onNodeDoubleClick={onNodeDoubleClick}
882884
onNodeContextMenu={onNodeContextMenu}
883885
selectionMode={SelectionMode.Partial}
884-
deleteKeyCode={[]}
886+
defaultViewport={{ x: 0, y: 0, zoom: 0.4 }}
885887
connectionLineComponent={floatingConnectionLine}
886888
className="visualizer__colors"
887889
>

integration/vscode/ada/src/visualizing/customNodes.tsx

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -259,12 +259,7 @@ function BasicNode(node: NodeProps<DataNode>) {
259259
);
260260

261261
return (
262-
<div
263-
tabIndex={0}
264-
className={nodeClass}
265-
data-node-id={data.id}
266-
title={(data.inProject ? '' : '[out of project] ') + data.label}
267-
>
262+
<div tabIndex={0} className={nodeClass} data-node-id={data.id}>
268263
{/* Hide the handles in the node and make them invisible as the user does not need to
269264
connect edges. */}
270265
<Handle
@@ -287,15 +282,23 @@ function BasicNode(node: NodeProps<DataNode>) {
287282
/>
288283
{/* The upper part of the node that contains the name of the symbol
289284
and its kind as an icon. */}
290-
<div className="visualizer__node-title">
285+
<div
286+
className="visualizer__node-title"
287+
title={(data.inProject ? '' : '[out of project] ') + data.label}
288+
>
291289
<span className={iconClass} style={{ color: color }}></span>
292290
<div className={'visualizer__text visualizer__ellipsis-text'}>{data.label}</div>
293291
</div>
294292
{/* The lower part of the node that contains information about the symbol. */}
295293
<div className="visualizer__node-body">
296-
<div className="visualizer__ellipsis-text">File : {fileName}</div>
297-
<div className="visualizer__ellipsis-text">
298-
Position : {data.string_location.position}
294+
<div className="visualizer__ellipsis-text" title={'File: ' + fileName}>
295+
<b>File</b>: {fileName}
296+
</div>
297+
<div
298+
className="visualizer__ellipsis-text"
299+
title={'Position: ' + data.string_location.position}
300+
>
301+
<b>Position</b>: {data.string_location.position}
299302
</div>
300303
</div>
301304
{/* The super class button allows requesting the parents of the node. */}

integration/vscode/ada/src/visualizing/nodeContextMenu.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export type NodeContextMenuProps = {
2828
right: number | undefined;
2929
bottom: number | undefined;
3030
locationsMap: Map<string, StringLocation[]>;
31+
receivedData: boolean;
3132
pane: DOMRect;
3233
onContextClose: () => void;
3334
deleteNodes: (toDeleteId: string[], recursive: boolean) => void;
@@ -207,6 +208,15 @@ export function NodeContextMenu(props: NodeContextMenuProps) {
207208
if (locations.length === 0 && props.locationsMap.size > 0) {
208209
referencePickerCreateList(props.locationsMap, locations, onClick, true);
209210
}
211+
// Else if data was received but the locationsMap is still empty,
212+
// add a single element to indicate to the user there are no references.
213+
else if (props.receivedData) {
214+
locations.push(
215+
<li className='"visualizer__references-picker-item' key="No references">
216+
<i>No references found</i>
217+
</li>,
218+
);
219+
}
210220

211221
let left: number | undefined = undefined;
212222
let right: number | undefined = undefined;

integration/vscode/ada/src/visualizing/referencesPickerMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ export function ReferencesPickerMenu(props: ReferencesPickerMenuProps) {
316316
else {
317317
locations.push(
318318
<li className='"visualizer__references-picker-item' key="No references">
319-
No references found
319+
<i>No references found</i>
320320
</li>,
321321
);
322322
}

integration/vscode/ada/src/visualizing/visualizerStyleSheet.css

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ body {
102102
border-bottom: inherit;
103103
}
104104

105-
/* Style the text in the body of the node. */
105+
/* Style the text in the title of the node. */
106106
.visualizer__text {
107107
margin-left: 3px;
108108
margin-bottom: 10px;
@@ -115,6 +115,11 @@ body {
115115
transform: translateY(15%);
116116
}
117117

118+
.visualizer__node-body-elem {
119+
padding-top: 5%;
120+
padding-bottom: 5%;
121+
}
122+
118123
/* Make sure the text doesn't overflow out of its container */
119124
.visualizer__ellipsis-text {
120125
white-space: nowrap;

0 commit comments

Comments
 (0)