ypresto / vscode-intelli-refactor

Smartly select range for refactoring under cursor. Use with VSCode Insiders.
MIT License
12 stars 1 forks source link

Add support for the C++ #3

Open VzdornovNA88 opened 4 years ago

VzdornovNA88 commented 4 years ago

Hello, Can you add support for C++? Unfortunately, there are no extensions for refactoring for C++ but I think that many people need it.

ypresto commented 3 years ago

Thanks for feedback! We need C++ AST to support it. I'm not familiar with C++, so do you know standard way to retrieve it (command, library, etc.)?

VzdornovNA88 commented 3 years ago

Hello,Sorry for my English. I thought that your project is dead and I am glad I made a mistake, so that is really complicated question even though I have been working in C++ for along time cause I don't know anything about an official ready-made solution for this problem but I know a few workarounds, so let's bagine : If I were solving this problem I would start with : https://github.com/llvm/llvm-project.git (https://llvm.org) - it is really important point cause this is universal program infrastructure of modular and reusable compiler and toolchain technologies , here we are interested in the module "CLANG" and "LIBCLANG" (https://github.com/llvm/llvm-project/tree/master/clang , https://clang.llvm.org/docs/Tooling.html) libclang provides API to work with AST of C++. So You can use libclang to create your plugin. Also project "CLANG" has bindings for other languages but unfortunately it is a python and nothing else no bindings. Also there is project emscripten (https://github.com/emscripten-core/emscripten) capable of running an interpreter of python. And also I think that there are a lot of converters python code to JS. So workarounds :

  1. Develop clang(libclang) binding for JS as well as for python here and then use it to create your plugin extension for C++.
  2. Use python binding in JS running it in interpreter emscripten and getting the results of execution in your JS code of plugin
  3. Convert code of python binding to JS and use the conversion result in your code of plugin.

At the moment these are superficial ways that came to my mind. I will think about it.