use of org.eclipse.xtext.naming.QualifiedName in project xtext-core by eclipse.
the class NamesAreUniqueValidationHelper method checkDescriptionForDuplicatedName.
protected void checkDescriptionForDuplicatedName(IEObjectDescription description, Map<EClass, Map<QualifiedName, IEObjectDescription>> clusterTypeToName, ValidationMessageAcceptor acceptor) {
EObject object = description.getEObjectOrProxy();
EClass eClass = object.eClass();
QualifiedName qualifiedName = description.getName();
EClass clusterType = getAssociatedClusterType(eClass);
Map<QualifiedName, IEObjectDescription> nameToDescription = clusterTypeToName.get(clusterType);
if (nameToDescription == null) {
nameToDescription = Maps.newHashMap();
nameToDescription.put(qualifiedName, description);
clusterTypeToName.put(clusterType, nameToDescription);
} else {
if (nameToDescription.containsKey(qualifiedName)) {
IEObjectDescription prevDescription = nameToDescription.get(qualifiedName);
if (prevDescription != null) {
createDuplicateNameError(prevDescription, clusterType, acceptor);
nameToDescription.put(qualifiedName, null);
}
createDuplicateNameError(description, clusterType, acceptor);
} else {
nameToDescription.put(qualifiedName, description);
}
}
}
use of org.eclipse.xtext.naming.QualifiedName in project xtext-core by eclipse.
the class SuperCallScope method getAllElements.
@Override
public Iterable<IEObjectDescription> getAllElements() {
AbstractRule contextRule = GrammarUtil.containingRule(context);
Grammar grammar = contextRule != null ? GrammarUtil.getGrammar(contextRule) : GrammarUtil.getGrammar(context);
Map<QualifiedName, IEObjectDescription> result = Maps.newLinkedHashMap();
if (grammar != null) {
String shortName = GrammarUtil.getSimpleName(grammar) + ".";
String longName = grammar.getName() + ".";
for (AbstractRule rule : grammar.getRules()) {
putIfAbsent(EObjectDescription.create(shortName + rule.getName(), rule), result);
putIfAbsent(EObjectDescription.create(longName + rule.getName(), rule), result);
}
boolean waitingForSuper = contextRule != null;
for (Grammar usedGrammar : GrammarUtil.allUsedGrammars(grammar)) {
shortName = GrammarUtil.getSimpleName(usedGrammar) + ".";
longName = usedGrammar.getName() + ".";
for (AbstractRule rule : usedGrammar.getRules()) {
if (waitingForSuper) {
assert contextRule != null;
if (rule.getName().equals(contextRule.getName())) {
putIfAbsent(EObjectDescription.create(SUPER, rule), result);
waitingForSuper = false;
}
}
putIfAbsent(EObjectDescription.create(SUPER + "." + rule.getName(), rule), result);
putIfAbsent(EObjectDescription.create(shortName + rule.getName(), rule), result);
putIfAbsent(EObjectDescription.create(longName + rule.getName(), rule), result);
}
}
}
return Lists.newArrayList(result.values());
}
Aggregations