IntelliSenseIntelliSense

IntelliSense 提供數個功能,可協助增強撰寫和編輯程式碼的體驗。IntelliSense provides several features to help enhance the experience of writing and editing code. 例如,除了程式碼完成之外,IntelliSense 引擎也提供成員清單、參數資訊和快速諮詢。For example, in addition to code completion, the IntelliSense engine also provides member lists, parameter info, and quick info.

在 Visual Studio for Mac 中,IntelliSense 是由核心編輯器服務提供,且支援多種語言,例如 C#、XAML、F#、JavaScript 等。In Visual Studio for Mac, IntelliSense is provided by the core editor service, and is supported in many languages, such as C#, XAML, F#, JavaScript and more. Visual Studio for Mac 也提供進階 IntelliSense 功能,例如能夠從程式庫顯示尚未匯入專案的完成項目。Visual Studio for Mac also features advanced IntelliSense features, such as the ability to show completions from libraries that are not yet imported into the project.

程式碼完成Code Completion

在支援的檔案 (例如 C# 程式碼檔案) 中鍵入時,會在完成清單中顯示對您目前鍵入字串有效的完成項目,並隨著您鍵入的內容進行更新。When typing within a supported file, such as a C# code file, valid completions for the string you are currently typing will be displayed in a completion list and updated as you type. 此外,如果您刪除文字,此清單會再次自動更新,以包含完成指定字串的更多可能性。Furthermore, if you delete text, the list will again auto-update to include the wider range of possibilities for completing the given string.

完成視窗也支援依類型篩選包含的完成項目。The completion window also offers support for filtering the included completions by type. 例如,您可以限制清單的成員只代表類型 (如類別或委派)。For example, it is possible to limit the members of the list to only represent types such as classes or delegates. 您可以透過按一下代表所要篩選類型的特定圖示,或經由對應於指定類型的鍵盤快速鍵來啟用此篩選程序。This filtering process can be enabled either through clicking on a specific icon representing the type which will be filtered or via keyboard shortcuts corresponding with a given type. 這些圖示位於完成視窗的底部,如下所示:The icons, which are located at the bottom of the completion window, are as follows:

圖示Icon NameName 關鍵字Keyword 熱鍵Hotkey
類別圖示 Class - 類別class class ⌥C⌥C
常數圖示 常數constant const ⌥O⌥O
委派圖示 Delegate - 委派delegate delegate ⌥D⌥D
列舉圖示 列舉enum enum ⌥E⌥E
事件圖示 eventevent ⌥V⌥V
欄位圖示 fieldfield ⌥F⌥F
介面圖示 interfaceinterface interface ⌥I⌥I
關鍵字圖示 關鍵字 (keyword)keyword ⌥K⌥K
方法圖示 methodmethod ⌥M⌥M
命名空間圖示 namespacenamespace namespace ⌥N⌥N
屬性圖示 屬性property ⌥P⌥P
程式碼片段圖示 程式碼片段snippet class ⌥S⌥S
結構圖示 structurestructure struct ⌥S⌥S

藉由按一下任何圖示,或是按下對應的快速鍵,完成清單就會僅限於篩選集所定義的類型。By clicking on any of the icons, or by pressing the corresponding hotkeys, the completion list will limit to only types as defined by the filter set.

Intellisense 類型篩選

參數視窗Parameter Window

IntelliSense 的另一項功能是能夠在適當的情況下提供參數清單。Another feature of IntelliSense is the ability to provide a parameter list where appropriate. 參數清單提供所呼叫程式碼的方法簽章詳細資料。The parameter list provides details of the method signatures for the code being called. 藉由按一下簽章內的向上/向下箭號,即可循環檢視每個可用參數簽章,以判斷最適合您需求的簽章。By clicking on the up/down arrows within the signature, you can cycle through each of the available parameter signatures to determine the most appropriate for your needs. 除了允許的資料類型詳細資料之外,也可能會有透過 XML 註解在目標方法中定義的描述。In addition to the details of the types of data allowed, there may also be a description as defined in the target method via XML comments.

參數清單

當您填入參數時,您目前編輯的參數會是粗體,而非使用中參數則具有標準字型粗細。As you fill in the parameters, the parameter that you are currently editing will be bolded, while the inactive parameters will have the standard weight.

觸發完成視窗和參數視窗Triggering Completion Window and Parameter Window

當您在原始程式檔中鍵入時,就會自動觸發完成視窗。The completion window will be triggered automatically as you type within your source file. 不過,您也可以使用快速鍵 control-space 來觸發完成視窗。However, you can also trigger the completion window by using the shortcut control-space. 此按鍵組合會使完成清單出現在插入號的目前位置。This key combination will cause the completion list to appear at the current position of your caret.

您也可以按下 control-shift-space 來手動觸發參數視窗的外觀。You can also manually trigger the appearance of the parameter window by typing control-shift-space. 當您的插入號位於對參數清單有效位置時,參數清單會出現在插入號位置附近。When your caret is in the position that is valid for a parameter list, the parameter list will appear near the caret position.

另請參閱See also