Java Code Examples for org.eclipse.xtext.AbstractMetamodelDeclaration#getAlias()
The following examples show how to use
org.eclipse.xtext.AbstractMetamodelDeclaration#getAlias() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XtextCrossReferenceSerializer.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Override protected String getUnconvertedLinkText(EObject object, EReference reference, EObject context) { if (reference == XtextPackage.eINSTANCE.getGrammar_UsedGrammars()) return ((Grammar) object).getName(); if (reference == XtextPackage.eINSTANCE.getTypeRef_Metamodel()) { AbstractMetamodelDeclaration casted = (AbstractMetamodelDeclaration) object; return casted.getAlias(); } if (reference == XtextPackage.eINSTANCE.getAbstractMetamodelDeclaration_EPackage()) return ((EPackage) object).getNsURI(); if (object instanceof AbstractRule) { if (reference == XtextPackage.eINSTANCE.getRuleCall_Rule()) { if (((RuleCall)context).isExplicitlyCalled()) { return super.getUnconvertedLinkText(object, reference, context); } } return ((AbstractRule) object).getName(); } return super.getUnconvertedLinkText(object, reference, context); }
Example 2
Source File: XtextProposalProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override protected String getDisplayString(EObject element, String proposal, String shortName) { if (element instanceof AbstractMetamodelDeclaration) { AbstractMetamodelDeclaration decl = (AbstractMetamodelDeclaration) element; if (!Strings.isEmpty(decl.getAlias())) return decl.getAlias(); } else if (element instanceof EPackage) { EPackage pack = (EPackage) element; return pack.getName() + " - " + pack.getNsURI(); } return super.getDisplayString(element, proposal, shortName); }
Example 3
Source File: XtextProposalProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
private void createClassifierProposals(AbstractMetamodelDeclaration declaration, EObject model, ContentAssistContext context, ICompletionProposalAcceptor acceptor) { String alias = declaration.getAlias(); QualifiedName prefix = (!Strings.isEmpty(alias)) ? QualifiedName.create(getValueConverter().toString(alias, grammarAccess.getValidIDRule().getName())) : null; boolean createDatatypeProposals = !(model instanceof AbstractElement) && modelOrContainerIs(model, AbstractRule.class); boolean createEnumProposals = !(model instanceof AbstractElement) && modelOrContainerIs(model, EnumRule.class); boolean createClassProposals = modelOrContainerIs(model, ParserRule.class, CrossReference.class, Action.class); Function<IEObjectDescription, ICompletionProposal> factory = new DefaultProposalCreator(context, null, classifierQualifiedNameConverter); for (EClassifier classifier : declaration.getEPackage().getEClassifiers()) { if (classifier instanceof EDataType && createDatatypeProposals || classifier instanceof EEnum && createEnumProposals || classifier instanceof EClass && createClassProposals) { String classifierName = getValueConverter().toString(classifier.getName(), grammarAccess.getValidIDRule().getName()); QualifiedName proposalQualifiedName = (prefix != null) ? prefix.append(classifierName) : QualifiedName .create(classifierName); IEObjectDescription description = EObjectDescription.create(proposalQualifiedName, classifier); ConfigurableCompletionProposal proposal = (ConfigurableCompletionProposal) factory.apply(description); if (proposal != null) { if (prefix != null) proposal.setDisplayString(classifier.getName() + " - " + alias); proposal.setPriority(proposal.getPriority() * 2); } acceptor.accept(proposal); } } }
Example 4
Source File: XtextLocationInFileProvider.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override protected EStructuralFeature getIdentifierFeature(EObject obj) { if (obj instanceof AbstractMetamodelDeclaration) { AbstractMetamodelDeclaration decl = (AbstractMetamodelDeclaration) obj; if (decl.getAlias() != null) return XtextPackage.Literals.ABSTRACT_METAMODEL_DECLARATION__ALIAS; if (decl instanceof GeneratedMetamodel && ((GeneratedMetamodel) decl).getName() != null) return XtextPackage.Literals.GENERATED_METAMODEL__NAME; return XtextPackage.Literals.ABSTRACT_METAMODEL_DECLARATION__EPACKAGE; } return super.getIdentifierFeature(obj); }