Java Code Examples for org.eclipse.xtext.validation.CheckType#NORMAL

The following examples show how to use org.eclipse.xtext.validation.CheckType#NORMAL . 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: SARLValidator.java    From sarl with Apache License 2.0 6 votes vote down vote up
/** Check if the closure parameters have a valid name.
 *
 * @param closure the closure to test.
 * @see SARLFeatureNameValidator
 */
@Check(CheckType.NORMAL)
public void checkParameterName(XClosure closure) {
	int index = 0;
	for (final JvmFormalParameter param : closure.getDeclaredFormalParameters()) {
		final QualifiedName name = Utils.getQualifiedName(param);
		if (isReallyDisallowedName(name)) {
			error(MessageFormat.format(
					Messages.SARLValidator_41,
					param.getName(), Messages.SARLValidator_14),
					closure,
					XbasePackage.Literals.XCLOSURE__DECLARED_FORMAL_PARAMETERS,
					index,
					VARIABLE_NAME_DISALLOWED);
		} else if (this.grammarAccess.getOccurrenceKeyword().equals(param.getName())) {
			error(MessageFormat.format(
					Messages.SARLValidator_101,
					this.grammarAccess.getOccurrenceKeyword(), Messages.SARLValidator_14),
					closure,
					XbasePackage.Literals.XCLOSURE__DECLARED_FORMAL_PARAMETERS,
					index,
					VARIABLE_NAME_DISALLOWED);
		}
		++index;
	}
}
 
Example 2
Source File: LanguageAwareMarkerTypeProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public CheckType getCheckType(String markerType) {
	if (fastValidationMarker.equals(markerType)) {
		return CheckType.FAST;
	}
	if (normalValidationMarker.equals(markerType)) {
		return CheckType.NORMAL;
	}
	if (expensiveValidationMarker.equals(markerType)) {
		return CheckType.EXPENSIVE;
	}
	return super.getCheckType(markerType);
}
 
Example 3
Source File: MarkerTypes.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public static CheckType toCheckType(String markerType) {
	if (FAST_VALIDATION.equals(markerType))
		return CheckType.FAST;
	if (NORMAL_VALIDATION.equals(markerType))
		return CheckType.NORMAL;
	if (EXPENSIVE_VALIDATION.equals(markerType))
		return CheckType.EXPENSIVE;
	// default
	return CheckType.FAST;
}
 
Example 4
Source File: CheckJavaValidator.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Checks that at least one issue expression exists in a context's constraints.
 * <p>
 * To be executed on save only as the error will otherwise be distracting.
 * </p>
 *
 * @param context
 *          the context to be checked
 */
@Check(CheckType.NORMAL)
public void checkIssueExpressionExists(final Context context) {
  if (context.getContextVariable() == null || context.getConstraint() == null) {
    return;
  }

  if (Iterables.isEmpty(generatorExtensions.issues(context))) {
    error(Messages.CheckJavaValidator_MISSING_ISSUE_EXPRESSION, context, CheckPackage.Literals.CONTEXT__CONSTRAINT, IssueCodes.MISSING_ISSUE_EXPRESSION);
  }
}
 
Example 5
Source File: SCTMarkerTypeProvider.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public CheckType getCheckType(String markerType) {
	if (SCTMarkerType.FAST_VALIDATION.equals(markerType))
		return CheckType.FAST;
	if (SCTMarkerType.NORMAL_VALIDATION.equals(markerType))
		return CheckType.NORMAL;
	if (SCTMarkerType.EXPENSIVE_VALIDATION.equals(markerType))
		return CheckType.EXPENSIVE;
	// default
	return CheckType.FAST;
}
 
Example 6
Source File: ErrorToDiagnoticTranslator.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
private CheckType getType(final CheckMode mode) {
	if (mode == CheckMode.FAST_ONLY) {
		return CheckType.FAST;
	} else if (mode == CheckMode.EXPENSIVE_ONLY) {
		return CheckType.EXPENSIVE;
	} else if (mode == CheckMode.ALL) {
		return CheckType.FAST;
	} else if (mode == CheckMode.NORMAL_AND_FAST) {
		return CheckType.FAST;
	} else if (mode == CheckMode.NORMAL_ONLY) {
		return CheckType.NORMAL;
	} else {
		return CheckType.FAST;
	}
}
 
Example 7
Source File: SARLValidator.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Check for multiple capacity use declaration.
 *
 * @param uses the capacity use declaration.
 */
@Check(CheckType.NORMAL)
public void checkMultipleCapacityUses(SarlCapacityUses uses) {
	if (!isIgnored(REDUNDANT_CAPACITY_USE)) {
		final XtendTypeDeclaration declaringType = uses.getDeclaringType();
		if (declaringType != null) {
			final Set<String> previousCapacityUses = doGetPreviousCapacities(uses,
					declaringType.getMembers().iterator());
			int index = 0;
			for (final JvmTypeReference capacity : uses.getCapacities()) {
				if (previousCapacityUses.contains(capacity.getIdentifier())) {
					addIssue(MessageFormat.format(
							Messages.SARLValidator_79,
							capacity.getSimpleName()),
							uses,
							SARL_CAPACITY_USES__CAPACITIES,
							index,
							REDUNDANT_CAPACITY_USE,
							capacity.getSimpleName());
				} else {
					previousCapacityUses.add(capacity.getIdentifier());
				}
				++index;
			}
		}
	}
}
 
Example 8
Source File: ExtraLanguageValidatorSupport.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Check the rules for the activated extra languages.
 *
 * @param currentObject the current object to test.
 */
@Check(CheckType.NORMAL)
public void checkExtraLanguageRules(EObject currentObject) {
	final List<AbstractExtraLanguageValidator> validators = this.validatorProvider.getValidators(
			currentObject.eResource());
	if (!validators.isEmpty()) {
		for (final AbstractExtraLanguageValidator validator : validators) {
			final ValidationMessageAcceptor acceptor = getMessageAcceptor();
			final StateAccess stateAccess = setMessageAcceptor(acceptor);
			validator.validate(stateAccess, acceptor);
		}
	}
}
 
Example 9
Source File: ExecutionEnvironmentCheckImpl.java    From dsl-devkit with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * greetingNameLengthGreeting.
 */
@Check(CheckType.NORMAL)
public void greetingNameLengthGreeting(final Greeting context) {
  greetingNameLengthImpl.runGreeting(context);
}
 
Example 10
Source File: ExecutionEnvironmentCheckImpl.java    From dsl-devkit with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * greetingNameLengthGreeting.
 */
@Check(CheckType.NORMAL)
public void greetingNameLengthGreeting(final Greeting context) {
  greetingNameLengthImpl.runGreeting(context);
}