.. _Tips and Tricks:

Tips and Tricks
===============


The following tips and tricks give some helpful ideas for increasing your productivity.


.. |mark-occurrences| image:: ../../images/icons/act16/mark_occurrences.png
  :class: inline

.. |rebuild| image:: ../../images/icons/act16/rebuild.png
  :class: inline

.. |last-edit-location| image:: ../../images/edt-tips-lastedit-location-btn.png
  :class: inline



Editing Source
--------------

.. list-table::
   :header-rows: 1
   :widths: auto

   * - Content assist
     - Content assist provides you with a list of suggested completions for partially entered text. In the e Language editor press :kbd:`Ctrl+Space`. 
       
       .. figure:: ../../images/edt_concepts_autocomplete_1.png
   * - Content assist for enumerated types
     - You can use content assist to speed up the access to enum items. Just press :kbd:`Ctrl+Space`.
       
       .. figure:: ../../images/edt-tips-cont-assist-enum-types.png
   * - Content assist for macros
     - You can use content assist to speed up the access to macros. Just press :kbd:`Ctrl+Space`.
       
       .. figure:: ../../images/edt-tips-cont-assist-macros.png
   * - Code templates
     - Code templates are presented in content assist if applicable.
       
       .. figure:: ../../images/common/global-code-templates-e-proposal.png
        
       To create your own templates, go to the E Language > Editor > Code Templates preference page and press the New button to create a template. 
       For example, a template for the full syntax of the sequence statement will look like: 
       
       .. figure:: ../../images/edt-template-full-sequence.png
   * - Matching brackets
     - To find a matching bracket place the cursor after the bracket and press :kbd:`Ctrl+Shift+P` or choose Source > Jump To Pair Bracket from the right click menu. You can also double click after the bracket - this selects the text between the two brackets.
      
       .. figure:: ../../images//edt-get_started-brackets-selection.png
   * - Toggle comment
     - You can toggle comment on/off for the current line or the selected lines. Press :kbd:`Ctrl+/` or from the right click menu in editor Source > Toggle Comment. You can choose the Verilog or the VHDL comment style. Right click in the editor and use the switch comment style action.
      
       .. figure:: ../../images//edt-tips-toggle-comment.png
   * - Expand/Restore Selection
     - Press :kbd:`Shift+Alt+Up` Arrow to incrementally expand the current selection. For example when the cursor is on a word, select the word. Press again to select the whole line. Then, each of the nested enclosing scopes is selected, for example the current action block, then the enclosing function, then the enclosing struct and so on. The same principle applies to nested enclosing parentheses, brackets and curly braces, as well as strings. Press :kbd:`Shift+Alt+Down` Arrow to restore the previous selection step made with :kbd:`Shift+Alt+Up` Arrow.
   * - Format source
     - Use the Format Source action from the editor right click menu :menuselection:`Source --> Format Source`. The whole file is formatted or the current selection, if any.
   * - One key indentation
     - If you press :kbd:`Tab` once at the beginning of a line, it is automatically aligned to the enclosing context. Press twice to insert a tab.
   * - Reminders (TODO markers)
     - When you tag a comment in e source code with **TODO**, a corresponding task is automatically created as a reminder. From the :guilabel:`Tasks View`, **double click** on the task takes you to the **TODO** in the code.Same for for **FIXME** (higher priority) and **XXX** (lower priority) markers.You can also add your own tags, see the :ref:`Reminders (TODO Markers)` section of the documentation.  
      
       .. figure:: ../../images//edt-get_started-todo_tasks-todo.png 
      
       .. figure:: ../../images//edt-get_started-todo_tasks-tasks.png
   * - Check Naming Conventions
     - Naming convention violations are presented as warnings in the :guilabel:`Problems View`. You can show the :guilabel:`Problems View` from menu :menuselection:`Window --> Show View --> Other --> General --> Problems`. **Double clicking** on some warning will jump to the source location.
      
       .. figure:: ../../images//edt-name-check-warnings.png
        
        Naming conventions are automatically checked when building a project. You just need to define them: 
        
        - Globally: Go to the Opens the name checks preference page e Language > E Name Checks preference page (via menu :menuselection:`Window --> Preferences --> DVT`); 
        - or Per Project: Right click on the project, choose Properties and go to the E Name Checks preference page.
      
       .. figure:: ../../images//edt-name-checks-preference-page.png
   * - Spell checking
     - You can enable spell-checking support in the e Language editor on the Opens the spelling preference page :menuselection:`General --> Editors --> Text Editors --> Spelling` preference page. Spelling errors are displayed in the e Language editor and corresponding Quick Fixes are available:
      
       .. figure:: ../../images//edt-spelling-correction-proposal.png
        
       There is currently no dictionary included in Eclipse. The required format is just a list of words separated by new lines. Quick Fixes allow you to add new words to the dictionary on-the-fly.
   * - Folding
     - You can fold code sections to improve read-ability. This is how a folded file looks like:
      
       .. figure:: ../../images//edt-folding.png
        
       Folding actions (to expand or collapse) are available in the toolbar. You may also use the **+** or **-** signs on the left side of the editor. 
       
       - Use **Collapse All Levels** for folding to statement level. 
       - Use **Show First Level** for folding to struct member level. 
       - Use **Expand All** to fully expand the file. When you type on a folded line, it is automatically expanded. You may see the folded code in a tooltip if you move with the mouse over the **+** sign.
   * - Folding custom areas
     - You can define custom folding areas using comments to indicate the start and the end of the area:  
      
       .. figure:: ../../images/common//dvt-custom-folding.png
   * - Maximize editor
     - **Double-click** on the editor tab to maximize editor to full window. **Double-click** again to restore.
   * - Show line numbers
     - Check :guilabel:`Show line numbers` from the Opens the general text editor preference page :menuselection:`General --> Editors --> Text Editors` preference page
   * - Local history
     - Whenever you edit a file, its previous contents are kept in the local history. **Right click** in the editor and choose :menuselection:`Compare With/Replace With --> Local History...`   
      
       .. figure:: ../../images//edt-local-history.png
   * - Go to line
     - Press :kbd:`Ctrl+L` shortcut or **double click** in the status bar to jump to a specific line.  
      
       .. figure:: ../../images/common//dvt-line-number-in-status-bar.png  
      
       .. figure:: ../../images/common//dvt-go-to-line.png
   * - Back/Forward navigation
     - You can navigate between editors in a browser like way using the Back/Forward Navigation Back/Forward Buttons
       
       .. figure:: ../../images/edt-tips-bkfwd-btn.png
   * - Go to last edit location
     - Useful when you navigated around in the code, before proceeding with the source change. **Click** on Last Edit Location button |last-edit-location| in the toolbar to jump to the file where you were previously editing.
   * - Local history
     - Whenever you edit a file, its previous contents are kept in the local history. **Right click** in the editor and choose :menuselection:`Compare With/Replace With --> Local History...`

      
       .. figure:: ../../images//edt-tips-compareto-localhist.png
   * - Inactive code highlight
     - The editor marks with a colored background the areas of code that are not compiled due to preprocessing. See the :ref:`Inactive Code Highlight` documentation section.
      
       .. figure:: ../../images//edt-macros-inactive-code-highlight.png
   * - Macro expansion
     - You can apply preprocessing for a macro called in your code. Place the cursor on the macro, then **right click > Macros > Expand All Levels** to inspect the expanded macro in a new file. You can also expand/collapse macros inline using :kbd:`Ctrl+Shift+=` respectively :kbd:`Ctrl+Shift+-`  
      
       .. figure:: ../../images//edt-macros-markers.png 
        
        See the :ref:`Macro Expansion` section in the documentation.
   * - Open file in more editors
     - To open multiple editors for the same file you should first open the file then **right click** on the editor's titlebar and select New Editor  
      
       .. figure:: ../../images//edt-tips-new-editor.png
   * - Split the editor view
     - To open multiple editors side by side follow these steps:  
       
       - open each file in its editor; if you wish to see the same file in a split view, **right click** on its titlebar and select New Editor  
       - if you wish to split horizontally, drag the title bar of the file you want to split and drop it over the horizontal scrollbar  
      
       .. figure:: ../../images//edt-tips-split-editor-horizontal.png  
        
       - if you wish to split vertically, drag the title bar of the file you want to split and drop it over the vertical scrollbar 
      
       .. figure:: ../../images//edt-tips-split-editor-vertical.png
   * - Column selection
     - You can switch to and from column (block) selection mode either by clicking on the Toggle Block Selection Mode button in the toolbar, or by using the :kbd:`Shift+Alt+A` shortcut key.  
      
       .. figure:: ../../images/common//dvt-toggle-block-selection.png


Searching
---------

.. list-table::

   * - Search for method, field, event etc.
     - To search for the declaration of a specific type, method, field etc.: 
       
       - Press :kbd:`Ctrl+H` to open the Search Dialog 
       - Click on the e Search tab. 
       - Type the name in the Search String (if you select in the editor before pressing :kbd:`Ctrl+H`, the Search String is automatically set to the selection). 
       - Select type or method etc. and Declarations 
       - Click Search. 
      
       .. figure:: ../../images//edt-tips-search-method.png
   * - Search for references
     - To search where a method (or field etc.) is used, hold :kbd:`Ctrl`, hover over its name and select Show Usages or **right click** on its name > Show > Usages or **right click** on its name > References > Project. The results are presented in the :guilabel:`Search View`. You can also search for references from the Search Dialog (:kbd:`Ctrl+H`).
      
       .. figure:: ../../images//edt-tips-right-click-references.png
   * - See macro instances
     - To see where a macro is used click on it and press :kbd:`Shift+F3`. The results are presented in the :ref:`Layers View`.
      
       .. figure:: ../../images//edt-tips-layers-view-macro.png
   * - Search for whole word
     - To search for a whole word in all e files, in comments or not:
       
       - Press :kbd:`Ctrl+H` to open the Search Dialog; 
       - Click on the e Search tab ; 
       - Type the name in the Search String (if you select in the editor before pressing :kbd:`Ctrl+H`, the Search String is automatically set to the selection) ;  
       - Select :guilabel:`Whole Word` and :kbd:`Do not search in comments` or :kbd:`All occurrences` ;  
       - Click Search. 
      
       .. figure:: ../../images//edt-tips-search-whole-word.png


Code Navigation
---------------

.. list-table::
   :header-rows: 1
   :widths: auto

   * - Tooltips
     - When you position the mouse over a type, method, field etc., a tooltip will pop-up showing information on corresponding declaration.
      
       .. figure:: ../../images//edt-tips-tooltip-method-info.png
   * - Hyperlinks
     - If you place the mouse over a type, method, field etc. and press the :kbd:`Ctrl` key, a hyperlink will be presented. **Click** on the hyperlink to jump to definition. You can also jump to a definition if you put the cursor on the relevant name and press :kbd:`F3`.
      
       .. figure:: ../../images//edt-tips-hyperlink-to-field.png

   * - Inheritance tree and members (Type Hierarchy View)
     - You can view the inheritance tree and all the members of a struct by placing the mouse over it and pressing the :kbd:`F4` key. See also :ref:`Type Hierarchy View`.  
      
       .. figure:: ../../images//edt_type_hierarchy_view.png
   * - Verification Hierarchy of a unit (Verification Hierarchy View)
     - You can view the :ref:`Verification Hierarchy View` of a unit (including ports) by placing the mouse over it and pressing :kbd:`Shift+F6`.
   * - Class Diagrams
     - You can create class diagrams to inspect or document the architecture of a verification environment. For more details see the :ref:`Class Diagrams <UML Diagrams>`
   * - Macro Hyperlinks and Tooltips
     - If you place the mouse over a macro you'll see a tooltip with the documentation. Define as macro tooltip example:
      
       .. figure:: ../../images//edt-tips-tooltip-macro-info.png 
        
       Preprocessing define tooltip example: 
      
       .. figure:: ../../images//edt-tips-tooltip-macro-info-preproc.png 
        
       If you press the :kbd:`Ctrl` key, a hyperlink will be presented. **Click** on the hyperlink to jump to definition. You can also jump to a definition if you put the cursor on the relevant name and press :kbd:`F3`. 
      
       .. figure:: ../../images//edt-tips-hyperlink-to-macro.png

   * - Scope
     - Your current scope (for example the method or struct you are editing) is always presented in the status bar.
      
       .. figure:: ../../images//edt-tips-current-scope.png
   * - Quick Types
     - You can quickly open a specific type definition, just press :kbd:`Ctrl+Shift+T`. The :guilabel:`Quick Types View` will pop-up and you can enter any regular expression to locate a type. Select and press :kbd:`Enter` or **click** to jump to its definition. 
      
       .. figure:: ../../images/common//quick-types-view.png
   * - Quick Macros
     - Press :kbd:`Ctrl+Shift+D` to open the :guilabel:`Quick Macros View`. It presents the available macros, both preprocessing and define as. You can enter any regular expression to locate a macro and jump to its definition (select and press Enter or click). 
      
       .. figure:: ../../images//edt_quick_macros_view.png
   * - Quick Outline
     - Press :kbd:`Ctrl+O` to open the :guilabel:`Quick Outline View`. It presents an overview of your file. You can enter any regular expression to locate a place to jump in the current file. 
      
       .. figure:: ../../images//edt-reference-views-quick_outline_view.png
   * - Quick Layers
     - Press :kbd:`Ctrl+Shift+O` with the cursor positioned on the name to quickly see extensions. 
      
       .. figure:: ../../images//edt_quick_layers_view.png
   * - Quickly jump to a layer of a field's type
     - Press :kbd:`Ctrl+Shift+O` twice with the cursor positioned on the field name (first time shows the field layers, second time the layers of the type of the field). Then you can use the filter to jump to the desired layer.
   * - Quick Compile Order
     - You can quickly open a compiled file. Just press :kbd:`Ctrl+I`.The Quick Compile Order View will pop-up and you can enter any regular expression to locate a file. Select and press :kbd:`Enter` or **click** to open the file.
      
       .. figure:: ../../images/common//quick-compile-order-view.png
   * - Quick Hierarchy
     - Position the cursor on the struct name and press :kbd:`Ctrl+T` to see the :ref:`Quick Type Hierarchy View`.
      
       .. figure:: ../../images//edt_quick_type_hierarchy_view.png
   * - Layers
     - You can view all the extensions (layers) of a specific type, method, event etc. Position the cursor on the relevant name and press :kbd:`Shift+F3` or **right click** and choose :menuselection:`Show --> Layers` from the menu. See :ref:`Layers View`.
      
       .. figure:: ../../images//edt-layers-view.png
   * - Event Layers
     - Layers include on and cover definition. Position the cursor on the event name and press :kbd:`Shift+F3` or **right click** and choose :guilabel:`Show Layers` from the menu. See also :ref:`Layers View`.
      
       .. figure:: ../../images//edt-tips-layers-view-event.png
   * - Types
     - You can view all types (enums, structs) in the project (including each struct fields, methods etc.) in the :ref:`Types View`. Open the view from menu :menuselection:`Window --> Show View --> Other... --> DVT --> Types`.
   * - Checks
     - You can view all the checks ("check that", "expect", "assert", "assume") in the project in the :ref:`Checks View`. Open the view from menu :menuselection:`Window --> Show View --> Other... --> DVT --> Checks`.
      
       .. figure:: ../../images//edt-checks-view.png
   * - Coverage
     - You can browse all the coverage definitions in the project using the :ref:`Coverage View`. Open the view from menu :menuselection:`Window --> Show View --> Other... --> DVT --> Coverage`.
      
       .. figure:: ../../images//edt-coverage-view.png
   * - Macros
     - You can see the macros in your project in the :ref:`Macros View`. Open the view from menu :menuselection:`Window --> Show View --> Other... --> DVT --> Macros`. **Double click** to jump to macro definition.
      
       .. figure:: ../../images//edt_macros_view.png
   * - Compile Order
     - You can see the compile order of the files in your project in the :ref:`Compile Order View`. Open the view from menu :menuselection:`Window --> Show View --> Other... --> DVT --> Compile Order`. 
      
       .. figure:: ../../images/common//compile-order-view-presentation-orig.png
   * - Outline
     - You can see the summary contents of the current file (structs, field, methods) in the :guilabel:`Outline View`. Open the view from menu :menuselection:`Window --> Show View --> Other... --> General --> Outline`. 
      
       .. figure:: ../../images//edt-reference-views-outline_view.png
   * - Mark occurrences
     - When working in the e Language editor, turn on Mark Occurrences in the toolbar |mark-occurrences| or press :kbd:`Alt+Shift+O`. 
      
       .. figure:: ../../images//edt-occurrences-highlighted.png
   * - Override Annotations
     - Override Annotations are markers that display special decoration icons to indicate that a method or TCM overrides a like super-type. 
      
       .. figure:: ../../images//edt-override-indication.png
   * - Bookmarks
     - Similar with a web browser, you can add bookmarks in your code without altering the code. **Right click** on the left vertical bar of the editor and choose :guilabel:`Add Bookmark...` 
      
       .. figure:: ../../images//edt-bookmark-action.png 
        
        Specify a meaningful name: 
      
       .. figure:: ../../images//edt-bookmark-dialog.png 
        
        You can jump to bookmarks from :guilabel:`Bookmarks View`. Open the view from menu :menuselection:`Window --> Show View --> Other... --> General --> Bookmarks`. 
      
       .. figure:: ../../images//edt-bookmarks-view.png


Miscellaneous
-------------

.. list-table::

   * - All shortcuts
     - Press :kbd:`Ctrl+Shift+L` to see all shortcuts.
      
       .. figure:: ../../images/common//dvt-all-shortcuts.png
   * - Project Properties
     - Select the project in the Navigator View, right click and choose Properties. Or from menu :menuselection:`Project --> Properties`.
   * - OVM Compliance Review
     - To perform the OVM compliance review of your project **click** the lint button in the toolbar 
     
       .. figure:: ../../images//edt-ovm_compl-button.png 
        
        For more details see the OVM Compliance Review chapter in EDT User Guide.
   * - Project Templates
     - A project template is a parameterized directory tree. Both in the file contents (.e, ,.sh - practically any file) and in the file or directory names you can use parameters. Combined with **TODO** markers, you can use a project template as a customized wizard. For more details see the Project Templates chapter in EDT User Guide.
   * - System Variables
     - See: :ref:`Build Configurations`
   * - Generic launch (make, scripts etc.)
     - See: :ref:`Run Configurations`
   * - Create dialogs for scripts & flows
     - You can create :ref:`Custom Dialogs` for your own scripts:  
     
      
       .. figure:: ../../images/common//dvt-customdialogs-demo.png  
        
        Follow the wizard from menu :menuselection:`New --> Example --> DVT --> DVT Custom Dialog`, then create a run configuration with the command echo ``${dvt_dialog_prompt:customdialog.swtxml}`` and run it.
   * - Open terminal
     - You can open a fully working command-line terminal inside of DVT: In the :guilabel:`Navigator View` **right-click** on the desired location and select Open Terminal Here
   * - Load in Specman
     - **Right click** on a file in Navigator (usually top or test) and from menu :guilabel:`Run As` choose :guilabel:`Load in Specman`.
      
       .. figure:: ../../images//edt-concepts-run_configurations-load_in_Specman.png
        
        The invocation output is dumped to the :guilabel:`Console View`. **Click** on hyperlinks in the :guilabel:`Console View` to jump directly to the to source location.
      
       .. figure:: ../../images//edt-console-hyperlinks.png
   * - External Builders
     - An external builder allows you to invoke any script/tool and back-annotate its output (errors, warnings etc.) to the source code. Practically it allows you to connect any 3d party tool (compiler, linter etc.) to DVT error signaling engines. For more details see :ref:`External Builders`.
   * - External Documentation
     - You can browse and search through 3rd party documentation using the Eclipse help system. For more details see the External Tools > External Documentation chapter in EDT User Guide.
   * - Context Sensitive Help
     - A focused set of help topics that is related to the current context can be shown to users on demand using context-sensitive help. This form of user assistance is delivered to users when a platform-specific trigger is activated (e.g. :kbd:`F1` key on Windows, :kbd:`Ctrl+F1` on GTK, Help key on Carbon). For more details see the Getting Started > Context Sensitive Help chapter in EDT User Guide.
      
       .. figure:: ../../images//edt-context-sensitive-help.png
   * - Mapping Linux to Windows (/proj/ to Z:\proj\)
     - Linux directories can be mapped to Windows drives in order to access them from Windows. For example /home/simi is mapped to Z:\. This has an impact on paths configured for a DVT project, for example INCDIRs etc. The paths are set using Linux conventions, however Eclipse runs in Windows and the DVT builder needs to know about the mapping in order to compile the files. To specify the mapping, set the system variable %DVT_CROSSPLATFORM_MAP% before invoking Eclipse. You can add multiple mappings separated by ";" e.g.: /projects/=p:\;/home/lars/=Z:\lars\
   * - Recover from abnormal inconsistencies
     - In the event of a disfunction (missing results in search, types in type browsing, hyperlinks, tooltips etc.), please manually trigger a rebuild |rebuild|.
   * - Add a new file extension to compile list extensions
     - Go to :menuselection:`Window --> Preferences --> General --> Content Types`, select a category from the list (for example e Source File) then **click** on :guilabel:`Add` and then on :guilabel:`Ok`. 
      
       .. figure:: ../../images//edt-contenttype-add-file-extension.png
   * - Share workspace settings
     - Export all Workspace/ Eclipse customization:
       
       - Go to :menuselection:`File --> Export --> General --> Preferences` 
       - Make sure :guilabel:`Export all` is selected 
       - Select a file where the preferences should be exported. Now you can share this file with your team. When it is imported into another instance of Eclipse (by using :menuselection:`File --> Import --> General --> Preferences`), the configuration (all options available in :menuselection:`Window --> Preferences`) is replaced by the imported one.
      
       .. note::
          You should restart Eclipse for the changes to be enforced (:menuselection:`File --> Restart`). 

       .. figure:: ../../images/common//export-preferences-select.png 
      
       .. figure:: ../../images/common//export-preferences-exportall.png
   * - Using System Varibles in Linked Resources
     - You can use System Variables in the path of linked resources. For example ``${DVT_ENV-SYSTEM_VARIABLE_NAME}/work`` is equivalent to ``$SYSTEM_VARIABLE_NAME/work`` in a console.
   * - Waive problems reported by DVT
     - You can use :ref:`Compile Waivers` to promote, demote or disable the problems reported by DVT.

       To quickly create a new waiver, in the :ref:`Problems View` **right click** on any problem reported by DVT and waive it. DVT proposes some default values for the waiver description, path and message. You can easily change them to fine-tune the waiver.

       To quickly start up a new waivers file click on the Edit waivers button in the Problems View. The **.dvt/waivers.xml** is created with a default content and opened. You can easily create your own waivers from the default generated ones.

       In the waivers editor you can use autocomplete for tags, attributes and attribute values.
   * - Open a file in DVT from the terminal
     - You can use the :ref:`Command Line Interface` like this: 
       
       .. code-block::
       
          $> dvt_cli.sh -workspace ~/dvt_workspace openFile $(readlink -f my/file.sv)
       
       The command can be shortened by defining this alias in your ~/.cshrc: 
      
       .. code-block::
          
          alias dvtopen 'dvt_cli.sh -workspace ~/dvt_workspace openFile `readlink -f \!*`'
       
       or by defining this function in your ~/.bashrc: 
       
       .. code-block::
       
          dvtopen () { dvt_cli.sh -workspace ~/dvt_workspace openFile $(readlink -f $1); }
          
       Then the command gets much shorter: 
       
       .. code-block::
       
          $> dvtopen my/file.sv
