Skip to content

Commit 8e47609

Browse files
Use language-service interface for diagram generation
Replaced CppService usage with the general language-service interface for generating diagrams in the new React WebGUI. Also added new diagram names needed by the Python plugin.
1 parent 3755e3f commit 8e47609

5 files changed

Lines changed: 32 additions & 25 deletions

File tree

plugins/python/service/include/service/pythonservice.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,11 @@ class PythonServiceHandler : virtual public LanguageServiceIf
145145

146146
enum DiagramType
147147
{
148-
FUNCTION_CALL,
149-
MODULE_DEPENDENCY,
150-
FUNCTION_USAGE,
151-
CLASS_USAGE,
152-
CLASS_OVERVIEW
148+
FUNCTION_CALL = 0,
149+
MODULE_DEPENDENCY = 10,
150+
FUNCTION_USAGE = 11,
151+
CLASS_USAGE = 12,
152+
CLASS_OVERVIEW = 2
153153
};
154154

155155
private:

webgui-new/src/components/diagrams/diagrams.tsx

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import { ZoomIn, ZoomOut } from '@mui/icons-material';
33
import { FileName } from 'components/file-name/file-name';
44
import React, { useContext, useEffect, useRef, useState, MouseEvent } from 'react';
55
import {
6-
getCppAstNodeInfo,
7-
getCppDiagram,
8-
getCppDiagramLegend,
9-
getCppFileDiagram,
10-
getCppFileDiagramLegend,
11-
getCppReferenceTypes,
12-
getCppReferences,
13-
} from 'service/cpp-service';
6+
getAstNodeInfo,
7+
getDiagram,
8+
getDiagramLegend,
9+
getFileDiagram,
10+
getFileDiagramLegend,
11+
getReferenceTypes,
12+
getReferences,
13+
} from 'service/language-service';
1414
import { TransformWrapper, TransformComponent, ReactZoomPanPinchRef } from 'react-zoom-pan-pinch';
1515
import { FileInfo, AstNodeInfo } from '@thrift-generated';
1616
import { AppContext } from 'global-context/app-context';
@@ -44,17 +44,17 @@ export const Diagrams = (): JSX.Element => {
4444
appCtx.diagramType === 'file'
4545
? await getFileInfo(appCtx.diagramGenId)
4646
: appCtx.diagramType === 'ast'
47-
? await getCppAstNodeInfo(appCtx.diagramGenId)
47+
? await getAstNodeInfo(appCtx.diagramGenId)
4848
: undefined;
4949

5050
if (!initDiagramInfo) return;
5151

5252
if (parseInt(appCtx.diagramTypeId) === 999) {
53-
const refTypes = await getCppReferenceTypes(initDiagramInfo.id as string);
53+
const refTypes = await getReferenceTypes(initDiagramInfo.id as string);
5454
if (refTypes.get('Definition') === undefined) return;
5555

5656
const astNodeDef = (
57-
await getCppReferences(initDiagramInfo.id as string, refTypes.get('Definition') as number, [])
57+
await getReferences(initDiagramInfo.id as string, refTypes.get('Definition') as number, [])
5858
)[0];
5959

6060
setDiagramInfo(astNodeDef);
@@ -64,9 +64,9 @@ export const Diagrams = (): JSX.Element => {
6464

6565
const diagram =
6666
initDiagramInfo instanceof FileInfo
67-
? await getCppFileDiagram(appCtx.diagramGenId, parseInt(appCtx.diagramTypeId))
67+
? await getFileDiagram(appCtx.diagramGenId, parseInt(appCtx.diagramTypeId))
6868
: initDiagramInfo instanceof AstNodeInfo
69-
? await getCppDiagram(appCtx.diagramGenId, parseInt(appCtx.diagramTypeId))
69+
? await getDiagram(appCtx.diagramGenId, parseInt(appCtx.diagramTypeId))
7070
: '';
7171

7272
sendGAEvent({
@@ -105,7 +105,7 @@ export const Diagrams = (): JSX.Element => {
105105
appCtx.diagramType === 'file'
106106
? await getFileInfo(appCtx.diagramGenId)
107107
: appCtx.diagramType === 'ast'
108-
? await getCppAstNodeInfo(appCtx.diagramGenId)
108+
? await getAstNodeInfo(appCtx.diagramGenId)
109109
: undefined;
110110

111111
if (!initDiagramInfo) return;
@@ -119,7 +119,7 @@ export const Diagrams = (): JSX.Element => {
119119
} as RouterQueryType,
120120
});
121121
} else if (initDiagramInfo instanceof AstNodeInfo) {
122-
const astNodeInfo = await getCppAstNodeInfo(diagramGenId);
122+
const astNodeInfo = await getAstNodeInfo(diagramGenId);
123123

124124
router.push({
125125
pathname: '/project',
@@ -146,9 +146,9 @@ export const Diagrams = (): JSX.Element => {
146146

147147
const diagramLegend =
148148
diagramInfo instanceof FileInfo
149-
? await getCppFileDiagramLegend(parseInt(appCtx.diagramTypeId))
149+
? await getFileDiagramLegend(parseInt(appCtx.diagramTypeId))
150150
: diagramInfo instanceof AstNodeInfo
151-
? await getCppDiagramLegend(parseInt(appCtx.diagramTypeId))
151+
? await getDiagramLegend(parseInt(appCtx.diagramTypeId))
152152
: '';
153153

154154
const parser = new DOMParser();

webgui-new/src/components/file-context-menu/file-context-menu.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import MenuItem from '@mui/material/MenuItem';
44
import { TabName } from 'enums/tab-enum';
55
import { FileInfo } from '@thrift-generated';
66
import { AppContext } from 'global-context/app-context';
7-
import { getCppFileDiagramTypes } from 'service/cpp-service';
7+
import { createClient, getFileDiagramTypes } from 'service/language-service';
88
import { Tooltip } from '@mui/material';
99
import { ChevronRight } from '@mui/icons-material';
1010
import { getBlameInfo, getRepositoryByProjectPath } from 'service/git-service';
@@ -40,7 +40,8 @@ export const FileContextMenu = ({
4040
useEffect(() => {
4141
if (!fileInfo) return;
4242
const init = async () => {
43-
const initDiagramTypes = await getCppFileDiagramTypes(fileInfo.id as string);
43+
createClient(appCtx.workspaceId, fileInfo?.type);
44+
const initDiagramTypes = await getFileDiagramTypes(fileInfo.id as string);
4445
setDiagramTypes(initDiagramTypes);
4546
};
4647
init();

webgui-new/src/enums/entity-types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ const diagramTypeArray = [
4848
i18n.t('diagramTypes.INCLUDE_DEPENDENCY'),
4949
i18n.t('diagramTypes.INTERFACE'),
5050
i18n.t('diagramTypes.SUBSYSTEM_DEPENDENCY'),
51+
i18n.t('diagramTypes.MODULE_DEPENDENCY'),
52+
i18n.t('diagramTypes.FUNCTION_USAGE'),
53+
i18n.t('diagramTypes.CLASS_USAGE'),
5154
];
5255

5356
export { referenceTypeArray, fileReferenceTypeArray, diagramTypeArray };

webgui-new/src/i18n/locales/en.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,10 @@
354354
"EXTERNAL_USERS": "Users of this module",
355355
"INCLUDE_DEPENDENCY": "Include Dependency",
356356
"INTERFACE": "Interface Diagram",
357-
"SUBSYSTEM_DEPENDENCY": "Internal architecture of this module"
357+
"SUBSYSTEM_DEPENDENCY": "Internal architecture of this module",
358+
"MODULE_DEPENDENCY": "Module dependency diagram",
359+
"FUNCTION_USAGE": "Function usage diagram",
360+
"CLASS_USAGE": "Class usage diagram"
358361
},
359362
"cookie": {
360363
"ACCEPT": "Accept",

0 commit comments

Comments
 (0)