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

\param and \return not generated for method #14

Open
LostInCompilation opened this issue Jul 23, 2021 · 6 comments
Open

\param and \return not generated for method #14

LostInCompilation opened this issue Jul 23, 2021 · 6 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@LostInCompilation
Copy link

When creating a doxygen comment for the method in a header file, param and return wont get generated for Foo(). However generations works on the above static function. and in the defining cpp file.
All settings for the plugin are on default, tried reinstalling it.
What should I do? The error seem to show up just sometimes, so hard to say what's causing this.

namespace A::B
{
	class DP_API MyClass
	{
	private:
		static HMODULE DLLModule;

		MyClass() {}

	public:
		/**
		 * Desc.
		 * 
		 * \param dllModule
		 */
		static void SetDLLModule(HMODULE dllModule) { DLLModule = dllModule; }

		/**
		 * Desc.
		 */
		bool Foo(HMODULE aValue);
};
@fingeg
Copy link
Owner

fingeg commented Nov 9, 2021

Hello, and apologies for not coming back to this earlier. Been crazy busy the past months.
I noticed this error once before and it seems to be connected to whether the function has an implementation in or not. Sometimes the visual studio API declares a function header without implementation just as normal code rather than as a function.
I am not sure how to fix this, considering that the function information is missing in the VS c++ API and not in my code. There may be another method to get this information, but I could not find one.

@fingeg fingeg added bug Something isn't working help wanted Extra attention is needed labels Nov 9, 2021
@Phil7789
Copy link

Phil7789 commented Apr 9, 2022

I am not sure if this is the same problem, but in header files only the default is generated for functions. So no params or returns are recognized. Only if I use doxygen in .cpp files

(Visual Studio Community 2022)

@rapperskull
Copy link

I have the same problem in CPP files. If I use the shortcut, nothing happens, and if I start typing /** above the function, the default format is used.
I don't know if I'm doing something wrong or what.

@Sedeniono
Copy link

Sedeniono commented May 14, 2023

I noticed the same issue while playing around with the VS API FileCodeModel2.CodeElementFromPoint(): It simply returns nothing for global function declarations, regardless of which vsCMElement you pass into CodeElementFromPoint(). Even VCFileCodeModel.CodeElements or VCFileCodeModel.Functions knows nothing about global declarations. Annoying bug in the VS API...

For member function declarations, it works.

@fingeg
Copy link
Owner

fingeg commented May 14, 2023

Yeah, haven't looked for a fix in a while but if you come across something, please share it here

Repository owner deleted a comment from Jcillo507 Feb 23, 2024
@Sedeniono
Copy link

Sedeniono commented May 25, 2024

@fingeg I played around with it again because I wanted to implement IntelliSense of \param and \tparam in my VSDoxyHighlighter extension. I found a somewhat reasonable way to workaround the issue that the FileCodeModel doesn't know about global function declarations. Basically, VS runs a background C++ parser thread which stores some of the results in an instance of the internal class Microsoft.VisualStudio.VC.SemanticTokensCache (which is stored on the text buffer's property). The SemanticTokensCache roughly contains the semantic meaning of every non-comment C++ token (e.g. if it is a parameter, or a type, or a macro, etc.). One can view the functionality of SemanticTokensCache via decompilation and access it via reflection.

So I am now assuming that, when the user types e.g. \param, the cursor is before a function (or class). I then iterate over the tokens in the SemanticTokensCache until I hit e.g. a function. Then I take the next tokens that are marked as parameters in the SemanticTokensCache. Somewhat similar, template parameters come before.
At least this is the very basic idea. Unfortunately, I had to implement quite a bunch of additional heuristics, because the semantics of the tokens are quite "shallow" (meaning a specific semantic token type is used in different contexts). Also, the SemanticTokensCache doesn't know about non-type template arguments.

After getting information from the SemanticTokensCache, I also query the FileCodeModel and see if it knows anything about the supposed function/class. If it does, I trust the FileCodeModel (because it is more accurate if it provides any information at all). If it doesn't, well, then I take the SemanticTokensCache for lack of a better alternative.
In the end, it is not pretty. But I think I managed to get it working reasonably well, although it isn't 100% accurate; in specific (but I guess/hope rare) cases it misses some things or shows incorrect ones.

The main C# class in my code that does this combination is CppFileSemanticsFromVSCodeModelAndCache. The CppFileSemanticsFromSemanticTokensCache class is the one that queries the SemanticTokensCache. Everything comes together to populate the IntelliSense autocomplete box here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants