Dart packages problems with intellij IDEA - intellij-idea

I'm actually trying to use Dart in IntelliJ IDEA, and I have successfully install the plugin for it, but I face numerous others problems.
But the problem I want to resolve the most, is the fact that for some packages, IntelliJ doesn't show the sources inside it and not with particular reason...
The whole project work in Dart Editor, and launch correctly, so the problem is not from pubspec.yaml.
To makes me more understandable, I will say that I "pub get" correctly the packages A and B, so they appear as folder link in IntelliJ :
http://imgur.com/rb0ZSVA
But like you see, I cannot enter in the b package to see the files inside it. I have checked the structure of the two folders without noticing any difference.
The more ridiculous in that is, I can see some of the files inside the B package in the editor of IntelliJ via Ctrl+Click in the dart files that import the files inside the B package. And it doesn't work for all of them ...

'b' is a 'path package' in your project. That means that b original source code is located on your computer and you specified path to it in pubspec.yaml. IntelliJ IDEA excludes all copies and leaves only original files in project. Root 'packages' folder is not excluded, but all its copies (for example in web folder) are excluded. packages/b is a copy and it is excluded. To work normally with source files from b package you should add path to b as a separate content root: Project Structure | Modules | your Dart module | Add content root.
In IntelliJ IDEA 14 excluded folders are visible by default. Use cases when you need to see excluded folder contents are rare so you may safely hide them (the option is under the gear in the Project View tool window title). With it you will see empty node in packages/b with a hint that it is just a link to b/lib folder. And anyway you should have path to b configured as a content root.

You should not open files of projects currently open in IntelliJ from the package folder but instead directly from the project. The b/lib after the folder icon indicates that this package is part of your currently opened IntelliJ project (may added as a Resource Root)
When you navigate to a referenced file ctrl+click the file is not opened from the packages symlink but from the package in your IntelliJ project (as you should do it manually as well).

The solution is to update IntelliJ to the Early Access update (139.2).
So this question will be useless in the next update, I will delete her at that moment.

Related

IntelliJ different project settings based on used IDE

I have a Git repo with two directories:
backend (PHP/Laravel code)
frontend (TypeScript/Vue code)
I would like that backend is marked as excluded when the project is opened in WebStorm and frontend to be excluded when it is opened in PhpStorm.
This is to ensure that searches/indexing only happen for the files that I would actually edit in that specific IDE.
When I change the excluded directory it seems to automatically apply this to the other IDE as well. Is there some way to keep this setting separate?
Comments:
I intentionally have both frontend and backend in one repository.
Opening the subdirectories in their own IDEA projects does not seem
to be an option because the Git integration only works when the
project is in the root folder of the repository.
When I change the excluded directory it seems to automatically apply this to the other IDE as well.
It is expected. That's because the project settings are stored in the .idea subfolder. All IDEA-based IDEs use the same .idea settings format. So opening the same folder/project in different IDEs simply makes them use that already-made config (shared between IDEs).
Plus, both PhpStorm and WebStorm use the same module type ID (WEB_MODULE) and can have only 1 module in total in a project. IntelliJ IDEA and some other IDEs (like PyCharm for example) can work with projects that can have more than one module and of different types.
Is there some way to keep this setting separate?
Yes, with the help of a small workaround: you need to store .idea used by another IDE in another place. As simple as that.
The setup and steps:
Lets assume that you have your project in C:\Projects\MyProject.
Make a brand new empty project in another place, e.g. C:\Projects\IDEProjectsStore\MyProject-frontend. It will be used for a frontend.
Go to Settings/Preferences | Directories and remove an existing Content Root (which will be C:\Projects\IDEProjectsStore\MyProject-frontend from the previous step).
Add new Content Root instead -- point to the actual project (C:\Projects\MyProject from step #1)
Save and configure as needed.
What you will have now:
This frontend project will now have its settings stored in C:\Projects\IDEProjectsStore\MyProject-frontend\.idea while another (original project with backend) will have them in C:\Projects\MyProject\.idea.
Projects (project-specific IDE settings) are stored in 2 separate places while they both use the same folder with the code.
Basically: a project in the IDE's eyes is an .idea folder with a parent folder added as a Content Root by default. Our workaround keeps the second project in a different folder while sharing the same Content Root between them.
https://youtrack.jetbrains.com/issue/IDEA-170102/ -- that's a ticket that asks for a straightforward way of doing this.
I would like that backend is marked as excluded when the project is opened in WebStorm and frontend to be excluded when it is opened in PhpStorm.
Why do you need two IDEs for this?
In case if you do not know: PhpStorm = WebStorm + PHP + Database. You do not really need WebStorm here. Just install any missing plugins that come bundled with WebStorm.

Something strange with Project Paths in IntelliJ 14.1.4

So, something has started to act weird in my intelliJ project. I even tried removing the iml and .idea data, to no avail.
I go to Project Structure. There, I have a content root. Withing, I have three folders - one for my jar (and jni lib), one for Samples and one for Tools (just tools written to use the jar). The jar, Samples and Tools are marked blue (sources).
In the jar folder, I have my source tree (com\company\projectname\XXX), a lib folder, a folder for my JNI lib and a folder I created call 'junit', which is the focus of this question. It is marked in Project Structure in green (Tests).
Within, I have a folder structure eerily similar to my code: com\company\projectname\junit.
When I open a file in junit\com\company\xxx\junit, I have a big red underline under my package com.company.xxx.junit; line which tells me: "Package name 'com.company.xxx.junit' does not correspond to the file path 'junit.com.company.xxx.junit'.
I was under the impression that marking a folder as 'Tests' would instruct the IDE to use that as a "parent" folder, if you will, eliminating the need to prepend another folder name.
How can I separate the code from unit tests and in fact, create two junit test suites (one is for internal use, the other is a 'skeleton' for distribution), park them under one "umbrella" folder and NOT have to prepend the package names with that folder name?
Update: Project structure:
Based on your screen shot, the issue is that the junit directory is a subdirectory of another source directory, namely MyProvider. A source directory (whether a "production" source or a unit test source directory) cannot be a subdirectory of another source directory.
You need to either:
move the junit directory out of MyProvider so it is a sibling directory, or
unmark MyProvider as a source directory, create a main (or some such directory) in MyProvider, mark it as a source directory, and then move the com directory/package into main.
Option 2 would be the preferred way to deal with this as it follows a very common directory structure standard.
UPDATE (Following comment from OP)
Here's a couple of screenshot showing the configuration you desire:
I removed the .IdeaIC15 folder and started over. Working for now. Something must have gotten confused in the config, either as part of the update, or in the course of operation. I have taken a backup copy as it is now, so if this happens again, I will have something to check.

Can't see project folders in IntelliJ IDEA

Every once in a while, I open an old project and I can't see any of the folders in the intelliJ project viewer. I can see all the files at the root.. but no folders. Yes I can delete the .iml file and .idea folder and re-create the project, but come on.. there's gotta be an easier way to fix this.
Is there?
If you look in project settings (ctrl-shift-alt-s), you should see a module structure. If you instead see "Nothing to see", do the following:
In Project Structure -> Modules, press the + button,
press enter (since, for some weird reason, it won't let me click on "New Module")
In the window that pops up, click on the "..." next to Content root, find your root folder, and select it
Press ok
ignore any warning that says the name is already in use (or to that effect)
the simplest solution worked from me, just delete the .idea folder
keep in mind this will delete all of idea's current project configuration, it'll create the folder with default settings when reload the project again... but all other configuration will be lost if not properly backed-up
It might be because the project didn't have any modules defined. Try adding existing source code by hitting File > New > Module from Existing Sources and select the parent directory of the project for source code
Go to pom.xml file -> right click -> maven -> generate source and update folders. You will see your files and folder structures in left hand side.
All the project-specific settings for a project opened through Intellij IDE are stored in the .idea folder.
The .idea folder (hidden on OS X) in the solution root contains
IntelliJ’s project-specific settings files. These include per-project
details such as VCS mapping and run and debug configurations, as well
as per-user details, such as currently open files, navigation history
and currently selected configuration.
So, if you are not able to see the project file structure in your Intellij IDE, just delete the .idea folder,
rm -rf .idea
and reload the project, then after reload you'll be easily able to get your project structure displayed.
Thank you very much. I just remove the .idea folder and works in my case.
rm -rf .idea
For me, the java folder was not showing up. I went into File->Project Structure. In the second column, I selected on _main. In the third column, I selected the tab "sources". In what I call the fourth column, where the "+Add Content Root" is shown, I verified, the java source/folder was present. In my case, there was an extra source folder, which was the current location. I removed this, applied and the java folder immediately showed up.
Right click on the Project name -> Open Module Setting -> Check the application context path set it up at your project location.
Check your idea.log -- it may have some details explaining why or what is happening (Help | Reveal log in Explorer). Possibly one of the config files got corrupted.
You can always backup and delete .idea subfolder (project settings) and re-create project from scratch. When it's wroking again (after basic configuration) you may copy some of the files from that folder back to recover some of your settings (if there were many).
This happened to me on a new computer when I opened up a Java project in the newly installed Intellij.
The problem was that I had not installed any JDK on the machine.
I had to install a JDK and then go into the settings at ctrl-shift-alt-s and add a JDK by specifying the folder where I installed it. It's possible that IntelliJ would have found it if I closed it and reopened it.
In my case the solution was to create a new project, specifying the project type and creating it within the same directory path as the project that does not load the project files correctly.
PhpStorm automatically detects that the directory exists and gives you the option to create project from existing sources.
This can be found under:
File --> New project...
For gradle users: "Reload All Gradle Projects" option should help.

How to force IntelliJ to use a different home folder

I have a computer with two hard drives. In the first one, an SSD disk, I have Windows partition (C) and on the second one (D), a raid volume, I install all the programs. I also moved my user folders (desktop, documents, downloads, pictures and videos) to D:/Users/David.
After installing IntelliJ Idea on D:/Program Filles(x86) a .IntelliJIdea13 directory appeared on D:/Users/David. No problem with this as all was working nice. Then I installed Scala plugin, created a new SBT project and build it. After this, the .sbt directory used by SBT was in C:/Users/David/.sbt but the references to the libraries in my project are pointing to D:/Users/David/.sbt. The question is, how can I force IntelliJ Idea or Scala plugin to download the libraries to D:/Users/David.sbt?
Not 100% sure if this can be a solution, you can change the HOME folder of Intellij IDEA. Look for the folder where the idea executable is. In Linux I have on
~/applications/idea13/bin
On Windows you can check the properties of the menu item. There should be file idea.properties that contains the home folder location of the idea files.
You can find more information here that describe more details:
Locations can be changed by editing the following file:
IDE_HOME\bin\idea.properties
Follow the comments in idea.properties file to change the defaults,
make sure to un-comment the lines defining these properties:
idea.config.path
idea.system.path
idea.plugins.path
idea.log.path
On the other hand you can change the location of your project to D:/Users/David. you should also have a look inside the project folder, there should be a .idea folder with has a library directory. They contains the location of the libs used in the project with their paths.
As dawez allready answered, you should edit idea.properties to set config, system, plugins and log paths.
But if you want to change the user.home path, then you must edit idea.exe.vmoptions file. Just add the following at the end of the file:
-Duser.home=your_new_user_home_path
If you use idea64.exe then you should edit idea64.exe.vmoptions file.
JetBrains had added complete set of features to support such a case and this is described here:
Changing IDE default directories used for config, plugins, and caches storage

How to add non-source folders to IntelliJ IDEA project

Recently set up a multi module project in IntelliJ with the following structure:
/module1
/module2
/web-module
/sql
/lib
/a few more folders
I set up module1+2 and web-module as modules in IntelliJ so those show up, but how do you make the sql and lib folder show up in the project panel? They should be included in VCS as well, but IntelliJ ignores them. How do you add folders outside modules to a project?
Screenshot of project and explorer view:
This is not a strict answer to the question, but it worked for me so I'm posting, perhaps someone will find this useful.
If you want to add an arbitrary folder to your project (even from some different location than your projects), just add it as a module. You needn't worry about the type so much e.g. I needed to add a folder with some SQL scripts, I added it as a Java module and it's nicely visible in IntelliJ even though it has no maven structure or Java sources.
This is how to do it:
File > Project Structure > Modules
Add > New Module > ... (e.g. Java Module)
In the new module settings mark the subfolders that you want to see as 'Sources'
Voilà! :)
This is something that I typically see when creating a project from existing modules. All the modules will show in the project but not the other project related directories. These directories might be, configuration files, environment scripts or bundles of SQL scripts that don't fit neatly into an Intellij module type.
To show the rest of the project source files and directories, I create a parent module from the project root.
File->Project Structure->Modules
Create a new module using the + sign. The new module could be any type (I use java).
On the Next screen set the Content root and Module file location to the Project's root folder.
Select Finish
All of your other modules should now be submodules of the root, and your other project files should now show up.
Add and remove content roots
To add a new content root:
Go to File | Project Structure, or press Ctrl+Shift+Alt+S.
Select Modules under the Project Settings section.
Select the necessary module, and then open the Sources tab in the right-hand part of the dialog.
Click Add Content Root.
Specify the folder that you want to add as a new content root, and click OK.
source: https://www.jetbrains.com/help/idea/creating-and-managing-modules.html
I used File -> New -> Module from Existing Sources...
Then I simply select the folder and add it.
In Project view mode all directories (except the ignored ones from the settings) should show up. Of course the base folder for your multi-project has to be the folder above module1.
EDIT:
Your project should look like this (project view tree):
MY_PROJECT_ROOT (~/the/folder/to/your/project)
|- /module1
|- /module2
|- /web-module
And in this case, you should definitely see the other folders. I got a sample project set up where this is working.
EDIT 2:
From your screenshot, I assume you are missing the root directory (the project root is not as you expected). I added another screenshot. There should be a single root folder for your 3 modules. This one is missing at your screenshot. You have 3 separate folders with no common root folder. On MacOs, the project root is displayed in the window title. In my case it points to ~/devel/sandbox.
I guess you should try to create a new project in for that trunk folder. From the scratch. Then add the existing modules and you should be fine?!