IntelliJ IDEA 2020 support for webdriverio selectors - intellij-idea

I have this kind of code:
get alcoholLink() {
return $('a=Alcohol');
}
which is valid webriverio selector for getting an element with text 'Alcohol'.
But IntelliJ IDEA underlines it red and displays "unexpected token" error.
Does anybody know how to tweak IntelliJ settings in order to recognize the code as valid webdriverio selector?
Thanks,
mismas

IDEA treats $ as jQuery and thus jQuery-CSS language is auto-injected in $() calls. And 'a=Alcohol' is not a valid CSS selector syntax - thus the error; deselecting the js: JQuery selectors language injection in Settings | Editor | Language Injections should help to get rid of the issue:

Related

How to avoid the error message when using thymeleaf templates in Intellij

I'm using spring boot and thymeleaf in Intellij Idea and try to get the parameters of the URL in the template, I use the following code:
<!--/*#thymesVar id="param" type="java.util.Map<java.lang.String, java.lang.String>"*/-->
<a th:href="#{/dashboard(version=${param.version})}">Dashboard</a>
It works correctly, but I want to clear the error message, Is there any good way to do this?
This is not an error. If you run your application, It is supposed to work (If there is no other errors), as you mentioned that It's working correctly. The JetBrains/ IntelliJ is not able to locate your model variables with Thymeleaf framework. So that's why I does show the red underline. For more details check the link how to resolve JetBrains model variables.
Hopefully in next version of IntelliJ IDEA, this issue would get resolved.
Let us know If It was helpful.

IntelliJ IDEA FXML is not correctly recognized

Why does IntelliJ does not recognize all tags in this *.fxml document?
The JavaFX plugin is enabled and some of the tags are recognized... (I created this with SceneBuilder)
How to solve this problem?
Don't rely on the wildcard import for resolution of the fx:root type attribute.
Use:
<fx:root type="javafx.scene.layout.GridPane" ...
Instead of:
<fx:root type="GridPane" ...
Then all of the node type specific tags (such as <children>) will resolve OK in the Idea editor and not be highlighted in red.
Do not ask me why this is so as I do not know.
I tested the above on Idea 15 EAP ideaIU-143.116.4-custom-jdk-bundled.dmg, it may or may not work on earlier Idea editions.

switching between languages in same file

I recently attended a user group meeting where the IntelliJ representative was demonstrating version 13.
He demonstrated how to switch the code completion view of a file. I do not exactly remember what the file extension of this particular file was, probably java.
The concept was that if the file is html with embedded javascript he could then switch the code completion between html and javascript with a shortcut. If he says treat the file as html then all code in file was treated for code completion purposes as html, and vice versa for javascript.
Does anybody know what shortcut he might have been using to enable the language switch?
Sounds like you may be referring to the IntelliLang feature. IntelliJ IDEA can be aware of other languages embedded within a file.
A simple example is in an HTML file that has CSS and JavaScript.
Notice when I am inside the HTML markup:
or inside an HTML element:
The code complete shows HTML completion options. However, when I am inside the style attribute, I get CSS code completion:
I also get CSS code completion if I am inside a <style> element. So even though I am in an HTML file, I see CSS code completion because of my location.
Same case with JavaScript. When I invoke code completion inside a <script> element, I get JavaScript completion, even though I am in an HTML file.
Anytime IntelliJ IDEA can determine that another embedded language is present, it provides, via IntelliLang, the appropriate syntax highlighting, error highlighting, and code completion. The same holds true for Java. Notice here that IDEA knows the method I am competing takes an SQL statement and therefore highlights the String value using SQL highlighting, and provides SQL code completion:
So even though I am in a .java file, I get SQL code completion. The reason is that IntelliLang comes pre-configured knowing the embedded language of some methods. You modify them, or add more, in File > Settings > [Project Settings] > Language Injections.
In addition, you can use an annotation to tell IntelliJ IDEA (as well as developers looking at the code) that a String must be valid in a particular language. For example, I can annotate a String field, variable, or parameter, to indicate it must be valid HTML:
Notice I get HTML syntax highlighting, HTML code completions, and the CSS color shows in the left gutter. If I annotate a method parameter, then any time I call the method, I get the appropriate syntax highlighting, code completion, and error/warning highlighting:
The #Language annotation is inside the annotations.jar that is contained in the redist directory inside the IntelliJ IDEA installation directory. It is also available in maven central, or IDEA will offer to attach it as a Library if you use the annotation without it being attached.
IntelliLang and the #Language annotation supports a large number of languages. Just use code Completion inside the quotes after typing #Language("") to see a list. (Inline search works in the list as well.) One of the most useful is Regexp. For example, if you have a method that expects the string passed in to be a valid Regular Expression, annotating it as such will give anyone that calls it Regex code completion and error highlighting if they are passing in an invalid Regex pattern. Even for developers using other IDEs it is useful as a form of documentation.
As for a shortcut to change the the language on the fly for code completion, the only thing I can think that you might be referring to is the "Inject Language" intention. If I am entering a String value, and I bring up the quick-fix/intention menu via Alt+Enter, I am given an option to inject a language:
If I select that, IntelliJ IDEA will ask me what language I want to use:
After making my selection, IntelliJ IDEA will give me temporary language injection (including code completion) for the selected language.
It also gives me an option to add the #Language annotation for permanent injection.
To the best of my knowledge (as a 10 year IntelliJ IDEA user) that is the only way to switch code completion language types. So hopefully that is what you are looking for. To me, IntelliLang is one of the coolest features in IntelliJ. (It actually started as a third party plug-in and JetBrains then absorbed it into the product.)

Weird coffeescript code style in Intellij IDEA

I have this line in my coffeescript file
if someVariable then no else yes
One of the most valuable feature in IDEA for me is code clean up. But it doesn't work as I expect here. After pressing Ctrl+Alt+L, IDEA reformats this line to ugly
if someVariable then {
no
} else yes
Which is not just bad style but error when compile from coffeescript to javascript.
Here is similar line which couldn't be formatted properly by IDEA.
return true if someVariable is 5
...becomes...
{
return true
} if someVariable is 5
Why is that?
It's a bug caused by the if() statement, Force braces: Always setting in JavaScript Wrapping and Braces.
Issue is submitted to YouTrack.
That looks like JavaScript code style. Try checking settings under File>Settings>Project Settings>Code Style.
If you can't manage to set the code style to a correct form, then you still have the option to customize it yourself..
Eventually take a look # http://www.jetbrains.com/webstorm/webhelp/coffeescript-support.html, you might find something interesting if you haven't gone over it all ready. Good luck!

Javascript code not recognised in Intellij IDEA 12 in scala template for Play 2

I just installed the recently released Intellij IDEA 12, which is GREAT for Play Framework 2.
However, I'm having the following issue: in an HTML Scala template, any JavaScript code enclosed in a <script> tag within the body of the template is not recognised as JavaScript by IDEA, thus not offering code completion and incorrectly showing errors where they aren't. I suspect it is interpreting the code as Scala code, ergo offering incorrect code completion and making it quite painful to write JS in a template.
This issue was not present in IDEA 11.
Any ideas?
Update
I have the JavaScript Support plugin enabled. Simple code completion works fine. However, if I type function (){} to code an anonymous function and hit Enter with the caret between the curly brackets, IDEA does the following:
If I manually fix the incorrectly added }, and write code for the anonymous function, it offers correct variable suggestion for the console.log although it is stil showing errors:
I can't confirm that, I can see that both, Scala and JavaScript completion works properly.
Go to Settings > Plugins and make sure that you have JavaScript Support enabled. After that close and reopen all your views to let the Idea analize syntax once again.
It appears that your function statement is invalid because you did not name your function. The details of what is going on here are answered in this post. I'm not sure of the details of your particular needs, but you might try this syntax instead:
<script>
(function() {
})();
</script>