use of org.eclipse.xtext.TypeRef in project xtext-core by eclipse.
the class TreeConstState method getTypesToCheck.
public Collection<TypeRef> getTypesToCheck() {
Map<EClassifier, TypeRef> localTypes = Maps.newLinkedHashMap();
for (TypeRef t : sortTypes(getTypes())) if (t != null)
localTypes.put(t.getClassifier(), t);
List<TreeConstTransition> incomming = getIncommingWithoutRuleCalls();
if (incomming.isEmpty())
return localTypes.values();
for (TreeConstTransition t : incomming) for (TypeRef r : t.getSource().getTypes()) if (r != null && !localTypes.containsKey(r.getClassifier()))
return localTypes.values();
return Collections.emptyList();
}
use of org.eclipse.xtext.TypeRef in project xtext-core by eclipse.
the class XtextValidationTest method testCheckRuleCallInUnorderedGroup_02.
@Test
public void testCheckRuleCallInUnorderedGroup_02() throws Exception {
XtextValidator validator = get(XtextValidator.class);
UnorderedGroup unorderedGroup = XtextFactory.eINSTANCE.createUnorderedGroup();
RuleCall ruleCall = XtextFactory.eINSTANCE.createRuleCall();
TypeRef typeRef = XtextFactory.eINSTANCE.createTypeRef();
typeRef.setClassifier(EcorePackage.Literals.EBIG_DECIMAL);
ParserRule parserRule = XtextFactory.eINSTANCE.createParserRule();
parserRule.setType(typeRef);
ruleCall.setRule(parserRule);
unorderedGroup.getElements().add(ruleCall);
ValidatingMessageAcceptor messageAcceptor = new ValidatingMessageAcceptor(null, false, false);
validator.setMessageAcceptor(messageAcceptor);
validator.checkRuleCallInUnorderedGroup(ruleCall);
messageAcceptor.validate();
}
use of org.eclipse.xtext.TypeRef in project xtext-core by eclipse.
the class XtextValidationTest method testBug318424_01.
@Test
public void testBug318424_01() throws Exception {
XtextValidator validator = get(XtextValidator.class);
CrossReference reference = XtextFactory.eINSTANCE.createCrossReference();
TypeRef typeRef = XtextFactory.eINSTANCE.createTypeRef();
reference.setType(typeRef);
typeRef.setClassifier(EcorePackage.Literals.EBOOLEAN);
ValidatingMessageAcceptor messageAcceptor = new ValidatingMessageAcceptor(typeRef, true, false);
validator.setMessageAcceptor(messageAcceptor);
validator.checkCrossReferenceType(reference);
messageAcceptor.validate();
}
use of org.eclipse.xtext.TypeRef in project xtext-core by eclipse.
the class XtextValidationTest method testBug318424_02.
@Test
public void testBug318424_02() throws Exception {
XtextValidator validator = get(XtextValidator.class);
Action action = XtextFactory.eINSTANCE.createAction();
TypeRef typeRef = XtextFactory.eINSTANCE.createTypeRef();
action.setType(typeRef);
typeRef.setClassifier(EcorePackage.Literals.EBOOLEAN);
ValidatingMessageAcceptor messageAcceptor = new ValidatingMessageAcceptor(typeRef, true, false);
validator.setMessageAcceptor(messageAcceptor);
validator.checkInstantiatedType(action);
messageAcceptor.validate();
}
use of org.eclipse.xtext.TypeRef in project xtext-core by eclipse.
the class GrammarAccessExtensions method getSingleElementDescription.
private List<String> getSingleElementDescription(final AbstractElement ele) {
final ArrayList<String> r = new ArrayList<String>(2);
boolean _matched = false;
if (ele instanceof Keyword) {
_matched = true;
String _value = ((Keyword) ele).getValue();
r.add(_value);
}
if (!_matched) {
if (ele instanceof Assignment) {
_matched = true;
String _feature = ((Assignment) ele).getFeature();
r.add(_feature);
}
}
if (!_matched) {
if (ele instanceof RuleCall) {
_matched = true;
String _name = ((RuleCall) ele).getRule().getName();
r.add(_name);
}
}
if (!_matched) {
if (ele instanceof Action) {
_matched = true;
TypeRef _type = ((Action) ele).getType();
EClassifier _classifier = null;
if (_type != null) {
_classifier = _type.getClassifier();
}
boolean _tripleNotEquals = (_classifier != null);
if (_tripleNotEquals) {
String _name = ((Action) ele).getType().getClassifier().getName();
r.add(_name);
}
boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(((Action) ele).getFeature());
boolean _not = (!_isNullOrEmpty);
if (_not) {
String _feature = ((Action) ele).getFeature();
r.add(_feature);
}
}
}
if (!_matched) {
if (ele instanceof CrossReference) {
_matched = true;
TypeRef _type = ((CrossReference) ele).getType();
EClassifier _classifier = null;
if (_type != null) {
_classifier = _type.getClassifier();
}
boolean _tripleNotEquals = (_classifier != null);
if (_tripleNotEquals) {
String _name = ((CrossReference) ele).getType().getClassifier().getName();
r.add(_name);
}
}
}
if (!_matched) {
if (ele instanceof EnumLiteralDeclaration) {
_matched = true;
String _name = ((EnumLiteralDeclaration) ele).getEnumLiteral().getName();
r.add(_name);
}
}
return r;
}
Aggregations