/** Space keyword is reserved. * * @param space the space to check. */ @Check public void checkSpaceUse(SarlSpace space) { error(MessageFormat.format( Messages.SARLValidator_0, this.grammarAccess.getSpaceKeyword()), space, null); }
/** Check if implemented interfaces of a Xtend Interface are redundant. * * @param xtendInterface the interface. */ @Check public void checkRedundantImplementedInterfaces(SarlInterface xtendInterface) { checkRedundantInterfaces( xtendInterface, XTEND_INTERFACE__EXTENDS, xtendInterface.getExtends(), Collections.<JvmTypeReference>emptyList()); }
@Check public void checkJavaKeywordConflict(XtendInterface member) { for (JvmTypeParameter p : member.getTypeParameters()) { checkNoJavaKeyword(p, TypesPackage.Literals.JVM_TYPE_PARAMETER__NAME); } }
/** Check if all the fields are initialized in a SARL agent. * * @param agent the agent. */ @Check public void checkFinalFieldInitialization(SarlAgent agent) { final JvmGenericType inferredType = this.associations.getInferredType(agent); if (inferredType != null) { checkFinalFieldInitialization(inferredType); } }
/** Check if the super default constructor is correctly invoked. * * @param agent the SARL element. */ @Check public void checkSuperConstructor(SarlAgent agent) { checkSuperConstructor( agent, XTEND_TYPE_DECLARATION__NAME, doGetConstructorParameterTypes(Agent.class, agent)); }
/** Check if the super default constructor is correctly invoked. * * @param event the SARL element. */ @Check public void checkSuperConstructor(SarlEvent event) { checkSuperConstructor( event, XTEND_TYPE_DECLARATION__NAME, doGetConstructorParameterTypes(Event.class, event)); }
@Check public void checkAssignment(XPostfixOperation postfixOperation) { if (expressionHelper.isGetAndAssign(postfixOperation)) { XExpression firstArgument = postfixOperation.getActualArguments().get(0); checkAssignment(firstArgument, false); } }
@Check public void checkRESTfulInterfaceNameUniqueness(ZenModel model) { Set<String> names = Sets.newHashSet(); for (ResourceAPI resourceAPI : model.getResourceAPIs()) { if (names.contains(resourceAPI.getName())) { error(String.format("Duplicate name of resource API '%s'", resourceAPI.getName()), resourceAPI, RapidmlPackage.Literals.RESOURCE_API__NAME); } names.add(resourceAPI.getName()); } }
@Check public void checkImportDeclaration(ImportDeclaration importDeclaration) { if (!Strings.isNullOrEmpty(importDeclaration.getImportedNamespace()) && !Strings.isNullOrEmpty(importDeclaration.getImportURI())) { if (!RapidmlModelUtils.getImportedNamespaces(importDeclaration) .contains(importDeclaration.getImportedNamespace())) { error(Messages.XtextDslJavaValidator_incorrectNamespace, importDeclaration, RapidmlPackage.Literals.IMPORT_DECLARATION__IMPORTED_NAMESPACE); } } }
@Check public void checkValidExtension(XtendField field) { if (field.isExtension()) { JvmField jvmField = associations.getJvmField(field); if (jvmField != null) { checkValidExtensionType(jvmField, field, XtendPackage.Literals.XTEND_FIELD__TYPE); } } }
@Check public void checkDeclaredExceptions(XtendFunction function){ JvmOperation jvmOperation = associations.getDirectlyInferredOperation(function); if (jvmOperation != null) { checkExceptions(function,jvmOperation.getExceptions(), XtendPackage.Literals.XTEND_EXECUTABLE__EXCEPTIONS); } }
@Check public void checkDeprecated(XImportDeclaration decl) { if (!isIgnored(DEPRECATED_MEMBER_REFERENCE)) { JvmType jvmType = decl.getImportedType(); checkDeprecated( jvmType, decl, XtypePackage.Literals.XIMPORT_DECLARATION__IMPORTED_TYPE); } }
@Check public void checkDeprecated(XAbstractFeatureCall expression) { if (!isIgnored(DEPRECATED_MEMBER_REFERENCE)) { JvmIdentifiableElement feature = expression.getFeature(); checkDeprecated( feature, expression, XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE); } }
@Check public void checkHiddenTokenIsNotAFragment(Grammar grammar) { if (grammar.isDefinesHiddenTokens()) { checkHiddenTokenIsNotAFragment(grammar, grammar.getHiddenTokens(), XtextPackage.Literals.GRAMMAR__HIDDEN_TOKENS); } }
@Check public void checkMessageParameterType(MessageParameter messageParameter) { if (messageParameter.getContainingMessage() instanceof TypedResponse && messageParameter.getHttpLocation() == HttpMessageParameterLocation.QUERY) { error(NLS.bind(Messages.XtextDslJavaValidator_messageParameterLocation, messageParameter.getHttpLocation().getLiteral().toLowerCase()), messageParameter, RapidmlPackage.Literals.MESSAGE_PARAMETER__HTTP_LOCATION); } }
@Check @Override protected void checkModifiers(XtendEnum oopEnum) { final EObject econtainer = oopEnum.eContainer(); if (econtainer instanceof SarlAgent) { this.nestedEnumerationInAgentModifierValidator.checkModifiers(oopEnum, MessageFormat.format(Messages.SARLValidator_9, oopEnum.getName())); } else { super.checkModifiers(oopEnum); } }
@Check protected void checkModifiers(XtendEnum xtendEnum) { EObject eContainer = xtendEnum.eContainer(); if (eContainer instanceof XtendFile) { enumModifierValidator.checkModifiers(xtendEnum, "enum " + xtendEnum.getName()); } else { nestedEnumModifierValidator.checkModifiers(xtendEnum, "enum " + xtendEnum.getName()); } }
@Check public void checkLocalUsageOfSwitchParameter(XSwitchExpression switchExpression) { JvmFormalParameter switchParam = switchExpression.getDeclaredParam(); if(!isIgnored(UNUSED_LOCAL_VARIABLE) && switchParam != null && !isLocallyUsed(switchParam, switchExpression)){ String message = "The value of the local variable " + switchParam.getName() + " is not used"; addIssue(message, switchParam, TypesPackage.Literals.JVM_FORMAL_PARAMETER__NAME, UNUSED_LOCAL_VARIABLE); } }
@Check public void checkTypes(XCatchClause catchClause) { LightweightTypeReference parameterType = getActualType(catchClause, catchClause.getDeclaredParam()); if (parameterType != null && !parameterType.isSubtypeOf(Throwable.class)) { error("No exception of type " + parameterType.getHumanReadableName() + " can be thrown; an exception type must be a subclass of Throwable", catchClause.getDeclaredParam(), TypesPackage.Literals.JVM_FORMAL_PARAMETER__PARAMETER_TYPE, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, INCOMPATIBLE_TYPES); } }
@Check public void checkRedundantCase(XSwitchExpression switchExpression) { XCasePart casePart = IterableExtensions.last(switchExpression.getCases()); if (casePart == null || !(casePart.isFallThrough() && casePart.getThen() == null)) { return; } if (switchExpression.getDefault() == null) { error("Redundant case.", casePart, null, IssueCodes.REDUNDANT_CASE); } else { warning("Redundant case.", casePart, null, IssueCodes.REDUNDANT_CASE); } }