use of org.eclipse.emf.ecore.EClassifier in project xtext-core by eclipse.
the class FollowElementComputer method collectAbstractElements.
public void collectAbstractElements(Grammar grammar, EStructuralFeature feature, IFollowElementAcceptor followElementAcceptor) {
for (Grammar superGrammar : grammar.getUsedGrammars()) {
collectAbstractElements(superGrammar, feature, followElementAcceptor);
}
EClass declarator = feature.getEContainingClass();
for (ParserRule rule : GrammarUtil.allParserRules(grammar)) {
for (Assignment assignment : GrammarUtil.containedAssignments(rule)) {
if (assignment.getFeature().equals(feature.getName())) {
EClassifier classifier = GrammarUtil.findCurrentType(assignment);
EClassifier compType = EcoreUtil2.getCompatibleType(declarator, classifier);
if (compType == declarator) {
followElementAcceptor.accept(assignment);
}
}
}
}
}
use of org.eclipse.emf.ecore.EClassifier in project xtext-core by eclipse.
the class IdeContentProposalProvider method _createProposals.
protected void _createProposals(CrossReference reference, ContentAssistContext context, IIdeContentProposalAcceptor acceptor) {
EClassifier type = currentTypeFinder.findCurrentTypeAfter(reference);
if (type instanceof EClass) {
EReference eReference = GrammarUtil.getReference(reference, ((EClass) type));
EObject currentModel = context.getCurrentModel();
if (eReference != null && currentModel != null) {
IScope scope = scopeProvider.getScope(currentModel, eReference);
crossrefProposalProvider.lookupCrossReference(scope, reference, context, acceptor, getCrossrefFilter(reference, context));
}
}
}
use of org.eclipse.emf.ecore.EClassifier in project xtext-core by eclipse.
the class Formatter2Fragment2 method getLocallyAssignedContainmentReferences.
protected void getLocallyAssignedContainmentReferences(final Grammar grammar, final Multimap<EClass, EReference> type2ref) {
List<Assignment> _containedAssignments = GrammarUtil.containedAssignments(grammar);
for (final Assignment assignment : _containedAssignments) {
{
final EClassifier type = GrammarUtil.findCurrentType(assignment);
if ((type instanceof EClass)) {
final EStructuralFeature feature = ((EClass) type).getEStructuralFeature(assignment.getFeature());
if (((feature instanceof EReference) && ((EReference) feature).isContainment())) {
type2ref.put(((EClass) type), ((EReference) feature));
}
}
}
}
List<Action> _containedActions = GrammarUtil.containedActions(grammar);
for (final Action action : _containedActions) {
{
final String featureName = action.getFeature();
if ((featureName != null)) {
final EClassifier type = action.getType().getClassifier();
if ((type instanceof EClass)) {
final EStructuralFeature feature = ((EClass) type).getEStructuralFeature(featureName);
if (((feature instanceof EReference) && ((EReference) feature).isContainment())) {
type2ref.put(((EClass) type), ((EReference) feature));
}
}
}
}
}
}
use of org.eclipse.emf.ecore.EClassifier in project xtext-core by eclipse.
the class EMFGeneratorFragment2 method putMappingData.
private void putMappingData(final Map<EObject, EObject> result, final EPackage usedEPackage, final EPackage loadedEPackage) {
if (((loadedEPackage != null) && (!Objects.equal(usedEPackage, loadedEPackage)))) {
result.put(usedEPackage, loadedEPackage);
EList<EClassifier> _eClassifiers = usedEPackage.getEClassifiers();
for (final EClassifier usedClassifier : _eClassifiers) {
{
final EClassifier loadedClassifier = loadedEPackage.getEClassifier(usedClassifier.getName());
if ((loadedClassifier == null)) {
String _name = usedClassifier.getName();
String _plus = ("Cannot find classifier \'" + _name);
String _plus_1 = (_plus + "\' in loaded EPackage from ");
URI _uRI = loadedEPackage.eResource().getURI();
String _plus_2 = (_plus_1 + _uRI);
throw new RuntimeException(_plus_2);
}
result.put(usedClassifier, loadedClassifier);
}
}
EList<EPackage> _eSubpackages = usedEPackage.getESubpackages();
for (final EPackage usedNestedPackage : _eSubpackages) {
{
final Function1<EPackage, Boolean> _function = (EPackage it) -> {
String _name = it.getName();
String _name_1 = usedNestedPackage.getName();
return Boolean.valueOf(Objects.equal(_name, _name_1));
};
final EPackage loadedNestedPackage = IterableExtensions.<EPackage>findFirst(loadedEPackage.getESubpackages(), _function);
if ((loadedNestedPackage != null)) {
this.putMappingData(result, usedNestedPackage, loadedNestedPackage);
}
}
}
}
}
use of org.eclipse.emf.ecore.EClassifier in project xtext-core by eclipse.
the class ResourceDescriptionStrategyFragment method generateResourceDescriptionStrategy.
protected JavaFileAccess generateResourceDescriptionStrategy(final Iterable<AbstractRule> exportedRules) {
TypeReference _abstractResourceDescriptionStrategyClass = this.getAbstractResourceDescriptionStrategyClass();
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("public class ");
String _simpleName = ResourceDescriptionStrategyFragment.this.getSuperTypeRef().getSimpleName();
_builder.append(_simpleName);
_builder.append(" extends ");
TypeReference _resourceDescriptionSuperClass = ResourceDescriptionStrategyFragment.this.getResourceDescriptionSuperClass();
_builder.append(_resourceDescriptionSuperClass);
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("public boolean createEObjectDescriptions(");
_builder.append(EObject.class, "\t");
_builder.append(" eObject, ");
_builder.append(IAcceptor.class, "\t");
_builder.append("<");
_builder.append(IEObjectDescription.class, "\t");
_builder.append("> acceptor) {");
_builder.newLineIfNotEmpty();
{
for (final AbstractRule exportedRule : exportedRules) {
_builder.append("\t\t");
_builder.append("if(eObject instanceof ");
EClassifier _classifier = exportedRule.getType().getClassifier();
ResourceSet _resourceSet = ResourceDescriptionStrategyFragment.this.getGrammar().eResource().getResourceSet();
TypeReference _typeReference = new TypeReference(((EClass) _classifier), _resourceSet);
_builder.append(_typeReference, "\t\t");
_builder.append(") {");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("\t");
_builder.append("return createEObjectDescriptionsFor");
String _name = exportedRule.getType().getClassifier().getName();
_builder.append(_name, "\t\t\t");
_builder.append("(eObject, acceptor);");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
}
}
{
boolean _needsToInvokeSuperResourceDescriptionStrategy = ResourceDescriptionStrategyFragment.this.needsToInvokeSuperResourceDescriptionStrategy();
if (_needsToInvokeSuperResourceDescriptionStrategy) {
_builder.append("\t\t");
_builder.append("return super.createEObjectDescriptions(eObject, acceptor);");
_builder.newLine();
} else {
_builder.append("\t\t");
_builder.append("return true;");
_builder.newLine();
}
}
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.newLine();
{
for (final AbstractRule exportedRule_1 : exportedRules) {
_builder.append("\t");
_builder.append("protected boolean createEObjectDescriptionsFor");
String _name_1 = exportedRule_1.getType().getClassifier().getName();
_builder.append(_name_1, "\t");
_builder.append("(");
_builder.append(EObject.class, "\t");
_builder.append(" eObject, ");
_builder.append(IAcceptor.class, "\t");
_builder.append("<");
_builder.append(IEObjectDescription.class, "\t");
_builder.append("> acceptor) {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
_builder.append("return super.createEObjectDescriptions(eObject, acceptor);");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
}
}
_builder.append("}");
_builder.newLine();
}
};
return this.fileAccessFactory.createJavaFile(_abstractResourceDescriptionStrategyClass, _client);
}
Aggregations