本文整理汇总了Java中org.eclipse.xtext.validation.ValidationMessageAcceptor类的典型用法代码示例。如果您正苦于以下问题:Java ValidationMessageAcceptor类的具体用法?Java ValidationMessageAcceptor怎么用?Java ValidationMessageAcceptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ValidationMessageAcceptor类属于org.eclipse.xtext.validation包,在下文中一共展示了ValidationMessageAcceptor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: checkAllAttributesConfigured
import org.eclipse.xtext.validation.ValidationMessageAcceptor; //导入依赖的package包/类
@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);
}
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:18,代码来源:XbaseWithAnnotationsValidator.java
示例2: checkFirstRule
import org.eclipse.xtext.validation.ValidationMessageAcceptor; //导入依赖的package包/类
@Check
public void checkFirstRule(Grammar g) {
if (g.getRules().isEmpty())
return;
AbstractRule firstRule = g.getRules().get(0);
if (!(firstRule instanceof ParserRule)) {
if (!containsAnyParserRule(g, new HashSet<Grammar>()))
return;
error(
"The first rule must be a parser rule.",
firstRule,
XtextPackage.Literals.ABSTRACT_RULE__NAME,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX);
}
else if (GrammarUtil.isDatatypeRule((ParserRule) firstRule)) {
if (!containsAnyParserRule(g, new HashSet<Grammar>()))
return;
error(
"The first rule must be a parser rule, but is a data type rule.",
firstRule,
XtextPackage.Literals.ABSTRACT_RULE__NAME,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX);
}
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:25,代码来源:XtextValidator.java
示例3: doPropagateValidationResult
import org.eclipse.xtext.validation.ValidationMessageAcceptor; //导入依赖的package包/类
private void doPropagateValidationResult(Diagnostic diagnostic,
GeneratedMetamodel metamodel, ValidationMessageAcceptor acceptor) {
boolean foundEObject = false;
Object firstData = null;
for(Object data: diagnostic.getData()) {
if (firstData == null) {
firstData = diagnostic.getData().get(0);
}
if (data instanceof EObject) {
if (createMessageForSource(diagnostic, (EObject) data, acceptor)) {
foundEObject = true;
}
if (data instanceof EStructuralFeature && ((EStructuralFeature) data).getEContainingClass() != firstData) {
EClass containingClass = ((EStructuralFeature) data).getEContainingClass();
createMessageForSource(diagnostic, containingClass, acceptor);
}
}
}
if (!foundEObject) {
doCreateMessage(
diagnostic,
metamodel,
XtextPackage.Literals.ABSTRACT_METAMODEL_DECLARATION__EPACKAGE,
acceptor);
}
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:27,代码来源:XtextValidator.java
示例4: checkCrossReferenceTerminal
import org.eclipse.xtext.validation.ValidationMessageAcceptor; //导入依赖的package包/类
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;
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:17,代码来源:XtextValidator.java
示例5: checkTerminalFragmentCalledFromTerminalRule
import org.eclipse.xtext.validation.ValidationMessageAcceptor; //导入依赖的package包/类
@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);
}
}
}
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:17,代码来源:XtextValidator.java
示例6: checkRuleCallInUnorderedGroup
import org.eclipse.xtext.validation.ValidationMessageAcceptor; //导入依赖的package包/类
@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);
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:17,代码来源:XtextValidator.java
示例7: createErrorMessages
import org.eclipse.xtext.validation.ValidationMessageAcceptor; //导入依赖的package包/类
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);
}
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:26,代码来源:PredicateUsesUnorderedGroupInspector.java
示例8: inspectKeywordHidesTerminalRule
import org.eclipse.xtext.validation.ValidationMessageAcceptor; //导入依赖的package包/类
public void inspectKeywordHidesTerminalRule(Keyword keyword) {
AbstractRule container = GrammarUtil.containingRule(keyword);
if (container instanceof TerminalRule)
return;
Grammar grammar = GrammarUtil.getGrammar(container);
List<TerminalRule> rules = GrammarUtil.allTerminalRules(grammar);
for(TerminalRule rule: rules) {
if (!rule.isFragment()) {
AbstractElement element = rule.getAlternatives();
if (element instanceof Keyword && Strings.isEmpty(element.getCardinality())) {
String value = ((Keyword) element).getValue();
if (value.equals(keyword.getValue()))
acceptor.acceptError(
"The keyword '" + value + "' hides the terminal rule " + rule.getName()+ ".",
keyword,
XtextPackage.Literals.KEYWORD__VALUE,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX, null);
}
}
}
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:22,代码来源:KeywordInspector.java
示例9: accept
import org.eclipse.xtext.validation.ValidationMessageAcceptor; //导入依赖的package包/类
/** {@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;
}
}
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:18,代码来源:AbstractIssue.java
示例10: checkFormalParameterNamesUnique
import org.eclipse.xtext.validation.ValidationMessageAcceptor; //导入依赖的package包/类
/**
* 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);
}
}
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:23,代码来源:CheckJavaValidator.java
示例11: warnOnDuplicates
import org.eclipse.xtext.validation.ValidationMessageAcceptor; //导入依赖的package包/类
/**
* 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);
}
}
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:27,代码来源:UniquenessJavaValidationHelper.java
示例12: errorOnDuplicates
import org.eclipse.xtext.validation.ValidationMessageAcceptor; //导入依赖的package包/类
/**
* 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);
}
}
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:27,代码来源:UniquenessJavaValidationHelper.java
示例13: checkConfigurationEqualsDefault
import org.eclipse.xtext.validation.ValidationMessageAcceptor; //导入依赖的package包/类
/**
* Checks whether a configured check's configuration equals the default. Emits an info if this is the case.
*
* @param configuredCheck
* the configured check
*/
@Check
public void checkConfigurationEqualsDefault(final ConfiguredCheck configuredCheck) {
final com.avaloq.tools.ddk.check.check.Check check = configuredCheck.getCheck();
if (!isParameterConfigured(configuredCheck) || check == null || check.eIsProxy()) {
return; // only interesting if check configured and resolvable
}
Iterable<FormalParameter> formalParameters = check.getFormalParameters();
for (final ConfiguredParameter configParam : configuredCheck.getParameterConfigurations()) {
try {
FormalParameter param = Iterables.find(formalParameters, new Predicate<FormalParameter>() {
@Override
public boolean apply(final FormalParameter input) {
return input == configParam.getParameter();
}
});
if (parameterValuesEqual(configParam.getNewValue(), param.getRight())) {
info(NLS.bind(Messages.CheckCfgJavaValidator_CONFIGURED_PARAM_EQUALS_DEFAULT, param.getName()), configParam, CheckcfgPackage.Literals.CONFIGURED_PARAMETER__NEW_VALUE, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, IssueCodes.CONFIGURED_PARAM_EQUALS_DEFAULT);
}
} catch (NoSuchElementException e) {
LOGGER.debug("Could not find referenced formal parameter");
}
}
}
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:31,代码来源:CheckCfgJavaValidator.java
示例14: checkConfiguredCatalogUnique
import org.eclipse.xtext.validation.ValidationMessageAcceptor; //导入依赖的package包/类
/**
* 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);
}
}
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:31,代码来源:CheckCfgJavaValidator.java
示例15: checkConfiguredCheckUnique
import org.eclipse.xtext.validation.ValidationMessageAcceptor; //导入依赖的package包/类
/**
* 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);
}
}
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:29,代码来源:CheckCfgJavaValidator.java
示例16: checkConfiguredParameterUnique
import org.eclipse.xtext.validation.ValidationMessageAcceptor; //导入依赖的package包/类
/**
* 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);
}
}
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:29,代码来源:CheckCfgJavaValidator.java
示例17: massVectorSizes
import org.eclipse.xtext.validation.ValidationMessageAcceptor; //导入依赖的package包/类
@Check
public void massVectorSizes(final Mass m) {
Matrix _position = m.getPosition();
int _length = this.getLength(_position);
boolean _notEquals = (_length != 3);
if (_notEquals) {
this.error("Mass position must be a 3D vector.", m, RigidBodiesPackage.Literals.MASS__POSITION,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX, RigidBodiesValidator.MASS_POS_NO_3D);
}
Matrix _inertia = m.getInertia();
int _length_1 = this.getLength(_inertia);
boolean _notEquals_1 = (_length_1 != 9);
if (_notEquals_1) {
this.error("Mass inertia must be a 3 by 3 matrix.", m, RigidBodiesPackage.Literals.MASS__INERTIA,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX, RigidBodiesValidator.MASS_INERTIA_NO_9D);
}
}
开发者ID:szschaler,项目名称:RigidBodies,代码行数:18,代码来源:RigidBodiesValidator.java
示例18: _checkIsValidLocking
import org.eclipse.xtext.validation.ValidationMessageAcceptor; //导入依赖的package包/类
private void _checkIsValidLocking(final AdditiveLockedJointType aljt, final JointTypeExpression exp) {
LockedJointTypeExpression _left = aljt.getLeft();
JointTypeExpression _get = JointTypeHelper.get(exp, 0);
this.checkIsValidLocking(_left, _get);
EList<LockedJointTypeExpression> _right = aljt.getRight();
final Procedure2<LockedJointTypeExpression, Integer> _function = new Procedure2<LockedJointTypeExpression, Integer>() {
@Override
public void apply(final LockedJointTypeExpression e, final Integer idx) {
final JointTypeExpression jt = JointTypeHelper.get(exp, ((idx).intValue() + 1));
boolean _notEquals = (!Objects.equal(jt, null));
if (_notEquals) {
RigidBodiesValidator.this.checkIsValidLocking(e, jt);
} else {
RigidBodiesValidator.this.error("No matching element in original joint type", e, null,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX, RigidBodiesValidator.LOCKED_TYPE_NO_MATCH);
}
}
};
IterableExtensions.<LockedJointTypeExpression>forEach(_right, _function);
}
开发者ID:szschaler,项目名称:RigidBodies,代码行数:21,代码来源:RigidBodiesValidator.java
示例19: generateErrors
import org.eclipse.xtext.validation.ValidationMessageAcceptor; //导入依赖的package包/类
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);
}
}
开发者ID:eclipse,项目名称:xsemantics,代码行数:22,代码来源:XsemanticsValidatorErrorGenerator.java
示例20: generateErrors
import org.eclipse.xtext.validation.ValidationMessageAcceptor; //导入依赖的package包/类
/**
* Copied from super class to create error messages from RuleFailedExceptions via method
* {@link TypeSystemErrorExtensions#compileMessage(RuleFailedException)}.
*/
@Override
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,
// ================================================================
// only change w.r.t. super-class method:
TypeSystemErrorExtensions.compileMessage(ruleFailedException2),
// ruleFailedException2.getMessage(),
// ================================================================
ruleFailedException2.getIssue(),
filter.filterErrorInformation(ruleFailedException2),
lastErrorInformationWithSource, originalSource);
}
}
开发者ID:eclipse,项目名称:n4js,代码行数:31,代码来源:N4JSValidatorErrorGenerator.java
注:本文中的org.eclipse.xtext.validation.ValidationMessageAcceptor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论