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

Create Definition on a constructor in a header isn't working #10463

Closed
sean-mcmanus opened this issue Feb 3, 2023 · 19 comments
Closed

Create Definition on a constructor in a header isn't working #10463

sean-mcmanus opened this issue Feb 3, 2023 · 19 comments
Assignees
Labels
bug Feature: Create Declaration or Definition Language Service more info needed The issue report is not actionable in its current state not reproing We're not able to reproduce the issue (it's unlikely to get fixed until we find one).

Comments

@sean-mcmanus
Copy link
Contributor

          I am on 1.14.1 (pre-release). I tried the feature:
  1. Pointed to the three dots under a constructor in a header file
  2. Clicked on Quick fix
  3. Selected the option to create the definition
    Nothing happens and I also don't see any messages in the C++ log.

Originally posted by @H-G-Hristov in #10189 (comment)

@sean-mcmanus
Copy link
Contributor Author

sean-mcmanus commented Feb 3, 2023

@H-G-Hristov I'm not reproing the bug, so we may need more repro details. Can you provide a code sample that repros it, i.e. what are the contents of the source and header files? And the OS.

Also, we're still working on adding better error logging, so once that's added the logging might show a more helpful error.

@sean-mcmanus sean-mcmanus self-assigned this Feb 3, 2023
@sean-mcmanus sean-mcmanus added bug Language Service more info needed The issue report is not actionable in its current state not reproing We're not able to reproduce the issue (it's unlikely to get fixed until we find one). Feature: Create Declaration or Definition labels Feb 3, 2023
@H-G-Hristov
Copy link

@sean-mcmanus The OS is as usual macOS. The project is my usual Cmake based project. I'll see if I can provide some repro but I can't promise.

@sean-mcmanus
Copy link
Contributor Author

@H-G-Hristov Our pending 1.14.2 pre-release will have error logging added. The OS isn't expected to matter, neither is the build system. It sounds like you're saying it might not repro in a simpler project.

@H-G-Hristov
Copy link

For example for this header I am unable to get the extension to generate definitions:

#pragma once

#include <nblib/logger/ILogger.hpp>

#include "register-with-server/macOS/IAdmInstallUserDataPlist.hpp"

namespace nbnc::register_with_server {

class AdmInstallUserDataPlist : public IAdmInstallUserDataPlist
{
public:
    AdmInstallUserDataPlist();

    explicit AdmInstallUserDataPlist(const ::nblib::utilities::ILogger& logger);

    ~AdmInstallUserDataPlist();

public:
    [[nodiscard]] bool IsValid() const noexcept override;

    tl::expected<void, std::string> LoadFromFile(std::string_view filepath) override;

public:
    [[nodiscard]] virtual tl::expected<Configuration, std::string> GetConfiguration() const override;

public:
    [[nodiscard]] virtual tl::optional<std::string> GetActivationKey() const noexcept override;

    [[nodiscard]] virtual tl::optional<std::string> GetADID() const noexcept override;

    [[nodiscard]] virtual tl::optional<std::int64_t> GetCustomerID() const noexcept override;

    [[nodiscard]] virtual tl::optional<std::string> GetCustomerName() const noexcept override;

    [[nodiscard]] virtual tl::optional<std::string> GetRegistrationToken() const noexcept override;

    [[nodiscard]] virtual tl::optional<std::string> GetServerURLs() const noexcept override;

    [[nodiscard]] virtual tl::optional<std::string> GetProxyURL() const noexcept override;

private:
    class Implementation;

private:
    std::unique_ptr<Implementation> impl;
    const ::nblib::utilities::ILogger& logger;
};

}  // namespace nbnc::register_with_server

@sean-mcmanus
Copy link
Contributor Author

I'm able to create definitions in a test.cpp when that code is in a test.h. Are you seeing this in our Outline view?

image

@sean-mcmanus
Copy link
Contributor Author

@H-G-Hristov 1.14.2 has error logging added -- https://github.com/microsoft/vscode-cpptools/releases/tag/v1.14.2 -- do you get any error message with that?

@H-G-Hristov
Copy link

This is want I am seeing:
Screenshot 2023-02-10 at 9 51 59
Here is how I am testing it right now:

  1. Commented the implementations of the two methods which are marked by three dots ...
  2. I hover on the dots and click "Quick fix"

@H-G-Hristov
Copy link

H-G-Hristov commented Feb 10, 2023

I opened one super simple project which I used in the past to report Clang-Tidy issues:

Screenshot 2023-02-10 at 9 56 28
Screenshot 2023-02-10 at 9 56 41
Yet again it doesn't work for me.

Screenshot 2023-02-10 at 9 45 51

Test.zip

@sean-mcmanus
Copy link
Contributor Author

sean-mcmanus commented Feb 11, 2023

That is strange. I'm not reproing it still and it looks like you're not getting an error (I think we show an error message in addition to in the log output). It seems like something is causing us to fail to locate the test.cpp or make edits to it (but I tried that and I get an error message if the file can't be found).

Could this be a permissions issue? Do clang-tidy fix code actions work? e.g.

image
with

int foo()
{
    int i;
    return 0;
}

@sean-mcmanus
Copy link
Contributor Author

Could the yellow squiggle on the "once" be relevant? That seems like it might be a clang-tidy warning.

@H-G-Hristov
Copy link

Could this be related:

[Error - 14:20:54] Sending request cpptools/getFoldingRanges failed.
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 14:20:54] The language server crashed. Restarting...

IntelliSense client has disconnected from the server - /Users/FFFF/Projects/GitHub/Test/test.hpp
IntelliSense process crash detected.

@H-G-Hristov
Copy link

Could the yellow squiggle on the "once" be relevant? That seems like it might be a clang-tidy warning.

Screenshot 2023-02-11 at 15 25 53

I have no idea what exactly is causing this warning and how to fix it. According to stack overflow the compiler can issue such warning when a header is compiled.

I am using Cmake:

add_executable(T
main.cpp
test.cpp
# test.hpp
)

@H-G-Hristov
Copy link

H-G-Hristov commented Feb 11, 2023

Could the yellow squiggle on the "once" be relevant? That seems like it might be a clang-tidy warning.

I can confirm that generally clang-tidy fixes work unless when Clang-Tidy gets stuck and requires VSCode to be restarted but that's a different issue which I reported before.

@sean-mcmanus
Copy link
Contributor Author

@H-G-Hristov The #pragma once in main file occurs if clang-tidy is run on the header and we're not able to select a source file to associate with it to run on instead. You can get rid of it via adding using setting "C_Cpp.codeAnalysis.clangTidy.args": ["--extra-arg=-Wno-pragma-once-outside-header"], assuming you don't want to fix the source file association. Maybe we could filter those warnings out ourselves.

The IntelliSense process crash might be interfering with create declaration/definition. I don't understand how you're getting a crash on such a simple header file though. Are you able to get it to not crash? Or can you comment out the code, attach a debugger to cpptools-srv, then uncomment out the code to get a crash call stack, i.e. https://github.com/microsoft/vscode-cpptools/wiki/Attaching-debugger-to-cpptools-or-cpptools%E2%80%90srv

@H-G-Hristov
Copy link

@H-G-Hristov The #pragma once in main file occurs if clang-tidy is run on the header and we're not able to select a source file to associate with it to run on instead. You can get rid of it via adding using setting "C_Cpp.codeAnalysis.clangTidy.args": ["--extra-arg=-Wno-pragma-once-outside-header"], assuming you don't want to fix the source file association. Maybe we could filter those warnings out ourselves.

The IntelliSense process crash might be interfering with create declaration/definition. I don't understand how you're getting a crash on such a simple header file though. Are you able to get it to not crash? Or can you comment out the code, attach a debugger to cpptools-srv, then uncomment out the code to get a crash call stack, i.e. https://github.com/microsoft/vscode-cpptools/wiki/Attaching-debugger-to-cpptools-or-cpptools%E2%80%90srv

Regarding the last part (attach a debugger) is this still an issue on macOS: #9810

@sean-mcmanus
Copy link
Contributor Author

@H-G-Hristov Oh, yeah, I didn't realize you were on Mac. Yeah, there might be blocking issues attaching a debugger on Mac. Some Macs are configured to be able log crashes to a text file in a particular crash diagnostics folder, but I'm not sure how to enable that.

@H-G-Hristov
Copy link

@H-G-Hristov The #pragma once in main file occurs if clang-tidy is run on the header and we're not able to select a source file to associate with it to run on instead. You can get rid of it via adding using setting "C_Cpp.codeAnalysis.clangTidy.args": ["--extra-arg=-Wno-pragma-once-outside-header"], assuming you don't want to fix the source file association. Maybe we could filter those warnings out ourselves.

I'd appreciate that.

@github-actions
Copy link

github-actions bot commented May 8, 2023

Hey @michelleangela, this issue might need further attention.

@sean-mcmanus, you can help us out by closing this issue if the problem no longer exists, or adding more information.

@github-actions
Copy link

github-actions bot commented Jul 7, 2023

This issue has been closed because it needs more information and has not had recent activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 7, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Aug 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Feature: Create Declaration or Definition Language Service more info needed The issue report is not actionable in its current state not reproing We're not able to reproduce the issue (it's unlikely to get fixed until we find one).
Projects
None yet
Development

No branches or pull requests

3 participants