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

Fail on "goto definition" and "peek definition" #323

Closed
mink99 opened this issue Apr 17, 2021 · 9 comments
Closed

Fail on "goto definition" and "peek definition" #323

mink99 opened this issue Apr 17, 2021 · 9 comments
Assignees
Labels
conclusion: duplicate Has already been submitted topic: language server Related to the Arduino Language Server type: imperfection Perceived defect in any part of project

Comments

@mink99
Copy link

mink99 commented Apr 17, 2021

Describe the bug
goto / peek definition fails, even if the symbol is shown in the outline view and is implemented in the current file
To Reproduce
Steps to reproduce the behavior:
some methods do not have hover info, when they are used,
right click on these methods and selecting "goto definition" or "peek definition" gives the wrong information
"no definition found for xxx"
Expected behavior
what is on the button : the ide should go to the definition

Screenshots
Image2

Desktop (please complete the following information):
win7/64
IDE beta 5

Additional context
from the clang log :
inols-clangd-err.log

@DaveTur
Copy link

DaveTur commented Sep 5, 2021

In IDE 2.0.0-beta.11 both "Go to Definition" and "peek" do work, but "Go to Definition" highlights the line below the line with the definition.
Running under Windows 10 Pro.

@cmaglie cmaglie removed the type: bug label Sep 16, 2021
@rsora rsora added type: imperfection Perceived defect in any part of project topic: language server Related to the Arduino Language Server labels Sep 22, 2021
@per1234
Copy link
Contributor

per1234 commented Dec 13, 2021

Thanks for your reports @mink99 and @DaveTur. There have been some recent improvements to the Arduino Language Server that provides this capability in the IDE. These improvements are available from the latest release of the Arduino IDE.

Please try again with the latest build of the Arduino IDE and let us know whether or not the bug is fixed for you.

@per1234 per1234 added the status: waiting for information More information must be provided before work can proceed label Dec 13, 2021
@per1234
Copy link
Contributor

per1234 commented Mar 11, 2022

Closing due to lack of response.

@mink99 or @DaveTur if you will provide the requested information by commenting here, I'll be happy to re-open this issue.

@per1234 per1234 closed this as completed Mar 11, 2022
@per1234 per1234 assigned per1234 and unassigned cmaglie Mar 11, 2022
@mink99
Copy link
Author

mink99 commented Mar 11, 2022

See "IntelliSense doesn't work without #include <Arduino.h> #55 " same bug, not fixed, not even tried....
These are two effects on the same underlying bug.
I would recommend to merge these two bugs, and remove the "imperfection" tag, as this feature is one of the USP of the 2.0.

@per1234
Copy link
Contributor

per1234 commented Mar 11, 2022

@mink99 please provide complete and detailed instructions I can follow for a minimal reproduction of the issue.

All I have to work with right now is a vague description and a screenshot of what appears to be a very complex sketch.

Are you able to reproduce the bug with this sketch?

void setup() {
  scanKeysforEdit();
}
void loop() {}
void scanKeysforEdit() {}

You can see that I am not:

image

win7/64

We do not provide support for Windows 7. Please try it with a computer that is running Windows 10 or newer.

remove the "imperfection" tag

Issues are divided into three primary categories:

  • type: imperfection - "Perceived defect in any part of the project"
  • type: enhancement - "Proposed improvement"
  • type: support - "OT: Request for help using the project"

Which of the other two would you suggest replacing the type: imperfection label with?

@mink99
Copy link
Author

mink99 commented Mar 11, 2022

Hi,
we may have an issue with the wording, as we both are not native english speakers. An Imperfection may be understood as "not perfect" which is far from "faulty". But ok, lets take it as an euphemism :)
The bug is completely OS independent, it is just based on the CLANG integration in the language server, and therefore can be reproduced on all of the supported operating systems.
As I see it, the two issues, #55 and this one are based on the same conceptually different understanding on what the scope of these features "goto definition / source" should be.

My understanding is that the scope of these navigation features should be the whole compilation unit, that is

  1. the main ino file
  2. all "includes" in the current project directory and subdirectories (the directory where the .ino is located)
  3. all thirdparty libraries, mentioned by an
  4. all system libraries
  5. all hardware specific libraries.

so basically everything that is provided to the compiler.

this is working perfectly in regards to the gcc, but the same information should be provided to the CLANG compiler to provide source navigation, tooltips, intellisense etc.
Reusing this information (the gcc ) may be a much more easy approach than running CLANG and GCC on a different set of information and generating both independently of each other.

At the time i filed this bug report (and the #55) you were only able to provide the data for the processed .ino file to CLANG, which lead to the embarassing picture on top if the thread (1) . Now, in the meantime, you were able to include the content of the project directory(2). While you are working hard on adding (4) & (5), on a different path, creating issues on many platforms and leaving out (3) .
So my recommendation is still , provide the full compilation path, as it is available for gcc, also to CLANG, and solve all those many issues within the build scripts or the according templates, once and for all.

But, to recreate this bug in its most simple form, you would need two files :
the main .ino

#include "sub/inc.h"
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial.println(findme);
}

void loop() {
  // put your main code here, to run repeatedly:

}

a header file , in a subdirectory called sub, in this example the header is calles inc.h:

int findme = 88;
int findmeFunc()
{
	return 89;
};

behaviour on intellisense and hover :

a1

Amnesia on goto definition:

a2

Same data from the same source ? obviously a failed redundancy....

@per1234
Copy link
Contributor

per1234 commented Mar 11, 2022

An Imperfection may be understood as "not perfect" which is far from "faulty"

The label is intentionally chosen to be applicable to any severity of defect on the spectrum from "missing comma in the readme" to "Skynet is waging war on humanity".

We have a separate set of "criticality" labels which are used to indicate severity. "criticality" labels are assigned by a manager during the planning process, while "type" labels are assigned by a maintainer during triage.

a header file , in a subdirectory called sub

OK, now it is clear. Thanks!

I also encountered this bug and submitted a report about it here: #722

Even though this one came first, I think #722 presents the issue in a way that is more clear to those investigating it, so I will leave this one closed.

I added a comment there referencing this issue to make sure that the valuable discussion you provided here is not missed. You are welcome to comment on that issue to add additional information. I have only described the bug itself, and nothing about the cause of it as you have done.

@per1234 per1234 added conclusion: duplicate Has already been submitted and removed status: waiting for information More information must be provided before work can proceed labels Mar 11, 2022
@mink99
Copy link
Author

mink99 commented Mar 11, 2022 via email

@mink99
Copy link
Author

mink99 commented Mar 17, 2022

I added another simple example :
src :

#include "inc.h"
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:

}

included : inc.h

void doit()
{
  Serial.println("epic fail");
}

result :
Serial is known in the main , but is a clang error in "inc.h"
Image7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: duplicate Has already been submitted topic: language server Related to the Arduino Language Server type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

6 participants