Skip to content

Commit db6b162

Browse files
committed
refactor(diagram): rename Graphviz classes to CodeTopology #438
Renamed all Graphviz-related classes, files, and references to CodeTopology for improved clarity and consistency across the diagram module.
1 parent f20c17b commit db6b162

33 files changed

+238
-240
lines changed

exts/ext-diagram/src/241/main/kotlin/cc/unitmesh/diagram/diagram/GraphvizDiagramPanel.kt renamed to exts/ext-diagram/src/241/main/kotlin/cc/unitmesh/diagram/diagram/CodeTopologyDiagramPanel.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package cc.unitmesh.diagram.diagram
22

33
import cc.unitmesh.diagram.editor.DiagramPreviewFileEditor
4-
import cc.unitmesh.diagram.sketch.GraphvizUmlProvider
4+
import cc.unitmesh.diagram.sketch.CodeTopologyUmlProvider
55
import com.intellij.diagram.DiagramBuilder
66
import com.intellij.diagram.DiagramBuilderFactory
77
import com.intellij.ide.DataManager
@@ -24,10 +24,10 @@ import javax.swing.JPanel
2424
* Panel for displaying Graphviz diagrams
2525
* Similar to JdlDiagramPanel in JHipster UML implementation
2626
*/
27-
class GraphvizDiagramPanel(private val fileEditor: DiagramPreviewFileEditor) : Disposable {
27+
class CodeTopologyDiagramPanel(private val fileEditor: DiagramPreviewFileEditor) : Disposable {
2828
private var builder: DiagramBuilder? = null
2929
private val chartPanel = MyPanel()
30-
private val umlProvider = GraphvizUmlProvider()
30+
private val umlProvider = CodeTopologyUmlProvider()
3131

3232
override fun dispose() {}
3333

@@ -39,7 +39,7 @@ class GraphvizDiagramPanel(private val fileEditor: DiagramPreviewFileEditor) : D
3939
if (builder == null) {
4040
val project = fileEditor.getProject()
4141
val virtualFile = fileEditor.getFile()
42-
val rootData = GraphvizElementManager.getRootData(project, virtualFile)
42+
val rootData = CodeTopologyElementManager.getRootData(project, virtualFile)
4343

4444
builder = DiagramBuilderFactory.getInstance()
4545
.create(project, umlProvider, rootData, null)

exts/ext-diagram/src/241/main/kotlin/cc/unitmesh/diagram/diagram/GraphvizDiagramService.kt renamed to exts/ext-diagram/src/241/main/kotlin/cc/unitmesh/diagram/diagram/CodeTopologyDiagramService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import com.intellij.openapi.components.Service
88
* Similar to JdlDiagramService in JHipster UML implementation
99
*/
1010
@Service(Service.Level.PROJECT)
11-
class GraphvizDiagramService : Disposable {
11+
class CodeTopologyDiagramService : Disposable {
1212

1313
override fun dispose() {
1414
// Clean up any resources if needed

exts/ext-diagram/src/241/main/kotlin/cc/unitmesh/diagram/diagram/GraphvizElementManager.kt renamed to exts/ext-diagram/src/241/main/kotlin/cc/unitmesh/diagram/diagram/CodeTopologyElementManager.kt

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,40 +18,40 @@ import javax.swing.Icon
1818
* Element manager for Graphviz diagrams
1919
* Similar to JdlUmlElementManager in JHipster UML implementation
2020
*/
21-
class GraphvizElementManager : AbstractDiagramElementManager<GraphvizNodeData>() {
22-
override fun findInDataContext(dataContext: DataContext): GraphvizNodeData? {
21+
class CodeTopologyElementManager : AbstractDiagramElementManager<GraphNodeData>() {
22+
override fun findInDataContext(dataContext: DataContext): GraphNodeData? {
2323
val psiFile = CommonDataKeys.PSI_FILE.getData(dataContext) ?: return null
2424
val virtualFile = psiFile.virtualFile ?: return null
2525
if (!isDotFile(virtualFile)) return null
2626
return getRootData(psiFile.project, virtualFile)
2727
}
2828

2929
override fun isAcceptableAsNode(element: Any?): Boolean {
30-
return element is GraphvizEntityNodeData || element is GraphvizSimpleNodeData
30+
return element is GraphEntityNodeData || element is GraphSimpleNodeData
3131
}
3232

3333
/**
3434
* Get node items (fields for entities, attributes for simple nodes)
3535
*/
36-
override fun getNodeItems(nodeElement: GraphvizNodeData): Array<Any> {
36+
override fun getNodeItems(nodeElement: GraphNodeData): Array<Any> {
3737
return when (nodeElement) {
38-
is GraphvizEntityNodeData -> nodeElement.getFields().toTypedArray()
39-
is GraphvizSimpleNodeData -> {
38+
is GraphEntityNodeData -> nodeElement.getFields().toTypedArray()
39+
is GraphSimpleNodeData -> {
4040
nodeElement.getAttributes().map { (key, value) ->
41-
GraphvizAttributeItem(key, value)
41+
GraphAttributeItem(key, value)
4242
}.toTypedArray()
4343
}
4444
else -> ArrayUtil.EMPTY_OBJECT_ARRAY
4545
}
4646
}
4747

48-
override fun getElementTitle(element: GraphvizNodeData): String? {
48+
override fun getElementTitle(element: GraphNodeData): String? {
4949
return element.getName()
5050
}
5151

52-
override fun getNodeTooltip(element: GraphvizNodeData): String? {
52+
override fun getNodeTooltip(element: GraphNodeData): String? {
5353
return when (element) {
54-
is GraphvizEntityNodeData -> {
54+
is GraphEntityNodeData -> {
5555
buildString {
5656
append("Entity: ${element.getName()}")
5757
append("\nFields: ${element.getFields().size}")
@@ -67,7 +67,7 @@ class GraphvizElementManager : AbstractDiagramElementManager<GraphvizNodeData>()
6767
}
6868
}
6969
}
70-
is GraphvizSimpleNodeData -> {
70+
is GraphSimpleNodeData -> {
7171
buildString {
7272
append("Node: ${element.getName()}")
7373
if (element.getDisplayLabel() != element.getName()) {
@@ -83,16 +83,16 @@ class GraphvizElementManager : AbstractDiagramElementManager<GraphvizNodeData>()
8383
}
8484

8585
override fun canBeBuiltFrom(element: Any?): Boolean {
86-
return element is GraphvizDiagramRootData || super.canBeBuiltFrom(element)
86+
return element is GraphDiagramRootData || super.canBeBuiltFrom(element)
8787
}
8888

8989
override fun getItemName(
90-
nodeElement: GraphvizNodeData?,
90+
nodeElement: GraphNodeData?,
9191
nodeItem: Any?,
9292
builder: DiagramBuilder
9393
): SimpleColoredText? {
9494
return when (nodeItem) {
95-
is GraphvizNodeField -> {
95+
is GraphNodeField -> {
9696
val displayName = nodeItem.getDisplayName()
9797
val attributes = when (nodeItem.changeStatus) {
9898
ChangeStatus.ADDED -> SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES
@@ -101,55 +101,55 @@ class GraphvizElementManager : AbstractDiagramElementManager<GraphvizNodeData>()
101101
}
102102
SimpleColoredText(displayName, attributes)
103103
}
104-
is GraphvizAttributeItem -> SimpleColoredText(nodeItem.key, SimpleTextAttributes.REGULAR_ATTRIBUTES)
104+
is GraphAttributeItem -> SimpleColoredText(nodeItem.key, SimpleTextAttributes.REGULAR_ATTRIBUTES)
105105
else -> null
106106
}
107107
}
108108

109109
override fun getItemType(
110-
nodeElement: GraphvizNodeData?,
110+
nodeElement: GraphNodeData?,
111111
nodeItem: Any?,
112112
builder: DiagramBuilder?
113113
): SimpleColoredText? {
114114
return when (nodeItem) {
115-
is GraphvizNodeField -> {
115+
is GraphNodeField -> {
116116
nodeItem.type?.let {
117117
SimpleColoredText(it, SimpleTextAttributes.REGULAR_ATTRIBUTES)
118118
}
119119
}
120-
is GraphvizAttributeItem -> SimpleColoredText(nodeItem.value, SimpleTextAttributes.REGULAR_ATTRIBUTES)
120+
is GraphAttributeItem -> SimpleColoredText(nodeItem.value, SimpleTextAttributes.REGULAR_ATTRIBUTES)
121121
else -> null
122122
}
123123
}
124124

125125
override fun getItemIcon(
126-
nodeElement: GraphvizNodeData?,
126+
nodeElement: GraphNodeData?,
127127
nodeItem: Any?,
128128
builder: DiagramBuilder?
129129
): Icon? {
130130
return when (nodeItem) {
131-
is GraphvizNodeField -> {
131+
is GraphNodeField -> {
132132
if (nodeItem.isRequired()) {
133133
PlatformIcons.FIELD_ICON // Could use a different icon for required fields
134134
} else {
135135
PlatformIcons.FIELD_ICON
136136
}
137137
}
138-
is GraphvizAttributeItem -> PlatformIcons.METHOD_ICON
138+
is GraphAttributeItem -> PlatformIcons.METHOD_ICON
139139
else -> null
140140
}
141141
}
142142

143-
companion object {
143+
companion object Companion {
144144
/**
145145
* Create root data for a DOT file
146146
*/
147-
fun getRootData(project: Project, virtualFile: VirtualFile): GraphvizDiagramRootData {
148-
val disposable = project.getService(GraphvizDiagramService::class.java)
147+
fun getRootData(project: Project, virtualFile: VirtualFile): GraphDiagramRootData {
148+
val disposable = project.getService(CodeTopologyDiagramService::class.java)
149149
val filePointer = VirtualFilePointerManager.getInstance()
150150
.create(virtualFile, disposable, null)
151151

152-
return GraphvizDiagramRootData(filePointer)
152+
return GraphDiagramRootData(filePointer)
153153
}
154154

155155
/**

exts/ext-diagram/src/241/main/kotlin/cc/unitmesh/diagram/diagram/GraphvizNodeCategoryManager.kt renamed to exts/ext-diagram/src/241/main/kotlin/cc/unitmesh/diagram/diagram/CodeTopologyNodeCategoryManager.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@ import cc.unitmesh.diagram.DiagramIcons
44
import com.intellij.diagram.AbstractDiagramNodeContentManager
55
import com.intellij.diagram.DiagramBuilder
66
import com.intellij.diagram.DiagramCategory
7-
import cc.unitmesh.diagram.model.GraphvizNodeField
8-
import cc.unitmesh.diagram.model.GraphvizAttributeItem
7+
import cc.unitmesh.diagram.model.GraphNodeField
8+
import cc.unitmesh.diagram.model.GraphAttributeItem
99
import com.intellij.icons.AllIcons
1010

1111
/**
1212
* Node content manager for Graphviz diagrams
1313
* Similar to JdlUmlCategoryManager in JHipster UML implementation
1414
*/
15-
class GraphvizNodeCategoryManager : AbstractDiagramNodeContentManager() {
16-
15+
class CodeTopologyNodeCategoryManager : AbstractDiagramNodeContentManager() {
1716
companion object Companion {
1817
private val FIELDS_CATEGORY = DiagramCategory(
1918
"Fields",
@@ -84,7 +83,7 @@ class GraphvizNodeCategoryManager : AbstractDiagramNodeContentManager() {
8483
builder: DiagramBuilder?
8584
): Boolean {
8685
return when (item) {
87-
is GraphvizNodeField -> {
86+
is GraphNodeField -> {
8887
when (category) {
8988
FIELDS_CATEGORY -> !item.isMethod() && item.isUnchanged()
9089
METHODS_CATEGORY -> item.isMethod() && item.isUnchanged()
@@ -95,7 +94,7 @@ class GraphvizNodeCategoryManager : AbstractDiagramNodeContentManager() {
9594
else -> false
9695
}
9796
}
98-
is GraphvizAttributeItem -> category == ATTRIBUTES_CATEGORY
97+
is GraphAttributeItem -> category == ATTRIBUTES_CATEGORY
9998
else -> super.isInCategory(nodeElement, item, category, builder)
10099
}
101100
}

exts/ext-diagram/src/241/main/kotlin/cc/unitmesh/diagram/diagram/GraphvizSketchProvider.kt renamed to exts/ext-diagram/src/241/main/kotlin/cc/unitmesh/diagram/diagram/CodeTopologySketchProvider.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import com.intellij.testFramework.LightVirtualFile
1212
* Language sketch provider for Graphviz DOT files
1313
* Provides LangSketch support for rendering DOT files in the AutoDev tool window
1414
*/
15-
class GraphvizSketchProvider : LanguageSketchProvider {
15+
class CodeTopologySketchProvider : LanguageSketchProvider {
1616

1717
override fun isSupported(lang: String): Boolean {
1818
val normalizedLang = lang.lowercase()

exts/ext-diagram/src/241/main/kotlin/cc/unitmesh/diagram/diagram/GraphvizVfsResolver.kt renamed to exts/ext-diagram/src/241/main/kotlin/cc/unitmesh/diagram/diagram/CodeTopologyVfsResolver.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@ package cc.unitmesh.diagram.diagram
22

33
import com.intellij.diagram.DiagramVfsResolver
44
import com.intellij.openapi.project.Project
5-
import cc.unitmesh.diagram.model.GraphvizNodeData
5+
import cc.unitmesh.diagram.model.GraphNodeData
66

77
/**
88
* VFS resolver for Graphviz diagrams
99
* Similar to JdlUmlVfsResolver in JHipster UML implementation
1010
*/
11-
class GraphvizVfsResolver : DiagramVfsResolver<GraphvizNodeData> {
11+
class CodeTopologyVfsResolver : DiagramVfsResolver<GraphNodeData> {
1212

13-
override fun getQualifiedName(data: GraphvizNodeData?): String? {
13+
override fun getQualifiedName(data: GraphNodeData?): String? {
1414
if (data == null) return null
1515

1616
val name = data.getName()
1717
return if (name.isNotEmpty()) name else null
1818
}
1919

20-
override fun resolveElementByFQN(fqn: String, project: Project): GraphvizNodeData? {
20+
override fun resolveElementByFQN(fqn: String, project: Project): GraphNodeData? {
2121
// For now, we don't support resolving elements by FQN
2222
// This could be implemented to support navigation and cross-references
2323
return null

exts/ext-diagram/src/241/main/kotlin/cc/unitmesh/diagram/diagram/graph/GraphvizDataModel.kt renamed to exts/ext-diagram/src/241/main/kotlin/cc/unitmesh/diagram/diagram/graph/CodeTopologyDataModel.kt

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,36 @@ import cc.unitmesh.diagram.parser.DotFileParser
1414
* Data model for Graphviz diagrams
1515
* Similar to JdlUmlDataModel in JHipster UML implementation
1616
*/
17-
class GraphvizDataModel(
17+
class CodeTopologyDataModel(
1818
project: Project,
19-
provider: DiagramProvider<GraphvizNodeData>,
20-
private val seedData: GraphvizNodeData?
21-
) : DiagramDataModel<GraphvizNodeData>(project, provider) {
19+
provider: DiagramProvider<GraphNodeData>,
20+
private val seedData: GraphNodeData?
21+
) : DiagramDataModel<GraphNodeData>(project, provider) {
2222

23-
private val nodes = mutableListOf<GraphvizDiagramNode>()
24-
private val edges = mutableListOf<DiagramEdge<GraphvizNodeData>>()
25-
private var diagramData: GraphvizDiagramData? = null
23+
private val nodes = mutableListOf<CodeTopologyDiagramNode>()
24+
private val edges = mutableListOf<DiagramEdge<GraphNodeData>>()
25+
private var diagramData: GraphDiagramData? = null
2626

2727
override fun getModificationTracker(): ModificationTracker {
2828
return PsiModificationTracker.getInstance(project)
2929
}
3030

31-
override fun getNodes(): Collection<DiagramNode<GraphvizNodeData>> {
31+
override fun getNodes(): Collection<DiagramNode<GraphNodeData>> {
3232
return nodes
3333
}
3434

35-
override fun getNodeName(diagramNode: DiagramNode<GraphvizNodeData>): String {
35+
override fun getNodeName(diagramNode: DiagramNode<GraphNodeData>): String {
3636
return diagramNode.identifyingElement.getName()
3737
}
3838

39-
override fun addElement(data: GraphvizNodeData?): DiagramNode<GraphvizNodeData>? {
39+
override fun addElement(data: GraphNodeData?): DiagramNode<GraphNodeData>? {
4040
if (data == null) return null
4141

42-
if (data is GraphvizDiagramRootData) {
42+
if (data is GraphDiagramRootData) {
4343
// Parse the DOT file and create nodes/edges
4444
this.diagramData = extractData(project, data)
4545

46-
val nodeMapping = mutableMapOf<String, DiagramNode<GraphvizNodeData>>()
46+
val nodeMapping = mutableMapOf<String, DiagramNode<GraphNodeData>>()
4747

4848
// Add all nodes
4949
diagramData?.nodes?.forEach { nodeData ->
@@ -67,19 +67,19 @@ class GraphvizDataModel(
6767
val targetNode = nodeMapping[edgeData.targetNodeId]
6868

6969
if (sourceNode != null && targetNode != null) {
70-
edges.add(GraphvizEntityEdge(sourceNode, targetNode, edgeData))
70+
edges.add(CodeTopologyEntityEdge(sourceNode, targetNode, edgeData))
7171
}
7272
}
7373

7474
return null
7575
}
7676

77-
val node = GraphvizDiagramNode(data, provider)
77+
val node = CodeTopologyDiagramNode(data, provider)
7878
nodes.add(node)
7979
return node
8080
}
8181

82-
override fun getEdges(): Collection<DiagramEdge<GraphvizNodeData>> {
82+
override fun getEdges(): Collection<DiagramEdge<GraphNodeData>> {
8383
return edges
8484
}
8585

@@ -90,7 +90,7 @@ class GraphvizDataModel(
9090
}
9191

9292
override fun refreshDataModel() {
93-
if (seedData is GraphvizDiagramRootData) {
93+
if (seedData is GraphDiagramRootData) {
9494
val newDiagramData = extractData(project, seedData)
9595

9696
if (newDiagramData == diagramData) return // nothing changed
@@ -105,14 +105,14 @@ class GraphvizDataModel(
105105
}
106106
}
107107

108-
companion object {
108+
companion object Companion {
109109
/**
110110
* Extract diagram data from a DOT file
111111
*/
112-
fun extractData(project: Project, rootData: GraphvizDiagramRootData): GraphvizDiagramData {
112+
fun extractData(project: Project, rootData: GraphDiagramRootData): GraphDiagramData {
113113
val virtualFile = rootData.getVirtualFile()
114114
if (virtualFile == null || !virtualFile.exists()) {
115-
return GraphvizDiagramData(
115+
return GraphDiagramData(
116116
nodes = emptyList(),
117117
entities = emptyList(),
118118
edges = emptyList()
@@ -125,7 +125,7 @@ class GraphvizDataModel(
125125
parser.parse(content)
126126
} catch (e: Exception) {
127127
// Return empty data if parsing fails
128-
GraphvizDiagramData(
128+
GraphDiagramData(
129129
nodes = emptyList(),
130130
entities = emptyList(),
131131
edges = emptyList()

0 commit comments

Comments
 (0)