citre icon indicating copy to clipboard operation
citre copied to clipboard

refactor: pluggable backend design

Open AmaiKinono opened this issue 2 years ago • 0 comments

The goal of this PR is to

  1. Separate the modules more clearly to ease the maintainence.
  2. Make it easy to create a backend so other tools like GNU Global or cscope could benefit from the UI of Citre.

The codebase is divided into 4 parts:

  1. Common Library: general utility functions. Including

    • citre-common-util.el: Helper functions of strings/files/processes...
    • citre-common-tag.el: The "tag" data structure and related functions.
  2. UI library: functions that shows and allows the user to interact with a set of tags. Including

  • citre-ui-jump.el
  • citre-ui-peek.el
  1. Frontend built on these 2 parts. Including

    • citre-backend-interface.el: Interface for defining a backend.
    • citre.el: User tools including commands, citre-mode, and capf/xref/imenu backend.
  2. Backends: Including

    • citre-tags.el: The "tags" backend, which uses readtags to read from a tags file.
    • citre-global.el: The GNU Global backend.

The "tags" backend is built on:

  • citre-readtags.el: The readtags program interface.
  • citre-ctags.el: Finding & generating tags files.
  • citre-lang-*.el: Language supports.
  • citre-tags.el: The backend definition and language support framework.

The tests are rearranged, and the Makefile target "test-common" tests the common library, and "test-tags", "test-global" test the backends. When testing the backends, the script checks if their dependencies exist. If not, it shows a warning and skip the tests, so #104 is closed.


TODOs:

  • [x] It's good time to review the naming of all identifiers.
  • [ ] citre-diagnostic which prints diagnostic information.
  • [ ] Rethink citre-auto-enable-citre-mode (How do we support multiple backends that have different capabilities?)
  • [ ] Improve the GNU Global backend.
  • [ ] Update documents & commentaries.
  • [ ] modify the CI in uctags repo to only test the tags backend after merge this.

AmaiKinono avatar Jun 04 '22 15:06 AmaiKinono