Closed Noam-Dori closed 2 years ago
I have used the CMake highlighter plugin in the past - only the free version - and I uninstalled it at some point. I can't remember why, I may have just not found the free version terribly useful. I primarily use CLion, and it has some rudimentary highlighting that I may have decided was sufficient. I'll install the plugin and let you know of any quirks I find.
For the past several months, I have been testing integration of the CMake highlighter plugin into this plugin. From my experience with the plugin, both as a general user and as a developer:
@NotNull
public static PsiReference[] getReferences(PsiElement o) {
if (!CMakeComponent.isCMakePlusActive) return PsiReference.EMPTY_ARRAY;
List<TextRange> innerVars = getInnerVars(o);
if (innerVars.isEmpty()) return PsiReference.EMPTY_ARRAY;
PsiReference[] result = new PsiReference[innerVars.size()];
for (int i=0; i<innerVars.size(); i++) {
TextRange innerVar = innerVars.get(i);
result[i] = new MyPsiPolyVariantReferenceBase<>(o, innerVar);
}
return result;
}
This piece of code is the plugin's way to allow things like command arguments to link to other objects throughout the project. These references are used a lot in IntelliJ, from completion to rename refactoring to Ctrl+Click. For example, they are used in .msg files to allow users to navigate from a used message to the file that defines it. In here, the kind of references CMake objects can provide is set in stone. It can only give one specific type of references, and only if the premium version is installed. The function should look like this:
@NotNull
public PsiReference[] getReferences(PsiElement o) {
return ReferenceProvidersRegistry.getReferencesFromProviders(o);
}
With this implementation other plugins can add additional work to link up CMake things with things like packages, message files, launch files etc. so that the IDE can really help out with things (for example, creating a new message file will require no additional user work since the plugin adds all of the boilerplate code)
Issues 4+5 pose a fatal blow to any hope of integrating the plugin into ROS. Therefore, this plugin must implement its own CMake language tool that will use the basic design concepts that went into the CMake plugin.
CMake is a major component of ROS projects. It is responsible for defining C++ executables, package decelaration, as well as linking everything together, especially with catkin_make in ROS1. Even in ROS2, packages still use CMake as a main tool.
Therefore, it is imperative that a proper ROS plugin would be able to use CMakeLists files to infer data, as well as automatically edit them. At the very least, it should be able to properly highlight them.
The current ability of JetBrains IDEs to interpret CMake depends on the IDE in question:
A good solution to the problem should be able to introduce CMake files without depending on CLion original CMake plugin but without interrupting its C++ functions.
There are two (maybe three) possible solutions:
I have never used the plugin, not to mention the paid variant. We get the following questions:
Plugin Version CMake integration is the main point of the next version - 0.1.7