J'e
J'e

Reputation: 3726

Eclipse Language Server Shows "Write Occurrence of var" Instead of Type Information on Hover

I'm working on a simple C++ project in Eclipse using the CDT language server. My code includes a basic template class, but when I hover over an auto variable deduced from a template method, the tooltip doesn't show the detailed type information I expect. Instead of displaying something like MyTemplate or int for the deduced type, it only shows generic text like "Write occurrence of obj" or "auto val".

Here’s a minimal reproducible example:

#include <iostream>

template<typename T>
class MyTemplate {
public:
    explicit MyTemplate(T value) : value_(value) {}
    T get() const { return value_; }
private:
    T value_;
};

int main() {
    MyTemplate<int> obj(42);
    auto val = obj.get();  // hover shows "auto val" but not int
    std::cout << "Value: " << obj.get() << "\n";
    return 0;
}

Questions:

Is this behavior a known limitation of the Eclipse CDT language server when dealing with template types? Are there any configuration options or workarounds in Eclipse to display the full type information on hover? If Eclipse CDT falls short here, what alternatives (e.g., clangd, Visual Studio Code) would you recommend for better C++ template introspection?

Upvotes: 0

Views: 30

Answers (0)

Related Questions