Ignore some classes in project from suggestion in code complete - phpstorm

I have file email.php where I have markup and declaration of class email_db which I never used in another place. But when I use autocomplete when I try type empty by 2 first letters em I often see this class as suggestion.
Is it possible to ignore some class names from code complete feature?

No, there's no option for that. The only thing you can try - is to move the file with class declaration to a folder marked "excluded".

Configuring imports
**To configure classes to be excluded from import
Open the Settings/Preferences dialog box, and under the Editor / General node, click Auto-Import.
On the Auto-Import page, click Alt+Insert.
In the dialog box that opens, type the name of the class or a whole package to be excluded, and click OK.
Use Alt+Insert and Alt+Delete to manage the list of classes and packages that IntelliJ IDEA shouldn't place to the suggestion list.
Apply changes and close Settings/Preferences dialog.
Original Link: https://www.jetbrains.com/help/idea/excluding-classes-from-auto-import.html
Hope this helps.

Related

Sublime text 2 Snippets - autocomplete

I've created a bunch of snippets in Sublime Text 2, but I cant remember them all off the top of my head. I've seen in a number of tutorials that as people start typing their snippets tab-triggers it will start to provide a list of the matching snippets. I don't see this.
Is there a setting somewhere for this? Or do I need to create a special file (completions file?). For most snippets I have the <scope> commented out as I may use in a PHP or HTML file for example depending what I am working on.
Most of my snippets tab triggers start the same elq- prefix, so it would be very helpful if it were to start showing me the options as I type.
The setting auto_complete_selector controls when Sublime automatically offers the popup for possible completions. The default value for this setting is:
// Controls what scopes auto complete will be triggered in
"auto_complete_selector": "source - comment",
This means that it will automatically pop up for any file that's considered a source code file, except within a comment.
The scopes for the file types that you mention in your question are text scopes and not source scopes, which stops the popup from appearing.
One way around that would be to manually invoke the auto complete panel by using the appropriate key binding, which by default is Alt+/ on Linux or Ctrl+Space on Windows/OSX. When you do that, the popup for possible completions at this point is manually displayed.
To allow this to work more automatically, you would need to modify the setting for auto_complete_selector to be more appropriate for your situation.
To do that you could select Preferences > Settings - User from the menu and add or modify the auto_complete_selector setting as follows:
"auto_complete_selector": "source - comment, text.html",
This says that the selector should always be displayed in source files except inside comments (like the default) and also within HTML files.
You could also use text instead of text.html if you want it to work in all text files of all types, although this would possibly get quite annoying while working with plain text files. Substitute an appropriate scope or set of scopes here as appropriate to dial in the places you want this to be automatically offered.

How to change automatic variable generation in PhpStorm?

With PhpStorm, if you type function foo(MyClass $, it will propose myClass as the variable name.
But since I added a WordPress project (I accepted default settings for WordPress as proposed), it propose my_class instead.
I really would like to bring back the camel case naming by default, but I don't find where it is configured.
Is there an option for this? Or maybe a configuration file to edit?
In the settings (Ctrl+Alt+S), go to Editor > Code Style > PHP, then click the Other tab. At the bottom of the screen, you should see the Variable Naming Style section. Select camelCase.

Disable rule in sonar

I want to disable a rule from Sonar so it doesn't show the results in the web page.
In my case I want to hide (or not capture) the results about trailing comments.
Is it posible to configure it somewhere?
Thanks.
The right way to do is to put something like this on sonar-project.properties file per project:
sonar.issue.ignore.multicriteria=e1,e2
# tab characters should not be used
sonar.issue.ignore.multicriteria.e1.ruleKey=squid:S00105
sonar.issue.ignore.multicriteria.e1.resourceKey=**/*.java
# right curly braces should be on a new line
sonar.issue.ignore.multicriteria.e2.ruleKey=squid:RightCurlyBraceStartLineCheck
sonar.issue.ignore.multicriteria.e2.resourceKey=**/*.java
There are docs here on how to ignore specific rules for specific files, which links to an example of how to search for specific rules, by language. This page on baeldung goes into additional detail better than the docs
You have to remove this rule in the quality profile that you are using to analyse your project.
Please refer to the documentation that describes all this: Quality Profiles in Sonar.
In web interface for particular rule just press Deactivate button:
Adding to #Vladmir's answer in a new answer as I am not able to comment.
You can not modify the built-in profiles. If you don't see the option of Deactivate, then copy the profile and set it as default. Now you will see the options to activate/deactivate.
An additional note for people ending up on this thread. I tested this quite a lot and finally found that setting common rules (anything that starts with "common-xxxx") from scanner side (pom, command line etc) will be ignored and it wont work. The language specific rules can be passed line arguments and thats why the "squid:S00105" rule is getting ignored correctly. Here is the issue link on the SonarQube JIRA board and it says that it "wont be fixed".
https://jira.sonarsource.com/browse/SONAR-8230
Here is the link to my answer: https://stackoverflow.com/a/60570763/1766402
on how to set it from UI.
You can't deactivate sonar way rules in a built-in profile. so you have to create your own profile by going to the Quality Profile section and choosing your desired language then click on the config icon the select copy with your favorite name and then you can change any rules in that
and then you can deactivate your considered rules
For Java, You can get sonarlint/sonarqube to ignore false-positives by just commenting //NOSONAR at the end of your code statement. As mentioned in my answer here

Where are these HTML elements created in the Joomla code?

I'm working on a site for a client, and I've never used Joomla before. I keep seeing elements in the HTML, that I can't find in the code. It's Joomla with Virtuemart and the bt_bazaar template.
For example, at the top of the page there's a div with the class bt_toolbar. When I search the entire public root of the site, it only turns up a match inside CSS, and this line from bt_bazaar/helpers/bt_helpers.php:
$this->bt_toolbar = '<jdoc:include type="modules" name="toolbar" style="BTxhtml" />';
Where is this toolbar? How do I find other module types in the code? Where is the class name bt_toolbar set?
Thanks,
Frankie
Its a Joomla Module.
You can find the joomla modules under
public_html/modules/mod_modulename.
here your module name is toolbar but this name may not be the module name (we can have option to use other names and same name).This name stands the position of the module.
go to admin side and in the module manager you can find a module name with toolbar position name.
eg: mod_somename.
Then go to front end modules/mod_somename/tmpl/default.php
This is the HTML out put of the module.
If you not found the same module on the above path or you changed the file not effecting it.
It may be overrided.
Then you can find the module at
public_html/templates/your_tmplate_name/html/mod_somename
it depends upon joomla version too.
Hope This will help you...
BTxhtml looks like module chrome so look in the modules.php file of your template and see if it is there.
Also name= tells you the name of the position the module is assigned to, so if you go to the module manager and filter on position toolbar you should find it.

Eclipse - how to extend HTML editor to add custom tags?

I write an application and inside of HTML code I have custom tags (of course these tags are parsed on server side and end user gets them as valid HTML code). Example of custom tag usage:
<html>
<body>
...
<Gallery type="grid" title="My Gallery" />
...
</body>
</html>
1.) How can I have eclipse recognize my custom tags inside of HTML code and add syntax highlighting to them?
2.) How can I add auto-suggestions to my custom tags? For example if I type "<Gallery " press "Ctrl+Space" - in the list of available attributes it shows me "type" and "title" and if I type "<Gallery type=" press "Ctrl+Space" I would see list of available values only for tag "Gallery" and its attribute "type".
Thanks in advance!
Not really what you want, but maybe it helps you:
You can try the Aptana Plug-in for Eclipse. It allows to write your own regular expression for HTML validation, so a custom tag would be ignored by the validator.
E.g.:
.gallery.
Eclipse allows you to add simple auto-suggestions via Templates. On
Eclipse 3.7.1 (Indigo) + PHP Dev Tools (PDT) 3.0.0: Window > Preferences > Web > HTML Files > Editor > Templates
Sadly, there is no easy way: you have to roll your own parser for this, and then add both your extra elements and the base grammar (HTML) to it.
If you have your parser, you could use it to do syntax highlighting (strictly speaking, for that simple lexing is enough); and a good parser can support content assist (auto-suggestions in your terminology).
Caveats:
Creating a parser for HTML is not an easy task. Maybe by aiming at a more often used subset is feasible.
If a parser exists, the editor parts are still hard to get well.
Some help on the other hand: you could use some text editor generators to ease your work:
Eclipse IMP http://www.eclipse.org/imp/ can in theory handle any type of parser, but currently it is most optimized for LPG. The documentation is scarce, but the developers are helpful in the forums.
Xtext http://www.eclipse.org/Xtext/ got quite a hype for creating text editors for DSLs. The generated editors are quite nice out of the box, but is not the best solution for large files. Has a really helpful developer community.
EMFText http://www.emftext.org/index.php/EMFText is a lesser known entity - I don't know it in details, but I guess, it is similar to Xtext.
I know its been a long time since this Q was asked,
but I hope this might help others like myself that reach this in search of a solution.
So, When using Eclipse (Mars.1 Release (4.5.1) - and possibly earlier - I did not check).
Go to Window - Prefrences
Then in the dialog that opens go to Web - HTML Files - Editor - Validation.
On the right side:
under Ignore specified element names in validation and enter the list of custom elements you use. (e.g. Gallery,tab,tabset,my-element-directives-*)
you might also like to go under Ignore specified attribute names in validation do the same for your custom attributes.(e.g. ng-*,my-attr-directives-*)
Two things to note:
After letting eclipse do a full validation you must also close the file and reopen it to have the warnings removed from the source code.
Using this method would ignore those attributes under any element. I don't think there is a simple way to tell it to ignore some-attribute only if its a child of some-element.
I find templates are an ok alternative but let's see if we can encourage a more robust solution; please take a moment and vote for this: https://bugs.eclipse.org/bugs/show_bug.cgi?id=422584
You need to add a new HTML template.To add a new template, complete the following steps:
1) From the Window menu, select Preferences.
2) In the Preferences page, select Web and XML > HTML Files > HTML Templates.
3) Click New.
4) Enter the new template name and a brief description of the template.
5) Using the Context drop-down list, specify the context in which the template is available.
6) In the Pattern field, enter the appropriate tags, attributes, or attribute values (the content of the template) to be inserted by content assist.
7) If you want to insert a variable, click the Variable button and select the variable to be inserted. For example, the word_selection variable indicates the word that is selected at the beginning of template insertion, and the cursor variable determines where the cursor will be after the template is inserted in the HTML document.
8) Click OK to save the new template.
You can edit, remove, import, or export a template by using the same Preferences page.
Reference : http://help.eclipse.org/kepler/index.jsp?topic=%2Forg.eclipse.wst.sse.doc.user%2Ftopics%2Ftsrcedt024.html