Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

=== Improvements

- https://github.com/eclipse-syson/syson/issues/1620[#1620] [services] Handle short names in qualified names when direct editing.

=== New features

- https://github.com/eclipse-syson/syson/issues/1581[#1581] [diagrams] Display inherited `PortUsages` as graphical border nodes in diagrams.
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*******************************************************************************
* Copyright (c) 2025 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Obeo - initial API and implementation
*******************************************************************************/
package org.eclipse.syson.application.data;

/**
* Identifiers for "GeneralView-DirectEdit" project.
*
* @author frouene
*/
public class GeneralViewDirectEditTestProjectData {

public static final String SCRIPT_PATH = "/scripts/database-content/GeneralView-DirectEdit.sql";

public static final String EDITING_CONTEXT_ID = "e13cbf2f-3817-4708-bc39-e94eb9ac0d96";

/**
* Ids of graphical elements.
*/
public static class GraphicalIds {

public static final String DIAGRAM_ID = "7464d7ea-ba4c-4171-b534-8b86ef6caf95";

}

/**
* Ids for the semantic elements.
*/
public static class SemanticIds {

public static final String PART_USAGE_ID = "8b4669e5-ac6b-41de-88c4-8d7b63fe534e";
public static final String PART_DEF_1_USAGE_ELEMENT_ID = "303aa440-a031-4419-a7b5-04fb8887a495";
public static final String PART_DEF_2_USAGE_ELEMENT_ID = "6866b297-0fd5-4a99-8ae3-48dd61aae575";
}

}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -355,25 +355,33 @@ private Collection<EObject> getAllRootsInResourceSet(EObject context) {

/**
* Check if the given element's name match the given String.
* If there is no match with the name, then the short name is checked.
*
* @param element
* the {@link Element} to check.
* the {@link Element} to check.
* @param name
* the name to match.
* @return <code>true</code> if the name match, <code>false</code> otherwise.
* the name to match.
* @return <code>true</code> if a match is found, <code>false</code> otherwise.
*/
private boolean nameMatches(Element element, String name) {
boolean matches = false;
if (element != null && name != null) {
String elementName = element.getName();
if (elementName != null) {
matches = elementName.strip().equals(name.strip());
if (!matches && name.startsWith("'") && name.endsWith("'")) {
// We give the option to quote names, but the quotes aren't part of the model.
elementName = "'" + elementName + "'";
matches = elementName.strip().equals(name.strip());
}
}
if (element == null || name == null) {
return false;
}
if (this.equalsConsideringOptionalQuotes(element.getName(), name)) {
return true;
}
return this.equalsConsideringOptionalQuotes(element.getShortName(), name);
}

private boolean equalsConsideringOptionalQuotes(String candidate, String query) {
if (candidate == null || query == null) {
return false;
}
boolean matches = candidate.strip().equals(query.strip());
if (!matches && query.startsWith("'") && query.endsWith("'")) {
// We give the option to quote names, but the quotes aren't part of the model.
candidate = "'" + candidate + "'";
matches = candidate.strip().equals(query.strip());
}
return matches;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,19 @@ public <T extends Element> T findByName(EObject object, String elementName) {
* @return the found element or <code>null</code>.
*/
public <T extends Element> T findByNameAndType(EObject object, String elementName, Class<T> elementType) {
// Use the semantic scoping rule based on Namespace resolution to find the most "valid" target
if (object instanceof Element element) {
Membership resolvedElement;
if (element instanceof Namespace namespace) {
resolvedElement = namespace.resolve(elementName);
} else {
resolvedElement = element.getOwningNamespace().resolve(elementName);
}
if (resolvedElement != null && elementType.isInstance(resolvedElement.getMemberElement())) {
return (T) resolvedElement.getMemberElement();
}
}
// No semantic valid target, fallback on any matching item but it might violate some scoping validation rule
return this.elementUtil.findByNameAndType(object, elementName, elementType);
}

Expand Down
19 changes: 19 additions & 0 deletions doc/content/modules/user-manual/pages/release-notes/2025.12.0.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,25 @@ requirement <'SN'> {

== Improvements

- In diagrams, when using direct edit on graphical elements, it's now possible to use _short names_ in the qualified names.
If two or more `Elements` share the same _short name_, {product} will search for the best candidate based on the scope of the element.
Furthermore, if an ambiguity exists between the _short name_ and the _declared name_ of two different `Elements`, the declared name will be preferred.

For example in:

```
package Drone {
package <LA> Drone_LogicalArchitecture {
part def CommonBattery;
}
package <PA> Drone_PhysicalArchitecture {
part def Battery :> LA::CommonBattery;
}
}
```

In the example above, when using the direct edit capability to subclass the _Battery_ `Part Definition`, it is now possible to type _LA::CommonBattery_ instead of _Drone_LogicalArchitecture::CommonBattery_.

== Technical details

* For technical details on this {product} release (including breaking changes and dependency updates), please refer to https://github.com/eclipse-syson/syson/blob/main/CHANGELOG.adoc[changelog].