How to change root directory for ReSharper's suggested namespaces? - namespaces

ReSharper wants me to change my namespace to ProjectName.Assets.Code.SomeNamespace. This is because this project has its code two folders down from the root of the project.
Is there some way I can set ReSharper to instead suggest ProjectName.SomeNamespace? It should assume the root directory for all our code is in ^/Assets/Code.

Select the folder you want to ignore in the Solution Explorer, then look at it's properties in the Property Window, you should see the setting for Namespace Provider, set it to False. (So in your case select the Assets and Code folders

Related

PhpStorm insert current namespace

I want the PhpStorm to insert current namespace by default or with a hotkey or with live templates.
Whet I create new Php class ("New | PHP Class" dialog) there is a field for a namespace. Is there a way for it to be filled automatically? It does not look a big deal because in my case a namespace is just directory path (I use composer) starting from src. My search efforts did not give my anything about this at all. Looks like PhpStrom does not have this feauture. But maybe there is some plugin or a hack?
New | PHP Class dialog should fill the namespace automatically based on the directory where file will be created. If it does not then you have not configured your project properly.
Settings/Preferences | Directories -- ensure that your src folder is marked as Source Root. That's depends on project, of course: for Laravel project you need to map app folder to App\ namespace (typical case).
PhpStorm can also detect source roots from your composer.json settings and can even keep it in sync since 2017.2 version (see https://blog.jetbrains.com/phpstorm/2017/07/configuring-with-composer-in-phpstorm-2017-2/).
Some links to read (official help pages):
https://www.jetbrains.com/help/phpstorm/configuring-php-namespaces-in-a-project.html
https://www.jetbrains.com/help/phpstorm/configuring-content-roots.html
https://www.jetbrains.com/help/phpstorm/directories.html

How can I handle html files in Luminus which aren't in "resources"?

I have this:
(defn about-page []
(layout/render "about.html" {:title "About"}))
But since I have moved the directory "templates" from "resources" to the root directory and on a server I might put it yet in another place, it doesn't work. I did it because I don't want the html templates to be embedded in the output jar.
So how can I make the code work, how can I get access to my html files in "templates" then?
And the same question for static images, css, js: I put them in the root directory for now, so they aren't in "resources". They're in "public" folder. However, when I refer to them as "public/css/css1.css", they aren't getting found, that is, the path localhost:3000/public/css/css1.css doesn't exist.
How can I tell Luminus where my statics are located now?
Templates location
Selmer's documentation describes how to change the location of the templates:
By default the templates are located relative to the ClassLoader URL.
If you'd like to set a custom location for the templates, you can use
selmer.parser/set-resource-path! to do that:
(selmer.parser/set-resource-path! "/var/html/templates/")
It's also
possible to set the root template path in a location relative to the
resource path of the application:
(set-resource-path! (clojure.java.io/resource "META-INF/foo/templates"))
This allows the templates to be refrerenced
using include and extends tags without having to specify the full
path.
To reset the resource path back to the default simply pass it a nil:
(selmer.parser/set-resource-path! nil)
The application will then look
for templates at this location. This can be useful if you're deploying
the application as a jar and would like to be able to modify the HTML
without having to redeploy it.
As you want your templates to be reload when you change them you should also remember that Selmer caches them:
When rendering files Selmer will cache the compiled template. A
recompile will be triggered if the last modified timestamp of the file
changes. Note that changes in files referenced by the template will
not trigger a recompile. This means that if your template extends or
includes other templates you must touch the file that's being rendered
for changes to take effect.
Alternatively you can turn caching on and off using
(selmer.parser/cache-on!) and (selmer.parser/cache-off!) respectively.
Assets location
Handling of static resources is configured using site-defaults in your <app>.middleware namespace. You need to configure its' :static entry to use :files instead:
(-> site-defaults
(assoc :static {:files "/var/www/html"}))
and you need to copy files from resources/public directory to that location.

Exclude some folders from module declaration suggestions in PhpStorm

When I try to click on some function in PhpStorm with a CRTL button the system tries to bring me to a definition of this function. Sometimes there are multiple definitions and the annoying page shows up telling to chose to which definition you want to go. Like here:
Because I am using grunt and minifing / concatenating results, the definitions is in multiple places. I know that I should ignore everything in node_modules, but the system does not. Is there a way for me to exclude some of the folders?
If you don't need any completion/navigation/etc. from your local node_modules, you can exclude this folder from your project:
right-click, Mark directory as/Excluded
You will still be able to run Grunt, but files in these folders won't be indexed and thus suggested for completion/navigation

How do you configure JSHint options globally in Sublime Text 2?

I'd like to turn off particular warnings globally when using Sublime Text 2's JSHint plugin. For instance, "laxcomma".
I tried editing the .jshintrc file in JSHint's Sublime Packages folder, but this did not work.
{
"laxcomma": true
}
Adding a project specific .jshintrc file with the same options solves the issue for that particular project, but I would like these options to be global.
Any suggestions?
From the JSHint docs page:
http://www.jshint.com/docs/
JSHint will look for this file in the current working directory and, if not found, will move one level up the directory tree all the way up to the filesystem root.
So, technically you could put a .jshintrc file at the root level of your filesystem (/.jshintrc) and every new project would default to those options. Individual projects could override them as needed.
If anyone's having trouble creating a .jshintrc in Windows, you could go to AppData\Roaming\Sublime Text 3\Packages\SublimeLinter, copy .editorconfig for example, rename and edit it then place it in your root directory like #philip-walton suggested.
If you edit the file here, you may need to Run your text editor as administrator.
If you try to rename the file here, you may need to right-click the file, go to Security, Advanced, change the Owner object name to yourself (PC-Name\User-Name), then also Add yourself to the list of Permissions by selecting the Principal.

ReSharper: Namespace does not correspond to file location

I renamed a folder and updated my namespace declarations, but ReSharper 6 claims that the namespace should be a reflection of how it was before the rename. Where is it storing the file location data?
Check to make sure your assembly name matches your new namespace. If you've changed your folder structure to match your new namespace, you may still see the ReSharper alert until you update the project properties.
As delliottg's comment says, in Visual Studio, go to
Project > [project name] Properties > Application
and change "Assembly name" as well as "Default namespace".
I also had this problem with a folder/namespace and none of the above steps fixed it.
In my case I had to do this in Visual Studio:
Right-click the "problem" folder in the solution explorer to open the properties
Ensure the "Namespace Provider" is set to true
This fixed the ReSharper issue for me and I was able to adjust namespaces as normal.
Root namespace is needed to be changed as following.
I use Resharper 2019.3.2 in VS 2019 vs 16.5.2 and I had similar issues.
When developing, I first work out my namespace hierarchy in a single project, then split the project in seperate class libraries. In the first stage, it is convenient to always let the subdirectory correspond to the namespace.
For example, my prototype MeshTools.dll project currently contains:
Meshtools ........................ 3 cs-files in \MeshTools
MeshTools.HeightField .......... 2 cs-files in \MeshTools\HeightField
MeshTools.VectorTools .......... 3 cs-files in \MeshTools\VectorTools
The above answers all assume one single namespace per project. Renaming directories manually may confuse Resharper and that can be repaired by setting the default assembly in the .csproj file to the proper namespace. Thanks for the tip.
However in my case, I have several namespaces in a single project, with each namespace in a Solution directory corresponding to a real directory. Setting the default assembly "Meshtools" does not affect ReSharper behaviour for HeightField and VectorTools, when things have gone wrong with the renaming.
I googled this issue and came by https://www.jetbrains.com/help/resharper/Refactorings__Adjust_Namespaces.html#
It turns out there is a right-click option on a Solution Directory -> Properties. You will find an option to decide, if the Solution Directory is a NameSpace provider or not. When something has gone wrong, Visual studio will reset the field to False. Set it back to True and Resharper will correctly refactor namespace or file location when needed..
If you're using JetBrains Rider, go to the Solution Explorer and right click on the csproj file, then properties in the context menu. In my case the Assembly Name was already updated but "Root Namespace" wasn't, updating Root Namespace allowed JetBrains to automatically update all namespaces.