auto-import of packages across project in eclipse - eclipse

I have used file search functionality in eclipse to replace a specific occurrence of text with a replace text which contains a java method name in all files across the workspace.
But now in all those files I have to add the import statement (for the method name to resolve).
Is there an automatic way of doing this instead of manually searching and importing the package myself in all files?
P.S.: I can't use java refactoring since the text I have changed is not a java element and Organize import option will make changes to lot of files (re-ordering imports) which will be problematic when I need to commit, I again have to manually check differences to see which files have actual changes instead of just organize import statements.

Instead of doing this with search and replace, try to use Refactor->rename which will do it correctly.
another options is to use organize imports, you can do it for an entire project as well (source -> organize imports).

Related

Is there a way to set `//#dart=2.12` for an entire package/lib/folder?

When migrating large code bases to nnbd, it would be helpful if we could opt entire local packages in/out of NNBD. For example, I may want to migrate some of my leaf nodes first, like /lib/helper_widgets/* before moving onto the higher-order views.
Currently dart supports this on a per file basis using // #dart=2.12 which is fairly tedious if your package has many files.
I was hoping I could do this with lib and part of, but this just gives me a compile error, to add a header to each file.
[Edit] A pragmatic solution here is to run something like find . -name "*.dart" | xargs sed -i "1s/^/\/\/ #dart=2.9\n/" on your project. That will put the 2.9 import in every file. At that pt, you can use find/replace to just turn on entire sub-directories of your /lib code.
It's gonna be either per file, or with the pubspec.yaml. The pubspec method will change the entire package. If you use dart migrate, that's one of the steps it performs. Then be sure to dart pub upgrade, because a different set of dependencies will then be available.

importing less files to webstorm without explicit "#import"

Can webstorm know that less files exist in the project without using "#import"? a way of reducing the use of "#import"! or at least, to import the file without giving it the full path?
In WebStorm, variables and mixins in LESS are resolved and completed in the following way:
If element can be resolved to declaration from current file or from
explicitly imported files, then it is resolved to it without any
warnings.
If element can't be found in current file or files
available by explicit imports, but similar declaration is found in
one of project .less files, then it is resolved just by name.
Resolved element is marked with a weak-warning inspection 'Resolved
by name only'.
Completion list for variables and mixins includes all variables/mixins from all files in project. Elements defined in current file or in explicitly imported files are placed on the top of completion list and have bold font. Variables/mixins from other files are marked with 'implicitly imported'-hint.
as for import paths, please see comments in WEB-7452 for possible workarounds

How to find and replace a string in all files of a project using netBeans

I have a PHP project in NetBeans
I have a constant named KEY and I want to change it to SECURE . This constant is spread through out many files of my project. How can I approach this very quickly. I've heard of refactoring, and even tried it but it only renamed the current file and not the whole project's files.
Use Ctrl+Shift+H, after clicked on project folder. Lower in dialog you may specify all needed params. As far as it's a constant, you may prefer to specify case match, or if needed, use regular expressions

How can I add a custom package to the startup path in Dymola/Modelica?

I have a custom package that I find myself reusing repeatedly in Dymola models, and I'd like to put this package in a common directory that is automatically loaded whenever I start Dymola. My current strategy is to load the custom package when a model I'm working on is loaded and then save total. This is not elegant because the contents of the custom package end up saved in multiple locations across my hard drive, and if I change one of them, the changes are not reflected everywhere. I would like a more robust way of distributing this custom package to all of my models. Is there a way to tell Dymola to automatically load my custom packaged every time?
The trick is to add the following lines to settings.mos in c:/Users/USERNAME/AppData/Roaming/Dynasim:
Utilities.setenv("MODELICAPATH", "C:\Users\USERNAME\Documents\Dymola");
openModel("c:\Users\USERNAME\Documents\Dymola\UserDefined\package.mo")
The first line adds the directory to the path that Dymola uses to search for packages that have not been loaded prior to the first run of a model, and the second line loads the specified package. These two commands may be somewhat redundant, but I am doing both because I want to make sure my custom packages are on the path in addition to loading the UserDefined package.
Two suggestions. First, you need to add your package to the MODELICAPATH. You'll have to consult the Dymola documentation to figure out exactly what you need to do. But normally, what this means is that you have to set an environment variable that gives a list of directories (; separated) to be searched for your package. Now that will put it in your path so it can find it automatically, but it won't load it until it needs it.
If you want it to always appear in the package browser, you'll probably need to set up a .mos file (script) to load it. Dymola has that capability, but you'll have to read the manual to figure out what that script has to be called and where Dymola expects to find it.
I hope that helps.
In the instalation folder of Dymola 2018 -> insert -> dymola.mos
I've added the lines:
Utilities.setenv("MODELICAPATH", "C:\Users\XXXX\Documents\Dymola");
openModel("C:\Users\XXXX\Documents\Dymola\DCOL\package.mo");
openModel(“C:\Users\XXXX\Documents\Dymola\Annex60 1.0.0\package.mo”);
Now I don't get the utilities sentence, as the DCOL package loads fine without it and the added 'utilities' package in the package menu is useless.
But it does not open the Annex60 package.
I've tried a lot of different combinations and can't get multiple packages to load. I doubt that "cd" and "Advanced.ParallelizeCode", which are also added in the text work.
The accepted answer does not work since Dymola 2017 FD01, as the file settings.mos is not used anymore. User settings are stored in the setup.dymx file instead, located in
C:\Users\USERNAME\AppData\Roaming\DassaultSystemes\Dymola
In contrast to the setup.mos file you can not include custom lines with modelica script in setup.dymx.
The answer using dymola.mos still works, but you need admin privileges to modify this file.
Here is a simple solution which works with all Dyomola versions:
You can pass a .mos-script as first parameter to the dymola.exe.
This can e.g. be done like this:
Create a .mos script somewhere with commands like openModel(), etc.
Create a desktop shortcut to Dymola.exe
Open the properties of the shortcut and add the path to the .mos script in the Target text field. It will then look something like this:
"C:\Program Files\Dymola 2018 FD01\bin64\Dymola.exe" "C:\<some-path>\startup.mos"
Start Dymola with the desktop shortcut. The script will be executed and eventual errors or messages are displayed in the Commands window
Another suggestion where you don't need to hardcode your package into an environment variable of your operating system (and maybe more safe for inexperienced programmers):
Go to the folder where Dymola is installed (e.g. C:\Program Files\Dymola 2020).
Search for the Dymola.mos file in the insert-folder. 'insert' folder
Open the script (e.g., in notepad++)
Add the link(s) to your Dymola-library-package.mo file(s) here with the openModel statement
e.g., openModel("C:/IDEAS/package.mo"); Dymola.mos script
Save the script. Now, every time you open Dymola, your libraries will be loaded automatically.

In Eclipse, exclude some files from debugging

Is it possible to exclude files from debugging in Eclipse?
There are my files which I have written and I am interesting in going through these files using debugger Step Over command.
But there are also many imported library files and Step Over goes into these files, which I'd like to avoid. So is there an option eother to specify which files to debug or which files to exclude?
If you're using a JVM based language (as you didn't specify), under Preferences, filter for Step Filtering.
You will see a list of packages. Add your packages to the list, and ensure Use Step Filters is selected.
Assuming it's an entire package you want filtered out, and you're using Java, this should do what you want.