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

The following examples show how to use org.eclipse.xtend.lib.macro.declaration.ResolvedMethod. 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: TracedAccessorsProcessor.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
public String featureName(final ResolvedMethod m) {
  String _xblockexpression = null;
  {
    final String n = m.getDeclaration().getSimpleName();
    int _xifexpression = (int) 0;
    boolean _startsWith = n.startsWith("get");
    if (_startsWith) {
      _xifexpression = 3;
    } else {
      _xifexpression = 2;
    }
    final int skip = _xifexpression;
    _xblockexpression = StringExtensions.toFirstLower(m.getDeclaration().getSimpleName().substring(skip));
  }
  return _xblockexpression;
}
 
Example #2
Source File: TracedAccessorsProcessor.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
public boolean isSupportedGetter(final ResolvedMethod it) {
  boolean _isEmpty = IterableExtensions.isEmpty(it.getDeclaration().getParameters());
  boolean _not = (!_isEmpty);
  if (_not) {
    return false;
  }
  boolean _isStatic = it.getDeclaration().isStatic();
  if (_isStatic) {
    return false;
  }
  final String n = it.getDeclaration().getSimpleName();
  String _qualifiedName = it.getDeclaration().getDeclaringType().getQualifiedName();
  String _name = Object.class.getName();
  boolean _equals = Objects.equal(_qualifiedName, _name);
  if (_equals) {
    return false;
  }
  return (n.startsWith("get") || n.startsWith("is"));
}
 
Example #3
Source File: DelegateProcessor.java    From xtext-lib with Eclipse Public License 2.0 5 votes vote down vote up
public boolean isObjectMethod(final ResolvedMethod it) {
  boolean _xblockexpression = false;
  {
    final String name = it.getDeclaration().getSimpleName();
    final Function1<ResolvedParameter, TypeReference> _function = (ResolvedParameter it_1) -> {
      return it_1.getResolvedType();
    };
    final List<TypeReference> parameterTypes = IterableExtensions.<TypeReference>toList(IterableExtensions.map(it.getResolvedParameters(), _function));
    _xblockexpression = (((((Objects.equal(name, "hashCode") && parameterTypes.isEmpty()) || (Objects.equal(name, "toString") && parameterTypes.isEmpty())) || (Objects.equal(name, "equals") && Objects.equal(parameterTypes, Collections.<TypeReference>unmodifiableList(CollectionLiterals.<TypeReference>newArrayList(this.context.getObject()))))) || (Objects.equal(name, "finalize") && parameterTypes.isEmpty())) || (Objects.equal(name, "clone") && parameterTypes.isEmpty()));
  }
  return _xblockexpression;
}
 
Example #4
Source File: DelegateProcessor.java    From xtext-lib with Eclipse Public License 2.0 5 votes vote down vote up
public String returnIfNeeded(final ResolvedMethod it) {
  String _xifexpression = null;
  boolean _isVoid = it.getResolvedReturnType().isVoid();
  if (_isVoid) {
    _xifexpression = "";
  } else {
    _xifexpression = "return ";
  }
  return _xifexpression;
}
 
Example #5
Source File: DelegateProcessor.java    From xtext-lib with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void doTransform(final List<? extends MutableMemberDeclaration> elements, @Extension final TransformationContext context) {
  @Extension
  final DelegateProcessor.Util util = new DelegateProcessor.Util(context);
  final Consumer<MutableMemberDeclaration> _function = (MutableMemberDeclaration it) -> {
    boolean _isValidDelegate = util.isValidDelegate(it);
    if (_isValidDelegate) {
      final Consumer<ResolvedMethod> _function_1 = (ResolvedMethod method) -> {
        util.implementMethod(it, method);
      };
      util.getMethodsToImplement(it).forEach(_function_1);
    }
  };
  elements.forEach(_function);
}
 
Example #6
Source File: CompilationUnitImpl.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
public ResolvedMethod toResolvedMethod(final IResolvedOperation delegate) {
  final Function1<IResolvedOperation, ResolvedMethodImpl> _function = (IResolvedOperation it) -> {
    ResolvedMethodImpl _resolvedMethodImpl = new ResolvedMethodImpl();
    final Procedure1<ResolvedMethodImpl> _function_1 = (ResolvedMethodImpl it_1) -> {
      it_1.setDelegate(delegate);
      it_1.setCompilationUnit(this);
    };
    return ObjectExtensions.<ResolvedMethodImpl>operator_doubleArrow(_resolvedMethodImpl, _function_1);
  };
  return this.<IResolvedOperation, ResolvedMethodImpl>getOrCreate(delegate, _function);
}
 
Example #7
Source File: TypeReferenceImpl.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Iterable<? extends ResolvedMethod> getDeclaredResolvedMethods() {
  final Function1<IResolvedOperation, ResolvedMethod> _function = (IResolvedOperation it) -> {
    return this.getCompilationUnit().toResolvedMethod(it);
  };
  return ListExtensions.<IResolvedOperation, ResolvedMethod>map(this.getCompilationUnit().getOverrideHelper().getResolvedFeatures(this.getDelegate()).getDeclaredOperations(), _function);
}
 
Example #8
Source File: TypeReferenceImpl.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Iterable<? extends ResolvedMethod> getAllResolvedMethods() {
  final Function1<IResolvedOperation, ResolvedMethod> _function = (IResolvedOperation it) -> {
    return this.getCompilationUnit().toResolvedMethod(it);
  };
  return ListExtensions.<IResolvedOperation, ResolvedMethod>map(this.getCompilationUnit().getOverrideHelper().getResolvedFeatures(this.getDelegate()).getAllOperations(), _function);
}
 
Example #9
Source File: DelegateProcessor.java    From xtext-lib with Eclipse Public License 2.0 4 votes vote down vote up
public boolean isStatic(final ResolvedMethod it) {
  return it.getDeclaration().isStatic();
}
 
Example #10
Source File: InferredTypeReferenceImpl.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
public Iterable<? extends ResolvedMethod> getAllResolvedMethods() {
  return this.throwInferredTypeException("getAllResolvedMethods").getAllResolvedMethods();
}
 
Example #11
Source File: InferredTypeReferenceImpl.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
public Iterable<? extends ResolvedMethod> getDeclaredResolvedMethods() {
  return this.throwInferredTypeException("getDeclaredResolvedMethods").getDeclaredResolvedMethods();
}
 
Example #12
Source File: TracedAccessorsProcessor.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public String tracerName(final ResolvedMethod m) {
  String _featureName = this.featureName(m);
  return ("_" + _featureName);
}