Good morning, I need help with the CANSparkMax code in Visual studio code when ever I put in CANSparkMax I get error in my code so I click on the quick fix for the CANSparkMax and they tells me to import com.revrobotics.CANSparkMax; but when I do that it also get and error and when I click on the quick fix I tells me to remove it. If you can help it will be really helpful.
Have you added the REV vendor dependency ?
Hello I just got back to my computer and yes I already have the REV vendor dependency and it still not working
Does your code compile with the import present? If so, this is just the vscode IntelliSense engine not being up to date. If that’s the case, you can fix it by running the Java: Clean Java Language Server Workspace
command from the Command Palette.
all the code compile with there import present except the CANSparkMax. So should I do the Java: Clean Java Language Server Workspace
and if so then how do I do that in Visual studio code.
If the code compiles with the CANSparkMax import, it’s a vscode issue. If it doesn’t, then it’s likely a vendor dependency issue. Posting the output here of the “WPILib: Open Project Information” command would be helpful too.
You can type Ctrl-Shift-P to pop up the command palette in vscode.
Hello again I don’t know how to see if the code is a vscode problem or a vendor dependency problem but I think it’s a vscode problem
That looks correct for versions / vendor libraries.
If you add the import for CANSparkMax, does the project successfully build?
No it doesn’t it just come as a error
Can you share the error message that the compiler is giving (e.g. the console output from the build)?
I’m talking about the error message from the build (WPILib: build robot code command). Your two screenshots are vscode intellisense messages and should be fixed by doing the Clean Java Workspace command and restarting vscode.
Okay how do I Clean Java Workspace command and restarting vscode.
Type Ctrl-Shift-P. That should pop up a command search box near the top of the vscode window you can type into. Search for “Java: Clean Java Language Server Workspace” and click it to run the command. Then exit vscode and start it again.
I don’t see the Clean Java Language Server Workspace when I hit Ctrl-Shift-P
Make sure you are in Java select language mode - see bottom of your VSC window.
Some Java “Lite” language mode will compile but not display correctly.
Clean is in two places and the easiest was mentioned
You have to start typing what you want then it appears
The other is on the file explorer JAVA PROJECTS … - bottom right corner
Whenever I think I did it right and VSC still doesn’t like my code, then CLEAN is my go-to function. Often fixes the problem.
Thank you’ll so much for the help It worked
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.