org.eclipse.xtext.xbase.lib.Functions.Function1 Java Examples

The following examples show how to use org.eclipse.xtext.xbase.lib.Functions.Function1. 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: XtendIncrementalBuilderPerformanceTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
public void doTestPerformance(final int max) {
  final Procedure1<BuildRequest> _function = (BuildRequest it) -> {
    final Function1<Integer, URI> _function_1 = (Integer it_1) -> {
      return this.toFile((it_1).intValue(), max);
    };
    it.setDirtyFiles(IterableExtensions.<URI>toList(IterableExtensions.<Integer, URI>map(new IntegerRange(1, max), _function_1)));
  };
  final BuildRequest buildRequest = this.newBuildRequest(_function);
  final Stopwatch sw = Stopwatch.createStarted();
  this.build(buildRequest);
  StringConcatenation _builder = new StringConcatenation();
  _builder.append(max);
  _builder.append(" file took ");
  long _elapsed = sw.elapsed(TimeUnit.MILLISECONDS);
  _builder.append(_elapsed);
  _builder.append(" ms");
  InputOutput.<String>println(_builder.toString());
}
 
Example #2
Source File: DeferredTypeParameterHintCollectorTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
public void hasNoHintsFor(final Map<JvmTypeParameter, LightweightMergedBoundTypeArgument> mapping, final String typeParamName) {
  final Set<JvmTypeParameter> allKeys = mapping.keySet();
  for (final JvmTypeParameter key : allKeys) {
    String _simpleName = key.getSimpleName();
    boolean _equals = Objects.equal(_simpleName, typeParamName);
    if (_equals) {
      LightweightTypeReference _typeReference = mapping.get(key).getTypeReference();
      final UnboundTypeReference unbound = ((UnboundTypeReference) _typeReference);
      boolean _isEmpty = unbound.getAllHints().isEmpty();
      boolean _not = (!_isEmpty);
      if (_not) {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("Unexpected mapping for ");
        _builder.append(typeParamName);
        _builder.append(" in ");
        final Function1<JvmTypeParameter, String> _function = (JvmTypeParameter it) -> {
          return it.getSimpleName();
        };
        Iterable<String> _map = IterableExtensions.<JvmTypeParameter, String>map(mapping.keySet(), _function);
        _builder.append(_map);
        Assert.fail(_builder.toString());
      }
    }
  }
}
 
Example #3
Source File: RequestManagerTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Test(timeout = 1000, expected = ExecutionException.class)
public void testRunReadCatchException() {
  final Runnable _function = () -> {
    try {
      final Function1<CancelIndicator, Object> _function_1 = (CancelIndicator it) -> {
        throw new RuntimeException();
      };
      final CompletableFuture<Object> future = this.requestManager.<Object>runRead(_function_1);
      Assert.assertEquals("Foo", future.get());
    } catch (Throwable _e) {
      throw Exceptions.sneakyThrow(_e);
    }
  };
  LoggingTester.captureLogging(Level.ALL, ReadRequest.class, _function);
  Assert.fail();
}
 
Example #4
Source File: JdtFindReferencesTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testClassJavaElements() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Xtend {");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final XtendTypeDeclaration clazz = IterableExtensions.<XtendTypeDeclaration>head(this._workbenchTestHelper.xtendFile("Xtend.xtend", _builder.toString()).getXtendTypes());
    IResourcesSetupUtil.waitForBuild();
    Iterable<IJavaElement> _javaElements = this._jvmModelFindReferenceHandler.getJavaElements(clazz);
    final Procedure1<Iterable<IJavaElement>> _function = (Iterable<IJavaElement> it) -> {
      Assert.assertEquals(1, IterableExtensions.size(it));
      final Function1<IJavaElement, Boolean> _function_1 = (IJavaElement it_1) -> {
        return Boolean.valueOf(((it_1 instanceof IType) && Objects.equal(((IType) it_1).getElementName(), "Xtend")));
      };
      Assert.assertTrue(IterableExtensions.<IJavaElement>exists(it, _function_1));
    };
    ObjectExtensions.<Iterable<IJavaElement>>operator_doubleArrow(_javaElements, _function);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #5
Source File: JvmAnnotationReferenceImpl.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public Expression getExpression(final String property) {
  final JvmOperation op = this.findOperation(property);
  final Function1<JvmAnnotationValue, Boolean> _function = (JvmAnnotationValue it) -> {
    return Boolean.valueOf((Objects.equal(it.getOperation(), op) || ((it.getOperation() == null) && Objects.equal(op.getSimpleName(), "value"))));
  };
  final JvmAnnotationValue annotationValue = IterableExtensions.<JvmAnnotationValue>findFirst(this.getDelegate().getValues(), _function);
  boolean _matched = false;
  if (annotationValue instanceof JvmCustomAnnotationValue) {
    _matched=true;
    EObject _head = IterableExtensions.<EObject>head(((JvmCustomAnnotationValue)annotationValue).getValues());
    final XExpression expression = ((XExpression) _head);
    if (((expression != null) && this.getCompilationUnit().isBelongedToCompilationUnit(expression))) {
      return this.getCompilationUnit().toExpression(expression);
    }
  }
  return null;
}
 
Example #6
Source File: ResourceMoveTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
protected void performMove(final IContainer theDestination, final IResource... theResources) {
  try {
    MoveResourcesDescriptor _moveResourcesDescriptor = new MoveResourcesDescriptor();
    final Procedure1<MoveResourcesDescriptor> _function = (MoveResourcesDescriptor it) -> {
      final Function1<IResource, IPath> _function_1 = (IResource it_1) -> {
        return it_1.getFullPath();
      };
      it.setResourcePathsToMove(((IPath[])Conversions.unwrapArray(ListExtensions.<IResource, IPath>map(((List<IResource>)Conversions.doWrapArray(theResources)), _function_1), IPath.class)));
      it.setDestinationPath(theDestination.getFullPath());
    };
    MoveResourcesDescriptor _doubleArrow = ObjectExtensions.<MoveResourcesDescriptor>operator_doubleArrow(_moveResourcesDescriptor, _function);
    this.performRefactoring(_doubleArrow);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #7
Source File: XbaseFormatter2.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
protected void _format(final XFeatureCall expr, final FormattableDocument format) {
  this.formatFeatureCallTypeParameters(expr, format);
  boolean _isExplicitOperationCall = expr.isExplicitOperationCall();
  if (_isExplicitOperationCall) {
    final ILeafNode open = this._nodeModelAccess.nodeForKeyword(expr, "(");
    final Procedure1<FormattingDataInit> _function = (FormattingDataInit it) -> {
      it.noSpace();
    };
    Function1<? super FormattableDocument, ? extends Iterable<FormattingData>> _prepend = this._formattingDataFactory.prepend(open, _function);
    format.operator_add(_prepend);
    boolean _isMultiParamInOwnLine = this.isMultiParamInOwnLine(expr, format);
    if (_isMultiParamInOwnLine) {
      this.formatFeatureCallParamsMultiline(open, expr.getFeatureCallArguments(), format);
    } else {
      this.formatFeatureCallParamsWrapIfNeeded(open, expr.getFeatureCallArguments(), format);
    }
  } else {
    EList<XExpression> _featureCallArguments = expr.getFeatureCallArguments();
    for (final XExpression arg : _featureCallArguments) {
      this.format(arg, format);
    }
  }
}
 
Example #8
Source File: JvmModelGenerator.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
protected Iterable<JvmMember> _getMembersToBeCompiled(final JvmEnumerationType type) {
  Iterable<JvmMember> _xblockexpression = null;
  {
    String _identifier = type.getIdentifier();
    String _plus = (_identifier + ".");
    String _plus_1 = (_plus + "valueOf(java.lang.String)");
    String _identifier_1 = type.getIdentifier();
    String _plus_2 = (_identifier_1 + ".");
    String _plus_3 = (_plus_2 + "values()");
    final Set<String> syntheticEnumMethods = Collections.<String>unmodifiableSet(CollectionLiterals.<String>newHashSet(_plus_1, _plus_3));
    final Function1<JvmMember, Boolean> _function = (JvmMember it) -> {
      return Boolean.valueOf((!((it instanceof JvmOperation) && syntheticEnumMethods.contains(it.getIdentifier()))));
    };
    _xblockexpression = IterableExtensions.<JvmMember>filter(type.getMembers(), _function);
  }
  return _xblockexpression;
}
 
Example #9
Source File: Solution_023.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
public static boolean isAbundant(final int input) {
  final int sqrt = Double.valueOf(Math.floor(Math.sqrt(input))).intValue();
  final Function1<Integer, Boolean> _function = (Integer div) -> {
    return Boolean.valueOf((((div).intValue() != input) && ((input % (div).intValue()) == 0)));
  };
  final Function2<Integer, Integer, Integer> _function_1 = (Integer i1, Integer i2) -> {
    int _xblockexpression = (int) 0;
    {
      final int other = (input / (i2).intValue());
      int _xifexpression = (int) 0;
      if (((other != (i2).intValue()) && (other != input))) {
        _xifexpression = (((i1).intValue() + (i2).intValue()) + other);
      } else {
        _xifexpression = ((i1).intValue() + (i2).intValue());
      }
      _xblockexpression = _xifexpression;
    }
    return Integer.valueOf(_xblockexpression);
  };
  final Integer sumOfDivisors = IterableExtensions.<Integer, Integer>fold(IterableExtensions.<Integer>filter(new IntegerRange(2, sqrt), _function), Integer.valueOf(1), _function_1);
  return ((sumOfDivisors).intValue() > input);
}
 
Example #10
Source File: QuickfixTestBuilder.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
public QuickfixTestBuilder assertModelAfterQuickfix(final CharSequence expectedModel) {
  QuickfixTestBuilder _xblockexpression = null;
  {
    final Function1<Issue, List<IssueResolution>> _function = (Issue it) -> {
      return this._issueResolutionProvider.getResolutions(it);
    };
    final List<IssueResolution> resolutions = IterableExtensions.<IssueResolution>toList(Iterables.<IssueResolution>concat(IterableExtensions.<Issue, List<IssueResolution>>map(this.getIssuesAtCaret(), _function)));
    final String originalModel = this.editor.getDocument().get();
    final IssueResolution resolution = IterableExtensions.<IssueResolution>head(resolutions);
    Assert.assertNotNull(resolution);
    resolution.apply();
    Assert.assertEquals(expectedModel.toString(), this.editor.getDocument().get());
    this.editor.getDocument().set(originalModel);
    this._syncUtil.waitForReconciler(this.editor);
    _xblockexpression = this;
  }
  return _xblockexpression;
}
 
Example #11
Source File: LiveShadowedChunkedContainerTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testDeleteElement() {
  try {
    this._parseHelper.parse("foo", this.fooURI, this.rs1).eResource().getContents().clear();
    final Function1<IEObjectDescription, String> _function = (IEObjectDescription it) -> {
      return it.getQualifiedName().toString();
    };
    Assert.assertEquals("", IterableExtensions.join(IterableExtensions.<IEObjectDescription, String>map(this.fooContainer.getExportedObjects(), _function), ","));
    Assert.assertEquals(1, IterableExtensions.size(this.fooContainer.getResourceDescriptions()));
    Assert.assertEquals(1, this.fooContainer.getResourceDescriptionCount());
    Assert.assertEquals(0, IterableExtensions.size(this.fooContainer.getExportedObjects()));
    Assert.assertEquals(1, IterableExtensions.size(this.barContainer.getResourceDescriptions()));
    Assert.assertEquals(1, this.barContainer.getResourceDescriptionCount());
    this.assertGlobalDescriptionsAreUnaffected();
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #12
Source File: Solution_021.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
public static Integer sumOfDivisors(final int input) {
  Integer _xblockexpression = null;
  {
    final int sqrt = Double.valueOf(Math.floor(Math.sqrt(input))).intValue();
    final Function1<Integer, Boolean> _function = (Integer div) -> {
      return Boolean.valueOf(((input % (div).intValue()) == 0));
    };
    final Function2<Integer, Integer, Integer> _function_1 = (Integer i1, Integer i2) -> {
      int _xblockexpression_1 = (int) 0;
      {
        final int other = (input / (i2).intValue());
        int _xifexpression = (int) 0;
        if ((other != (i2).intValue())) {
          _xifexpression = (((i1).intValue() + (i2).intValue()) + other);
        } else {
          _xifexpression = ((i1).intValue() + (i2).intValue());
        }
        _xblockexpression_1 = _xifexpression;
      }
      return Integer.valueOf(_xblockexpression_1);
    };
    _xblockexpression = IterableExtensions.<Integer, Integer>fold(IterableExtensions.<Integer>filter(new IntegerRange(2, sqrt), _function), Integer.valueOf(1), _function_1);
  }
  return _xblockexpression;
}
 
Example #13
Source File: GrammarPDAProviderTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
private void assertNoLeakedGrammarElements(final Grammar grammar, final Pda<ISerState, RuleCall> pda) {
  final Function1<ISerState, AbstractElement> _function = (ISerState it) -> {
    return it.getGrammarElement();
  };
  Iterable<AbstractElement> _filterNull = IterableExtensions.<AbstractElement>filterNull(IterableExtensions.<ISerState, AbstractElement>map(new NfaUtil().<ISerState>collect(pda), _function));
  for (final AbstractElement ele : _filterNull) {
    {
      final Grammar actual = GrammarUtil.getGrammar(ele);
      if ((actual != grammar)) {
        String _objPath = EmfFormatter.objPath(ele);
        String _plus = ("Element " + _objPath);
        String _plus_1 = (_plus + " leaked!");
        Assert.fail(_plus_1);
      }
    }
  }
}
 
Example #14
Source File: RebuildAffectedResourcesTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
public void assertHasErrors(final IFile file, final String msgPart) {
  try {
    final IMarker[] findMarkers = file.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
    for (final IMarker iMarker : findMarkers) {
      if (((MarkerUtilities.getSeverity(iMarker) == IMarker.SEVERITY_ERROR) && MarkerUtilities.getMessage(iMarker).contains(msgPart))) {
        return;
      }
    }
    IPath _fullPath = file.getFullPath();
    String _plus = ((("Expected an error marker containing \'" + msgPart) + "\' on ") + _fullPath);
    String _plus_1 = (_plus + " but found ");
    final Function1<IMarker, String> _function = (IMarker it) -> {
      return MarkerUtilities.getMessage(it);
    };
    String _join = IterableExtensions.join(ListExtensions.<IMarker, String>map(((List<IMarker>)Conversions.doWrapArray(findMarkers)), _function), ",");
    String _plus_2 = (_plus_1 + _join);
    Assert.fail(_plus_2);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #15
Source File: CommonSuperTypeTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
public String getEquivalent(final ParameterizedTypeReference type) {
  boolean _isEmpty = type.getTypeArguments().isEmpty();
  if (_isEmpty) {
    return type.getType().getSimpleName();
  }
  StringConcatenation _builder = new StringConcatenation();
  String _simpleName = type.getType().getSimpleName();
  _builder.append(_simpleName);
  _builder.append("<");
  final Function1<LightweightTypeReference, CharSequence> _function = (LightweightTypeReference it) -> {
    return it.getSimpleName();
  };
  String _join = IterableExtensions.<LightweightTypeReference>join(type.getTypeArguments(), ", ", _function);
  _builder.append(_join);
  _builder.append(">");
  return _builder.toString();
}
 
Example #16
Source File: TypeLookupImpl.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
private <T extends Object> T recursiveFindType(final String qualifiedName, final Iterable<? extends T> typeDeclarations, final Function1<? super T, ? extends String> qualifiedNameProvider, final Function1<? super T, ? extends Iterable<? extends T>> subTypeProvider) {
  final char dot = '.';
  for (final T type : typeDeclarations) {
    {
      final String name = qualifiedNameProvider.apply(type);
      boolean _equals = Objects.equal(qualifiedName, name);
      if (_equals) {
        return type;
      }
      if ((qualifiedName.startsWith(name) && (qualifiedName.charAt(name.length()) == dot))) {
        return this.<T>recursiveFindType(qualifiedName, subTypeProvider.apply(type), qualifiedNameProvider, subTypeProvider);
      }
    }
  }
  return null;
}
 
Example #17
Source File: IteratorExtensionsTest.java    From xtext-lib with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testToMap() {
	List<Pair<Integer, String>> pairs = new ArrayList<Pair<Integer, String>>();
	pairs.add(new Pair<Integer, String>(1, "A"));
	pairs.add(new Pair<Integer, String>(1, "a"));
	pairs.add(new Pair<Integer, String>(2, "B"));
	pairs.add(new Pair<Integer, String>(2, "b"));
	Function1<Pair<Integer, String>, Integer> computeKeys = new Function1<Pair<Integer, String>, Integer>() {

		@Override
		public Integer apply(Pair<Integer, String> p) {
			return p.getKey();
		}
	};
	Map<Integer, Pair<Integer, String>> map = IteratorExtensions.toMap(pairs.iterator(), computeKeys);
	Assert.assertEquals("Expected grouped map size", 2, map.size());
	Assert.assertTrue("Contains 1 as key", map.keySet().contains(1));
	Assert.assertEquals("Contains entry 1->a for key 1", map.get(1), new Pair<Integer, String>(1, "a"));
	Assert.assertTrue("Contains 2 as key", map.keySet().contains(2));
	Assert.assertEquals("Contains entry 2->b for key 2", map.get(2), new Pair<Integer, String>(2, "b"));
}
 
Example #18
Source File: JvmTypeDeclarationImpl.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
public FieldDeclaration findDeclaredField(final String name) {
  final Function1<FieldDeclaration, Boolean> _function = (FieldDeclaration field) -> {
    String _simpleName = field.getSimpleName();
    return Boolean.valueOf(Objects.equal(_simpleName, name));
  };
  return IterableExtensions.findFirst(this.getDeclaredFields(), _function);
}
 
Example #19
Source File: DelegateCompilerTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testDelegateField() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import org.eclipse.xtend.lib.annotations.Delegate");
    _builder.newLine();
    _builder.append("interface A {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def void m()");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("class B implements A {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("override m() {}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("class C implements A{");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("@Delegate B delegate");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final String text = _builder.toString();
    this._validationTestHelper.assertNoIssues(this.file(text));
    final IAcceptor<CompilationTestHelper.Result> _function = (CompilationTestHelper.Result it) -> {
      final Function1<Method, Boolean> _function_1 = (Method it_1) -> {
        return Boolean.valueOf(((Objects.equal(it_1.getName(), "m") && ((List<Class<?>>)Conversions.doWrapArray(it_1.getParameterTypes())).isEmpty()) && Objects.equal(it_1.getReturnType(), void.class)));
      };
      Assert.assertTrue(IterableExtensions.<Method>exists(((Iterable<Method>)Conversions.doWrapArray(it.getCompiledClass().getDeclaredMethods())), _function_1));
    };
    this.compilationTestHelper.compile(text, _function);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #20
Source File: DirtyStateEditorSupportTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
private List<Annotation> getErrorAnnotations(final XtextEditor editor) {
  final Function1<Annotation, Boolean> _function = (Annotation it) -> {
    String _type = it.getType();
    return Boolean.valueOf(Objects.equal(_type, "org.eclipse.xtext.ui.editor.error"));
  };
  return IteratorExtensions.<Annotation>toList(IteratorExtensions.<Annotation>filter(Iterators.<Annotation>filter(editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput()).getAnnotationIterator(), Annotation.class), _function));
}
 
Example #21
Source File: Ecore2XtextExtensions.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
public static Iterable<EStructuralFeature> inlinedFeatures(final EClass it) {
  final Function1<EStructuralFeature, Boolean> _function = (EStructuralFeature f) -> {
    return Boolean.valueOf(Ecore2XtextExtensions.needsAssignment(f));
  };
  final List<EStructuralFeature> features = IterableExtensions.<EStructuralFeature>toList(IterableExtensions.<EStructuralFeature>filter(it.getEAllStructuralFeatures(), _function));
  features.remove(Ecore2XtextExtensions.idAttribute(it));
  features.removeAll(IterableExtensions.<EStructuralFeature>toList(Ecore2XtextExtensions.prefixFeatures(it)));
  return features;
}
 
Example #22
Source File: EqualsHashCodeProcessor.java    From xtext-lib with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void doTransform(final MutableClassDeclaration it, @Extension final TransformationContext context) {
  AnnotationReference _findAnnotation = it.findAnnotation(context.findTypeGlobally(Data.class));
  boolean _tripleNotEquals = (_findAnnotation != null);
  if (_tripleNotEquals) {
    return;
  }
  @Extension
  final EqualsHashCodeProcessor.Util util = new EqualsHashCodeProcessor.Util(context);
  boolean _hasEquals = util.hasEquals(it);
  if (_hasEquals) {
    final AnnotationReference annotation = it.findAnnotation(context.findTypeGlobally(EqualsHashCode.class));
    context.addWarning(annotation, "equals is already defined, this annotation has no effect");
  } else {
    boolean _hasHashCode = util.hasHashCode(it);
    if (_hasHashCode) {
      context.addWarning(it, "hashCode is already defined, this annotation has no effect");
    } else {
      final Function1<MutableFieldDeclaration, Boolean> _function = (MutableFieldDeclaration it_1) -> {
        return Boolean.valueOf((((!it_1.isStatic()) && (!it_1.isTransient())) && context.isThePrimaryGeneratedJavaElement(it_1)));
      };
      final Iterable<? extends MutableFieldDeclaration> fields = IterableExtensions.filter(it.getDeclaredFields(), _function);
      util.addEquals(it, fields, util.hasSuperEquals(it));
      util.addHashCode(it, fields, util.hasSuperHashCode(it));
    }
  }
}
 
Example #23
Source File: XtendMethodDeclarationImpl.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Iterable<? extends ParameterDeclaration> getParameters() {
  final Function1<XtendParameter, XtendParameterDeclarationImpl> _function = (XtendParameter it) -> {
    return this.getCompilationUnit().toXtendParameterDeclaration(it);
  };
  return ListExtensions.<XtendParameter, XtendParameterDeclarationImpl>map(this.getDelegate().getParameters(), _function);
}
 
Example #24
Source File: XbaseFormatter2.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected void _format(final JvmTypeParameter ref, final FormattableDocument document) {
  EList<JvmTypeConstraint> _constraints = ref.getConstraints();
  for (final JvmTypeConstraint c : _constraints) {
    {
      final Procedure1<FormattingDataInit> _function = (FormattingDataInit it) -> {
        it.oneSpace();
      };
      Function1<? super FormattableDocument, ? extends Iterable<FormattingData>> _prepend = this._formattingDataFactory.prepend(this._nodeModelAccess.nodeForEObject(c), _function);
      document.operator_add(_prepend);
      this.format(c, document);
    }
  }
}
 
Example #25
Source File: N4GetterDeclarationImpl.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public boolean isAbstract() {
	return ((((this.eContainer() instanceof N4InterfaceDeclaration) && (this.getBody() == null)) && 
		(!IterableExtensions.<Annotation>exists(this.getAnnotations(), new Function1<Annotation, Boolean>() {
			public Boolean apply(final Annotation it) {
				String _name = it.getName();
				return Boolean.valueOf(Objects.equal(_name, "ProvidesDefaultImplementation"));
			}
		}))) || this.isDeclaredAbstract());
}
 
Example #26
Source File: BuildContext.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Run the given logic on all uris with clustering enabled.
 */
public <T> Iterable<T> executeClustered(Iterable<URI> uris, Function1<? super Resource, ? extends T> operation) {
	if (loader == null) {
		loader = new ClusteringStorageAwareResourceLoader(this);
	}
	return loader.executeClustered(Iterables.filter(uris, this::canHandle), operation);
}
 
Example #27
Source File: XbaseFormatter2.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected void _format(final JvmTypeConstraint constraint, final FormattableDocument document) {
  final Procedure1<FormattingDataInit> _function = (FormattingDataInit it) -> {
    it.oneSpace();
  };
  Function1<? super FormattableDocument, ? extends Iterable<FormattingData>> _prepend = this._formattingDataFactory.prepend(this._nodeModelAccess.nodeForFeature(constraint, TypesPackage.Literals.JVM_TYPE_CONSTRAINT__TYPE_REFERENCE), _function);
  document.operator_add(_prepend);
  this.format(constraint.getTypeReference(), document);
}
 
Example #28
Source File: ServerTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testIncrementalBuildWithError() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("type Test {");
  _builder.newLine();
  _builder.append("    ");
  _builder.append("NonExisting foo");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  this.writeFile("MyType1.testlang", _builder);
  this.initialize();
  this.assertEquals("Couldn\'t resolve reference to TypeDeclaration \'NonExisting\'.", IterableExtensions.<Diagnostic>head(IterableExtensions.<List<Diagnostic>>head(this.getDiagnostics().values())).getMessage());
  StringConcatenation _builder_1 = new StringConcatenation();
  _builder_1.append("type NonExisting {");
  _builder_1.newLine();
  _builder_1.append("}");
  _builder_1.newLine();
  final String path = this.writeFile("MyType2.testlang", _builder_1);
  WorkspaceService _workspaceService = this.languageServer.getWorkspaceService();
  FileEvent _fileEvent = new FileEvent(path, FileChangeType.Created);
  DidChangeWatchedFilesParams _didChangeWatchedFilesParams = new DidChangeWatchedFilesParams(Collections.<FileEvent>unmodifiableList(CollectionLiterals.<FileEvent>newArrayList(_fileEvent)));
  _workspaceService.didChangeWatchedFiles(_didChangeWatchedFilesParams);
  Assert.assertNotNull(this.getDiagnostics().get(path));
  final Function1<List<Diagnostic>, Boolean> _function = (List<Diagnostic> it) -> {
    return Boolean.valueOf(it.isEmpty());
  };
  Assert.assertTrue(IterableExtensions.join(this.getDiagnostics().values(), ","), IterableExtensions.<List<Diagnostic>>forall(this.getDiagnostics().values(), _function));
}
 
Example #29
Source File: JvmInterfaceDeclarationImpl.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Iterable<? extends TypeParameterDeclaration> getTypeParameters() {
  final Function1<JvmTypeParameter, TypeParameterDeclaration> _function = (JvmTypeParameter it) -> {
    return this.getCompilationUnit().toTypeParameterDeclaration(it);
  };
  return ListExtensions.<JvmTypeParameter, TypeParameterDeclaration>map(this.getDelegate().getTypeParameters(), _function);
}
 
Example #30
Source File: ASTFlattenerUtils.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
public Iterable<Expression> findAssignmentsInBlock(final Block scope, final VariableDeclaration varDecl) {
  final Function1<Expression, Boolean> _function = (Expression it) -> {
    Expression name = null;
    boolean _matched = false;
    if (it instanceof Assignment) {
      _matched=true;
      name = ((Assignment)it).getLeftHandSide();
    }
    if (!_matched) {
      if (it instanceof PrefixExpression) {
        _matched=true;
        name = ((PrefixExpression)it).getOperand();
      }
    }
    if (!_matched) {
      if (it instanceof PostfixExpression) {
        _matched=true;
        name = ((PostfixExpression)it).getOperand();
      }
    }
    if ((name instanceof Name)) {
      final IBinding binding = ((Name)name).resolveBinding();
      if ((binding instanceof IVariableBinding)) {
        final IVariableBinding declBinding = varDecl.resolveBinding();
        return Boolean.valueOf((varDecl.getName().getIdentifier().equals(this.toSimpleName(((Name)name))) && ((IVariableBinding)binding).equals(declBinding)));
      }
    }
    return Boolean.valueOf(false);
  };
  return this.findAssignmentsInBlock(scope, _function);
}