@Override public List<LightweightTypeReference> getIllegallyDeclaredExceptions() { if (getDeclaration().getExceptions().isEmpty()) return Collections.emptyList(); List<IResolvedOperation> overriddenAndImplemented = getOverriddenAndImplementedMethods(); if (overriddenAndImplemented.isEmpty()) return Collections.emptyList(); List<LightweightTypeReference> exceptions = getResolvedExceptions(); List<LightweightTypeReference> result = Lists.newArrayListWithCapacity(exceptions.size()); for(LightweightTypeReference exception: exceptions) { if (!exception.isSubtypeOf(RuntimeException.class) && !exception.isSubtypeOf(Error.class)) { if (isIllegallyDeclaredException(exception, overriddenAndImplemented)) { result.add(exception); } } } return result; }
@Check public void checkDeclaredExceptions(XtendFunction function){ JvmOperation jvmOperation = associations.getDirectlyInferredOperation(function); if (jvmOperation != null) { checkExceptions(function,jvmOperation.getExceptions(), XtendPackage.Literals.XTEND_EXECUTABLE__EXCEPTIONS); } }
@Override public void apply(final JvmOperation it) { it.setVisibility(JvmVisibility.PUBLIC); EList<JvmTypeReference> _exceptions = it.getExceptions(); PatternGroupClassInferrer.this._eMFJvmTypesBuilder.<JvmTypeReference>operator_add(_exceptions, incQueryException); StringConcatenationClient _client = new StringConcatenationClient() { @Override protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { _builder.append("return "); _builder.append(classRef, ""); _builder.append(".instance();"); } }; PatternGroupClassInferrer.this._eMFJvmTypesBuilder.setBody(it, _client); } };
@Check public void checkMethodReferenceToThrowFixtureException(final MethodReference reference) { final JvmOperation operation = reference.getOperation(); if ((operation != null)) { boolean _isEmpty = operation.getExceptions().isEmpty(); if (_isEmpty) { this.warning( Messages.Validation_MethodReference_FixtureExceptionMissing, reference, AmlPackage.Literals.METHOD_REFERENCE__OPERATION, AmlValidator.METHOD_REFERENCE__EXCEPTION_MISSING); } final Function1<JvmTypeReference, String> _function = (JvmTypeReference it) -> { return it.getQualifiedName(); }; final Function1<String, Boolean> _function_1 = (String it) -> { boolean _equals = it.equals("org.testeditor.fixture.core.FixtureException"); return Boolean.valueOf((!_equals)); }; boolean _exists = IterableExtensions.<String>exists(ListExtensions.<JvmTypeReference, String>map(operation.getExceptions(), _function), _function_1); if (_exists) { this.error( Messages.Validation_MethodReference_UnexpectedCheckedException, reference, AmlPackage.Literals.METHOD_REFERENCE__OPERATION, AmlValidator.METHOD_REFERENCE__UNEXPECTED_CHECKED_EXCEPTION); } } }
protected boolean _throwsFixtureException(final TestStep testStep) { final TemplateContainer container = this.getTemplateContainer(testStep); boolean _matched = false; if (container instanceof InteractionType) { _matched=true; MethodReference _defaultMethod = ((InteractionType)container).getDefaultMethod(); JvmOperation _operation = null; if (_defaultMethod!=null) { _operation=_defaultMethod.getOperation(); } EList<JvmTypeReference> _exceptions = null; if (_operation!=null) { _exceptions=_operation.getExceptions(); } final Function1<JvmTypeReference, Boolean> _function = (JvmTypeReference it) -> { return Boolean.valueOf(FixtureException.class.getName().equals(it.getQualifiedName())); }; return IterableExtensions.<JvmTypeReference>exists(_exceptions, _function); } if (!_matched) { if (container instanceof Macro) { _matched=true; return this.throwsFixtureException(((Macro)container).getContexts()); } } return false; }
protected ITypeComputationState getClosureBodyTypeComputationState(ITypeAssigner typeAssigner) { ITypeComputationState result = assignParameters(typeAssigner); LightweightTypeReference expectedType = getExpectation().getExpectedType(); if (expectedType == null) { throw new IllegalStateException(); } JvmType knownType = expectedType.getType(); if (knownType != null && knownType instanceof JvmGenericType) { result.assignType(IFeatureNames.SELF, knownType, expectedType); } List<JvmTypeReference> exceptions = operation.getExceptions(); if (exceptions.isEmpty()) { result.withinScope(getClosure()); return result; } List<LightweightTypeReference> expectedExceptions = Lists.newArrayListWithCapacity(exceptions.size()); for (JvmTypeReference exception : exceptions) { expectedExceptions.add(typeAssigner.toLightweightTypeReference(exception)); } result.withinScope(getClosure()); return result.withExpectedExceptions(expectedExceptions); }
InternalEList<JvmTypeReference> exceptions = (InternalEList<JvmTypeReference>)result.getExceptions(); for (Type exceptionType : exceptionTypes) { exceptions.addUnique(createTypeReference(exceptionType));
@Override public void apply(final JvmOperation it) { CharSequence _javadocGroupClassInstanceMethod = PatternGroupClassInferrer.this._javadocInferrer.javadocGroupClassInstanceMethod(model); String _string = _javadocGroupClassInstanceMethod.toString(); PatternGroupClassInferrer.this._eMFJvmTypesBuilder.setDocumentation(it, _string); it.setVisibility(JvmVisibility.PUBLIC); it.setStatic(true); EList<JvmTypeReference> _exceptions = it.getExceptions(); PatternGroupClassInferrer.this._eMFJvmTypesBuilder.<JvmTypeReference>operator_add(_exceptions, incQueryException); StringConcatenationClient _client = new StringConcatenationClient() { @Override protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { _builder.append("if (INSTANCE == null) {"); _builder.newLine(); _builder.append("\t"); _builder.append("INSTANCE = new "); _builder.append(groupClass, "\t"); _builder.append("();"); _builder.newLineIfNotEmpty(); _builder.append("}"); _builder.newLine(); _builder.append("return INSTANCE;"); _builder.newLine(); } }; PatternGroupClassInferrer.this._eMFJvmTypesBuilder.setBody(it, _client); } };
@Override public void apply(final JvmOperation it) { it.setVisibility(JvmVisibility.PUBLIC); it.setStatic(true); CharSequence _javadocQuerySpecificationMethod = PatternMatcherClassInferrer.this._javadocInferrer.javadocQuerySpecificationMethod(pattern); String _string = _javadocQuerySpecificationMethod.toString(); PatternMatcherClassInferrer.this._eMFJvmTypesBuilder.setDocumentation(it, _string); EList<JvmTypeReference> _exceptions = it.getExceptions(); JvmTypeReference _typeRef = PatternMatcherClassInferrer.this.builder.typeRef(IncQueryException.class); PatternMatcherClassInferrer.this._eMFJvmTypesBuilder.<JvmTypeReference>operator_add(_exceptions, _typeRef); StringConcatenationClient _client = new StringConcatenationClient() { @Override protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { _builder.append("return "); JvmTypeReference _typeRef = PatternMatcherClassInferrer.this.builder.typeRef(specificationClass); _builder.append(_typeRef, ""); _builder.append(".instance();"); _builder.newLineIfNotEmpty(); } }; PatternMatcherClassInferrer.this._eMFJvmTypesBuilder.setBody(it, _client); } };
it.setVisibility(JvmVisibility.PUBLIC); it.setStatic(true); EList<JvmTypeReference> _exceptions = it.getExceptions(); JvmTypeReference _typeRef = PatternQuerySpecificationClassInferrer.this.builder.typeRef(IncQueryException.class); PatternQuerySpecificationClassInferrer.this._eMFJvmTypesBuilder.<JvmTypeReference>operator_add(_exceptions, _typeRef);
@Override public void apply(final JvmOperation it) { it.setVisibility(JvmVisibility.PUBLIC); EList<JvmTypeReference> _exceptions = it.getExceptions(); PatternGroupClassInferrer.this._eMFJvmTypesBuilder.<JvmTypeReference>operator_add(_exceptions, incQueryException); EList<JvmFormalParameter> _parameters = it.getParameters(); JvmTypeReference _typeRef = PatternGroupClassInferrer.this.builder.typeRef(IncQueryEngine.class); JvmFormalParameter _parameter = PatternGroupClassInferrer.this._eMFJvmTypesBuilder.toParameter(model, "engine", _typeRef); PatternGroupClassInferrer.this._eMFJvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); StringConcatenationClient _client = new StringConcatenationClient() { @Override protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { _builder.append("return "); _builder.append(classRef, ""); _builder.append(".on(engine);"); } }; PatternGroupClassInferrer.this._eMFJvmTypesBuilder.setBody(it, _client); } };
return Boolean.valueOf(it.equals(FixtureException.class.getName())); }; boolean _exists = IterableExtensions.<String>exists(ListExtensions.<JvmTypeReference, String>map(method.getOperation().getExceptions(), _function), _function_1); boolean _not = (!_exists); if (_not) {
JvmFormalParameter _parameter = PatternMatcherClassInferrer.this._eMFJvmTypesBuilder.toParameter(pattern, "engine", _typeRef); PatternMatcherClassInferrer.this._eMFJvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); EList<JvmTypeReference> _exceptions = it.getExceptions(); JvmTypeReference _typeRef_1 = PatternMatcherClassInferrer.this.builder.typeRef(IncQueryException.class); PatternMatcherClassInferrer.this._eMFJvmTypesBuilder.<JvmTypeReference>operator_add(_exceptions, _typeRef_1);
b.increaseIndentation(); LightweightTypeReference returnType = getClosureOperationReturnType(type, operation); compile(closure.getExpression(), b, returnType, newHashSet(operation.getExceptions())); closeBlock(b); } finally {
JvmFormalParameter _parameter = PatternQuerySpecificationClassInferrer.this._eMFJvmTypesBuilder.toParameter(pattern, "engine", _typeRef); PatternQuerySpecificationClassInferrer.this._eMFJvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); EList<JvmTypeReference> _exceptions = it.getExceptions(); JvmTypeReference _typeRef_1 = PatternQuerySpecificationClassInferrer.this.builder.typeRef(IncQueryException.class); PatternQuerySpecificationClassInferrer.this._eMFJvmTypesBuilder.<JvmTypeReference>operator_add(_exceptions, _typeRef_1);
initializer.setReturnType(typeReferences.getTypeForName(Void.TYPE, source)); for (JvmTypeReference exception : source.getExceptions()) { initializer.getExceptions().add(jvmTypesBuilder.cloneWithProxies(exception));
protected SignatureHashBuilder appendSignature(JvmOperation operation) { appendVisibility(operation.getVisibility()).append(" "); if (operation.isAbstract()) append("abstract "); if (operation.isStatic()) append("static "); if (operation.isFinal()) append("final "); appendType(operation.getReturnType()).appendTypeParameters(operation).append(" ") .append(operation.getSimpleName()).append("("); for (JvmFormalParameter p : operation.getParameters()) { appendType(p.getParameterType()); append(" "); } append(") "); for (JvmTypeReference ex : operation.getExceptions()) { appendType(ex).append(" "); } return this; }
copyAndFixTypeParameters(source.getTypeParameters(), operation); for (JvmTypeReference exception : source.getExceptions()) { operation.getExceptions().add(jvmTypesBuilder.cloneWithProxies(exception));
private JvmOperation createSetupMethod(final SetupAndCleanupProvider container, final String reportPrefix) { final TestSetup setup = IterableExtensions.<TestSetup>head(container.getSetup()); final Procedure1<JvmOperation> _function = (JvmOperation it) -> { EList<JvmTypeReference> _exceptions = it.getExceptions(); JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(Exception.class); this._jvmTypesBuilder.<JvmTypeReference>operator_add(_exceptions, _typeRef);
private JvmOperation createCleanupMethod(final SetupAndCleanupProvider container, final String reportPrefix) { final TestCleanup cleanup = IterableExtensions.<TestCleanup>head(container.getCleanup()); final Procedure1<JvmOperation> _function = (JvmOperation it) -> { EList<JvmTypeReference> _exceptions = it.getExceptions(); JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(Exception.class); this._jvmTypesBuilder.<JvmTypeReference>operator_add(_exceptions, _typeRef);