use of org.eclipse.xtext.common.types.access.TypeResource in project xtext-eclipse by eclipse.
the class JdtTypeProviderTest method testGetResource_02.
@Test
public void testGetResource_02() {
URI primitivesURI = URI.createURI("java:/Primitives");
TypeResource resource = (TypeResource) resourceSet.getResource(primitivesURI, false);
assertNull(resource);
}
use of org.eclipse.xtext.common.types.access.TypeResource in project xtext-eclipse by eclipse.
the class JdtTypeProvider method createResourceAndFindType.
/* @Nullable */
private JvmType createResourceAndFindType(/* @NonNull */
URI resourceURI, /* @NonNull */
IType type, /* @NonNull */
String signature, boolean traverseNestedTypes) throws IOException {
TypeResource resource = createResource(resourceURI, type);
resource.load(Collections.singletonMap(TypeResource.OPTION_CLASSPATH_CONTEXT, javaProject));
return findTypeBySignature(signature, resource, traverseNestedTypes);
}
use of org.eclipse.xtext.common.types.access.TypeResource in project xtext-eclipse by eclipse.
the class JdtTypeProvider method createResource.
private TypeResource createResource(URI resourceURI, IType type) {
TypeResource resource = doCreateResource(resourceURI);
getResourceSet().getResources().add(resource);
if (type.exists()) {
IMirror mirror = createMirror(type);
resource.setMirror(mirror);
}
return resource;
}
use of org.eclipse.xtext.common.types.access.TypeResource in project xtext-xtend by eclipse.
the class ConstantExpressionsInterpreter method evaluateField.
protected Object evaluateField(final XAbstractFeatureCall call, final JvmField field, final Context context) {
if ((field.isSetConstant() || (field.eResource() instanceof TypeResource))) {
boolean _isConstant = field.isConstant();
if (_isConstant) {
return field.getConstantValue();
} else {
String _simpleName = field.getDeclaringType().getSimpleName();
String _plus = ("Field " + _simpleName);
String _plus_1 = (_plus + ".");
String _simpleName_1 = field.getSimpleName();
String _plus_2 = (_plus_1 + _simpleName_1);
String _plus_3 = (_plus_2 + " is not a constant");
throw new ConstantExpressionEvaluationException(_plus_3);
}
}
final XExpression expression = this.containerProvider.getAssociatedExpression(field);
boolean _contains = context.getAlreadyEvaluating().contains(expression);
if (_contains) {
throw new ConstantExpressionEvaluationException("Endless recursive evaluation detected.");
}
try {
final Map<String, JvmIdentifiableElement> visibleFeatures = this.findVisibleFeatures(expression);
JvmTypeReference _type = field.getType();
ClassFinder _classFinder = context.getClassFinder();
Set<XExpression> _alreadyEvaluating = context.getAlreadyEvaluating();
final Context ctx = new Context(_type, _classFinder, visibleFeatures, _alreadyEvaluating);
return this.evaluate(expression, ctx);
} catch (final Throwable _t) {
if (_t instanceof ConstantExpressionEvaluationException) {
final ConstantExpressionEvaluationException e = (ConstantExpressionEvaluationException) _t;
throw new StackedConstantExpressionEvaluationException(call, field, e);
} else {
throw Exceptions.sneakyThrow(_t);
}
}
}
Aggregations