IntelliJ Plugin, Sync Virtual files to real files - intellij-idea

I'm running some script command which generates files under my project, how can I refresh/reload the file tree when my command is terminated?
I have seen this Synchronize virtual file to the physical file in the Intellij IDEA plugin
I have tried to use this but no luck:
FileDocumentManager.getInstance().saveAllDocuments();
or
VirtualFileManager.getInstance().syncRefresh();
or even
currentProject.getBaseDir().refresh(false, true);
None of these methods refresh the project tree.

Just found the correct way to do it :
VirtualFile apiDir = currentProject.getBaseDir();
VfsUtil.markDirtyAndRefresh(true, true, true, apiDir);
Methods under my question were not working because my new files were generated outside IntelliJ.

Related

Where does intellij idea save the local storage and preferences of libgdx (pc)

I started working with files, a simple operation of writing and reading files.
But i had an error when writing a file and now i have to fix it by hand.
Thats the problem, i don't know where is my file.
Also i would like to see the file i'm writing.
I am working with intellij idea 2016 1.4, maybe the file is complied in a jar?
Yes, i know that clearing cache its an option.
nothing here: https://github.com/libgdx/libgdx/wiki/File-handling
on the wiki link only talk about where you can find the ablolute path file but thats not my case. I get the file this way:
this.resolver = Gdx.files.local(path + "item"+ String.valueOf(weaponNumber) + ".txt");
String description = this.resolver.readString();
So.. where is the file? thanks
In the desktop version it saves the file in the assets folder inside your android module.
FileHandle file = Gdx.files.local("myfile.txt");
file.writeString("Test libGDX", false);
System.out.println(Gdx.files.getLocalStoragePath());
Output: D:\Dropbox\Projetos\Outros\gdxTest\android\assets\
The project folder in my computer is gdxTest.
In your case you have the path var so probably will be a folder inside assets folder.
But when you pack the desktop game into a jar file, the file will be created in the same folder where your game jar file is located. Usually yourProject\desktop\build\libs.
The difference is because when we configure the desktop project we set the Working Directory in the yourProject\android\assets\ folder. So to Android Studio it is the local folder of your project.

Use Intellij File Watcher only on Open File

I've been using the Intellij Golang plugin recently (it's great) but I've been running into an issue with the File Watchers I set up. My working directory is set to my $GOPATH directory and I would like to be able to run golint and goimports after I save a file I'm working on. The issue I have is if I use git to clone a repo the next time I open Intellij it runs both golint and goimports on all the newly imported files which can take a long time for large projects. Is there a way to set up File Watcher so it only watches a file that is currently open? I added a screenshot of my current settings below:
Open Watcher setting -> Scope , change it to Open Files
If you wanna more control over the plugin, you can have a look at the official doc
Instead of file watcher you can get External tools configured to achieve almost the same functionality. The only difference is that this won't run on save but rather you'll have to trigger this manually. Or you could configure a macro to run them on save (but I don't have experience with macros + external tools so I'm not if this will work).

How to create new compilerconfig.json Web compiler (Extension)?

I have project with a lot of less files, I'm used in Web compiler (developer Mads Kristensen) Extension for visual studio 2015.
my way to create compilerconfig.json is to compile single file and then edit manually the file, to work with all the other less files in the project.
I'm sure it's wrong way...
I don't understand, how I can to create new compilerconfig.json file that include all the less files in existing project?
because in this situation when I added new less file the only way to add file is go to compilerconfig.json and add it manually.
we don't have option to create new compilerconfig.json with all the less files in automatically way?
Less Web Compiler
All you need to do after adding a new .less file to your project is right click the new .less file and "Compile File" should be the only option, by selecting that option it will then be added to the compilerconfig.json file. This will not add all the .less files in the project to the config, with a single click, but it will automatically add them with a quick click on each file, and you wont have to be adding them manually.
BEFORE:
[
{
"outputFile": "less/site.css",
"inputFile": "less/site.less"
}
]
AFTER:
[
{
"outputFile": "less/site.css",
"inputFile": "less/site.less"
},
{
"outputFile": "less/theme.css",
"inputFile": "less/theme.less"
}
]
You can also recompile all the files from the Task Runner Explorer window (View -> Other Windows -> Task Runner Explorer). There you should see the compilerconfig.json, below that you will see "LESS", you can "Run" that to compile all, or a select a single file. You can also compile on build.
An alternative method would be to use a gulp file. You can set up a task to get all the less files in your project, without another thought to it after setting it up.

Dont index files from extension pattern in WebStorm 7.0.2 IDE

I added an issue on the official tracker: http://youtrack.jetbrains.com/issue/WEB-10127
Is it possible to not indexing some kind of file in webstorm?
Extension: *.concat.js, I use Grunt to concat files from directories and generate d.ts.concat.js, lib.concat.js, and I merge all files in one and at the end with grunt uglify I minify the final file.
But when I run the script the IDE froze completely and stop working 75% times.
Any solution?
Solution:
Put these files in a separate directory and exclude it from the project (right click on dir => Mark directory as => excluded)
Or :
register *.concat.js as a text file (Settings/File Types/Text Files, add *.concat.js to the list of registered patterns)

IntelliJ/WebStorm File search with Dart

The following line of Dart code shows true for existing files when run from the Terminal but false when run from IntelliJ or WebStorm. Can someone explain why and how to set up Idea editors so that it will return the same results as the Terminal run.
bool pathExists(String path) => new File(path).existsSync();
Update
After tinkering I've now found out that if I create the project in WebStorm 5 using 'open directory' it works fine for all(WebStorm, IntelliJ, and the Terminal). The problem is when I try to create the project in IntelliJ 12 as there seems to be no equivalent to open directory it seems to try to create a Java project. WebStorm seems to have better support for creating a Dart application from scratch at the moment. See answers below for instructions.
You really should show the whole program and how you run it, otherwise I can only guess. And my guess would be that you are passing a relative path to the function and you run the program from a different directory than IntelliJ.
Let's say I have this Dart program:
import 'dart:io';
bool pathExists(String path) => new File(path).existsSync();
main() {
print(pathExists('books.txt'));
}
This program will print true when the books.txt file exists in the current directory. I happen to have such file in my home directory, so when I do
ladicek#argondie:~$ dart check_file.dart
it will obviously print true. But if I run the same program from another directory, it will surely print false. And that's probably what happens in your case.
You should check the Run/Debug Configuration in IntelliJ, it lets you configure the directory where the program is started.
Following #CrazyCoder's comment: Selecting
Create New Project
then
Static Web/Web Module
and choose your folder at
Project Location
then expand
More Settings
and finally make sure that
Module File Location
is set to where your main() dart file is located. By default it is set to the content root.
Has the same effect as Open Directory. I've tried it and it works fine.