Code Import Options

www.altova.com Print this Topic Previous Page Up One Level Next page

Home >  Projects and Code Engineering > Importing Source Code >

Code Import Options

When importing program code into a UModel project, you may need to set or change the options listed below. These options are available on the dialog box which appears when you run the menu command Project | Import Source Project or Project | Import Source Directory.

um_dlg_import_source_project

Import Source Project dialog box

Most of the options on the dialog box above can also be changed at any time later, see Code Synchronization Settings.

 

The following options are applicable to all project types, regardless of the language or platform:

 

Option

Description

Import project relative to UModel project file

By default, this option is selected, which means that a relative path dependency will be established between the UModel project and the imported source code project.

 

After source code is imported, a UML component is generated automatically in the UModel project (it is available in the Model Tree, as a child of "Component View"). This component realizes the interfaces or classes to be engineered; it also specifies the code engineering options, including the path to the source project or directory. This will be a relative path if Import project relative to UModel project file is selected; otherwise, it will be an absolute path.

Merge Code into Model / Overwrite Model according to Code

If Merge... is selected, potential name conflicts (such as package or class names) will be resolved by appending a number to the element that is being imported.

 

If Overwrite... is selected, and if there are name conflicts, the imported element will take precedence over (overwrite) the one existing in the project.

Enable diagram generation

Optionally, select this check box if you want to generate Class and Package diagrams from the imported classes. When this check box is selected, the import wizard includes additional steps which enable you to customize the look of the generated diagrams.

 

The following options are applicable only to C++ projects:

um_dlg_import_source_project_cpp

C++ Project Settings dialog box

Option

Description

Microsoft Visual C++ Compatibility

This option is applicable only when importing C++ code compiled with Visual Studio; it lets you specify the Microsoft Visual C++ compiler compatibility. Set this to the compiler version (code dialect) used by your Visual Studio C++ project. Be aware that this setting refers to the code dialect of the source code files; the Visual Studio project (or solution) itself must be saved with Visual Studio 2010 or later to qualify for import. To import source code authored in an IDE other than Visual Studio, use the Project | Import Source Directory command.

Additional compiler options (clang)

Internally, UModel uses the clang compiler version 3.8 to read C++ code. Additional code parsing options can be specified in this text box if necessary (if applicable to UModel), see also clang documentation (http://releases.llvm.org/3.8.1/tools/docs/UsersManual.html#command-line-options).

Include directories

Use this option to specify any additional directories where UModel should look for C++ classes when reverse engineering the C++ code. Specifying include directories is optional if the source project is a Visual Studio project.

 

If you select the auto-detect and use system include directories check box, UModel will attempt to detect any include directories defined system-wide, in addition to those explicitly mentioned in this dialog box.

 

It is also possible to define the include directories paths from the UMODEL_CPP_INCLUDE system environment variable, see Reverse engineering C++ projects. In this case, the include directories defined in the UMODEL_CPP_INCLUDE system environment variable will replace those which would otherwise be included if the auto-detect and use system include directories check box is selected.

Preprocessor definitions

Use this option to specify any C++ preprocessor directives required to compile the code. If the source project is a Visual Studio project, the preprocessor directives are detected automatically.

Import mode

The option read C++ source files will parse all files of the source project. This is the default option. If you want to import only C++ libraries, select the option read C++ headers only, which will also make the import operation faster.

 
By default, .h files are treated as C++ headers. Clear the check box treat .h files as C++ headers if the source project is using another extension for header files.

 

The following options are applicable only to C# and VB.NET projects:

 

Option

Description

DocComments as Documentation

Select this check box to convert comments found in the C# code into UModel element documentation (see also Documentation).

Resolve aliases

 

 

 

This check box is enabled by default. If your C# or VB.NET code contains namespace or class aliases like in the code listing below, it is recommended to keep this check box selected. Otherwise, associations and dependencies involving aliased classes and namespaces in your code may not be detected automatically by UModel during the import (and thus would not be present in the model).

 

using Q = System.Collections.Generic.Queue<String>;
Q myQueue;

Example of an alias in C# code

During the source code import, any potentially conflicting aliases are added to the "Unknown externals" package of the UModel project if their use is unclear.

 

When you update the code back from the model (round-trip engineering), aliases will be retained as they exist in the generated code.

 

The Resolve aliases option can be changed at any time later, see Code Synchronization Settings. If you enable this option after (not before) the import operation, UModel prompts you to update the project from the code again, since the option also has consequences for forward engineering.

Defined symbols

If your C# or VB.NET code includes symbols that are defined through preprocessor directives such as #if, #endif, you can instruct UModel to take them into account while reverse engineering code.

 

#if DEBUG      

       static void DisplayMessage()

       {

           Console.WriteLine("Please wait...");          

       }

#endif

Example of a conditional compilation symbol in C# code

For example, if you reverse engineer the code above, the method DisplayMessage() will only be imported into the model if you specified the DEBUG symbol.

 

To specify conditional compilation symbols, enter them in the "Defined symbols" text box, delimited by a semicolon.

 

During the reverse engineering process, UModel outputs all symbols used in the source code in the Messages window.

 

The following option is applicable only to Java projects:

 

Option

Description

JavaDocs as Documentation

Select this check box to convert JavaDocs-style comments found in the code into UModel element documentation (see also Documentation).

 

Note: Only comments applicable for Java classes, interfaces, operations, and properties are converted.


© 2019 Altova GmbH