Is there a way to have WebStorm complete a whole line? - intellij-idea

Is there a way to have WebStorm complete a whole line?
I'm not looking for anything smart, just something like vim's i_CTRL-X_CTRL-L
This can come in handy for repetitive import statements on top of a file:
import Rea can be completed to import React from 'react'; that shows multiple times in other files of a project.

Based on their documentation, IntelliJ only supports the following Auto-Completing Code scenarios:
Basic code completion on ⌃Space.
Type completion on ⌃⇧Space.
Completing punctuation on ⏎.
Completing statements with smart ⏎.
Completing paths in the Select Path dialog.
Expanding words with ⌥/.
Negating expressions with an exclamation mark.
Various tips and tricks on using the suggestion lists that appear on invoking code completion.

Related

Get auto import completions without adding import statements

I have python embedded into my program and added a few functions using the Python C API. I'd like to get PyLance IntelliSense providing autocompletion for it.
After setting up paths to a dummy python file (with dummy functions), PyLance seems to suggest auto completions for my functions but also adds the top-level from x import y statements. I've tried to set the python.analysis.autoImportCompletions to false but it disables the autocompletion entirely.
So, how to get the autocompletion without PyLance adding the import statements at the top? (I know it's not practical but I think it suits my use case here)

React-Native Uncaught syntax error: Cannot import statement outside a module

Here is an image of the top lines of a simple(ish) app.js (not using the bluetooth stuff yet - all commented out)
So no biggie as app seems to work regardless, but I'm interested in why I get it and what can be done to remove it.
Some previous questions seem related to the use of something called Jest (no idea what that is - I suppose I should look it up?)
Jest Testing React Native cannot use import statement outside of a module
Putting it here for benefit of others who may come across it.

Can't always set React Native breakpoints in Chrome

While debugging my React Native app in Chrome, I'm often unable to set breakpoints in the Sources tab. When I click on a line of code to add the breakpoint, a breakpoint is added instead to the next function declaration line in my module.
This doesn't happen in all of my source modules, but often enough that it prevents me from debugging efficiently.
I'm currently using RN 0.22 but this has been happening on older versions of RN as well (e.g. RN 0.18).
This problem maybe caused by babel. When use normal function and arrow function together, it happened.
"sourceMaps": "inline" in .babelrc fixed this for me.
I've only experienced this issue under the following conditions:
1) The .js file contains multiple functions, and
2) Attempting to set a breakpoint within a function that is not the last function in the .js file
So, a partial workaround is to move a function such that it is the last function in the .js file. Or, you could assign a single function per file. Either way, you will be able to set breakpoints.
This is far from ideal, but it's the only "solution" I've found so far.
I had the same issue, and I have a cozy solution for now :
I put the word "debugger" in the file which I want to debug.
I refresh the browser to see that it stops.
after it stops, I can add as much as breakpoints as I want and remove the "debugger" word from file
Try this package
https://www.npmjs.com/package/react-breakpoint-fix
just install the package and run react-breakpoint-fix from the terminal.
This fixed it for me. I'm using react-scripts#3.x

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.)

FlashDevelop code completion AIR API

I haven't used FlashDevelop in half a year, and on returning (and updating it) the code completion no longer functions properly. I'm not entirely sure, but I think the code completion doesn't know the AIR library.
When pressing "Ctrl+Space" after typing "import" will only show me the classes I have already imported.
Pressing "Ctrl+Space" after typing "import f" or "import flash." returns no suggestions.
If I type of the import by hand, the class will successfully compile though.
I have updated Flex, FlashDevelop, the debugger
Code completion is activated
I have set Compiler Options >> SWC Included Libraries to "Flex 4.6\frameworks\libs\player\11.1\playerglobal.swc"
searched google and stack overflow for a solution
I have tried shang's suggestions (this & this too)
and I'm out of ideas.
any help would be greatly appreciated.
Jake
Ctrl+Alt+Space will show all the classes included in the classpath. Select an entry and it will generate the import statement.