CodeCompass icon indicating copy to clipboard operation
CodeCompass copied to clipboard

Python plugin implementation

Open barnabasdomozi opened this issue 11 months ago • 6 comments

This PR implements the Python plugin for CodeCompass.

Plugin components:

Parser:

  • The main parser component is pyparser written in Python, uses the Jedi static analysis library. Moreover, pyparser also parses the Python AST in order to achieve better results.
  • During parsing, the pyparser module gets loaded using the Python C API
  • The nodes are inserted to a database table named PYName

Service:

  • PythonService implements most Language Service functionality with a few missing
  • PythonDiagram class to generate the following diagrams: function call, class overview, usage, module dependency diagram.

WebGUI:

  • It mainly targets the legacy WebGUI, however Info Tree functionality works fine in the new WebGUI

Tests:

  • Implemented test for the Parser and Service components.

Documentation:

  • Added documentation to doc/pythonplugin.md.

The missing part is the diagrams in the new WebGUI, however the diagrams component file needs some refactoring to use the new language-service instead of CppService (similarly to https://github.com/Ericsson/CodeCompass/pull/759). I think we should implement that in a separate PR.

barnabasdomozi avatar Feb 27 '25 13:02 barnabasdomozi

@wbqpk3 Nice and large 😅 work, I will try to find some time to review it.

Meanwhile please rebase it to master, as some used GitHub Actions had to be updated for the CI to run. So we can see whether the CI passes or not.

mcserep avatar Mar 04 '25 09:03 mcserep

@mcserep Rebased to master.

barnabasdomozi avatar Mar 04 '25 16:03 barnabasdomozi

Copilot reviewed 40 out of 46 changed files in this pull request and generated 5 comments.

Files not reviewed (6)

@wbqpk3 I just tried out this Copilot-based review feature of GitHub. The suggestions maybe worth a check, but feel free to ignore them in case they look unimportant.

mcserep avatar Apr 08 '25 04:04 mcserep

@wbqpk3 The CI fails for Ubuntu 20.04. While we should drop support for Ubuntu 20.04, it should still be checked why the build fails there.

[ 84%] Building CXX object plugins/python/test/CMakeFiles/pythonservicetest.dir/src/pythonservicetest.cpp.o In file included from /home/runner/work/CodeCompass/CodeCompass/plugins/python/service/include/service/pythonservice.h:15, from /home/runner/work/CodeCompass/CodeCompass/plugins/python/test/src/pythonservicetest.cpp:4: /home/runner/cc-build/service/language/gen-cpp/LanguageService.h:10:10: fatal error: thrift/TDispatchProcessor.h: No such file or directory 10 | #include <thrift/TDispatchProcessor.h> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated. make[2]: *** [plugins/python/test/CMakeFiles/pythonservicetest.dir/build.make:93: plugins/python/test/CMakeFiles/pythonservicetest.dir/src/pythonservicetest.cpp.o] Error 1 make[1]: *** [CMakeFiles/Makefile2:3021: plugins/python/test/CMakeFiles/pythonservicetest.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs....

mcserep avatar Apr 08 '25 04:04 mcserep

@wbqpk3 The CI fails for Ubuntu 20.04. While we should drop support for Ubuntu 20.04, it should still be checked why the build fails there.

UPDATE: CI jobs for Ubuntu 20.04 already started to skip, due to image unavailability. I have disabled the CI build for Ubuntu 20.04 in https://github.com/Ericsson/CodeCompass/commit/b9e67335ce73025df49bb84bc84796b2cc9b32b8, and added an issue https://github.com/Ericsson/CodeCompass/issues/789 to deprecate it completely.

Fixing this CI fail is not required.

mcserep avatar Apr 08 '25 17:04 mcserep

@mcserep

Rebased this patch to master. I also reviewed the AI's suggestions and there was actually a good finding. It's now fixed in commit: https://github.com/Ericsson/CodeCompass/pull/781/commits/4ddb215cd90c401b2cb4edb38d1bd8f168388684

barnabasdomozi avatar Sep 23 '25 13:09 barnabasdomozi