All Projects → tqchen → Ffi Navigator

tqchen / Ffi Navigator

Licence: apache-2.0

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Ffi Navigator

vscode-caddyfile-support
Rich Caddyfile support for Visual Studio Code
Stars: ✭ 30 (-75.41%)
Mutual labels:  language-server, vscode-extension
Vshaxe
Haxe Support for Visual Studio Code
Stars: ✭ 234 (+91.8%)
Mutual labels:  vscode-extension, language-server
Vscode Swift
An extension for VS Code which provides support for the Swift language.
Stars: ✭ 132 (+8.2%)
Mutual labels:  vscode-extension, language-server
Vscode R Lsp
R LSP Client for Visual Studio Code
Stars: ✭ 57 (-53.28%)
Mutual labels:  vscode-extension, language-server
Language Tools
The Svelte Language Server, and official extensions which use it
Stars: ✭ 516 (+322.95%)
Mutual labels:  vscode-extension, language-server
vscode-tenkawa-php
Visual Studio Code extension integrating Tenkawa PHP language server.
Stars: ✭ 28 (-77.05%)
Mutual labels:  language-server, vscode-extension
Langserver Swift
A Swift implementation of the open Language Server Protocol.
Stars: ✭ 171 (+40.16%)
Mutual labels:  vscode-extension, language-server
Vscode Haskell
VS Code extension for Haskell, powered by haskell-language-server
Stars: ✭ 311 (+154.92%)
Mutual labels:  vscode-extension, language-server
Vscode Intelephense
PHP intellisense for Visual Studio Code
Stars: ✭ 872 (+614.75%)
Mutual labels:  vscode-extension, language-server
Vscode Java
Java Language Support for Visual Studio Code
Stars: ✭ 1,370 (+1022.95%)
Mutual labels:  vscode-extension, language-server
I18n Ally
🌍 All in one i18n extension for VS Code
Stars: ✭ 1,931 (+1482.79%)
Mutual labels:  vscode-extension
Lzmq
Lua binding to ZeroMQ
Stars: ✭ 110 (-9.84%)
Mutual labels:  ffi
Swift Haskell Tutorial
Integrating Haskell with Swift Mac Apps
Stars: ✭ 118 (-3.28%)
Mutual labels:  ffi
Nvim Lspconfig
Quickstart configurations for the Nvim LSP client
Stars: ✭ 3,410 (+2695.08%)
Mutual labels:  language-server
Vscode
Unibeautify for VSCode
Stars: ✭ 110 (-9.84%)
Mutual labels:  vscode-extension
Fficxx
Haskell-C++ Foreign Function Interface Generator
Stars: ✭ 117 (-4.1%)
Mutual labels:  ffi
Vscode Js Annotations
Javascript / Typescript Parameter Annotations for Visual Studio Code
Stars: ✭ 110 (-9.84%)
Mutual labels:  vscode-extension
Vscode Ptt
在 VSCode 瀏覽 PTT!
Stars: ✭ 110 (-9.84%)
Mutual labels:  vscode-extension
Vscode Amiga Debug
One-stop Visual Studio Code Extension to compile, debug and profile Amiga C/C++ programs compiled by the bundled gcc 10.1 with the bundled WinUAE.
Stars: ✭ 107 (-12.3%)
Mutual labels:  vscode-extension
Lsp4intellij
This language client library provides language server protocol support for IntelliJ IDEA and other Jetbrains IDEs.
Stars: ✭ 121 (-0.82%)
Mutual labels:  language-server

FFI Navigator

Build Status

Most modern IDEs support find function definition within the same language(e.g. python or c++). However, it is very hard to do that for cross-language FFI calls. While solving this general problem can be very technically challenging, we can get around it by building a project-specific analyzer that matches the FFI registration code patterns and recovers the necessary information.

This project is an example of that. Currently, it supports the PackedFunc FFI in the Apache TVM project. It is implemented as a language server that provides getDefinition function for FFI calls and returns the location of the corresponding C++ API in the TVM project. It complements the IDE tools that support navigation within the same language. We also have preliminary support for MXNet, DGL, and PyTorch, so we can do goto-definition from Python to C++ in these projects too.

Installation

Install python package

pip install --user ffi-navigator

VSCode

See vscode-extension

Emacs

Install lsp-mode

Add the following configuration

(lsp-register-client
 (make-lsp-client
  :new-connection (lsp-stdio-connection '("python3" "-m" "ffi_navigator.langserver"))
  :major-modes '(python-mode c++-mode)
  :server-id 'ffi-navigator
  :add-on? t))
  • Use commands like M-x lsp-find-definition and M-x lsp-find-references

If you use eglot instead, check out this PR. eglot does not support multiple servers per language at the moment, the PR above contains a workaround.

Other editors/IDEs

It should be straightforward to add support for other editors or IDEs that have a LSP client implementation. Please refer to this site for the availability of clients.

Since ffi-navigator is intended to be used with other general purpose servers such as pyls, your LSP client needs to be able to talk to multiple servers per language. If your client does not have such feature, check out this PR and the discussion there for a workaround. This branch has fallback to pyls and it is always kept up to date with the master branch.

Features

TVM FFI

  • Find definition/references of FFI objects(e.g. PackedFunc in TVM) on the python and c++ side.
    • Jump from a python PackedFunc into TVM_REGISTER_GLOBAL, @register_func
  • Find definition/references of FFI objects on the python and c++ side.
    • move cursor to the object class name on the python side.
    • move cursor to the _type_key string on the c++ side.

PyTorch

  • Jump to C10 registered ops. In python they corresponds to functions under torch.ops namespace.
    • Example: torch.ops.quantized.conv2d (py) -> c10::RegisterOperators().op("quantized::conv2d", ...) (cpp)
  • Jump to cpp functions wrapped by pybind.
    • Example: torch._C._jit_script_class_compile (py) -> m.def( "_jit_script_class_compile", ...) (cpp)

Development

For developing the python package locally, we can just make sure ffi_navigator is in your python path in bashrc.

export PYTHONPATH=${PYTHONPATH}:/path/to/ffi-navigator/python

Project Structure

  • python/ffi_navigator The analysis code and language server
  • python/ffi_navigator/dialect Per project dialects
  • vscode-extension language server extension for vscode

Adding Support for New FFI Patterns

Add your FFI convention to dialect namespace.

Demo

VSCode

See vscode-extension

Emacs

Goto definition from Python to C++

goto-def-py-cpp

Goto definition from C++ to Python

goto-def-py-cpp

Find reference across Python and C++

goto-def-py-cpp

Goto definition in PyTorch

goto-def-py-cpp

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].