microsoft / microsoft/vscode-cpptools

Make constraint based auto-complete work with alias declarations.

Open
#11,288 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Feature Request Feature: Auto-complete Language Service Visual Studio
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Feature Request

Environment

OS and Version: Ubuntu 23.04
VS Code Version: 1.79.0
C/C++ Extension Version: 1.16.3

This should be the last of my issues. I'm putting the finishing touches on my code base and this is the last of the low hanging issues with how autocomplete and intellisense work with my concept system. Really great work so far, btw. I think the autocomplete should document my library nicely.

The following is a minimal example of what I mean

template <typename Type>
concept HasFoo = requires(Type &type) {
    type.foo();
};

struct T {
    void foo () {}
};

template <HasFoo Type>
struct Foo {
    using T = Type;
    Foo () {
        T x;
        Type y;
        // T will autocomplete `foo()`, x will NOT
    }
};

int main () {
    Foo<T> a{};
}

The name T cannot be associated to anything other than Type, which will have foo() suggested for it. However this suggestion does not appear after T x.

template <typename Types>
concept HasReal = requires(typename Types::Real &real) {
    real.reduce();
};

struct T {
    struct Real {
        void reduce () {}
    };
};

template <HasReal Types>
struct Foo {
    using R = typename Types::Real x;
    Foo () {
        R x;
        typename Types::Real y;
    }
};

int main () {
    Foo<T>();
}

This is another example of the auto complete not working as expected. It will work for typename Types::Real y but not R x.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the two minimal C++ examples, focusing on autocomplete and IntelliSense for concept-constrained types and alias declarations. Compare completion for the direct type declarations with the aliases; done means aliases such as T and R provide the same member suggestions as their underlying types.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, typescript, vscode
Domain
devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.