Code Monkey home page Code Monkey logo

Comments (15)

jacobdufault avatar jacobdufault commented on May 30, 2024

This will probably require changes in the indexer so it indexes comments. It may also be possible to do try to find the cursor in an active code completion translation unit and lookup documentation from there.

from cquery.

ruipacheco avatar ruipacheco commented on May 30, 2024

+1

from cquery.

romix avatar romix commented on May 30, 2024

+1

from cquery.

romix avatar romix commented on May 30, 2024

So, I tried a quick hack to see how far I can get.

It turned out that with only a small change in the indexer.cc you can get pretty far:
src/indexer.cc | 17 ++++++++++-------

The idea is the prepend the documentation comment right before the existing hover text. Almost all of the changes look like:

-      var->def.hover = type_name;
+      var->def.hover = decl_cursor.get_comments() + "\n" + type_name;

It works, though the formatting may need to be improved.

One thing, that is kind of annoying, is the fact that only certain kind of comments reported. E.g. /* */ and ///. But it does not report any // comments that are often used for local variables, etc. And the reason for this is that ClangCursor::get_comments() uses clang_Cursor_getRawCommentText, which does not report this type of comments. The only related discussion I've found is here. It talks about using getRawCommentForDeclNoCache, but this is a method on ASTContext which cquery does not seem to use.

Anyone has ideas how to add support for all types of comments? Is it important at all? IMHO, it is useful for local declarations. All functions, methods and types usually use the supported Doxygen-style comments anyways.

from cquery.

MaskRay avatar MaskRay commented on May 30, 2024

Comment support is very useful! I'd like to know how clients will display them.

Emacs lsp-mode curently displays textDocument/hover responses via eldoc-documentation-function:

hover reports macro declaration

With comments spanning a lot of lines, this may need improving.

from cquery.

romix avatar romix commented on May 30, 2024

I'll try to submit a PR later today or tomorrow, so that others can have a look and experiment with it.

And yes, with comments spanning a lot of lines, some additional formatting to make them look nice may be required.

from cquery.

MaskRay avatar MaskRay commented on May 30, 2024

@romix Add a new field for comments instead of prepending/appending them to hover. Then the behavior can be controlled with some command line option / other knob as clients are not generally ready for the UI challenge..

from cquery.

romix avatar romix commented on May 30, 2024

@MaskRay Yes, that could be a good idea.

from cquery.

jacobdufault avatar jacobdufault commented on May 30, 2024

Yea, please add a new field instead of prepending to hover.

from cquery.

romix avatar romix commented on May 30, 2024

If it is a new field, where/how do I return it back to the client? With hover it was easy, as it is handled already.

from cquery.

MaskRay avatar MaskRay commented on May 30, 2024

src/messages/text_document_hover.cc:GetHoverForSymbol but I'm not sure how to access command line option / initializationOptions there

Filed feature requests for some editors.

from cquery.

romix avatar romix commented on May 30, 2024

@MaskRay @jacobdufault I created a PR #183, so that other can try it out, propose improvements, etc.

from cquery.

romix avatar romix commented on May 30, 2024

Created #187, which improves the formatting of comments in hover pop-ups

from cquery.

MaskRay avatar MaskRay commented on May 30, 2024

Updated https://github.com/jacobdufault/cquery/wiki

from cquery.

MaskRay avatar MaskRay commented on May 30, 2024

Hover reports documentation with cquery --enable-comments --language-server
See #187 for discussion.

from cquery.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.