org.eclipse.xtext.validation.ValidationMessageAcceptor Java Examples
The following examples show how to use
org.eclipse.xtext.validation.ValidationMessageAcceptor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UniquenessJavaValidationHelper.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
/** * Find duplicates in the given objects and mark them (on the given feature) as * errors. * * @param possiblyDuplicateObjects * an Iterable into which to look for duplicates * @param featureProvider * provides the feature of the duplicate object on which to anchor the marker * @param issueCode * the issue code */ public void errorOnDuplicates(final Iterable<T> possiblyDuplicateObjects, final Function<T, EStructuralFeature> featureProvider, final String issueCode) { if (acceptor == null) { throw new IllegalArgumentException(ACCEPTOR_CAN_T_BE_NULL); } if (possiblyDuplicateObjects == null) { return; // NO_ERROR } Set<T> duplicateEObjects = findDuplicates(possiblyDuplicateObjects); for (final T duplicate : duplicateEObjects) { final EStructuralFeature feature = featureProvider.apply(duplicate); acceptor.acceptError(getMessage(duplicate), duplicate, feature, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, issueCode); } }
Example #2
Source File: XbaseWithAnnotationsValidator.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Check public void checkAllAttributesConfigured(XAnnotation annotation) { JvmType annotationType = annotation.getAnnotationType(); if (annotationType == null || annotationType.eIsProxy() || !(annotationType instanceof JvmAnnotationType)) return; Iterable<JvmOperation> attributes = ((JvmAnnotationType) annotationType).getDeclaredOperations(); for (JvmOperation jvmOperation : attributes) { XExpression value = annotationUtil.findValue(annotation, jvmOperation); if(value == null) { if (jvmOperation.getDefaultValue() == null) { error("The annotation must define the attribute '"+jvmOperation.getSimpleName()+"'.", annotation, null, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, ANNOTATIONS_MISSING_ATTRIBUTE_DEFINITION); } } else annotationValueValidator.validateAnnotationValue(value, this); } }
Example #3
Source File: SARLUIValidator.java From sarl with Apache License 2.0 | 6 votes |
@Check @Override public void checkFileNamingConventions(XtendFile sarlFile) { // // The wrong package is a warning in SARL (an error in Xtend). // final String expectedPackage = Strings.nullToEmpty(getExpectedPackageName(sarlFile)); final String declaredPackage = Strings.nullToEmpty(sarlFile.getPackage()); if (!Objects.equal(expectedPackage, declaredPackage)) { if (expectedPackage.isEmpty()) { warning(Messages.SARLUIValidator_0, sarlFile, XtendPackage.Literals.XTEND_FILE__PACKAGE, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, IssueCodes.WRONG_PACKAGE, expectedPackage); } else { warning(MessageFormat.format(Messages.SARLUIValidator_1, expectedPackage), sarlFile, XtendPackage.Literals.XTEND_FILE__PACKAGE, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, IssueCodes.WRONG_PACKAGE, expectedPackage); } } }
Example #4
Source File: QuickfixCrossrefTestLanguageValidator.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Check(CheckType.FAST) public void checkBadNames(Main main) { Resource res = main.eResource(); for (Element root : main.getElements()) { List<String> fragments = Lists.newArrayList(); for (Element ele : EcoreUtil2.getAllContentsOfType(root, Element.class)) { if ("badname".equals(ele.getName())) { fragments.add(res.getURIFragment(ele)); } } if (!fragments.isEmpty()) { warning(BAD_NAME_IN_SUBELEMENTS, root, QuickfixCrossrefPackage.Literals.ELEMENT__NAME, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, BAD_NAME_IN_SUBELEMENTS, Joiner.on(";").join(fragments)); } } }
Example #5
Source File: CheckCfgJavaValidator.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
/** * Checks that a Configured Check has unique Configured Parameters. * * @param configuredCheck * the configured check */ @Check public void checkConfiguredParameterUnique(final ConfiguredCheck configuredCheck) { if (configuredCheck.getParameterConfigurations().size() < 2) { return; } Predicate<ConfiguredParameter> predicate = new Predicate<ConfiguredParameter>() { @Override public boolean apply(final ConfiguredParameter configuredParameter) { return configuredParameter.getParameter() != null && !configuredParameter.getParameter().eIsProxy(); } }; Function<ConfiguredParameter, String> function = new Function<ConfiguredParameter, String>() { @Override public String apply(final ConfiguredParameter from) { return from.getParameter().getName(); } }; for (final ConfiguredParameter p : getDuplicates(predicate, function, configuredCheck.getParameterConfigurations())) { error(Messages.CheckCfgJavaValidator_DUPLICATE_PARAMETER_CONFIGURATION, p, CheckcfgPackage.Literals.CONFIGURED_PARAMETER__PARAMETER, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, IssueCodes.DUPLICATE_PARAMETER_CONFIGURATION); } }
Example #6
Source File: SARLValidator.java From sarl with Apache License 2.0 | 6 votes |
/** Check if the given field has a valid name. * * @param field the field to test. * @see SARLFeatureNameValidator */ @Check(CheckType.FAST) public void checkFieldName(SarlField field) { final JvmField inferredField = this.associations.getJvmField(field); final QualifiedName name = Utils.getQualifiedName(inferredField); if (isReallyDisallowedName(name)) { final String validName = Utils.fixHiddenMember(field.getName()); error(MessageFormat.format( Messages.SARLValidator_41, field.getName(), Messages.SARLValidator_100), field, XTEND_FIELD__NAME, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, VARIABLE_NAME_DISALLOWED, validName); } else if (this.grammarAccess.getOccurrenceKeyword().equals(field.getName())) { error(MessageFormat.format( Messages.SARLValidator_101, this.grammarAccess.getOccurrenceKeyword(), Messages.SARLValidator_100), field, XTEND_FIELD__NAME, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, VARIABLE_NAME_DISALLOWED); } }
Example #7
Source File: SARLValidator.java From sarl with Apache License 2.0 | 6 votes |
/** Check if the parameter of the bahavior unit is an event. * * @param behaviorUnit the behavior unit to test. */ @Check(CheckType.FAST) public void checkBehaviorUnitEventType(SarlBehaviorUnit behaviorUnit) { final JvmTypeReference event = behaviorUnit.getName(); final LightweightTypeReference ref = toLightweightTypeReference(event); if (ref == null || !this.inheritanceHelper.isSarlEvent(ref)) { error(MessageFormat.format( Messages.SARLValidator_75, event.getQualifiedName(), Messages.SARLValidator_62, this.grammarAccess.getOnKeyword()), event, null, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, TYPE_BOUNDS_MISMATCH); } }
Example #8
Source File: ImportsVariableResolver.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Override public void validateParameters(Variable variable, ValidationMessageAcceptor validationMessageAcceptor) { if (variable.getParameters().isEmpty()) { validationMessageAcceptor.acceptError(getType() + "-variables have mandatory parameters.", variable, TemplatesPackage.Literals.VARIABLE__TYPE, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, null); } else { EList<String> parameters = variable.getParameters(); for (int i = 0; i < parameters.size(); i++) { String param = parameters.get(i); try { IValueConverter<String> converter = ((XbaseValueConverterService) valueConverterService) .getQualifiedNameWithWildCardValueConverter(); converter.toString(param); } catch (ValueConverterException e) { validationMessageAcceptor.acceptError(getType() + " - parameter " + param + " is not a valid qualifier.", variable, TemplatesPackage.Literals.VARIABLE__PARAMETERS, i, null); } } } }
Example #9
Source File: SARLValidator.java From sarl with Apache License 2.0 | 6 votes |
/** Check for usage of break inside loops. * * @param expression the expression to analyze. */ @Check public void checkBreakKeywordUse(SarlBreakExpression expression) { final EObject container = Utils.getFirstContainerForPredicate(expression, it -> !(it instanceof XExpression) || it instanceof XAbstractWhileExpression || it instanceof XBasicForLoopExpression || it instanceof XForLoopExpression); if (container instanceof XExpression) { if (!isIgnored(DISCOURAGED_LOOP_BREAKING_KEYWORD_USE) && container instanceof XBasicForLoopExpression) { addIssue( MessageFormat.format(Messages.SARLValidator_17, this.grammarAccess.getBreakKeyword()), expression, null, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, DISCOURAGED_LOOP_BREAKING_KEYWORD_USE); } } else { error(MessageFormat.format(Messages.SARLValidator_18, this.grammarAccess.getBreakKeyword()), expression, null, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, INVALID_USE_OF_LOOP_BREAKING_KEYWORD); } }
Example #10
Source File: XtendUIValidator.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Check public void checkFileNamingConventions(XtendFile xtendFile) { String expectedPackage = getExpectedPackageName(xtendFile); String declaredPackage = xtendFile.getPackage(); if(expectedPackage != null && !((isEmpty(expectedPackage) && declaredPackage == null) || expectedPackage.equals(declaredPackage))) { error("The declared package '" + notNull(declaredPackage) + "' does not match the expected package '" + notNull(expectedPackage) + "'", XtendPackage.Literals.XTEND_FILE__PACKAGE, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, IssueCodes.WRONG_PACKAGE, expectedPackage); } if (xtendFile.getXtendTypes().size() == 1) { XtendTypeDeclaration xtendType = xtendFile.getXtendTypes().get(0); String currentFileName = xtendFile.eResource().getURI().trimFileExtension().lastSegment(); String expectedFileName = xtendType.getName(); if (expectedFileName != null && !equal(currentFileName, expectedFileName)) { addIssue("The type name '" + expectedFileName + "' doesn't match the file name '" + currentFileName + "'", xtendType, XtendPackage.Literals.XTEND_TYPE_DECLARATION__NAME, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, IssueCodes.WRONG_FILE, expectedFileName); } } }
Example #11
Source File: CheckCfgJavaValidator.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
/** * Checks that within a Check Configuration all Catalog Configurations are unique, meaning that a referenced * Check Catalog can only be configured in one place. * * @param configuration * the configuration */ @Check public void checkConfiguredCatalogUnique(final CheckConfiguration configuration) { if (configuration.getLegacyCatalogConfigurations().size() < 2) { return; } Predicate<ConfiguredCatalog> predicate = new Predicate<ConfiguredCatalog>() { @Override public boolean apply(final ConfiguredCatalog configuredCatalog) { final CheckCatalog catalog = configuredCatalog.getCatalog(); return catalog != null && !catalog.eIsProxy(); } }; Function<ConfiguredCatalog, String> function = new Function<ConfiguredCatalog, String>() { @Override public String apply(final ConfiguredCatalog from) { return from.getCatalog().getName(); } }; for (final ConfiguredCatalog c : getDuplicates(predicate, function, configuration.getLegacyCatalogConfigurations())) { error(Messages.CheckCfgJavaValidator_DUPLICATE_CATALOG_CONFIGURATION, c, CheckcfgPackage.Literals.CONFIGURED_CATALOG__CATALOG, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, IssueCodes.DUPLICATE_CATALOG_CONFIGURATION); } }
Example #12
Source File: SARLValidator.java From sarl with Apache License 2.0 | 6 votes |
/** Check for usage of continue inside loops. * * @param expression the expression to analyze. * @since 0.7 */ @Check public void checkContinueKeywordUse(SarlContinueExpression expression) { final EObject container = Utils.getFirstContainerForPredicate(expression, it -> !(it instanceof XExpression) || it instanceof XAbstractWhileExpression || it instanceof XBasicForLoopExpression || it instanceof XForLoopExpression); if (container instanceof XExpression) { if (!isIgnored(DISCOURAGED_LOOP_BREAKING_KEYWORD_USE) && container instanceof XBasicForLoopExpression) { addIssue( MessageFormat.format(Messages.SARLValidator_17, this.grammarAccess.getContinueKeyword()), expression, null, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, DISCOURAGED_LOOP_BREAKING_KEYWORD_USE); } } else { error(MessageFormat.format(Messages.SARLValidator_18, this.grammarAccess.getContinueKeyword()), expression, null, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, INVALID_USE_OF_LOOP_BREAKING_KEYWORD); } }
Example #13
Source File: CheckCfgJavaValidator.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
/** * Checks that Check Configurations are unique. A Configured Catalog may only contain one configuration for each referenced Check. * * @param configuration * the configuration */ @Check public void checkConfiguredCheckUnique(final ConfiguredCatalog configuration) { if (configuration.getCheckConfigurations().size() < 2) { return; } Predicate<ConfiguredCheck> predicate = new Predicate<ConfiguredCheck>() { @Override public boolean apply(final ConfiguredCheck configuredCheck) { return configuredCheck.getCheck() != null && !configuredCheck.getCheck().eIsProxy(); } }; Function<ConfiguredCheck, String> function = new Function<ConfiguredCheck, String>() { @Override public String apply(final ConfiguredCheck from) { return from.getCheck().getName(); } }; for (final ConfiguredCheck c : getDuplicates(predicate, function, configuration.getCheckConfigurations())) { error(Messages.CheckCfgJavaValidator_DUPLICATE_CHECK_CONFIGURATION, c, CheckcfgPackage.Literals.CONFIGURED_CHECK__CHECK, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, IssueCodes.DUPLICATE_CHECK_CONFIGURATION); } }
Example #14
Source File: XsemanticsValidatorErrorGenerator.java From xsemantics with Eclipse Public License 1.0 | 6 votes |
protected void generateErrors( ValidationMessageAcceptor validationMessageAcceptor, RuleFailedException ruleFailedException, EObject originalSource) { if (ruleFailedException == null) { return; } Iterable<RuleFailedException> allFailures = filter .filterRuleFailedExceptions(ruleFailedException); // the last information about a model element with error ErrorInformation lastErrorInformationWithSource = null; // we will use it to print error messages which do not have // an associated model element for (RuleFailedException ruleFailedException2 : allFailures) { lastErrorInformationWithSource = generateErrors( validationMessageAcceptor, ruleFailedException2.getMessage(), ruleFailedException2.getIssue(), filter.filterErrorInformation(ruleFailedException2), lastErrorInformationWithSource, originalSource); } }
Example #15
Source File: UniquenessJavaValidationHelper.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
/** * Find duplicates in the given objects and mark them (on the given feature) as * warnings. * * @param possiblyDuplicateObjects * an Iterable into which to look for duplicates * @param featureProvider * provides the feature of the duplicate object on which to anchor the marker * @param issueCode * the issue code */ public void warnOnDuplicates(final Iterable<T> possiblyDuplicateObjects, final Function<T, EStructuralFeature> featureProvider, final String issueCode) { if (acceptor == null) { throw new IllegalArgumentException(ACCEPTOR_CAN_T_BE_NULL); } if (possiblyDuplicateObjects == null) { return; // NO_ERROR } Set<T> duplicateEObjects = findDuplicates(possiblyDuplicateObjects); for (final T duplicate : duplicateEObjects) { final EStructuralFeature feature = featureProvider.apply(duplicate); acceptor.acceptWarning(getMessage(duplicate), duplicate, feature, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, issueCode); } }
Example #16
Source File: CheckJavaValidator.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
/** * Checks that a Check defines parameters with unique names. * * @param check * the check to be checked */ @Check public void checkFormalParameterNamesUnique(final com.avaloq.tools.ddk.check.check.Check check) { if (check.getFormalParameters().size() < 2) { return; } Function<FormalParameter, String> function = new Function<FormalParameter, String>() { @Override public String apply(final FormalParameter from) { return from.getName(); } }; for (final FormalParameter p : getDuplicates(Predicates.<FormalParameter> alwaysTrue(), function, check.getFormalParameters())) { error(Messages.CheckJavaValidator_DUPLICATE_PARAMETER_DEFINITION, p, XbasePackage.Literals.XVARIABLE_DECLARATION__NAME, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, IssueCodes.DUPLICATE_PARAMETER_DEFINITION); } }
Example #17
Source File: AbstractIssue.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
/** {@inheritDoc} */ public void accept(final ValidationMessageAcceptor acceptor, final EObject object, final EStructuralFeature feature, final String message, final SeverityKind severityKind, final int index, final String issueCode, final String... issueData) { switch (severityKind) { case ERROR: acceptor.acceptError(message, object, feature, index, issueCode, issueData); return; case WARNING: acceptor.acceptWarning(message, object, feature, index, issueCode, issueData); return; case INFO: acceptor.acceptInfo(message, object, feature, index, issueCode, issueData); return; case IGNORE: default: return; } }
Example #18
Source File: STextNamesAreUniqueValidationHelper.java From statecharts with Eclipse Public License 1.0 | 6 votes |
protected void checkDescriptionForDuplicatedName(IEObjectDescription description, ValidationMessageAcceptor acceptor) { if (!shouldValidateEClass(description.getEClass())) { return; } QualifiedName qName = description.getName(); // check for exactly equal names IEObjectDescription existing = nameMap.put(qName, description); // check for names that only differ in case, like 'x' and 'X' IEObjectDescription existingLowerCase = caseInsensitiveMap.put(qName.toLowerCase(), description); // check for names where the qualifier is different but the name is the // same, like 'region1.StateA' and 'region2.StateA'. IEObjectDescription existingLastElement = lastElementMap.put(qName.getLastSegment(), description); if (existing != null) { validateEqualName(description, existing, acceptor); } else if (existingLowerCase != null) { validateCapitonym(description, existingLowerCase, acceptor); } if (existingLastElement != null) { duplicateLastElement(description, existingLastElement, acceptor); } }
Example #19
Source File: PredicateUsesUnorderedGroupInspector.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
public void createErrorMessages(UnorderedGroup object) { acceptError( "Cannot use unordered groups in syntactic predicates.", object, null, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, null); for(AbstractElement element: elementStack) { acceptError( "A predicate may not use an unordered group.", element, XtextPackage.Literals.ABSTRACT_ELEMENT__PREDICATED, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, null); } for(RuleCall ruleCall: callHierarchy) { if (!ruleCall.isPredicated()) acceptError( "The rule call is part of a call hierarchy that leads to a predicated unordered group.", ruleCall, XtextPackage.Literals.RULE_CALL__RULE, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, null); } }
Example #20
Source File: XtextValidator.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Check public void checkRuleCallInUnorderedGroup(final RuleCall call) { if (call.getRule() == null || call.getRule().eIsProxy() || !(call.getRule() instanceof ParserRule)) return; if (GrammarUtil.isDatatypeRule((ParserRule) call.getRule())) return; if (GrammarUtil.isAssigned(call)) return; if (EcoreUtil2.getContainerOfType(call, UnorderedGroup.class) != null) error( "Unassigned rule calls may not be used in unordered groups.", call, null, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, null); }
Example #21
Source File: XtextValidator.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Check public void checkTerminalFragmentCalledFromTerminalRule(final RuleCall call) { if (call.getRule() != null && !call.getRule().eIsProxy()) { if (call.getRule() instanceof TerminalRule && ((TerminalRule) call.getRule()).isFragment()) { AbstractRule container = GrammarUtil.containingRule(call); if (!(container instanceof TerminalRule)) { getMessageAcceptor().acceptError( "Only terminal rules may use terminal fragments.", call, XtextPackage.Literals.RULE_CALL__RULE, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, null); } } } }
Example #22
Source File: XtextValidator.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
public boolean checkCrossReferenceTerminal(RuleCall call) { if (call.getRule() != null && call.getRule().getType() != null) { EClassifier type = call.getRule().getType().getClassifier(); EDataType dataType = GrammarUtil.findEString(GrammarUtil.getGrammar(call)); if (dataType == null) dataType = EcorePackage.Literals.ESTRING; if (type != null && dataType != type) { error( "The rule '" + call.getRule().getName() + "' is not valid for a cross reference since it does not return "+ "an EString. You'll have to wrap it in a data type rule.", call, null, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, null); return true; } } return false; }
Example #23
Source File: SARLValidator.java From sarl with Apache License 2.0 | 6 votes |
/** Check if the given action has a valid name. * * @param action the action to test. * @see SARLFeatureNameValidator */ @Check(CheckType.FAST) public void checkActionName(SarlAction action) { final JvmOperation inferredOperation = this.associations.getDirectlyInferredOperation(action); final QualifiedName name = QualifiedName.create(inferredOperation.getQualifiedName('.').split("\\.")); //$NON-NLS-1$ if (isReallyDisallowedName(name)) { final String validName = Utils.fixHiddenMember(action.getName()); error(MessageFormat.format( Messages.SARLValidator_39, action.getName()), action, XTEND_FUNCTION__NAME, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, INVALID_MEMBER_NAME, validName); } else if (!isIgnored(DISCOURAGED_FUNCTION_NAME) && this.featureNames_.isDiscouragedName(name)) { warning(MessageFormat.format( Messages.SARLValidator_39, action.getName()), action, XTEND_FUNCTION__NAME, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, DISCOURAGED_FUNCTION_NAME); } }
Example #24
Source File: StateNamesAreUniqueValidationHelper.java From statecharts with Eclipse Public License 1.0 | 5 votes |
@Override protected void duplicateLastElement(IEObjectDescription description, IEObjectDescription doublet, ValidationMessageAcceptor acceptor) { if (inSameResource(doublet, description) && description.getEClass() == SGraphPackage.Literals.STATE && doublet.getEClass() == SGraphPackage.Literals.STATE && shouldValidate(description)) { createDuplicateStateNameError(description, acceptor); createDuplicateStateNameError(doublet, acceptor); } }
Example #25
Source File: LibraryChecksCheckImpl.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
/** * checkCatalogIsActiveGreeting. */ @Check(CheckType.FAST) public void checkCatalogIsActiveGreeting(final Greeting it) {// Issue diagnostic libraryChecksCatalog.accept(getMessageAcceptor(), // it, // context EObject null, // EStructuralFeature libraryChecksCatalog.getCheckCatalogIsActiveMessage(), // Message libraryChecksCatalog.getCheckCatalogIsActiveSeverityKind(it), // Severity ValidationMessageAcceptor.INSIGNIFICANT_INDEX, // Marker index LibraryChecksIssueCodes.CHECK_CATALOG_IS_ACTIVE // Issue code & data ); }
Example #26
Source File: SARLValidator.java From sarl with Apache License 2.0 | 5 votes |
/** Check for usage of assert keyword. * * @param expression the expression to analyze. */ @Check public void checkAssertKeywordUse(SarlAssertExpression expression) { final XExpression condition = expression.getCondition(); if (condition != null) { final LightweightTypeReference fromType = getActualType(condition); if (!fromType.isAssignableFrom(Boolean.TYPE)) { error(MessageFormat.format( Messages.SARLValidator_38, getNameOfTypes(fromType), boolean.class.getName()), condition, null, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, INCOMPATIBLE_TYPES); return; } if (getExpressionHelper() instanceof SARLExpressionHelper) { final SARLExpressionHelper helper = (SARLExpressionHelper) getExpressionHelper(); final Boolean constant = helper.toBooleanPrimitiveWrapperConstant(condition); if (constant == Boolean.TRUE && !isIgnored(DISCOURAGED_BOOLEAN_EXPRESSION)) { addIssue(Messages.SARLValidator_51, condition, null, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, DISCOURAGED_BOOLEAN_EXPRESSION); return; } } } }
Example #27
Source File: SARLValidator.java From sarl with Apache License 2.0 | 5 votes |
/** Check if a capacity has a feature defined inside. * * @param capacity the capacity to test. */ @Check(CheckType.FAST) public void checkCapacityFeatures(SarlCapacity capacity) { if (capacity.getMembers().isEmpty()) { if (!isIgnored(DISCOURAGED_CAPACITY_DEFINITION)) { addIssue(Messages.SARLValidator_77, capacity, null, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, DISCOURAGED_CAPACITY_DEFINITION, capacity.getName(), "aFunction"); //$NON-NLS-1$ } } }
Example #28
Source File: PredicateUsesUnorderedGroupInspector.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
public PredicateUsesUnorderedGroupInspector(ValidationMessageAcceptor validationMessageAcceptor) { this.validationMessageAcceptor = validationMessageAcceptor; this.validatedRules = Sets.newHashSet(); this.callHierarchy = Sets.newHashSet(); this.erroneousElements = Sets.newHashSet(); this.alreadyChecked = Sets.newHashSet(); this.elementStack = new Stack<AbstractElement>(); }
Example #29
Source File: XtextValidator.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Check public void checkCrossReferenceNotInAlternatives(Alternatives alternatives) { int numOfCrossRefs = IterableExtensions.size(IterableExtensions.filter(alternatives.getElements(), CrossReference.class)); if (numOfCrossRefs > 1) { String errorMessage = "Cross references using the pattern 'feature=([SomeClass|ID] | [SomeClass|STRING])' are not allowed." + " Use the pattern '(feature=[SomeClass|ID] | feature=[SomeClass|STRING])' instead."; error(errorMessage, alternatives, null, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, CROSS_REFERENCE_IN_ALTERNATIVES); } }
Example #30
Source File: XbaseValidator.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Check public void checkVariableDeclaration(XVariableDeclaration declaration) { if (declaration.getRight() == null) { if (!declaration.isWriteable()) error("Value must be initialized", Literals.XVARIABLE_DECLARATION__WRITEABLE, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, MISSING_INITIALIZATION); if (declaration.getType() == null) error("Type cannot be derived", Literals.XVARIABLE_DECLARATION__NAME, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, MISSING_TYPE); } }