Java Code Examples for org.eclipse.xtend.lib.macro.declaration.TypeReference#isInferred()

The following examples show how to use org.eclipse.xtend.lib.macro.declaration.TypeReference#isInferred() . 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: MutableJvmInterfaceDeclarationImpl.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void setExtendedInterfaces(final Iterable<? extends TypeReference> superinterfaces) {
  this.checkMutable();
  ConditionUtils.checkIterable(superinterfaces, "superinterfaces");
  this.getDelegate().getSuperTypes().clear();
  for (final TypeReference typeRef : superinterfaces) {
    {
      boolean _isInferred = typeRef.isInferred();
      if (_isInferred) {
        throw new IllegalArgumentException("Cannot use inferred type as extended interface.");
      }
      EList<JvmTypeReference> _superTypes = this.getDelegate().getSuperTypes();
      JvmTypeReference _jvmTypeReference = this.getCompilationUnit().toJvmTypeReference(typeRef);
      _superTypes.add(_jvmTypeReference);
    }
  }
}
 
Example 2
Source File: ConditionUtils.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
public static void checkInferredTypeReferences(final String typeName, final TypeReference... types) {
  for (final TypeReference type : types) {
    if (((type != null) && type.isInferred())) {
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("Cannot use inferred type as ");
      _builder.append(typeName);
      _builder.append(".");
      throw new IllegalArgumentException(_builder.toString());
    }
  }
}
 
Example 3
Source File: JvmExecutableDeclarationImpl.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
public MutableParameterDeclaration addParameter(final String name, final TypeReference type) {
  this.checkMutable();
  ConditionUtils.checkJavaIdentifier(name, "name");
  Preconditions.checkArgument((type != null), "type cannot be null");
  boolean _isInferred = type.isInferred();
  if (_isInferred) {
    throw new IllegalArgumentException("Cannot use inferred type as parameter type.");
  }
  final JvmFormalParameter param = TypesFactory.eINSTANCE.createJvmFormalParameter();
  param.setName(name);
  param.setParameterType(this.getCompilationUnit().toJvmTypeReference(type));
  this.getDelegate().getParameters().add(param);
  ParameterDeclaration _parameterDeclaration = this.getCompilationUnit().toParameterDeclaration(param);
  return ((MutableParameterDeclaration) _parameterDeclaration);
}
 
Example 4
Source File: TypeReferenceImpl.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public boolean isAssignableFrom(final TypeReference typeReference) {
  boolean _xblockexpression = false;
  {
    boolean _isInferred = typeReference.isInferred();
    if (_isInferred) {
      throw new UnsupportedOperationException("Cannot check assignability with an inferred type reference.");
    }
    _xblockexpression = this.getDelegate().isAssignableFrom(((TypeReferenceImpl) typeReference).getDelegate());
  }
  return _xblockexpression;
}
 
Example 5
Source File: AccessorsProcessor.java    From xtext-lib with Eclipse Public License 2.0 4 votes vote down vote up
public boolean isBooleanType(final TypeReference it) {
  return ((!it.isInferred()) && Objects.equal(it, this.context.getPrimitiveBoolean()));
}