当前位置: 首页>>代码示例>>Java>>正文


Java ValidationMessageAcceptor类代码示例

本文整理汇总了Java中org.eclipse.xtext.validation.ValidationMessageAcceptor的典型用法代码示例。如果您正苦于以下问题:Java ValidationMessageAcceptor类的具体用法?Java ValidationMessageAcceptor怎么用?Java ValidationMessageAcceptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ValidationMessageAcceptor类属于org.eclipse.xtext.validation包,在下文中一共展示了ValidationMessageAcceptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的org.eclipse.xtext.validation.ValidationMessageAcceptor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。