VSCode not showing function parameter list in Dart code - flutter

When I edit JavaScript code, VSCode immediately show me a popup with a list of parameters as soon as I have typed a function name followed by (.
When editing Dart code this is not the case. Here I have to use the mouse to hover over the function name to show a popup with information about the function.
Is this normal behaviour? Are there any way to change this behaviour? Does anyone know a shortcut to show the popup?

This is controlled by a VS Code user setting in the Dart extension (dart.triggerSignatureHelpAutomatically). It's not on by default because there are some quirks (that I don't remember exactly off the top of my head).
There's work in progress to move the extension to using the LSP protocol which will push some of this functionality into the Dart analysis server, which may make it easier to make some functionality like this more reliable (since more info is available in the language server than is currently exposed to the VS Code extension).

Related

How to get VS Code to list methods of object when multiple extensions are competing for tab complete

In VS Code, when writing the name of a method on an object, it seems to take a while for the method menu to pop up. I also am using github copilot, which is great, but it's suggestions often show first and I don't see the menu for the methods until I type some more letters.
Example, let's say I have the following line of code:
my_json = My_Class(id=5).
and I want to type the name of the method that returns some json. Gitlab copilot might suggest something like the following, where the 'get_json' portion is in grey and available for tab complete.
my_json = My_Class(id=5).get_json()
But, let's say the correct name for the method is 'get_object_json', I would have to type the following before the object method/attribute menu pops up
my_json = My_Class(id=5).get_o
Is there a way to manually open the object method/attribute menu? A keyboard shortcut? So that I can open it right after I have typed the period?
Similarly, sometimes I DO want the GitHub suggestion but, right as I hit tab, Pylance IntelliSense replaces the tab complete with the name of some variable or library, or global (i.e. some built-in exception class).
It would be great if there was a way to assign a specific key combo for tab complete of GitHub copilot. Like tab-option, or something, that will only complete the github copilot suggestion, if there is one.

How to create a modal for a VSCode extension?

I'm trying to make an extension for VSCode to Find text in File (Like in Notepad++).
Is there an API for using a modal in a VSCode extension? or at least extend the Command Palette?
VS Code (1.34) has no concept modal UI. Extensions can only show basic dialog messages modally using the showMessage apis.
Messages can show message text and a set of buttons. By default VS Code will render messages in its UI. The MessageOptions.modal option makes VS Code render the message using system UI instead.
Try positing a more specific question about what you are trying to accomplish. VS Code's extension model is different from other editors, so if you are trying to replicate functionality from another editor like Notepad++ you may need to rethink the user experience.
I believe what you are looking for is an input box. It will show a UI where you can input text. From there you can grab the text of a document and parse it for entered text. For completeness, VS Code does this with ctrl + f or cmd + f depending on OS. Add the shift key to search the whole project.
As mentioned above there are the limited built-in inputs and message box (which can also be used to display choice buttons).
You can also have a look at WebView these can be used to display a side-bar view (like the EXPLORER) or a full document. They are made up from HTML and plain old JavaScript. You will have to pass simple string messages between your HTML/JS view and vscode itself.
https://code.visualstudio.com/api/extension-guides/webview
https://github.com/Microsoft/vscode-extension-samples/tree/main/tree-view-sample
A large 'document' view example vscode extension is call 'nearest-icons'
https://github.com/noGreg/nearest-icons

Is there a way to turn off naming suggestions in a code snippet?

I'm writing Selenium page object classes in Java in Visual Studio Code. I created a custom code snippet that, when entered, looks more or less like this:
public WebElement ELEMENTNAME() {
return driver.findElementByCssSelector("CSSSELECTOR");
}
After I enter the snippet name and hit Tab, ELEMENTNAME gets the focus. I type the element name I've picked, such as ConfirmButton, and hit Tab...whereupon I find that my method now has the name ConfirmButtonElement, because VS Code decided to accept its own naming suggestion instead of what I typed.
How can I turn this "feature" off?
Usually VS Code's autocomplete suggestions are helpful, so I don't want to disable them entirely. But I definitely want to disable them in the case of naming things. Is there a way to do that?
(I'm not sure whether the behavior comes from VS Code itself or from an extension such as the Red Hat Java extensions.)
1. Extension to blame: It is actually happening because of Microsoft Java Extension Pack. Though it also includes the Red Hat Java Package
2. To disable this package: You can navigate to Extensions tab in VScode and search for Microsoft Java Extension Pack and click disable package.
I don't know when this may have been added to vscode, but have a look at:
// Control whether an active snippet prevents quick suggestions.
"editor.suggest.snippetsPreventQuickSuggestions": true,
true is the default, try false.

Analog of class view in Visual Studio Code

Is there a way to quickly navigate through large files with multiple functions?
Something like class view in VS ?
Yes, there is the workbench.action.gotoSymbol command also known as outlining. Its default shortcut is CTRL+Shift+O.
If you have an extension installed which supports this command for the current file type then a list of methods, classes and maybe other symbols for the current file will drop down which allows you to jump to their definitions.
Yes, there is now a built-in Outline View in VS CODE
There is a built-in Outline View in Vscode (as other answer said)
There is also [outline-map] https://marketplace.visualstudio.com/items?itemName=Gerrnperl.outline-map
it collapses the object/hierarchy automatically, & expands as you scroll to it.
(recommended, more usable than the built-in one)
(or just find other ones in Vscode Extension Marketplace)

Method List in Visual Studio Code

I've recently started using the Visual Studio Code editor. I'm really loving it, but there's one critical feature (for me) that I haven't been able to find. Is there a method list, similar to the Navigator in NetBeans or Member dropdown in Visual Studio?
Yes, there is the workbench.action.gotoSymbol command. On Windows and Linux it's set to CTRL+Shift+O by default, on Mac it's Cmd+Shift+O.
If this command isn't available for the file types you are working with then you should take a look at the VSCode extensions. Not all languages support this feature.
Update: As stated in the comments by #jeff-xiao this extension is Deprecated and it's now a built in feature of Visual Studio code. It should be available at the bottom of file explorer as "Outline" view.
Previous text:
There is now an Extension that supports this. Code Outline creates a panel in the "Explorer" section and for JavaScript, will list variables and functions in a file. I've been using this for a while now and it scratches the itch I had. Other commenters have mentioned it supports Python and PHP well.
It still seems to be in development but I haven't had any issues. Development version available on GitHub. If you're the author reading this - thanks!
This is how it looks:
If Code Outline is not visible, you can show it by:
Invoke Code's Go to symbol command:
macOS: cmd+shift+o (the letter o, not zero)
Windows/Linux: ctrl+shift+o
Typing a colon (:) after invoking Go to symbol will group symbols by type (classes, interfaces, methods, properties, variables). Then just scroll to the methods section.
In 2020 version of VSCode
Cmd+P
# - Find symbol across files
# - Find symbol within file
#: - Group symbols within a file
In VSCode 1.24 you can do that.
Right click on EXPLORER on the side bar and checked Outline.
There is a new release that can do that!
Check here the latest release notes regarding code outline
UPDATE: The extension features are now built-in and the extension itself is now deprecated
I have found this extention: Code Outline.
This is how it looks like:
I believe that is what you have been looking for.
There's no such feature today,
the CTRL+SHIFT+O == CTRL+P # doesn't work for all languages.
As a last resort you can use the search panel - although it is not so fast an easy to use as you'd like - you can enter this regex in the search panel to find all functions:
function\s([_A-Za-z0-9]+)\s*\(
For PHP users :)
Make sure you have 'PHP Symbol' plugin then you can get all methods and class in 'OUTLINE' Sidebar's Bottom.
Press ⌘ command + ⇧ shift + O in "macOS" or Ctrl + Shift + O while using "Windows"
OUTLINE:
#Symbol:
For python in Explorer View, click on OUTLINE as below:
Visual Studio Code market place has a very nice extension named Go To Method for navigating only methods in a code file.
Hit Ctrl+Shift+P and type the install extensions and press enter
Now type Add to method in search box of extensions market place and press enter.
Click install to install the extension.
Last step is to bind a keyboard shortcut to the command workbench.action.gotoMethod to make it a real productivity thing for a developer.
Watch this link: https://code.visualstudio.com/updates/v1_40#_type-filters-for-outline-and-breadcrumbs
Explorer -> OUTLINE, you can choose what you want to show (only methods and functions in your case) and the result is similar to Netbeans:
Open symbol by name :
CTRL+T
might be what you are looking for. Works perfectly with my TypeScript project.
It is an extra part to the answer to this question here but I thought it might be useful. As many people mentioned, Visual Studio Code has the OUTLINE part which provides the ability to browse to different function and show them on the side.
I also wanted to add that if you check the follow cursor mark, it highlights that function name in the OUTLINE view, which is very helpful in browsing and seeing which function you are in.
ctrl+shift+o // This should work for javascript files by default
For PHP install the extension PHP SYMBOLS
FOR PYTHON install the extension PYTHON
On Reload, this will work fine
in-built code OUTLINE available now with VS code
There is a plugin called show functions which lists all the function definitions in a file. It also allows you to sort the function so can search them easily.
CTRL+F12 (CMD+F12 for Mac) - opens for me all methods and members in PHP class.
For find method in all files you can press CTRL + P and then start search with #
example : #signin
Take a look at Show Functions plugin.
It can list functions, symbols, bookmarks by configurable regular expressions. Regular expressions are a real saver, expecially when you're not using a mainstream language and when CodeOutline doesn't do the job.
It's ugly to see a split window with these functions (CodeOutline seems to be better integrated) but at least there's something to use
If you are using typescript you can use this extension "Code navigator for typescript".
I have been trying it and found it useful to list my typescript class methods.