Java Code Examples for org.eclipse.emf.ecore.util.EcoreUtil.getRootContainer()

The following are Jave code examples for showing how to use getRootContainer() of the org.eclipse.emf.ecore.util.EcoreUtil class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: rest-modeling-framework   File: ResponsesValidator.java   View Source Code Vote up 6 votes
private List<Diagnostic> contentTypeMustBeDefined(Body body) {
    final List<Diagnostic> validationErrors = new ArrayList<>();
    final EObject rootContainer = EcoreUtil.getRootContainer(body);

    final boolean contentTypesDefined;
    if (rootContainer instanceof Api) {
        final Api api = (Api) rootContainer;
        contentTypesDefined = api.getMediaType().size() > 0 || body.getContentTypes().size() > 0;
    } else {
        contentTypesDefined = body.getContentTypes().size() > 0;
    }
    if (!contentTypesDefined) {
        validationErrors.add(error("Content type undefined", body));
    }
    return validationErrors;
}
 
Example 2
Project: n4js   File: OriginAwareScope.java   View Source Code Vote up 5 votes
/**
 * Enhanced query-Method marking the originating import as used.
 *
 * @see org.eclipse.xtext.scoping.IScope#getSingleElement(org.eclipse.xtext.naming.QualifiedName)
 */
@Override
public IEObjectDescription getSingleElement(QualifiedName name) {
	IEObjectDescription ret = delegatee.getSingleElement(name);
	if (ret == null)
		return null;

	ImportSpecifier origin = origins.get(ret);
	if (origin != null) {
		EObject script = EcoreUtil.getRootContainer(origin);
		if ((script instanceof Script) && ((Script) script).isFlaggedUsageMarkingFinished()) {
			// do nothing as linking phase is over
		} else {
			markAsUsed(origin);

			// TODO: Mark Twin-Ambiguous as well as used.
			if (ret instanceof AmbiguousImportDescription) {
				AmbiguousImportDescription ambiguousImportDescription = (AmbiguousImportDescription) ret;
				for (ImportSpecifier ispec : ambiguousImportDescription.getOriginatingImports()) {
					markAsUsed(ispec);
				}
			} else if (ret instanceof PlainAccessOfAliasedImportDescription) {
				PlainAccessOfAliasedImportDescription plainAccess = (PlainAccessOfAliasedImportDescription) ret;
				ImportSpecifier plainImport = origins.get(plainAccess.getDelegate());
				if (plainImport != null)
					markAsUsed(plainImport);
			}
		}
	}
	return ret;
}
 
Example 3
Project: OCCI-Studio   File: GenUtils.java   View Source Code Vote up 4 votes
public String getExtendedPackage(EObject eObject) {
	Extension extension = (Extension) EcoreUtil.getRootContainer(eObject);
	String extensionFile = OcciRegistry.getInstance().getFileURI(extension.getScheme());
	String[] args = extensionFile.split("\\/");
	return args[args.length-3];
}
 
Example 4
Project: OCCI-Studio   File: GenUtils.java   View Source Code Vote up 4 votes
public String getExtendedPackage(EObject eObject) {
	Extension extension = (Extension) EcoreUtil.getRootContainer(eObject);
	String extensionFile = OcciRegistry.getInstance().getFileURI(extension.getScheme());
	String[] args = extensionFile.split("\\/");
	return args[args.length-3];
}