# Private import statement

**URL:** <https://alf.discourse.group/t/private-import-statement/19>\
**Category:** Tool Question\
**Created:** [February 1, 2019, 2:00pm UTC](https://alf.discourse.group/t/private-import-statement/19 "2019-02-01T14:00:06Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tim](https://yyz2.discourse-cdn.com/free1/user_avatar/alf.discourse.group/tim/32/5_2.png) [@Tim](https://alf.discourse.group/u/Tim)\
**Post date:** [February 1, 2019, 2:00pm UTC](https://alf.discourse.group/t/private-import-statement/19/1 "2019-02-01T14:00:06Z")

</div>

In MagicDraw 19.0 with Alf plugin, we defined an activity with import statements. The Alf code starts with:

private import Util::Protocol::Messages::Start;  
private import Util::Protocol::Messages::End;

activity ‘AbstractSemanticTest$behavior$1’() {

The compiler marks the first word “private” as an error:

![Capture](https://global.discourse-cdn.com/free1/uploads/alf1/original/1X/5e1b81bc3b34b91750a0ea05730db7c9aa91d908.jpeg)

What’s wrong? Private import statements are supported by Alf.

Tim

---

<div class="post-metadata">

**Author:** ![seidewitz](https://yyz2.discourse-cdn.com/free1/user_avatar/alf.discourse.group/seidewitz/32/7_2.png) [@seidewitz](https://alf.discourse.group/u/seidewitz)\
**Post date:** [February 5, 2019, 10:48pm UTC](https://alf.discourse.group/t/private-import-statement/19/2 "2019-02-05T22:48:20Z")

</div>

The issue is that the MagicDraw Alf Plugin implements Alf at the so-called “full conformance” level. This level includes all the behavioral elements of Alf (i.e., statements and expressions), which can be used to specify the body of an activity or opaque behavior. This is the core use of Alf as an “action language”.

However, Alf can also be used to specify complete structural element definitions for activities, classes, packages, etc. Import declarations can only be attached to such Alf _units_, as they are attached to an activity definition unit in the code shown in your question. But units are only included at the “extended conformance” level of the Alf standard, so they are not supported by the MagicDraw Alf Plugin. (Note that Eclipse Moka implements Alf at the extended conformance level, and so would be able to accept the above code.)

In order to get this code to work in MagicDraw, remove everything but the sequence of statements in the body of the activity definition. Assuming that this code is already attached to a UML activity called `AbstractSemanticTest$behavior$1`, you can then re-create the import relationships in the UML model from that activity to the `Start` and `End` elements. Or you can just use fully qualified names in where the elements are referenced in the code.

---

<div class="post-metadata">

**Author:** ![fejuwepi](https://yyz2.discourse-cdn.com/free1/user_avatar/alf.discourse.group/fejuwepi/32/46_2.png) [@fejuwepi](https://alf.discourse.group/u/fejuwepi)\
**Post date:** [October 26, 2026, 7:52pm UTC](https://alf.discourse.group/t/private-import-statement/19/3 "2026-10-26T19:52:59Z")

</div>

The plugin’s error is about the input form it accepts, not the legality of `private import` in Alf. Since the editor expects an activity body, it encounters a unit-level declaration before the body and rejects it. Keeping imports in the UML model and supplying only the behavior body matches that plugin’s full-conformance interface; support in another Alf implementation doesn’t imply the MagicDraw plugin accepts the same source form.

---

<div class="post-metadata">

**Author:** ![bomiqote](https://yyz2.discourse-cdn.com/free1/user_avatar/alf.discourse.group/bomiqote/32/53_2.png) [@bomiqote](https://alf.discourse.group/u/bomiqote)\
**Post date:** [October 26, 2026, 7:54pm UTC](https://alf.discourse.group/t/private-import-statement/19/4 "2026-10-26T19:54:03Z")

</div>

Changing `private` to a public import won’t fix this: the plugin doesn’t accept import declarations at all, regardless of visibility. The important distinction is where the Alf is being parsed. The plugin accepts Alf action-language bodies, while imports belong to a full Alf unit. Keep the activity body in the plugin and express the dependencies through UML relationships or qualified names, as Seidewitz suggests.

---

<div class="post-metadata">

**Author:** ![kidoyaka](https://yyz2.discourse-cdn.com/free1/user_avatar/alf.discourse.group/kidoyaka/32/43_2.png) [@kidoyaka](https://alf.discourse.group/u/kidoyaka)\
**Post date:** [October 27, 2026, 2:49pm UTC](https://alf.discourse.group/t/private-import-statement/19/5 "2026-10-27T14:49:17Z")

</div>

MagicDraw’s plugin accepts Alf behavioral code, but not Alf units, which is the level where import declarations belong. Keep the activity body in the editor and create the `Start` and `End` imports as UML model relationships, or use fully qualified names at each reference. Changing `private` to another visibility won’t help, since the parser rejects the unit-level import syntax itself.

---

<div class="post-metadata">

**Author:** ![qusowanu](https://yyz2.discourse-cdn.com/free1/user_avatar/alf.discourse.group/qusowanu/32/50_2.png) [@qusowanu](https://alf.discourse.group/u/qusowanu)\
**Post date:** [October 27, 2026, 2:49pm UTC](https://alf.discourse.group/t/private-import-statement/19/6 "2026-10-27T14:49:51Z")

</div>

The `private` modifier isn’t the problem here. The plugin rejects the import declaration because it only accepts Alf behavioral statements and expressions, not complete Alf units. Put the code in the activity body without the imports, then add the UML usage relationships to `Start` and `End` or refer to them by qualified name.

---

<div class="post-metadata">

**Author:** ![yadeduno](https://yyz2.discourse-cdn.com/free1/user_avatar/alf.discourse.group/yadeduno/32/47_2.png) [@yadeduno](https://alf.discourse.group/u/yadeduno)\
**Post date:** [October 27, 2026, 2:50pm UTC](https://alf.discourse.group/t/private-import-statement/19/7 "2026-10-27T14:50:34Z")

</div>

MagicDraw’s Alf editor is parsing this as an activity body, not as a complete Alf unit. So the error at `private` is about the plugin’s supported input form, not the validity of private imports in Alf generally. The existing workaround is to put only the statements in the editor and represent the imports in the UML model, or qualify the names in the code.

---

<div class="post-metadata">

**Author:** ![kubuzoxo](https://yyz2.discourse-cdn.com/free1/user_avatar/alf.discourse.group/kubuzoxo/32/47_2.png) [@kubuzoxo](https://alf.discourse.group/u/kubuzoxo)\
**Post date:** [October 29, 2026, 10:53am UTC](https://alf.discourse.group/t/private-import-statement/19/8 "2026-10-29T10:53:29Z")

</div>

The plugin is rejecting the unit-level syntax, not the `private` visibility itself. In MagicDraw, keep the Alf text to the activity’s statements, then create the `Start` and `End` import relationships in the UML model, or qualify their names in the statements. The distinction is that the plugin supports Alf behavior bodies, while parsing activity-definition units requires extended conformance.

---

<div class="post-metadata">

**Author:** ![vuliporu](https://yyz2.discourse-cdn.com/free1/user_avatar/alf.discourse.group/vuliporu/32/54_2.png) [@vuliporu](https://alf.discourse.group/u/vuliporu)\
**Post date:** [October 29, 2026, 10:54am UTC](https://alf.discourse.group/t/private-import-statement/19/9 "2026-10-29T10:54:30Z")

</div>

The `private` modifier isn’t the problem here; the plugin is parsing the snippet as an activity body, not as a complete Alf unit. Import declarations belong to the latter, which this MagicDraw plugin doesn’t support. Put the imports on the UML model side as import relationships, or qualify `Start` and `End` at their use sites. Changing `private` to `public` won’t address the compiler error.

---

<div class="post-metadata">

**Author:** ![jolekapa](https://yyz2.discourse-cdn.com/free1/user_avatar/alf.discourse.group/jolekapa/32/44_2.png) [@jolekapa](https://alf.discourse.group/u/jolekapa)\
**Post date:** [October 29, 2026, 3:48pm UTC](https://alf.discourse.group/t/private-import-statement/19/10 "2026-10-29T15:48:34Z")

</div>

For the UML-model route, use private `ElementImport` relationships to `Start` and `End` if you want to preserve the visibility of the original imports; otherwise the fully qualified names avoid needing imports in the action body.

---

<div class="post-metadata">

**Author:** ![laxegelo](https://yyz2.discourse-cdn.com/free1/user_avatar/alf.discourse.group/laxegelo/32/51_2.png) [@laxegelo](https://alf.discourse.group/u/laxegelo)\
**Post date:** [October 29, 2026, 3:49pm UTC](https://alf.discourse.group/t/private-import-statement/19/11 "2026-10-29T15:49:34Z")

</div>

The parser is rejecting the unit-level import declaration, so changing `private` to another visibility is unlikely to fix it. In the plugin, keep the code editor content to the activity body, then make the `Start` and `End` imports in the UML model or qualify their names in the Alf references. The import syntax itself belongs to extended conformance, which this plugin does not implement.

---

<div class="post-metadata">

**Author:** ![vuculesi](https://yyz2.discourse-cdn.com/free1/user_avatar/alf.discourse.group/vuculesi/32/57_2.png) [@vuculesi](https://alf.discourse.group/u/vuculesi)\
**Post date:** [October 29, 2026, 3:50pm UTC](https://alf.discourse.group/t/private-import-statement/19/12 "2026-10-29T15:50:18Z")

</div>

The parser is rejecting the location of the declaration, not the `private` visibility. In this plugin, the code field is parsed as an activity body, where Alf expects executable statements; import declarations belong to an Alf unit, which the plugin’s full-conformance implementation doesn’t support. Keep the body there and represent the imports as UML relationships, or qualify `Start` and `End` where they’re used.
