Skip to content

Commit

Permalink
Support assignment of relative class name
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineGautier committed Jan 7, 2025
1 parent 5dca8bf commit fd7cee1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
3 changes: 2 additions & 1 deletion server/src/parser/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -498,8 +498,9 @@ export class ShortClass extends Element {
super();
const specifier = (definition.class_definition ?? definition)
.class_specifier.short_class_specifier;
const specifierType = typeStore.get(specifier.value?.name, basePath);
this.name = specifier.identifier;
this.value = specifier?.value?.name;
this.value = specifierType?.modelicaPath || specifier.value?.name;
this.modelicaPath = `${basePath}.${this.name}`;
this.type = this.modelicaPath;
const registered = this.registerPath(this.modelicaPath, this.type);
Expand Down
3 changes: 1 addition & 2 deletions server/tests/integration/parser/template.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
Template,
getOptions,
} from "../../../src/parser/";
import fs from "fs";
import { getTemplates, getProject } from "../../../src/parser/template";

const TEMPLATE_PATH = "TestPackage.Template.TestTemplate";
Expand Down Expand Up @@ -220,7 +219,7 @@ describe("'Project' items are extracted", () => {
});
});

it("Replaceable short class definitions ***using full class names*** are supported", () => {
it("Replaceable short class definitions are supported", () => {
const templates = getTemplates();
const template = templates.find(
(t) => t.modelicaPath === TEMPLATE_PATH,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,8 @@ model TestTemplate "Test Template"
Dialog(group="Selectable Component"));

// Test short class definition
// Currently only full class names are supported for short class assignments
replaceable model ShortClass =
TestPackage.Component.FirstComponent
Component.FirstComponent
constrainedby TestPackage.Interface.PartialComponent
"Replaceable short class"
annotation(choices(
Expand Down

0 comments on commit fd7cee1

Please sign in to comment.