Skip to content
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

Is it possible to improve the completion API? #538

Open
ema2159 opened this issue Jun 14, 2019 · 2 comments
Open

Is it possible to improve the completion API? #538

ema2159 opened this issue Jun 14, 2019 · 2 comments

Comments

@ema2159
Copy link

ema2159 commented Jun 14, 2019

I've been improving the company-box package adding support for several company backends such as company-tern or company-anaconda. I also started working with company-irony but I found that I had to do kinda weird workarounds to find out the kind of completion candidate (i.e. if it is a class, a function, a struct, a variable etc). Other modes that provide completion just as anaconda-mode provide a nice API with information that tells you exactly the kind of the candidate (keyword, function, instance, class etc...). Am I missing something? Is there a way to extract that kind of information from company-irony candidates?

@Sarcasm
Copy link
Owner

Sarcasm commented Jun 17, 2019

I guess it's just a matter of exposing clang_getCompletionParent():

Which I think returns this list of possibilities:

You could try to add this information as a new member of the completion candidates:

  • (defun irony-completion-candidates (&optional prefix style)
    "Return the list of candidates at point.
    A candidate is composed of the following elements:
    0. The typed text. Multiple candidates can share the same string
    because of overloaded functions, default arguments, etc.
    1. The priority.
    2. The [result-]type of the candidate, if any.
    3. If non-nil, contains the Doxygen brief documentation of the
    candidate.
    4. The signature of the candidate excluding the result-type
    which is available separately.
    Example: \"foo(int a, int b) const\"
    5. The annotation start, a 0-based index in the prototype string.
    6. Post-completion data. The text to insert followed by 0 or
    more indices. These indices work by pairs and describe ranges
    of placeholder text.
    Example: (\"(int a, int b)\" 1 6 8 13)
    7. The availability (CXAvailabilityKind) of the candidate."

@ema2159
Copy link
Author

ema2159 commented Jun 17, 2019

I guess it's just a matter of exposing clang_getCompletionParent():

Which I think returns this list of possibilities:

You could try to add this information as a new member of the completion candidates:

  • (defun irony-completion-candidates (&optional prefix style)
    "Return the list of candidates at point.
    A candidate is composed of the following elements:
    0. The typed text. Multiple candidates can share the same string
    because of overloaded functions, default arguments, etc.
    1. The priority.
    2. The [result-]type of the candidate, if any.
    3. If non-nil, contains the Doxygen brief documentation of the
    candidate.
    4. The signature of the candidate excluding the result-type
    which is available separately.
    Example: \"foo(int a, int b) const\"
    5. The annotation start, a 0-based index in the prototype string.
    6. Post-completion data. The text to insert followed by 0 or
    more indices. These indices work by pairs and describe ranges
    of placeholder text.
    Example: (\"(int a, int b)\" 1 6 8 13)
    7. The availability (CXAvailabilityKind) of the candidate."

This is just what I need. I'll try to explore it and then I'll open a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants