File Types
File Types
A file type is a file classification that is defined with the File Type Options command. There are file types for
"C/C++ Source Files", "Java Source Files", and so on. Source Insight uses each file's name to determine its file type. For example a file matching the
*.c
wildcard is a "C/C++ Source File". The file type defines parsing, display, and editing options.
Figure 3.4 The file name determines the file type. The file type determines the font, the language type used to parse the file and display it with syntax formatting, and other editing options.
The File Type Options command defines new file types or changes the built-in types. See “File Type Options” on page 207.
Language Types
Source Insight uses a language abstraction to encapsulate the properties of various programming languages.
Each file type specifies a language type in the Parsing section. Therefore the file type and language type are separate, but connected. For example, there is a file type named "C/C++ Source File", which uses the "C/C++
Language" for parsing.
File-Type-Specific Options
The file type is key to determining how Source Insight treats a file. Most importantly, it controls what programming language is associated with each file. A file type also specifies editing and display options, such as the tab width, word wrap, auto-indentation, display font, and others.
Tip:
To see what file type is associated with the current file, right-click on the source file window and select
File
Type Options
. The file's current file type is automatically selected in the dialog box.
Associating Files with File Types
The File Type Options command associates a file type with a filename wildcard. For any given file, Source
Insight determines the file type by matching its name with the filename wildcards specified in all defined file types. For example,
*.c files belong to the "C/C++ Source File" file type, while
*.py
files belong to the
"Python Source File" file type.
70 Source Insight 4 User Guide
File Types
Associating File Names Without Extensions
Some files in your project may not have any file extension. For instance, the standard C++ header files, such as "complex" do not have file extensions. This situation makes it difficult to use wildcard specifications to associate a file with a file type. For that reason, Source Insight uses a special file named filealias.txt to create file name aliases for the purpose determining the file's file type.
The filealias.txt file is stored in your Source Insight program directory. You can edit this file. By default, it contains the names of the standard C++ header files.
The format of filealias.txt is as follows: oldfilename=newfilename
This maps oldfilename to newfilename before determining the file's file type. For example: algorithm=algorithm.h
When Source Insight sees the file algorithm, it uses the alias algorithm.h when determining the file type of the file.
Adding New File Types
Adding new file types makes Source Insight aware of new types of files. All the defined file types become
Source Insight's file “vocabulary”. That is, when Source Insight shows you the files in a directory, it will only display files that belong to currently defined file types. In addition, when Source Insight automatically adds files to a project, it will only add files that belong to known file types. Therefore, by adding a new file type, you are expanding Source Insight's knowledge of file types.
Editing the File Types
The easiest way to edit a file's file type, or to see what file type it belongs to, is to make sure the file’s window is activated, then select Options > File Type Options. The file type of the current file is automatically selected
in the File Types dialog. See “File Type Options” on page 207.
Source Insight 4 User Guide 71