Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
PTP/photran/documentation/photran5advanced
You are here: PTP > Photran > Documentation > Photran 5.0 Advanced Features
Photran 5.0 Advanced Features
IMPORTANT: For the time being, this is just an outline of the
documentation we intend to write before the release of Photran 5.0
in September, 2009. It is not useful yet. Of course, you are
welcome to fill in any sections you wish... this is a wiki!
Introduction
TODO
- Indexing
- Problems view (cf. below)
Enabling Advanced Features
In order to use any of the advanced features described in this document, you must specifically enable them as described below. After you do this, Photran will index your project; that is, it will build a database of what modules, subprograms, etc. are declared in every file in your project. This information will be updated incrementally every time you save a file. Although this process is reasonably fast in most cases, it may become disruptive when working on very large projects, so it has been disabled by default. Note that the first time your project is indexed, it may take a while, because Photran must analyze every file in your project; after that, it will only index files that have changed (or that depend on a file that has changed), so it will generally be much faster.
How to Enable Advanced Features
- Right-click on your project's folder in the Fortran Projects view
- Click on Properties
- Expand Fortran General in the list on the left, and click on Analysis/Refactoring
- Check the "Enable Fortran analysis/refactoring" check box
- If you want to enable content assist, the Fortran Declaration view, etc., check those boxes as well
- You may also want to set module and include paths at this point (see below)
- Click OK
Setting Module and Include Paths
If your source code contains INCLUDE lines or USE lines referencing modules in other files, Photran needs to know where to look in order to find these. It will not figure this out automatically. For each project in which you plan to use refactoring support,
- Right-click on your project's folder in the Fortran Projects view
- Click on Properties
- Expand Fortran General in the list on the left, and click on Analysis/Refactoring
- List the folders in which Photran should search for INCLUDE files and modules when refactoring. They will be searched in order from the first folder listed to the last. Subfolders are not searched automatically; you must include them explicitly.
- Click OK
The Fortran Analysis/Refactoring Problems View
TODO
Advanced Editing Features
Content Assist
TODO
Fortran Declaration View
TODO
Hover Tips
TODO
TODO
Open Declaration
TODO
Fortran Search
TODO
- Fortran Search dialog
- Find References
Refactoring
Introduction
- What is refactoring
- Note fixed form not supported
- How to activate
- Refactor menu (if in editor)
- Editor context menu (if in editor)
- Fortran Projects View context menu (multiple files)
Rename
- Description: Rename is essentially a "smart" search and replace: It allows you to change the name of a variable, subprogram, etc. It correctly observes scoping and shadowing rules can also rename subprograms and module entities across files.
- Applies To:
- Local variables1,2
- Subprograms3 (including external and interface declarations)
- Derived types
- Module entities (variables and subprograms)
- Main programs
- Namelists
- Common blocks
- Block data subprograms
- Operation:
- Click on the name of a local variable, subprogram, etc.
- Click Refactor > Rename... The Rename dialog will appear.
- Enter a new name for the variable/subprogram/etc.
- If you are renaming an external subprogram or a subprogram declared in an interface block, you may want to (un)check the box labeled Match external subprograms with interfaces and external declarations. If this is checked, the refactoring will attempt to find all external subprograms, EXTERNAL statements, and subprogram declarations in INTERFACE blocks that have the given name, and they will all be renamed.
- Click Preview to see what changes will be made, then click OK to apply them.
- Example:
1. Dummy subprogram arguments cannot be renamed
2. Components of derived types cannot be renamed
3. Intrinsic subprograms and type-bound procedures (Fortran 2003) cannot be renamed
Introduce Implicit None
- Description: Introduce Implicit None adds IMPLICIT NONE statements to a file and adds explicit declarations for all variables that were previously declared implicitly.
- Applies To: All main programs, subprograms, and modules in one or more files.
- Operation:
- This is a multiple-file refactoring.
- To Introduce Implicit None in a single file, open the file in the editor and choose Refactor > Introduce Implicit None from the menu bar.
- To Introduce Implicit None in multiple files, select the files in the Fortran Projects view, right-click on any of the selected filenames, and choose Refactor > Introduce Implicit None from the popup menu.
- Click Preview to see what changes will be made, then click OK to apply them.
- This is a multiple-file refactoring.
- Example:
Move Saved Variables to Common Block
- Description: Move Saved Variables to Common Block creates a common block for all "saved" variables of a subprogram. Declarations of these variables in the subprogram are transformed such that they are no longer "saved". The generated common block is declared both in the main PROGRAM and in the affected subprogram. Variables placed in the common block are renamed such that they do not conflict or shadow other variables. The current implementation assumes that the subprogram is in the CONTAINS section of the PROGRAM.
- Applies To: Subprograms.
- Operation:
- Click on the declaration statement of a subprogram.
- Click Refactor > Move Saved Variables to Common Block.
- Click Preview to see what changes will be made, then click OK to apply them.
- Example:
Replace Obsolete Operators
- Description: Replace Obsolete Operators replaces all uses of old-style comparison operators (such as .LT. and .EQ.) with their newer equivalents (symbols such as < and ==). and adds explicit declarations for all variables that were previously declared implicitly.
- Applies To: All uses of the following operators in one or more files: .LT. .LE. .EQ. .NE. .GT. .GE.
- Operation:
- This is a multiple-file refactoring.
- To Replace Obsolete Operators in a single file, open the file in the editor and choose Refactor > Replace Obsolete Operators from the menu bar.
- To Replace Obsolete Operators in multiple files, select the files in the Fortran Projects view, right-click on any of the selected filenames, and choose Refactor > Replace Obsolete Operators from the popup menu.
- Click Preview to see what changes will be made, then click OK to apply them.
- This is a multiple-file refactoring.
- Example: