-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[clangd enhancement] enhancing the non-template completion experience with type holes #137111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I can't infer the exact issue from the current description. Do you want to add a helper header with proposed contents to clangd (or elsewhere)? |
#pragma once
#include <utility>
namespace type_holes {
struct Hole {
template <typename T> operator T() const noexcept {
return std::declval<T>();
}
};
constexpr auto _ = Hole{};
constexpr auto $hole = Hole{};
constexpr auto hole = Hole{}; // If the code does not use type holes, it will not cause a compilation error because the template is not instantiated.
} // namespace type_holes #include <type_holes.h>
using namespace type_holes;
int main() {
std::vector<int> vec = _;
vec.push_back(0);
// vec.push_back(value_type &&x)
}
|
I apologize for not realizing that this is an issues for llvm-project, there are many other different components and I should have been more specific in describing which compiler component is the issues. |
Oh, I could infer that this is clangd-related according to your previous issues. But it's unclear what should be done. Did you ask a question, request enhancement, or report a bug? |
I'm also confused. Could you describe please:
|
invoke code completion at this locationwhen I typing Expected behaviorI would like clangd to support {
"clangd.completion.placeholder" : "$hole"
} expect it complete result is If clangd complete a type hole, we can hove on this hole, then we can know what the type is expected in this argument. the default behavior cause If clangd complete or ambiguous. Step 1replace a hole with Step 2#pragma once
#include <utility>
namespace type_holes {
struct Hole {
template <typename T> operator T() const noexcept {
return std::declval<T>();
// If the user code does not use type holes,
// it will not cause a compilation error because the template is not instantiated.
}
};
constexpr auto _ = Hole{};
constexpr auto $hole = Hole{};
constexpr auto hole = Hole{};
} // namespace type_holes Actual behavorclangd will complete both type and parameter Reference
|
I found related issue in here #63565 (comment), I think we can add a new option to support this feature. |
Ok, thanks, I think I understand the feature request now. Note that the intention behind placeholders is that you immediately type over them (and the editor facilitates this by pre-selecting the first one and making it so that Tab jumps to the next one). The placeholder contents (e.g. Perhaps you would find |
use holes we not need immediately handle all type check error, We can solve later code then fix before code, we can jump random access to write code, not always from top to bottom.
I found a solution allow this unimplemented code trigger error in runtime not complietime. sometime we want to write some scaffold not indent immediately implementation it.
use |
Use type holes to help write code, reduce to many parse error or unbound variables. then clangd can use AST correct program to give we more useful information.
named requirement
ambiguous
type infomation
The text was updated successfully, but these errors were encountered: