use of org.eclipse.xtext.naming.QualifiedName in project xtext-eclipse by eclipse.
the class AbstractScopeResourceDescriptionsTest method assertExportedObject.
protected void assertExportedObject(Resource resource, String name) {
IResourceDescriptions resourceDescriptions = resourceDescriptionsProvider.getResourceDescriptions(resource);
IResourceDescription resourceDescription = resourceDescriptions.getResourceDescription(resource.getURI());
assertNotNull(resourceDescription);
QualifiedName qname = QualifiedName.create(name);
assertFalse(isEmpty(resourceDescription.getExportedObjects(EcorePackage.Literals.EOBJECT, qname, false)));
}
use of org.eclipse.xtext.naming.QualifiedName in project xtext-eclipse by eclipse.
the class XtextCallHierarchyLabelProvider method _getStyledText.
protected StyledString _getStyledText(final XtextCallHierarchyNode it) {
IEObjectDescription _element = it.getElement();
boolean _tripleEquals = (_element == null);
if (_tripleEquals) {
return this.hierarchyLabelProvider.getStyledText(it);
}
QualifiedName _qualifiedName = it.getElement().getQualifiedName();
String _plus = ("" + _qualifiedName);
final StyledString styledString = new StyledString(_plus);
IEObjectDescription _grammarDescription = it.getGrammarDescription();
boolean _tripleEquals_1 = (_grammarDescription == null);
if (_tripleEquals_1) {
return styledString;
}
QualifiedName _qualifiedName_1 = it.getGrammarDescription().getQualifiedName();
String _plus_1 = (" - " + _qualifiedName_1);
StyledString _styledString = new StyledString(_plus_1, StyledString.QUALIFIER_STYLER);
return styledString.append(_styledString);
}
use of org.eclipse.xtext.naming.QualifiedName in project xtext-eclipse by eclipse.
the class XtextProposalProvider method getStyledDisplayString.
@Override
protected StyledString getStyledDisplayString(IEObjectDescription description) {
if (EcorePackage.Literals.EPACKAGE == description.getEClass()) {
if ("true".equals(description.getUserData("nsURI"))) {
String name = description.getUserData("name");
if (name == null) {
return new StyledString(description.getName().toString());
}
String string = name + " - " + description.getName();
return new StyledString(string);
}
} else if (XtextPackage.Literals.GRAMMAR == description.getEClass()) {
QualifiedName qualifiedName = description.getQualifiedName();
if (qualifiedName.getSegmentCount() > 1) {
return new StyledString(qualifiedName.getLastSegment() + " - " + qualifiedName.toString());
}
return new StyledString(qualifiedName.toString());
} else if (XtextPackage.Literals.ABSTRACT_RULE.isSuperTypeOf(description.getEClass())) {
EObject object = description.getEObjectOrProxy();
if (!object.eIsProxy()) {
AbstractRule rule = (AbstractRule) object;
Grammar grammar = GrammarUtil.getGrammar(rule);
if (description instanceof EnclosingGrammarAwareDescription) {
if (grammar == ((EnclosingGrammarAwareDescription) description).getGrammar()) {
return getStyledDisplayString(rule, null, rule.getName());
}
}
return getStyledDisplayString(rule, grammar.getName() + "." + rule.getName(), description.getName().toString().replace(".", "::"));
}
}
return super.getStyledDisplayString(description);
}
use of org.eclipse.xtext.naming.QualifiedName in project xtext-eclipse by eclipse.
the class XtextProposalProvider method createClassifierProposals.
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);
}
}
}
use of org.eclipse.xtext.naming.QualifiedName in project xtext-eclipse by eclipse.
the class EcoreRefactoringParticipant method getRenamedElementsOrProxies.
@Override
protected List<EObject> getRenamedElementsOrProxies(EObject originalTarget) {
if (originalTarget instanceof ParserRule) {
TypeRef returnType = ((ParserRule) originalTarget).getType();
if (returnType != null && returnType.getClassifier() != null && !Strings.isEmpty(returnType.getClassifier().getName()) && equal(((ParserRule) originalTarget).getName(), returnType.getClassifier().getName()) && returnType.getClassifier().eClass() != null && returnType.getClassifier().getEPackage() != null && !Strings.isEmpty(returnType.getClassifier().getEPackage().getNsURI())) {
String packageNsURI = returnType.getClassifier().getEPackage().getNsURI();
QualifiedName classifierQualifiedName = QualifiedName.create(packageNsURI, returnType.getClassifier().getName());
URI platformResourceURI = findPlatformResourceURI(classifierQualifiedName, EcorePackage.Literals.ECLASS);
if (platformResourceURI == null) {
if (returnType.getMetamodel() instanceof ReferencedMetamodel)
getStatus().add(ERROR, "Return type '{0}' is not indexed.", returnType.getClassifier());
} else {
EObject classifierProxy = EcoreFactory.eINSTANCE.create(returnType.getClassifier().eClass());
((InternalEObject) classifierProxy).eSetProxyURI(platformResourceURI);
if (!isDisableWarning)
getStatus().add(WARNING, "Renaming EClass '{0}' in ecore file. Please rerun the Ecore generator.", returnType.getClassifier());
return singletonList(classifierProxy);
}
}
}
return null;
}
Aggregations