use of org.osate.aadl2.AadlPackage in project AGREE by loonwerks.
the class AGREESimulationState method buildPackageToConstantsMap.
private static Map<String, Map<String, ConstStatement>> buildPackageToConstantsMap(final IProject[] projects) {
// Build a mapping between lower case package names and a map between constant names to constant statements
final Map<String, Map<String, ConstStatement>> packageToConstantsMap = new HashMap<>();
try {
final Set<IFile> aadlFiles = new HashSet<>();
getAadlFiles(projects, aadlFiles);
for (final IFile aadlFile : aadlFiles) {
// final Resource aadlRes = OsateResourceUtil.getResource(aadlFile);
final Resource aadlRes = getResource(URI.createPlatformResourceURI(aadlFile.getFullPath().toString(), false));
if (aadlRes != null && !aadlRes.getContents().isEmpty()) {
final EObject content = aadlRes.getContents().get(0);
if (content instanceof AadlPackage) {
// Find all AGREE Libraries
final AadlPackage pkg = (AadlPackage) content;
if (pkg.getPublicSection() != null && pkg.getName() != null) {
final Map<String, ConstStatement> constants = new HashMap<>();
packageToConstantsMap.put(pkg.getQualifiedName().toLowerCase(), constants);
for (final AnnexLibrary lib : pkg.getPublicSection().getOwnedAnnexLibraries()) {
// Look for AGREE annex libraries
if (lib instanceof DefaultAnnexLibrary && "agree".equalsIgnoreCase(lib.getName())) {
final AnnexLibrary parsedLib = ((DefaultAnnexLibrary) lib).getParsedAnnexLibrary();
if (parsedLib instanceof AgreeContractLibrary) {
final AgreeContractLibrary agreeContractLib = (AgreeContractLibrary) parsedLib;
if (agreeContractLib.getContract() instanceof AgreeContract) {
final AgreeContract agreeContract = (AgreeContract) agreeContractLib.getContract();
for (final SpecStatement spec : agreeContract.getSpecs()) {
if (spec instanceof ConstStatement) {
final ConstStatement constStatement = (ConstStatement) spec;
// Check that the statement is of a supported type
if (getType(constStatement) != null) {
constants.put(constStatement.getName().toLowerCase(), constStatement);
}
}
}
}
}
}
}
}
}
}
}
} catch (CoreException e) {
throw new AGREESimulatorException(null, e, "Unable to build constants map");
}
return packageToConstantsMap;
}
use of org.osate.aadl2.AadlPackage in project AGREE by loonwerks.
the class VerifyHandler method getComponentImplementations.
private List<ComponentImplementation> getComponentImplementations(ComponentType ct) {
List<ComponentImplementation> result = new ArrayList<>();
AadlPackage pkg = AadlUtil.getContainingPackage(ct);
for (ComponentImplementation ci : EcoreUtil2.getAllContentsOfType(pkg, ComponentImplementation.class)) {
if (ci.getType().equals(ct)) {
result.add(ci);
}
}
return result;
}
use of org.osate.aadl2.AadlPackage in project AGREE by loonwerks.
the class AgreeAnnexContentAssist method getNestedDotIDCandidates.
private List<String> getNestedDotIDCandidates(SelectionExpr id) {
NamedElement base = ((NamedElmExpr) id).getElm();
NamedElement namedEl = null;
if (base instanceof Arg) {
Type type = ((Arg) base).getType();
DoubleDotRef elID = ((DoubleDotRef) type);
namedEl = elID.getElm();
// =======
// DoubleDotRef elID = ((RecordType) type).getRecord();
// namedEl = elID.getElm();
// >>>>>>> origin/develop
} else if (base instanceof DataPort) {
namedEl = ((DataPort) base).getDataFeatureClassifier();
} else if (base instanceof EventDataPort) {
namedEl = ((EventDataPort) base).getDataFeatureClassifier();
} else if (base instanceof AadlPackage) {
return getNestedDotIDCandidates((AadlPackage) base);
} else {
return new ArrayList<>();
}
return getNestedDotIDCandidates(namedEl);
}
use of org.osate.aadl2.AadlPackage in project AGREE by loonwerks.
the class AgreeValidator method getEnumValueDefLocation.
private String getEnumValueDefLocation(NamedID id) {
EObject container = id.eContainer();
EnumStatement enumStatement = (EnumStatement) container;
String enumName = enumStatement.getName();
while (!(container instanceof AadlPackage) && !(container instanceof ComponentClassifier)) {
container = container.eContainer();
}
return ((NamedElement) container).getQualifiedName() + "::" + enumName;
}
use of org.osate.aadl2.AadlPackage in project AGREE by loonwerks.
the class AgreeValidator method checkNamedElement.
@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) {
// 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();
checkDupNames(namedEl, type, compImpl);
} 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");
}
}
}
// check name space collision with enumerated types
}
Aggregations