|
|
|
|
|
Re: [XTEXT1] JvmParameterizedTypeReference and nested classes [message #726058 is a reply to message #726025] |
Fri, 16 September 2011 12:55 |
Sebastian Zarnekow Messages: 3118 Registered: July 2009 |
Senior Member |
|
|
Hi Victor,
you may want to bind your own IJdtTypeProvider.Factory for the
JDT scenario and return a derived implementation of the
JdtTypeProvider that overrides #findTypeByName as follows
@Override
public JvmType findTypeByName(String name) throws
TypeNotFoundException {
if (Strings.isEmpty(name))
throw new IllegalArgumentException("null");
String signature = null;
try {
signature = name.startsWith("[") ? name :
Signature.createTypeSignature(name, true);
} catch (IllegalArgumentException e) {
throw new TypeNotFoundException(name);
}
URI resourceURI = typeUriHelper.createResourceURI(signature);
String resourcePath = resourceURI.path();
if (resourcePath.startsWith(URIHelperConstants.PRIMITIVES)) {
TypeResource resource = (TypeResource)
getResourceSet().getResource(resourceURI, true);
JvmType result = findTypeBySignature(signature, resource);
return result;
} else {
String topLevelType =
resourceURI.segment(resourceURI.segmentCount() - 1);
try {
int lastDot = topLevelType.lastIndexOf('.');
String packageName = null;
String typeName = topLevelType;
if (lastDot != -1) {
typeName = typeName.substring(lastDot + 1);
packageName = topLevelType.substring(0, lastDot);
}
if (javaProject.findType(packageName, typeName) != null) {
TypeResource resource = (TypeResource)
getResourceSet().getResource(resourceURI, true);
JvmType result = findTypeBySignature(signature, resource);
return result;
} else {
throw new TypeNotFoundException(name);
}
} catch (JavaModelException e) {
throw new TypeNotFoundException(name);
}
}
}
See also commit 5e0cdb18285483378f69c6f4fbc7245b435b4a53
Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
On 16.09.11 14:42, Victor wrote:
> Ok thanks, I was looking for at least a workaround waiting to port my
> language to xtext 2.0, I will try to do something about it, thanks :)
|
|
|
|
Powered by
FUDForum. Page generated in 0.03397 seconds