org.eclipse.xtend.lib.macro.declaration.MethodDeclaration Java Examples

The following examples show how to use org.eclipse.xtend.lib.macro.declaration.MethodDeclaration. 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: DeclarationsTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testOverriddenMethodFromSource() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("package p");
  _builder.newLine();
  _builder.newLine();
  _builder.append("abstract class C extends java.util.AbstractList<String> implements I {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("override add(String s);");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  _builder.append("interface I {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def boolean add(String s)");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  final Procedure1<CompilationUnitImpl> _function = (CompilationUnitImpl it) -> {
    Assert.assertEquals("p", it.getPackageName());
    TypeDeclaration _head = IterableExtensions.head(it.getSourceTypeDeclarations());
    final ClassDeclaration clazz = ((ClassDeclaration) _head);
    Assert.assertEquals("p.C", clazz.getQualifiedName());
    final MethodDeclaration add = IterableExtensions.head(clazz.getDeclaredMethods());
    final Iterable<? extends MethodDeclaration> allOverridden = add.getOverriddenOrImplementedMethods();
    Assert.assertEquals(2, IterableExtensions.size(allOverridden));
    final MethodDeclaration listAdd = IterableExtensions.head(allOverridden);
    Assert.assertEquals("add", listAdd.getSimpleName());
    Assert.assertEquals("E", IterableExtensions.head(listAdd.getParameters()).getType().getSimpleName());
    final MethodDeclaration intfAdd = IterableExtensions.last(allOverridden);
    Assert.assertEquals("add", intfAdd.getSimpleName());
    Assert.assertEquals("String", IterableExtensions.head(intfAdd.getParameters()).getType().getSimpleName());
  };
  this.asCompilationUnit(this.validFile(_builder), _function);
}
 
Example #2
Source File: JvmClassDeclarationImpl.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public MethodDeclaration findDeclaredMethod(final String name, final TypeReference... parameterTypes) {
  MethodDeclaration _xblockexpression = null;
  {
    ConditionUtils.checkIterable(((Iterable<?>)Conversions.doWrapArray(parameterTypes)), "parameterTypes");
    final Function1<MethodDeclaration, Boolean> _function = (MethodDeclaration it) -> {
      return Boolean.valueOf((Objects.equal(it.getSimpleName(), name) && Objects.equal(IterableExtensions.<TypeReference>toList(IterableExtensions.map(it.getParameters(), ((Function1<ParameterDeclaration, TypeReference>) (ParameterDeclaration it_1) -> {
        return it_1.getType();
      }))), IterableExtensions.<TypeReference>toList(((Iterable<TypeReference>)Conversions.doWrapArray(parameterTypes))))));
    };
    _xblockexpression = IterableExtensions.<MethodDeclaration>findFirst(Iterables.<MethodDeclaration>filter(this.getDeclaredMembers(), MethodDeclaration.class), _function);
  }
  return _xblockexpression;
}
 
Example #3
Source File: XtendTypeDeclarationImpl.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public MethodDeclaration findDeclaredMethod(final String name, final TypeReference... parameterTypes) {
  final Function1<MethodDeclaration, Boolean> _function = (MethodDeclaration method) -> {
    return Boolean.valueOf((Objects.equal(method.getSimpleName(), name) && Objects.equal(IterableExtensions.<TypeReference>toList(IterableExtensions.map(method.getParameters(), ((Function1<ParameterDeclaration, TypeReference>) (ParameterDeclaration it) -> {
      return it.getType();
    }))), IterableExtensions.<TypeReference>toList(((Iterable<TypeReference>)Conversions.doWrapArray(parameterTypes))))));
  };
  return IterableExtensions.findFirst(this.getDeclaredMethods(), _function);
}
 
Example #4
Source File: JvmMethodDeclarationImpl.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Iterable<? extends MethodDeclaration> getOverriddenOrImplementedMethods() {
  final ResolvedFeatures resolvedFeatures = this.getCompilationUnit().getOverrideHelper().getResolvedFeatures(this.getDelegate().getDeclaringType());
  final IResolvedOperation resolvedOperation = resolvedFeatures.getResolvedOperation(this.getDelegate());
  final List<IResolvedOperation> overriddenOrImplemented = resolvedOperation.getOverriddenAndImplementedMethods();
  final Function1<IResolvedOperation, MemberDeclaration> _function = (IResolvedOperation it) -> {
    return this.getCompilationUnit().toMemberDeclaration(it.getDeclaration());
  };
  return Iterables.<MethodDeclaration>filter(ListExtensions.<IResolvedOperation, MemberDeclaration>map(overriddenOrImplemented, _function), MethodDeclaration.class);
}
 
Example #5
Source File: AccessorsProcessor.java    From xtext-lib with Eclipse Public License 2.0 5 votes vote down vote up
public boolean hasGetter(final FieldDeclaration it) {
  final Function1<String, Boolean> _function = (String name) -> {
    MethodDeclaration _findDeclaredMethod = it.getDeclaringType().findDeclaredMethod(name);
    return Boolean.valueOf((_findDeclaredMethod != null));
  };
  return IterableExtensions.<String>exists(this.getPossibleGetterNames(it), _function);
}
 
Example #6
Source File: XtendMethodDeclarationImpl.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Iterable<? extends MethodDeclaration> getOverriddenOrImplementedMethods() {
  boolean _isOverride = this.getDelegate().isOverride();
  if (_isOverride) {
    final JvmOperation jvmOperation = this.getCompilationUnit().getJvmModelAssociations().getDirectlyInferredOperation(this.getDelegate());
    final ResolvedFeatures resolvedFeatures = this.getCompilationUnit().getOverrideHelper().getResolvedFeatures(jvmOperation.getDeclaringType());
    final IResolvedOperation resolvedOperation = resolvedFeatures.getResolvedOperation(jvmOperation);
    final List<IResolvedOperation> overriddenOrImplemented = resolvedOperation.getOverriddenAndImplementedMethods();
    final Function1<IResolvedOperation, MemberDeclaration> _function = (IResolvedOperation it) -> {
      return this.getCompilationUnit().toMemberDeclaration(it.getDeclaration());
    };
    return Iterables.<MethodDeclaration>filter(ListExtensions.<IResolvedOperation, MemberDeclaration>map(overriddenOrImplemented, _function), MethodDeclaration.class);
  }
  return CollectionLiterals.<MethodDeclaration>emptyList();
}
 
Example #7
Source File: DelegateProcessor.java    From xtext-lib with Eclipse Public License 2.0 5 votes vote down vote up
public CharSequence delegateAccess(final MemberDeclaration it, final MethodDeclaration method) {
  if (it instanceof MethodDeclaration) {
    return _delegateAccess((MethodDeclaration)it, method);
  } else if (it instanceof FieldDeclaration) {
    return _delegateAccess((FieldDeclaration)it, method);
  } else {
    throw new IllegalArgumentException("Unhandled parameter types: " +
      Arrays.<Object>asList(it, method).toString());
  }
}
 
Example #8
Source File: JvmTypeDeclarationImpl.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
public MethodDeclaration findDeclaredMethod(final String name, final TypeReference... parameterTypes) {
  MethodDeclaration _xblockexpression = null;
  {
    ConditionUtils.checkIterable(((Iterable<?>)Conversions.doWrapArray(parameterTypes)), "parameterTypes");
    final Function1<MethodDeclaration, Boolean> _function = (MethodDeclaration method) -> {
      return Boolean.valueOf((Objects.equal(method.getSimpleName(), name) && Objects.equal(IterableExtensions.<TypeReference>toList(IterableExtensions.map(method.getParameters(), ((Function1<ParameterDeclaration, TypeReference>) (ParameterDeclaration it) -> {
        return it.getType();
      }))), IterableExtensions.<TypeReference>toList(((Iterable<TypeReference>)Conversions.doWrapArray(parameterTypes))))));
    };
    _xblockexpression = IterableExtensions.findFirst(this.getDeclaredMethods(), _function);
  }
  return _xblockexpression;
}
 
Example #9
Source File: DelegateProcessor.java    From xtext-lib with Eclipse Public License 2.0 5 votes vote down vote up
public boolean hasValidSignature(final MethodDeclaration it) {
  boolean _switchResult = false;
  final Function1<ParameterDeclaration, TypeReference> _function = (ParameterDeclaration it_1) -> {
    return it_1.getType();
  };
  List<TypeReference> _list = IterableExtensions.<TypeReference>toList(IterableExtensions.map(it.getParameters(), _function));
  boolean _matched = false;
  if (Objects.equal(_list, Collections.<Object>unmodifiableList(CollectionLiterals.<Object>newArrayList()))) {
    _matched=true;
  }
  if (!_matched) {
    TypeReference _string = this.context.getString();
    if (Objects.equal(_list, Collections.<TypeReference>unmodifiableList(CollectionLiterals.<TypeReference>newArrayList(_string)))) {
      _matched=true;
    }
  }
  if (!_matched) {
    TypeReference _string_1 = this.context.getString();
    TypeReference _newArrayTypeReference = this.context.newArrayTypeReference(this.context.newTypeReference(Class.class, this.context.newWildcardTypeReference()));
    TypeReference _newArrayTypeReference_1 = this.context.newArrayTypeReference(this.context.getObject());
    if (Objects.equal(_list, Collections.<TypeReference>unmodifiableList(CollectionLiterals.<TypeReference>newArrayList(_string_1, _newArrayTypeReference, _newArrayTypeReference_1)))) {
      _matched=true;
    }
  }
  if (_matched) {
    _switchResult = true;
  }
  if (!_matched) {
    boolean _xblockexpression = false;
    {
      this.context.addError(it, "Not a valid delegate signature, use () or (String methodName) or (String methodName, Class<?>[] argumentTypes, Object[] arguments)");
      _xblockexpression = false;
    }
    _switchResult = _xblockexpression;
  }
  return _switchResult;
}
 
Example #10
Source File: DelegateProcessor.java    From xtext-lib with Eclipse Public License 2.0 5 votes vote down vote up
protected CharSequence _delegateAccess(final FieldDeclaration it, final MethodDeclaration method) {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("this.");
  String _simpleName = it.getSimpleName();
  _builder.append(_simpleName);
  return _builder;
}
 
Example #11
Source File: DelegateProcessor.java    From xtext-lib with Eclipse Public License 2.0 5 votes vote down vote up
public boolean isValidDelegate(final MemberDeclaration it) {
  if (it instanceof MethodDeclaration) {
    return _isValidDelegate((MethodDeclaration)it);
  } else if (it instanceof FieldDeclaration) {
    return _isValidDelegate((FieldDeclaration)it);
  } else {
    throw new IllegalArgumentException("Unhandled parameter types: " +
      Arrays.<Object>asList(it).toString());
  }
}
 
Example #12
Source File: DelegateProcessor.java    From xtext-lib with Eclipse Public License 2.0 5 votes vote down vote up
public TypeReference getType(final MemberDeclaration it) {
  if (it instanceof MethodDeclaration) {
    return _getType((MethodDeclaration)it);
  } else if (it instanceof FieldDeclaration) {
    return _getType((FieldDeclaration)it);
  } else {
    throw new IllegalArgumentException("Unhandled parameter types: " +
      Arrays.<Object>asList(it).toString());
  }
}
 
Example #13
Source File: MutableJvmAnnotationTypeDeclarationImpl.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public Iterable<? extends MutableMethodDeclaration> getDeclaredMethods() {
  Iterable<? extends MethodDeclaration> _declaredMethods = super.getDeclaredMethods();
  return ((Iterable<? extends MutableMethodDeclaration>) _declaredMethods);
}
 
Example #14
Source File: DeclarationsTest.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void testXtendInterfaceWithDefaultMethod() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("package p");
  _builder.newLine();
  _builder.newLine();
  _builder.append("interface MyIntf {");
  _builder.newLine();
  _builder.append("\t");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def String dflt() { \"\" }");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def String abstrct()");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def static String statc() { \"\" }");
  _builder.newLine();
  _builder.append("\t");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  final Procedure1<CompilationUnitImpl> _function = (CompilationUnitImpl it) -> {
    Assert.assertEquals("p", it.getPackageName());
    TypeDeclaration _head = IterableExtensions.head(it.getSourceTypeDeclarations());
    final InterfaceDeclaration intf = ((InterfaceDeclaration) _head);
    Assert.assertEquals("p.MyIntf", intf.getQualifiedName());
    Assert.assertTrue(IterableExtensions.isEmpty(intf.getExtendedInterfaces()));
    Assert.assertEquals(3, IterableExtensions.size(intf.getDeclaredMembers()));
    final MethodDeclaration dflt = IterableExtensions.head(intf.getDeclaredMethods());
    Assert.assertTrue(dflt.isDefault());
    Assert.assertFalse(dflt.isAbstract());
    final MethodDeclaration abstract_ = ((MethodDeclaration[])Conversions.unwrapArray(intf.getDeclaredMethods(), MethodDeclaration.class))[1];
    Assert.assertFalse(abstract_.isDefault());
    Assert.assertTrue(abstract_.isAbstract());
    final MethodDeclaration static_ = ((MethodDeclaration[])Conversions.unwrapArray(intf.getDeclaredMethods(), MethodDeclaration.class))[2];
    Assert.assertFalse(static_.isDefault());
    Assert.assertFalse(static_.isAbstract());
    Assert.assertTrue(static_.isStatic());
  };
  this.asCompilationUnit(this.validFile(_builder), _function);
}
 
Example #15
Source File: MutableJvmClassDeclarationImpl.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public MutableMethodDeclaration findDeclaredMethod(final String name, final TypeReference... parameterTypes) {
  MethodDeclaration _findDeclaredMethod = super.findDeclaredMethod(name, parameterTypes);
  return ((MutableMethodDeclaration) _findDeclaredMethod);
}
 
Example #16
Source File: MutableJvmClassDeclarationImpl.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public Iterable<? extends MutableMethodDeclaration> getDeclaredMethods() {
  Iterable<? extends MethodDeclaration> _declaredMethods = super.getDeclaredMethods();
  return ((Iterable<? extends MutableMethodDeclaration>) _declaredMethods);
}
 
Example #17
Source File: JvmTypeDeclarationImpl.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
public Iterable<? extends MethodDeclaration> getDeclaredMethods() {
  return Iterables.<MethodDeclaration>filter(this.getDeclaredMembers(), MethodDeclaration.class);
}
 
Example #18
Source File: MutableJvmEnumerationTypeDeclarationImpl.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public MutableMethodDeclaration findDeclaredMethod(final String name, final TypeReference... parameterTypes) {
  MethodDeclaration _findDeclaredMethod = super.findDeclaredMethod(name, parameterTypes);
  return ((MutableMethodDeclaration) _findDeclaredMethod);
}
 
Example #19
Source File: MutableJvmEnumerationTypeDeclarationImpl.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public Iterable<? extends MutableMethodDeclaration> getDeclaredMethods() {
  Iterable<? extends MethodDeclaration> _declaredMethods = super.getDeclaredMethods();
  return ((Iterable<? extends MutableMethodDeclaration>) _declaredMethods);
}
 
Example #20
Source File: XtendTypeDeclarationImpl.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public Iterable<? extends MethodDeclaration> getDeclaredMethods() {
  return Iterables.<MethodDeclaration>filter(this.getDeclaredMembers(), MethodDeclaration.class);
}
 
Example #21
Source File: MutableJvmInterfaceDeclarationImpl.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public MutableMethodDeclaration findDeclaredMethod(final String name, final TypeReference... parameterTypes) {
  MethodDeclaration _findDeclaredMethod = super.findDeclaredMethod(name, parameterTypes);
  return ((MutableMethodDeclaration) _findDeclaredMethod);
}
 
Example #22
Source File: MutableJvmInterfaceDeclarationImpl.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public Iterable<? extends MutableMethodDeclaration> getDeclaredMethods() {
  Iterable<? extends MethodDeclaration> _declaredMethods = super.getDeclaredMethods();
  return ((Iterable<? extends MutableMethodDeclaration>) _declaredMethods);
}
 
Example #23
Source File: MutableJvmAnnotationTypeDeclarationImpl.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public MutableMethodDeclaration findDeclaredMethod(final String name, final TypeReference... parameterTypes) {
  MethodDeclaration _findDeclaredMethod = super.findDeclaredMethod(name, parameterTypes);
  return ((MutableMethodDeclaration) _findDeclaredMethod);
}
 
Example #24
Source File: DeclarationsTest.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void testXtendClassWithMethodFieldAndConstructor() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("package foo");
  _builder.newLine();
  _builder.newLine();
  _builder.append("class MyClass<T extends CharSequence> {");
  _builder.newLine();
  _builder.append("\t");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("String myField");
  _builder.newLine();
  _builder.append("\t");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("new(String initial) {");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("this.myField = initial");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("}");
  _builder.newLine();
  _builder.append("\t");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def <T2 extends CharSequence> MyClass myMethod(T2 a, T b) {");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("myField = myField + a + b");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("return this");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("}");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  final Procedure1<CompilationUnitImpl> _function = (CompilationUnitImpl it) -> {
    Assert.assertEquals("foo", it.getPackageName());
    TypeDeclaration _head = IterableExtensions.head(it.getSourceTypeDeclarations());
    final ClassDeclaration clazz = ((ClassDeclaration) _head);
    final MutableClassDeclaration genClazz = it.getTypeLookup().findClass("foo.MyClass");
    Assert.assertEquals("foo.MyClass", clazz.getQualifiedName());
    Assert.assertNull(clazz.getExtendedClass());
    Assert.assertTrue(IterableExtensions.isEmpty(clazz.getImplementedInterfaces()));
    Assert.assertEquals(3, IterableExtensions.size(clazz.getDeclaredMembers()));
    Assert.assertEquals("T", IterableExtensions.head(clazz.getTypeParameters()).getSimpleName());
    Assert.assertEquals("CharSequence", IterableExtensions.head(IterableExtensions.head(clazz.getTypeParameters()).getUpperBounds()).toString());
    Assert.assertSame(clazz, IterableExtensions.head(clazz.getTypeParameters()).getTypeParameterDeclarator());
    final FieldDeclaration field = IterableExtensions.head(clazz.getDeclaredFields());
    Assert.assertSame(clazz, field.getDeclaringType());
    Assert.assertEquals("myField", field.getSimpleName());
    Assert.assertEquals("String", field.getType().toString());
    Assert.assertFalse(field.isFinal());
    final ConstructorDeclaration constructor = IterableExtensions.head(clazz.getDeclaredConstructors());
    Assert.assertSame(clazz, constructor.getDeclaringType());
    Assert.assertEquals("MyClass", constructor.getSimpleName());
    Assert.assertEquals("initial", IterableExtensions.head(constructor.getParameters()).getSimpleName());
    Assert.assertEquals("String", IterableExtensions.head(constructor.getParameters()).getType().toString());
    final MethodDeclaration method = IterableExtensions.head(clazz.getDeclaredMethods());
    final MutableMethodDeclaration genMethod = IterableExtensions.head(genClazz.getDeclaredMethods());
    Assert.assertSame(clazz, method.getDeclaringType());
    Assert.assertEquals("a", IterableExtensions.head(method.getParameters()).getSimpleName());
    Assert.assertEquals("T2", IterableExtensions.head(method.getParameters()).getType().toString());
    Assert.assertSame(IterableExtensions.head(genMethod.getTypeParameters()), IterableExtensions.head(method.getParameters()).getType().getType());
    Assert.assertEquals("T", (((ParameterDeclaration[])Conversions.unwrapArray(method.getParameters(), ParameterDeclaration.class))[1]).getType().toString());
    Assert.assertSame(IterableExtensions.head(genClazz.getTypeParameters()), (((ParameterDeclaration[])Conversions.unwrapArray(method.getParameters(), ParameterDeclaration.class))[1]).getType().getType());
    Assert.assertSame(genClazz, method.getReturnType().getType());
    Assert.assertEquals("T2", IterableExtensions.head(method.getTypeParameters()).getSimpleName());
    Assert.assertEquals("CharSequence", IterableExtensions.head(IterableExtensions.head(method.getTypeParameters()).getUpperBounds()).toString());
    Assert.assertSame(IterableExtensions.head(method.getTypeParameters()), IterableExtensions.head(method.getTypeParameters()));
    Assert.assertSame(method, IterableExtensions.head(method.getTypeParameters()).getTypeParameterDeclarator());
    Assert.assertSame(field, ((Object[])Conversions.unwrapArray(clazz.getDeclaredMembers(), Object.class))[0]);
    Assert.assertSame(constructor, ((Object[])Conversions.unwrapArray(clazz.getDeclaredMembers(), Object.class))[1]);
    Assert.assertSame(method, ((Object[])Conversions.unwrapArray(clazz.getDeclaredMembers(), Object.class))[2]);
  };
  this.asCompilationUnit(this.validFile(_builder), _function);
}
 
Example #25
Source File: AbstractMethodProcessor.java    From xtext-lib with Eclipse Public License 2.0 4 votes vote down vote up
public void doRegisterGlobals(List<? extends MethodDeclaration> annotatedMethods, RegisterGlobalsContext context) {
	for (MethodDeclaration annotatedMethod : annotatedMethods) {
		doRegisterGlobals(annotatedMethod, context);
	}
}
 
Example #26
Source File: ToStringProcessor.java    From xtext-lib with Eclipse Public License 2.0 4 votes vote down vote up
public boolean hasToString(final ClassDeclaration it) {
  MethodDeclaration _findDeclaredMethod = it.findDeclaredMethod("toString");
  return (_findDeclaredMethod != null);
}
 
Example #27
Source File: DelegateProcessor.java    From xtext-lib with Eclipse Public License 2.0 4 votes vote down vote up
protected TypeReference _getType(final MethodDeclaration it) {
  return it.getReturnType();
}
 
Example #28
Source File: DelegateProcessor.java    From xtext-lib with Eclipse Public License 2.0 4 votes vote down vote up
protected boolean _isValidDelegate(final MethodDeclaration it) {
  return (((this.hasValidType(it) && this.hasValidSignature(it)) && (!this.hasDelegationConflicts(it))) && this.areListedInterfacesValid(it));
}
 
Example #29
Source File: AccessorsProcessor.java    From xtext-lib with Eclipse Public License 2.0 4 votes vote down vote up
public boolean hasSetter(final FieldDeclaration it) {
  MethodDeclaration _findDeclaredMethod = it.getDeclaringType().findDeclaredMethod(this.getSetterName(it), this.orObject(it.getType()));
  return (_findDeclaredMethod != null);
}
 
Example #30
Source File: EqualsHashCodeProcessor.java    From xtext-lib with Eclipse Public License 2.0 4 votes vote down vote up
public boolean hasEquals(final ClassDeclaration it) {
  final Function1<MethodDeclaration, Boolean> _function = (MethodDeclaration it_1) -> {
    return Boolean.valueOf(((Objects.equal(it_1.getSimpleName(), "equals") && (IterableExtensions.size(it_1.getParameters()) == 1)) && Objects.equal(IterableExtensions.head(it_1.getParameters()).getType(), this.context.getObject())));
  };
  return IterableExtensions.exists(it.getDeclaredMethods(), _function);
}