Make IntelliJ understand usage of Babel's moduleRoot - intellij-idea

For our project we use EcmaScript 6 through Babel, Gulp and npm.
We have three projects: Base, Common and Game.
We're actively developing Common and Game so we have those checked out (and npm link from Game to Common), while we get the Base project through npm and don't change it often.
The import paths we use start with the project name such as import "Base/utils/svg" or import "Game/model/boardtile". The map according to the following on the file system:
Base → /intellij-project/base-project-src/node_modules/base/
Common → /intellij-project/base-project-src/js/
Game → /intellij-project/game-project-src/js/
The problem: IntelliJ does not understand this import scheme. We use the moduleRoot and moduleId options of Babel to identify our AMD modules that way during the gulp build process. When that is done we concatenate everything into one big file. That works, but IntelliJ does not know that we do this magic.
Is there a way to still make IntelliJ understand our imports? So that it will know that Base/utils/svg actually means /intellij-project/base-project-src/node_modules/base/? At the moment the IDE is mostly a glorified text editor, as refactorings obviously relies on the IDE understanding the imports.
Note: Unfortunately I can't change the import structure, as it's a decision I can't change. Nor can I switch to other tools instead of the above mentioned ones, such as WebPack.

I'm facing the same problem with this. I'm looking for a way to get rid of the annoying relative paths as you guys have done, but to get them to work with IntelliJ is another piece of work.
What can help is the symlink approach that can be found here.
https://gist.github.com/branneman/8048520
IntelliJ can work nicely with node_modules, so you could symlink a folder in your node_modules to point to the real thing. Then I suppose IntelliJ will be able to resolve your imports.

Related

Installing dependencys with Gradle Kotlin DSL does not work

Hi everyone I am new to IntelliJ in general and especially to Gradle and I feel like a total noob. :D
Im not sure if this is a Kotlin DSL thing or if I just do it the wrong way and it wouldn't work in Groovey either.
After hours of trial and error and reading other SO posts I'm still not able to install a simple dependency... it can't be that hard...
Currently I am playing around with Jetpack Compose for Desktop even though it's still in alpha and it works but for the love of god I am not able to add a dependency.
So here is my Problem:
I try to install the dependency like they say I should in
https://developer.android.com/jetpack/compose/navigation#kts
and yes I know it's an android package so it may not compile or it may crash during runtime but shouldn't it at least find and download the dependency???
So... if I add
implementation("androidx.navigation:navigation-compose:2.4.0-alpha10")
to my build.gradle.kts
And try to compile it I get an exception during the build process:
What I tried so far:
I checked if the repository maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
who is configured in my build.gradle.kts repositories-section and in my settings.gradle.kts pluginManagement-section contains the package that I want.
The site https://mvnrepository.com/artifact/androidx.navigation/navigation-compose?repo=space-public-compose-dev tells me, that the repository contains the package that I need.
I checked the error log itself.
But I don't relly know what it tries to say.
I use Java SDK16, since I expect downward compatibility and the fact that the dependency is still in alpha I assume it should be compatible.
I use Kotlin 1.5....
that's it.
Thanks for reading all that :) I really appreciate your time... If I forgot some crucial information let me know and I will add it as soon as I can.
the problem which I feel is, is you are basically opening the wrong file. (I don't use jetpack compose so the answer might differ)
on the top left corner in the image, where there is project dropdown, open it and select android.
now there will be a different set of files in the Gradle folder, in fact, there will be 2 different files in that folder.
build.gradle (project: <project_name>)
build.gradle (Module: <project_name>.app)
open the second file and there will be dependencies copy + paste implementation code there.
the file which you have opened is actually the first file.
Well... here I am back again answering my own question.
After I switched to the terminal in IntelliJ Idea (which to be honest I could have thought of that prior to posting my question) there was highlighted text that gave me the necessary insight, why it wasn't working.
And after some searching the web in order to find out what an "aar" file is and why I didn't get a jar file like I expected it turns out that android has it's own little file format for android applications and that those cannot be used in regular java/kotlin projects.
I read somewhere, that 'aar' files contain a jar file and some other stuff and extracting the jar file from the aar file may be a way to get it working, but it didn't fix anything, maybe because the dependencies of the navigation package are aar files as well and therefor I'd need those packages as well and extract the jar file from those as well and it all seems like this isn't the right way...
So I guess I have to wait until Jetpack Compose for desktop somehow is able to use aar files or until the repositories deliver the packages in a regular jar file.

How to lint LESS or CSS in PhpStorm?

I was searching for linters in PhpStorm's plugin directory, but there are no results, which seems strange to me. Are people not using linters for their stylesheets in PhpStorm?
Is there any other way to lint LESS files in a PhpStorm project?
For example, I need all properties to be sorted alphabetically within a class definition.
At this time, there is no easy way to automatically rearrange the style properties in LESS files using a PhpStorm plugin. (The stylint plugin in in version 2016.3 does not affect LESS files).
I ended up building a grunt task for CSSComb, which works fine.

Intellij can not locate some classes - Play SBT. Intellij bug?

I have a few import statements in my project that are displayed in RED. Intellij shows 'Cannot resolve symbol' errors, and I am not able to autocomplete these classes or their methods. However, when I run my project it runs perfectly fine. This is strange so much so, that lets say I have an import statement
import org.apache.velocity.app.Velocity
It cannot resolve the 'Velocity' class, even though when I do a ctrl+b selecting the 'app' package, it clearly shows the Velocity class:
I am lost in this and I am struggling to code like this. Any help will be appreciated.
Best Regards.
EDIT: In my project, some of the dependencies are also not resolved, although I refreshed my project multiple times. The exact same dependencies are resolved in my colleague's system, who is using the same code-branch and environment as me.
I can see that the unresolved dependencies lie inside the play.sbt package, but are still not resolved. Is there a compatibility issue between Intellij("15.0.2") and SBT("0.13.8" mentioned in build.properties of my app)?
Reimport project using option 'Import project from external model' and choose 'sbt'. In next window choose options like 'use auto-import' and download 'sources for SBT and plugins'.

Golang plugin in intellij-Idea not finding all files

This relates to the go language plugin (version 0.9.15.3) for IntelliJ IDEA.
I have a directory structure in the following format:
src/
fred/
fred.go
bill/
bill.go
In (say) bill/bill.go, I import fred.go, and the compiler picks up references to fred.Something (when run from the command line).
But IntelliJ IDEA does not recognise the references to fred.Something; they come up in red, and actions such as 'go to definition' do not work.
Is there anything I can do to make this work?
I don't want to upgrade to the alpha version of the plugin if I can help it, unless it is stable (in which case, it should not be alpha).
Please don't use 0.9.15.3. The latest plugin should work properly for your case, if not please open a issue.
To get the latest plugin, please follow the instructions from here: https://github.com/go-lang-plugin-org/go-lang-idea-plugin#pre-release-builds

IntelliJ IDEA and PlayFramework modules

After a lot of good comment about IDEA, I decided to give it a try. I downloaded the Community Edition and would like to use it for PlayFramework development.
I have followed official documentation and some other information gathered around, but I have not succeeded completely. When using a project with differents (play) modules, the different classes are not found.
For example when using Secure module, IDEA keeps complaining about not finding Secure.class. It has to be a classpath issue. I tried to attach Java source & classes ($PLAY/modules/secure/) in module settings (F4), class is still not found. Did I miss something?
BTW, I have done a play dependencies and play idealize, which seems to add another module Secure into project in IDEA.
Thanks,
The answer is to run the following:
play deps
play idealize
This forces the IDEA .iml project file to be refreshed with the updated class path entries for the new module (in this case Secure).
A issue I came across using IntelliJ and Playframework.
The log4j.properties file or log4j.xml file are not in classpath by default. You have to add the conf as a source folder in module settings.
You need to add the Secure module you have created in IDEA as a dependency to the main application module:
Go to File -> Project Structure
Choose the main module
Choose the Dependencies tab
Click Add -> Module Dependency
Choose the IDEA Module you created for the Play Secure module
Also make sure you have the correct source path selected for the Secure module in IDEA.