I need to develop some UML diagrams for vala projects, I've been using draw.io to generate one by hand, but it's labour intensive. I understand that Umbrello has code generation for Vala, it'd be nice to to have code import too.
This requires a Vala parser in C++ and a class/method that runs through the parsed tree to create the corresponding uml objects.
According to https://wiki.gnome.org/Projects/Vala/Syntax, the syntax is like C#, which would make it possible to use the already available C# importer (called CSharpImport).
I'm not familiar with the project or C++, are you able to set the C# importer to load .vala and .vapi files in a branch I can test?
At first glance, the C# import internally has the extension'*.cs' permanently wired and would require several modifications. To start it would be possible to rename a *.vala file to *.cs without any further changes and then try to import it as C#.
Some test files showing the syntax for classes, methods, attributes, visibility, associations such as generalizations would also be useful to see how much work it would be.
Here's the project I'm trying to map out, there's quite a few vala projects on GitHub at different sizes and complexities. https://github.com/elementary/music There's also an extensive manual of features here. http://www.vala-project.org/doc/vala/ I could knock out a test class that covers the syntax and types but it might take a while for me to complete it. linked list data structures aren't in the core they use the Gee package. https://valadoc.org/gee-0.8/Gee.html
Created attachment 114654 [details] screenshot from imported vala test file For a quick impression 1. I downloaded the code fragment from https://wiki.gnome.org/Projects/Vala/GIOSamples#Asynchronous_File_Listing to test.vala 2. created a symbolic link named test.cs 3. Imported test.cs with c# importer The appended screenshot shows the result: 1. The class ASyncGIOSample was imported with inheritance correctly 2. the attribue 'model' has been imported with visibility and correct type 3. The constructor has been imported correctly 4. method 'list_directory' shows some errors 4.1 'async' has been wrongly imported as type 4.2 the name of the method is 'voidlist_directory(){stdout.printf("Start scanning home directory\n")', which is incorrect
Just for the record: umbrello already supports a vala writer, which may be used to generate test files for a vala importer.
Git commit ae8b7ca95e405dddbe87a5a505d7600c70e916f7 by Ralf Habacker. Committed on 28/08/2018 at 13:31. Pushed by habacker into branch 'work/397909-vala-importer'. Add initial support for a vala importer M +1 -0 umbrello/CMakeLists.txt M +7 -0 umbrello/basictypes.cpp M +3 -0 umbrello/codeimport/classimport.cpp M +8 -2 umbrello/codeimport/csharp/csharpimport.cpp M +6 -0 umbrello/codeimport/csharp/csharpimport.h A +27 -0 umbrello/codeimport/valaimport.cpp [License: GPL (v2+)] A +25 -0 umbrello/codeimport/valaimport.h [License: GPL (v2+)] https://commits.kde.org/umbrello/ae8b7ca95e405dddbe87a5a505d7600c70e916f7
I just pushed https://cgit.kde.org/umbrello.git/log/?h=work/397909-vala-importer with an initial vala importer based on C# import. I added member m_language to class CSharpImport holding the currently processed language. https://github.com/KDE/umbrello is a clone of the git repo mentioned above, from which you can create and edit a fork. For working on class method parsing you may inspect bool CSharpImport::parseStmt().
A possibly relevant merge request was started @ https://invent.kde.org/sdk/umbrello/-/merge_requests/27
Git commit 7dbb75549a72334cf426969295364aee5f9ff0c7 by Oliver Kellogg. Committed on 16/02/2022 at 03:44. Pushed by okellogg into branch 'master'. New class CsValaImportBase is quasi abstract base for C# and Vala import - Move content of umbrello/codeimport/csharp/csharpimport.{h,cpp} to umbrello/codeimport/csvalaimportbase.{h,cpp} and adjust class name to CsValaImportBase. - Move umbrello/codeimport/valaimport.{h,cpp} to new subdirectory vala and derive the class from CsValaImportBase. - Copy content of umbrello/codeimport/vala/valaimport.{h,cpp} to umbrello/codeimport/csharp/csharpimport.{h,cpp}, restore class name CSharpImport, and restore correct body of function fileExtension(). - In umbrello/codeimport/CMakeLists.txt add file csvalaimportbase.cpp and adjust to new subdirectory "vala" with file valaimport.cpp. M +3 -1 umbrello/codeimport/CMakeLists.txt M +5 -760 umbrello/codeimport/csharp/csharpimport.cpp M +5 -67 umbrello/codeimport/csharp/csharpimport.h C +42 -42 umbrello/codeimport/csvalaimportbase.cpp [from: umbrello/codeimport/csharp/csharpimport.cpp - 090% similarity] C +6 -7 umbrello/codeimport/csvalaimportbase.h [from: umbrello/codeimport/csharp/csharpimport.h - 088% similarity] A +31 -0 umbrello/codeimport/vala/valaimport.cpp [License: GPL(v2.0+)] A +25 -0 umbrello/codeimport/vala/valaimport.h [License: GPL(v2.0+)] D +0 -27 umbrello/codeimport/valaimport.cpp D +0 -25 umbrello/codeimport/valaimport.h https://invent.kde.org/sdk/umbrello/commit/7dbb75549a72334cf426969295364aee5f9ff0c7
Git commit ae8b7ca95e405dddbe87a5a505d7600c70e916f7 by Ralf Habacker. Committed on 28/08/2018 at 13:31. Pushed by okellogg into branch 'master'. Add initial support for a vala importer M +1 -0 umbrello/CMakeLists.txt M +7 -0 umbrello/basictypes.cpp M +3 -0 umbrello/codeimport/classimport.cpp M +8 -2 umbrello/codeimport/csharp/csharpimport.cpp M +6 -0 umbrello/codeimport/csharp/csharpimport.h A +27 -0 umbrello/codeimport/valaimport.cpp [License: GPL (v2+)] A +25 -0 umbrello/codeimport/valaimport.h [License: GPL (v2+)] https://invent.kde.org/sdk/umbrello/commit/ae8b7ca95e405dddbe87a5a505d7600c70e916f7
Git commit 43a486bff7096f091c4ee649088752d3e2a105cf by Oliver Kellogg. Committed on 19/02/2022 at 16:39. Pushed by okellogg into branch 'master'. umbrello/codeimport/csvalaimportbase.cpp followup to commit a5893a5 : - In function fillSource condense single dimension array into the type name as done in the defaultDatatypes() of CSharpWriter and ValaWriter. M +10 -0 umbrello/codeimport/csvalaimportbase.cpp https://invent.kde.org/sdk/umbrello/commit/43a486bff7096f091c4ee649088752d3e2a105cf
Git commit c28f11f6e59819b108b8c3b18e5c0c255d5476cd by Oliver Kellogg. Committed on 19/02/2022 at 17:00. Pushed by okellogg into branch 'master'. test/import/vala/helloWorld.vala : First rudimentary test case for ValaImport A +13 -0 test/import/vala/helloWorld.vala https://invent.kde.org/sdk/umbrello/commit/c28f11f6e59819b108b8c3b18e5c0c255d5476cd