Skip to content

Commit

Permalink
Consider attributes with the keyword name as identifiers for the meta…
Browse files Browse the repository at this point in the history
…model tree view.
  • Loading branch information
tsaglam committed Feb 7, 2024
1 parent 60c7ad4 commit 258d0e0
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import org.eclipse.emf.ecore.ENamedElement;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.resource.Resource;

import de.jplag.TokenTrace;
Expand Down Expand Up @@ -50,6 +51,7 @@ public MetamodelToken convertToMetadataEnrichedToken(MetamodelToken token) {
}

private final class TreeViewBuilder extends AbstractMetamodelVisitor {
private static final String IDENTIFIER_FEATURE = "name";
private static final String INDENTATION = " ";
private static final String NAME_SEPARATOR = " : ";

Expand All @@ -59,6 +61,12 @@ protected void visitEObject(EObject eObject) {
String line = prefix;
if (eObject instanceof ENamedElement element) {
line += element.getName() + NAME_SEPARATOR;
} else {
for (EStructuralFeature feature : eObject.eClass().getEAllStructuralFeatures()) {
if (feature.getName().toLowerCase().matches(IDENTIFIER_FEATURE) && eObject.eGet(feature) != null) {
line += eObject.eGet(feature).toString() + NAME_SEPARATOR;
}
}
}
line += eObject.eClass().getName();

Expand Down

0 comments on commit 258d0e0

Please sign in to comment.