Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AGREE Same Name In AGREE Annex and Subcomponent Validator Check Not Catching All Cases #130

Open
aaurandt opened this issue Aug 18, 2023 · 0 comments

Comments

@aaurandt
Copy link
Contributor

aaurandt commented Aug 18, 2023

Validator check in question (lines 1939-1948 specifically):

@Check(CheckType.FAST)
public void checkNamedElement(NamedElement namedEl) {
// check for namespace collision in component types of component
// implementations
// and for collisions between subcomponent and feature names
EObject container = namedEl.eContainer();
if (container == null) {
return;
}
if (container instanceof RecordDef || container instanceof NodeDef) {
// don't care about arguments to recDefs and nodeDefs
// TODO: perhaps we can ignore all arguments?
return;
}
while (!(container instanceof AadlPackage || container instanceof ComponentImplementation
|| container instanceof ComponentType)) {
container = container.eContainer();
}
ComponentImplementation compImpl = null;
ComponentType type = null;
if (container instanceof ComponentImplementation) {
compImpl = (ComponentImplementation) container;
type = compImpl.getType();
} else if (container instanceof ComponentType) {
type = (ComponentType) container;
}
if (type != null && (namedEl.getName() != null)) {
for (Feature feat : type.getAllFeatures()) {
if (namedEl.getName().equals(feat.getName())) {
error(feat, "Element of the same name ('" + namedEl.getName() + "') in AGREE Annex in '"
+ (compImpl == null ? type.getName() : compImpl.getName()) + "'");
error(namedEl, "Feature of the same name ('" + namedEl.getName() + "') in component type");
}
}
if (compImpl != null) {
for (Subcomponent sub : compImpl.getAllSubcomponents()) {
if (namedEl.getName().equals(sub.getName())) {
error(sub, "Element of the same name ('" + namedEl.getName() + "') in AGREE Annex in '"
+ (compImpl == null ? type.getName() : compImpl.getName()) + "'");
error(namedEl, "Subcomponent of the same name ('" + namedEl.getName()
+ "') in component implementation");
}
}
}
}
// TODO: check name space collision with enumerated types
}

The error is flagged with this code:

package TestPackage
public

system sys
end sys;

system implementation sys.impl
	subcomponents
		test : device TestSensor;
	annex agree {**
		eq test : int = 100;
	**};
end sys.impl;

device TestSensor
end TestSensor;


end TestPackage;

But it is not triggered with the following code:

package TestPackage
public

system sys
	annex agree {**
		eq test : int = 100;
	**};
end sys;

system implementation sys.impl
	subcomponents
		test : device TestSensor;
end sys.impl;

device TestSensor
end TestSensor;


end TestPackage;
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

No branches or pull requests

1 participant