Why cannot find declaration to go to in IntelliJ Idea? - intellij-idea

I have a code in go, and I am using IntelliJIdea for development. It used to work fine, but since the time I have changed the folder where the code used to be, IntelliJ has been behaving in a weird manner. It shows me a lot of unable to find declaration to go to errors. After changing the folder where my project used to be, I changed the GOPATH and imported from the new directory once again.
I am attaching the screenshot as that will be better for understanding.
See the conductor.Start(). This function is right there in the package app. But it can't find this.
PS: I have tried importing the project from scratch and invalidating and restarting multiple times, but that didn't help.

I'm using Gogland, which is also a JetBrains IDE, but I also had a problem with symbols not getting resolved.
I fixed it by deleting the project's index file.
Close the IDE.
In your project directory, find a directory named ".idea".
Delete all files with the extension ".iml" in that directory.
Restart the IDE.
The project should get reindexed and symbols will be resolved.
https://www.jetbrains.org/intellij/sdk/docs/basics/project_structure.html?search=.iml

For my case, Intellij didn't have Rust installed. I found that out while trying to create a new project (it had JAVA and other language support). As soon as I installed Rust, it worked.

For my case, I have 2 virtual environments, and I found that I did not set the correct environment in Pycharm. The environment I used did not include these packages. After I changed the environment, everything goes well.

Related

Getting set up with intelliJ IDEA

Really basic question here but this has always stopped me from using any JetBrains product, but here I am trying once again. I also have the same issues with CLion but that will be for another time and hopefully I can figure it out based on some feedback from this post.
I need to set up my environment in IntelliJ. Nothing special. No build tools. Currently I just run my school projects using
javac Main.java
java Main
This has gotten me so far but I really want to use IntelliJ tools to their full capacity.
I want to be able to set break points and step in and out of my code in their debugger and all the other nice tools that come with running my code through IntelliJ
Every get started tutorial that I have watched on YouTube or from JetBrains themselves already has a basic build configuration set up to run your basic "Hello World" application and that is what I think I need. Just compile my java files into classes and run/debug them.
This is what the run configuration icon in the IDE should look like
And this is what mine currently looks like
I have set many different JDKs to go along with my projects but none of them seem to get the tools I need set up in the IDE. I have even let IntelliJ download one for me and set it up itself to see if maybe I downloaded and installed it wrong and IntelliJ maybe wasn't recognizing it.
This picture below is showing the project structure for an application that I let IntelliJ download a JDK for and set it up itself
So if someone could help me that would be fantastic. Links to videos, blogs are welcome even though I know that isn't the convention on this forum but I think that would be sufficient for my situation. Thanks in advance!
---Update---
I have found that if I create a project in IntelliJ that I get all the default configurations that I need. The problem is when I need to get a project from VCS that I am not getting any of the configurations that I need to run/debug my program in IntelliJ.
The easiest solution here would be to click the green play button next to your main method, on the left where line numbers are displayed.
Intellij will configure a default java run configuration for you. It will be displayed in the menu for later use, like in the screenshot you posted, after your first run.
You can also create one using the to menu: Run > Edit run configuration to add some more options like arguments, environment variables (that only apply for the run config), etc.
A good starting point would be the Intellij help page on that topic. This help pages are always a good start and you find comprehensible instructions there on every topic.
Another good resource is the Intellij by JetBrains YouTube channel. This video about debugging shows both ways I described above. They have lots of quick tutorials about lot of features, like code generation or build tools. Check out the channel's playlists for specific topics.
Update
The problem with the already created project is that the default/ folder is not marked as source folder. You can do that by File > 'Project Structure...' and set the default/ folder as Sources:
The cause for intellij not recognizing this is because you didn't use a folder structure like the one of maven.
For source code:
src/main/java
src/main/resources
and for tests:
src/test/java
src/test/resources
If you set it up that way IntelliJ everything works as expected. I created a pull request to your repo. If you check out the branch, IntelliJ will setup everything correctly automatically.

How can installed packages of a Python project in Pycharm IDE be used in every new Projects

Hello from the other side,
Python file on pycharm
I pip installed some packages using pycharm terminal: mysql connector, pymysql, pillow, etc needed for my programmes.
I have created some Python files and imported mysql connector, pymysql, PIL, etc and my codes worked fine.
Recently I tried creating a new python file in a new project, when I tried to import mysql connector and pymysql, my codes get red underline, notifying me that the imported modules can't be found.
These are the same packages I imported in my previous files and they worked fine.
So why are they turning red underline and greyed out now?
Do I need to be pip installing these packages for every new project?
I tried to see how I could resolve this by making some researches and asking some friends. I was advised to go to the settings and try to create a new environment with the installed packages of my choice, and then checking the boxes for global inheritance and making it available for other projects.
After this, the OK button was inactive (greyed), so I couldnt apply this change. I discovered I was notified that the enviroment rowbox wasnt empty and that I should use a new virtual environment which is empty but I really don't know how to create this.
Please if you've encountered something like this before or can assist, kindly give me a step-by-step approach.
Open File -> Settings
Select Project Interpreter than go to the gear wheel in the upper right corner and select add.
Use Virtual Environment, select your prefered base Interpreter in my case 3.6 and add the name for the virtual environment and where you want to store it
If you don't need to I would suggest to not inherit global site packages
But you should select make it available to other projects.
Confirm it.
Afterwards the virtual env should be selected in project interpreter if not select it from the list. Right beside the List you see a plus, you can use this to add new packages with python (doesn't work all the time for me -> then use terminal)
I really thank everyone who made effort to attempt my question. After much trial, I was able to resolve it and I will post how I resolved it step-by-step to enable others like me understand better.
First, when installing our Pycharm, a folder is automatically created for storing every project we shall be working on, this folder becomes the database of our projects. In most cases, folder is stored in our C:\drive.
Now, open your pycharm window (I mean your working template),
File ----> open (this diplays the folders in your drive) ----> select the folder for storing your Pycharm projects and click ok. NOTE: do not open this folder to show your projects, just click on it and click ok. There are some situations whereby the Pycharm projects folder is already displayed on our pycharm window, this is because we already chose it during our installation. In a case like this, no need trying to bring it to the Projects displayed in our window as it'd already be displayed in the Projects in our window.
Your Pycharm projects folder will then display in your pycharm window under Projects.
Click on the Pycharm projects folder under your Projects and it will be highlighted blue.
Go to settings ----> Project: (your pycharm projects folder will also show here)
By the right, select Project interpreter.
Do your normal installation of packages by clicking on the + sign at the right extreme (that is if you haven't installed any package before)
Then configure your environment setting by making sure the boxes for inheriting global site packages and making this available to other projects are checked.
When configuring your environment setting for the pycharm projects folder, the location path should also end with your pycharm projects folder\venv ; please do not include the name of any particular project in the location path as doing this will make these changes effective in only that particular project files.
Then click ok.
Whatever project your create under the Pycharm projects folder will then inherit every packages you've installed in the pycharm project settings.
I believe this will help those who have been having difficulty resolving this.

qtcreator cmake "No executable specified"

Im having a very annoying issue with qtcreator and cmake projects: qtcreator fails to find the executable. It just prints "No executable specified" when trying to launch any executable from the IDE. Everything works fine after configuring the project (first time only). The issue manifests when loading the project afterwards. Only workaround is deleting the "CMakeLists.txt.user" before every use. This is tedious and unnecessary.
This is happening to projects that were running just fine for years, both my own and my colleagues, on multiple machines running ubuntu 14.04 & 14.10. Problems started with qtcreator version 3 and higher from ubuntu 14.04 upwards.
Assuming that the issue is triggered by some changes in the "CMakeLists.txt.user", after the project is closed the first time, I replaced the file with a copy of it right after it was created the first time. This worked, thus confirming that there is either something wrong with the file itself, or changes to it trigger an existing bug in qt-creator. Unfortunately it is just as tedious as deleting the file in the first place.
My Challenge:
Unfortunately I am not familiar with the inner workings of qtcreaor, however I managed to identify the specific config lines that are responsible. What does qtcreator actually change here?
Please note that "racoon" is the project name and the above diff screenshot is much larger than formatted by stackoverflow (right-click to view full resolution).
Thank you.
i had exactly the same problem using Ubuntu 14.10 and resolved it by doing the following:
Get ftp://ftp.pbone.net/mirror/ftp.sourceforge.net/pub/sourceforge/a/an/anthonos/mirror/os3-next/os3-rpm/q/qtcreator-3.1.2-0.x86_64.rpm
Extract the file /usr/lib/qtcreator/plugins/QtProject/libCMakeProjectManager.so
Overwrite this file at
/usr/lib/x86_64-linux-gnu/qtcreator/plugins/ ( at least on x64)
in your system
This will replace the cmake plugin which is currently version 3.1.1 with 3.1.2 which will make the problem disappear !
I installed qtcreator using Qt's own installer instead of the one provided by Ubuntu. It installs version 5.3.1 and fixes the problem.

IntelliJ: cannot find java.util.Optional

In a new project in IntelliJ I have set up a Java 8 JRE/JDK and language level 8.0.
But for some reason, the IDE cannot find java.util.Optional. The project compiles and works just fine (from within the IDE, too) but code completion does not work.
Any ideas? I'd like to ask a few other users before creating a ticket on their bugtracker...
I finally figured this out. For whatever reason, there was an entry for java.util.Optional in the exlusions under Editor, General, and Auto Import.
Removing that did the trick. No idea how or why it ended up being there. Doesn't sound like anything I would want to do.
Stupid IntelliJ.
I have a SpringBoot project which worked just fine. Then, the next day, when I want to run it, I got this error:
Caused by: java.lang.Error: Unresolved compilation problem:
The type java.util.Optional cannot be resolved. It is indirectly referenced from required .class files without changing anything!
I cleared IntelliJ cache.
Although it was a maven project it was already using JDK8,
I have changed the Project Settings, and said (again) to use JDK8,
Maven re-import, Cleaned the project, Build->Rebuild project, and it magically worked again
I had a similar problem in ubuntu. For me the problem was that I used JDK1.7 and when I changed it to JDK1.8 everything worked just fine.
Now, that makes sense, as Optional is something that was introduced in JDK1.8, before that the concept was exists only in Guava: http://onelineatatime.io/optional-guava-and-java-8/
Ran into the same problem (in IntelliJ 2017.2.7) and solved it like this:
Project Structure->Modules->Module SDK and there change it to 1.8
I've also first set Java compiler to 8 and Project Structure->Project->Project SDK and Project language level also set to 8 without success. In the end, the step I described finally fixed it.
I ran into this recently. The issue was related to my Project SDK setting. Didn't have to clear any caches.
The issue shows with my Project SDK set to 1.8 (1.8.0_202). The issue was fixed by changing it to 11 (11.0.6). Also confirmed that the issue reappears when I switched it back to 1.8.
In java 8 some functions of Optional class not supported such as isEmpty, ifPresentOrElse, or, stream, orElseThrow. You should check whether you use them or not. If you want to use these functions you can use java 11.

Why does IntelliJ IDEA 13.1 show sbt files with so many lines in red?

I had a working sbt based project. After some small change that I can not specifically identify all the sbt files are having object resolution issues (see screenshots).
I tried the following:
sbt refresh
project rebuild
reimport project
These did not work.
Then I started going farther afield to resolve the issue. I copied the *.sbt files from another project on top of the ones in this project. Still no dice. Now I do not have time presently to actually completely destroy, rebuild the project from scratch - and in any case that does not lead to any insight on the root cause here.
Has anyone experienced this issue - and any suggestions on remedies/workarounds?
Update I finally tried
sbt gen-idea
even though this project was **not ** built that way.. It did make a difference: at least the crazy errors went away. But now a different set of problems arises: the assembly and packaging imports are not being resolved (see LAST screenshot). But this seems a bit more healthy at least .
Following screenshot is after running sbt gen-idea. Situation has improved but now get assembly/packaging import errors.
Another update
OK, I have quit and restarted IJ and things are finally back.
So the objective changes that I made:
sbt gen-idea
stop/restart IJ
This is feeling like magic incantations here .. Not a solid process.
A sort of a workaround could be to upgrade to the latest EAP of IntelliJ IDEA 13.1.3 build 135.909, released on May 23rd, 2014. It comes with more sophisticated Scala plugin that is much clever than the previous versions and hopefully could help here and there.