public static ExpressionInOcl resolveMessage( MetaModelManager metaModelManager, URI uri, ExpressionInOcl specification, String expression) throws ParserException { try { Resource resource = createXtextResource(metaModelManager, uri, specification, expression); checkResourceErrors(NLS.bind(OCLMessages.ErrorsInResource, expression), resource); return getExpressionInOcl(resource); } catch (IOException e) { // throw new ParserException("Failed to load expression", e); OclExpression invalidValueBody = metaModelManager.createInvalidExpression(); specification.setBodyExpression(invalidValueBody); return specification; } }
public static ExpressionInOcl resolveSpecification( MetaModelManager metaModelManager, URI uri, NamedElement contextClassifier, String expression) throws ParserException { Resource resource = null; try { resource = createXtextResource(metaModelManager, uri, contextClassifier, expression); checkResourceErrors(NLS.bind(OCLMessages.ErrorsInResource, expression), resource); return getExpressionInOcl(resource); } catch (IOException e) { // throw new ParserException("Failed to load expression", e); ExpressionInOcl specification = PivotFactory.eINSTANCE.createExpressionInOcl(); OclExpression invalidValueBody = metaModelManager.createInvalidExpression(); specification.setBodyExpression(invalidValueBody); return specification; } finally { if (resource != null) { MetaModelManagerResourceAdapter adapter = MetaModelManagerResourceAdapter.findAdapter(resource); if (adapter != null) { adapter.dispose(); } } } }