use of org.eclipse.xtext.naming.QualifiedName in project xtext-eclipse by eclipse.
the class WorkingCopyOwnerProvider method getWorkingCopyOwner.
@Override
public WorkingCopyOwner getWorkingCopyOwner(final IJavaProject javaProject, final ResourceSet resourceSet) {
return new WorkingCopyOwner() {
@Override
public String findSource(String typeName, String packageName) {
if (packageName.startsWith("java"))
return super.findSource(typeName, packageName);
QualifiedName qn = toQualifiedName(packageName, typeName);
final IResourceDescriptions descriptions = descriptionsProvider.getResourceDescriptions(resourceSet);
Iterator<IEObjectDescription> exportedObjects = descriptions.getExportedObjects(TypesPackage.Literals.JVM_DECLARED_TYPE, qn, false).iterator();
while (exportedObjects.hasNext()) {
IEObjectDescription candidate = exportedObjects.next();
URI uri = candidate.getEObjectURI();
if (uri.isPlatformResource() && URI.decode(uri.segment(1)).equals(javaProject.getElementName())) {
IResourceDescription resourceDescription = descriptions.getResourceDescription(uri.trimFragment());
return getSource(typeName, packageName, candidate, resourceSet, resourceDescription);
}
}
return super.findSource(typeName, packageName);
}
/**
* not implemented because we don't have a proper index for Java package names and the very rare cases in which this would
* cause trouble are not worth the general degrade in performance.
*/
@Override
public boolean isPackage(String[] pkg) {
return super.isPackage(pkg);
}
};
}
use of org.eclipse.xtext.naming.QualifiedName in project xtext-eclipse by eclipse.
the class JvmElementFinder method findJvmElementDeclarationInIndex.
public EObject findJvmElementDeclarationInIndex(EObject jvmElement, IProject project, ResourceSet resourceSet) {
JvmType type = EcoreUtil2.getContainerOfType(jvmElement, JvmType.class);
if (type == null)
return null;
QualifiedName qualifiedName = qualifiedNameProvider.getFullyQualifiedName(type);
if (qualifiedName != null) {
Iterator<IEObjectDescription> exportedObjects = resourceDescriptions.getExportedObjects(type.eClass(), qualifiedName, false).iterator();
if (exportedObjects.hasNext()) {
URI eObjectURI = exportedObjects.next().getEObjectURI();
EObject eObject = resourceSet.getEObject(eObjectURI, true);
if (type != jvmElement) {
TreeIterator<EObject> contents = eObject.eAllContents();
QualifiedName nameOfActualElement = qualifiedNameProvider.getFullyQualifiedName(jvmElement);
while (contents.hasNext()) {
EObject next = contents.next();
if (jvmElement.eClass().isInstance(next) && nameOfActualElement.equals(qualifiedNameProvider.getFullyQualifiedName(next))) {
return next;
}
}
}
return eObject;
}
}
return null;
}
use of org.eclipse.xtext.naming.QualifiedName in project xtext-eclipse by eclipse.
the class DeltaConverter method getAdditionallyExportedEObjects.
/**
* @deprecated This method is not used anymore.
*/
@Deprecated
protected List<IEObjectDescription> getAdditionallyExportedEObjects(IType type, IJavaElementDelta delta) {
QualifiedName typeName = nameConverter.toQualifiedName(type.getFullyQualifiedName());
NameBasedEObjectDescriptionBuilder descriptionBuilder = new NameBasedEObjectDescriptionBuilder(typeName);
traverseDelta(delta, descriptionBuilder);
return descriptionBuilder.getExported();
}
use of org.eclipse.xtext.naming.QualifiedName in project xtext-eclipse by eclipse.
the class NameBasedEObjectDescriptionBuilder method accept.
public void accept(String simpleName) {
QualifiedName next = baseName.append(simpleName);
exported.add(new NameBasedEObjectDescription(next));
}
use of org.eclipse.xtext.naming.QualifiedName in project xtext-eclipse by eclipse.
the class NameBasedEObjectDescriptionBuilder method nestType.
public NameBasedEObjectDescriptionBuilder nestType(String simpleName) {
String newLastSegment = baseName.getLastSegment() + "$" + simpleName;
QualifiedName next = baseName.skipLast(1).append(newLastSegment);
return new NameBasedEObjectDescriptionBuilder(next, exported);
}
Aggregations