Skip to content

Add support for Import Statements#107

Merged
h-man2 merged 4 commits intouseocl:masterfrom
matthias-mar:imports
Jun 25, 2025
Merged

Add support for Import Statements#107
h-man2 merged 4 commits intouseocl:masterfrom
matthias-mar:imports

Conversation

@matthias-mar
Copy link

No description provided.

@ichxorya
Copy link
Collaborator

Very cool feature! Hopefully this can be reviewed and merged into the code base.

…ed elements via model qualifier, integration tests for imported models
@matthias-mar
Copy link
Author

Changes:

  • Added dedicated file path during compilation, since imports rely on well-formed file paths to locate imported specifications
  • Introduced model qualifier concept:
    • Users can import elements using their model name as a qualifier (import modelName#elementName from "modelName.use"), to avoid name conflicts with duplicate element identifiers
    • Uniqueness of identifiers is only guaranteed between a model and its direct imports, transitively imported elements must be accessed using the qualified name syntax (model A imports class B from model C, class B has attribute x with imported data type D from model E -> in order to assign a value to attribute x, the constructor must be called like !set b.x := E#D(1,1)
  • Added Shell integration tests for models with imports

Copy link
Contributor

@h-man2 h-man2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments

Please add dev documentation about the internals


// check for constructor call
MClassifier cf = ctx.model().getClassifier(opname);
MClassifier cf = srcClassifier.model() != null ? srcClassifier.model().getClassifier(opname)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please clarify the reason behind the check.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clarification added.

fName = name;
}

public Token getfName() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove f from name

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw many f in the code base and still doesn't get the convention, do you know why there were f variables?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed f's from variable names.

* of external model files and their specified elements.
*/
public class ASTImportStatement extends AST {
private final List<String> fSymbols;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please f from Name (old style).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, removed f's from variable names.

* @author Stefan Schoon
* @author Mark Richters
* @author Lars Hamann
* @author Stefan Schoon
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add @author

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Authorship added to relevant classes.

Copy link
Contributor

h-man2 commented Jun 17, 2025

It was an old prefix for "field" i.e. an instance variable.

Copy link
Contributor

@h-man2 h-man2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🔥

@h-man2 h-man2 merged commit 9c04e5e into useocl:master Jun 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants