Java Code Examples for org.eclipse.xtext.xbase.lib.CollectionLiterals#newHashSet()

The following examples show how to use org.eclipse.xtext.xbase.lib.CollectionLiterals#newHashSet() . 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: Solution_021.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
public static void main(final String[] args) {
  HashSet<Integer> result = CollectionLiterals.<Integer>newHashSet();
  final int max = 10000;
  IntegerRange _upTo = new IntegerRange(1, max);
  for (final Integer i : _upTo) {
    boolean _contains = result.contains(i);
    boolean _not = (!_contains);
    if (_not) {
      final Integer sumOfDivisors = Solution_021.sumOfDivisors((i).intValue());
      if (((!Objects.equal(sumOfDivisors, i)) && ((sumOfDivisors).intValue() <= max))) {
        final Integer otherSumOfDivisors = Solution_021.sumOfDivisors((sumOfDivisors).intValue());
        boolean _equals = Objects.equal(otherSumOfDivisors, i);
        if (_equals) {
          result.add(i);
          result.add(sumOfDivisors);
        }
      }
    }
  }
  final Function2<Integer, Integer, Integer> _function = (Integer i1, Integer i2) -> {
    return Integer.valueOf(((i1).intValue() + (i2).intValue()));
  };
  InputOutput.<Integer>println(IterableExtensions.<Integer>reduce(result, _function));
}
 
Example 2
Source File: QuickfixTestBuilder.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
public void setSeverity(final String issueCode, final String severity) {
  if ((this.modifiedIssueCodes == null)) {
    this.modifiedIssueCodes = CollectionLiterals.<String>newHashSet();
  }
  this.modifiedIssueCodes.add(issueCode);
  this.getPreferenceStore().setValue(issueCode, "error");
}
 
Example 3
Source File: EMFGeneratorFragment2.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
protected Set<EPackage> getReferencedEPackages(final List<EPackage> packs) {
  final HashSet<EPackage> result = CollectionLiterals.<EPackage>newHashSet();
  for (final EPackage pkg : packs) {
    {
      final TreeIterator<EObject> iterator = pkg.eAllContents();
      while (iterator.hasNext()) {
        {
          final EObject obj = iterator.next();
          EList<EObject> _eCrossReferences = obj.eCrossReferences();
          for (final EObject crossRef : _eCrossReferences) {
            boolean _eIsProxy = crossRef.eIsProxy();
            if (_eIsProxy) {
              URI _eProxyURI = ((InternalEObject) crossRef).eProxyURI();
              String _plus = ("Proxy \'" + _eProxyURI);
              String _plus_1 = (_plus + "\' could not be resolved");
              EMFGeneratorFragment2.LOG.error(_plus_1);
            } else {
              final EPackage p = EcoreUtil2.<EPackage>getContainerOfType(crossRef, EPackage.class);
              if ((p != null)) {
                result.add(p);
              }
            }
          }
        }
      }
    }
  }
  result.removeAll(packs);
  result.remove(EcorePackage.eINSTANCE);
  result.remove(XMLTypePackage.eINSTANCE);
  result.remove(XMLNamespacePackage.eINSTANCE);
  return result;
}
 
Example 4
Source File: ValidatorFragment2.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @since 2.14
 */
protected List<AbstractRule> getDeprecatedRulesFromGrammar() {
  final HashSet<EClassifier> alreadyCollected = CollectionLiterals.<EClassifier>newHashSet();
  final Function1<AbstractRule, Boolean> _function = (AbstractRule it) -> {
    return Boolean.valueOf((this.isDeprecated(it) && alreadyCollected.add(it.getType().getClassifier())));
  };
  return IterableExtensions.<AbstractRule>toList(IterableExtensions.<AbstractRule>filter(this.getGrammar().getRules(), _function));
}
 
Example 5
Source File: Declarators.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
public Declarators.DeclaratorsData getDeclaratorData(final TargetURIs targetURIs, final IReferenceFinder.IResourceAccess resourceAccess) {
  Declarators.DeclaratorsData result = targetURIs.<Declarators.DeclaratorsData>getUserData(Declarators.KEY);
  if ((result != null)) {
    return result;
  }
  final HashSet<QualifiedName> declaratorNames = CollectionLiterals.<QualifiedName>newHashSet();
  final Consumer<URI> _function = (URI uri) -> {
    final IUnitOfWork<Object, ResourceSet> _function_1 = (ResourceSet it) -> {
      Object _xblockexpression = null;
      {
        final Consumer<URI> _function_2 = (URI objectURI) -> {
          final EObject object = it.getEObject(objectURI, true);
          if ((object != null)) {
            final JvmType type = EcoreUtil2.<JvmType>getContainerOfType(object, JvmType.class);
            if ((type != null)) {
              QualifiedName _lowerCase = this.nameConverter.toQualifiedName(type.getIdentifier()).toLowerCase();
              declaratorNames.add(_lowerCase);
              QualifiedName _lowerCase_1 = this.nameConverter.toQualifiedName(type.getQualifiedName('.')).toLowerCase();
              declaratorNames.add(_lowerCase_1);
            }
          }
        };
        targetURIs.getEObjectURIs(uri).forEach(_function_2);
        _xblockexpression = null;
      }
      return _xblockexpression;
    };
    resourceAccess.<Object>readOnly(uri, _function_1);
  };
  targetURIs.getTargetResourceURIs().forEach(_function);
  Declarators.DeclaratorsData _declaratorsData = new Declarators.DeclaratorsData(declaratorNames);
  result = _declaratorsData;
  targetURIs.<Declarators.DeclaratorsData>putUserData(Declarators.KEY, result);
  return result;
}
 
Example 6
Source File: DefaultXtendOutlineContext.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public IXtendOutlineContext newContext() {
  DefaultXtendOutlineContext _cloneContext = this.cloneContext();
  final Procedure1<DefaultXtendOutlineContext> _function = (DefaultXtendOutlineContext it) -> {
    it.processedMembers = CollectionLiterals.<JvmMember>newHashSet();
  };
  return ObjectExtensions.<DefaultXtendOutlineContext>operator_doubleArrow(_cloneContext, _function);
}
 
Example 7
Source File: SemanticSequencerExtensions.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
public List<ISemanticSequencerNfaProvider.ISemState> getLinearListOfMandatoryAssignments(final IGrammarConstraintProvider.IConstraint constraint) {
  final Nfa<ISemanticSequencerNfaProvider.ISemState> nfa = constraint.getNfa();
  ISemanticSequencerNfaProvider.ISemState state = nfa.getStart();
  final List<ISemanticSequencerNfaProvider.ISemState> result = CollectionLiterals.<ISemanticSequencerNfaProvider.ISemState>newArrayList();
  final Set<EStructuralFeature> features = CollectionLiterals.<EStructuralFeature>newHashSet();
  while ((state != null)) {
    {
      ISemanticSequencerNfaProvider.ISemState _stop = nfa.getStop();
      boolean _tripleEquals = (state == _stop);
      if (_tripleEquals) {
        List<ISemanticSequencerNfaProvider.ISemState> _xifexpression = null;
        boolean _isEmpty = result.isEmpty();
        if (_isEmpty) {
          _xifexpression = null;
        } else {
          _xifexpression = result;
        }
        return _xifexpression;
      }
      int _size = state.getFollowers().size();
      boolean _tripleNotEquals = (_size != 1);
      if (_tripleNotEquals) {
        return null;
      }
      ISemanticSequencerNfaProvider.ISemState _start = nfa.getStart();
      boolean _tripleNotEquals_1 = (state != _start);
      if (_tripleNotEquals_1) {
        final EStructuralFeature feature = state.getFeature();
        if ((((feature == null) || feature.isMany()) || (!features.add(feature)))) {
          return null;
        }
        result.add(state);
      }
      state = IterableExtensions.<ISemanticSequencerNfaProvider.ISemState>head(state.getFollowers());
    }
  }
  return null;
}
 
Example 8
Source File: AbstractQueuedBuildDataTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
public Collection<? extends IResourceDescription.Delta> assertThereAreDeltas(final Collection<? extends IResourceDescription.Delta> deltas, final String... expectedExportedNames) {
  Collection<? extends IResourceDescription.Delta> _xblockexpression = null;
  {
    int _size = deltas.size();
    boolean _notEquals = (0 != _size);
    Assert.assertTrue("There are not deltas", _notEquals);
    int _length = expectedExportedNames.length;
    boolean _notEquals_1 = (_length != 0);
    if (_notEquals_1) {
      final HashSet<String> remainingExportedNames = CollectionLiterals.<String>newHashSet(expectedExportedNames);
      final HashSet<String> unexpectedExportedNames = CollectionLiterals.<String>newHashSet();
      HashSet<String> _exportedNames = this.getExportedNames(deltas);
      for (final String exportedName : _exportedNames) {
        {
          final Function1<String, Boolean> _function = (String it) -> {
            return Boolean.valueOf(Objects.equal(exportedName, it));
          };
          final String qualifiedName = IterableExtensions.<String>findFirst(((Iterable<String>)Conversions.doWrapArray(expectedExportedNames)), _function);
          if ((qualifiedName == null)) {
            unexpectedExportedNames.add(exportedName);
          } else {
            remainingExportedNames.remove(qualifiedName);
          }
        }
      }
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("There are unexpected exported names: ");
      _builder.append(unexpectedExportedNames);
      Assert.assertEquals(_builder.toString(), 0, 
        ((Object[])Conversions.unwrapArray(unexpectedExportedNames, Object.class)).length);
      StringConcatenation _builder_1 = new StringConcatenation();
      _builder_1.append("There are not expected exported names ");
      _builder_1.append(remainingExportedNames);
      Assert.assertEquals(_builder_1.toString(), 0, 
        ((Object[])Conversions.unwrapArray(remainingExportedNames, Object.class)).length);
    }
    _xblockexpression = deltas;
  }
  return _xblockexpression;
}
 
Example 9
Source File: SyntacticSequencerExtensions.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
protected String elementAliasToIdentifier(final GrammarAlias.AbstractElementAlias alias) {
  final Set<String> rulesSet = CollectionLiterals.<String>newHashSet();
  final String body = this.elementAliasToIdentifier(alias, rulesSet, false);
  final List<String> rulesList = CollectionLiterals.<String>newArrayList(((String[])Conversions.unwrapArray(rulesSet, String.class)));
  ListExtensions.<String>sortInplace(rulesList);
  final String rule = IterableExtensions.join(rulesList, "_");
  return ((rule + "_") + body);
}
 
Example 10
Source File: SwitchConstantExpressionsInterpreter.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
public Object evaluate(final XExpression it, final boolean validationMode) {
  Object _xblockexpression = null;
  {
    HashSet<XExpression> _newHashSet = CollectionLiterals.<XExpression>newHashSet();
    final SwitchConstantExpressionsInterpreter.SwitchContext ctx = new SwitchConstantExpressionsInterpreter.SwitchContext(null, null, null, _newHashSet);
    ctx.validationMode = validationMode;
    _xblockexpression = this.evaluate(it, ctx);
  }
  return _xblockexpression;
}
 
Example 11
Source File: AbstractConstructorCallTypeTest.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@BeforeClass
public static void createSeenExpressionsSet() {
  AbstractConstructorCallTypeTest.seenExpressions = CollectionLiterals.<String>newHashSet();
}
 
Example 12
Source File: SwitchConstantExpressionsInterpreter.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
public Object evaluate(final XExpression it) {
  HashSet<XExpression> _newHashSet = CollectionLiterals.<XExpression>newHashSet();
  Context _context = new Context(null, null, null, _newHashSet);
  return this.evaluate(it, _context);
}
 
Example 13
Source File: AbstractTypeArgumentTest.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@BeforeClass
public static void createSeenExpressionsSet() {
  AbstractTypeArgumentTest.seenExpressions = CollectionLiterals.<String>newHashSet();
}
 
Example 14
Source File: AbstractClosureTypeTest.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@BeforeClass
public static void createSeenExpressionsSet() {
  AbstractClosureTypeTest.seenExpressions = CollectionLiterals.<String>newHashSet();
}
 
Example 15
Source File: MockTypeParameterSubstitutor.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected Set<JvmTypeParameter> createVisiting() {
  return CollectionLiterals.<JvmTypeParameter>newHashSet();
}
 
Example 16
Source File: SynonmyTypesTest.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
public void hasSynonyms(final Pair<String, String> typeAndTypeParams, final String... expectedSynonyms) {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("def ");
    {
      boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(typeAndTypeParams.getValue());
      boolean _not = (!_isNullOrEmpty);
      if (_not) {
        _builder.append("<");
        String _value = typeAndTypeParams.getValue();
        _builder.append(_value);
        _builder.append("> ");
      }
    }
    _builder.append("void method(");
    String _key = typeAndTypeParams.getKey();
    _builder.append(_key);
    _builder.append(" p) {}");
    final String signature = _builder.toString();
    final XtendFunction function = this.function(signature.toString());
    final JvmOperation operation = this._iXtendJvmAssociations.getDirectlyInferredOperation(function);
    LightweightTypeReference _xifexpression = null;
    String _key_1 = typeAndTypeParams.getKey();
    boolean _tripleNotEquals = (_key_1 != null);
    if (_tripleNotEquals) {
      _xifexpression = this.toLightweightTypeReference(IterableExtensions.<JvmFormalParameter>head(operation.getParameters()).getParameterType());
    } else {
      _xifexpression = this.getOwner().newAnyTypeReference();
    }
    final LightweightTypeReference primary = _xifexpression;
    final HashSet<String> actualSynonyms = CollectionLiterals.<String>newHashSet();
    final SynonymTypesProvider.Acceptor _function = new SynonymTypesProvider.Acceptor() {
      @Override
      protected boolean accept(final LightweightTypeReference type, final int conformance) {
        return actualSynonyms.add(type.getSimpleName());
      }
    };
    this._synonymTypesProvider.collectSynonymTypes(primary, _function);
    Assert.assertEquals(actualSynonyms.toString(), expectedSynonyms.length, actualSynonyms.size());
    Assert.assertTrue(actualSynonyms.toString(), actualSynonyms.containsAll(((Collection<?>)Conversions.doWrapArray(expectedSynonyms))));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 17
Source File: DefaultXtendOutlineContext.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
public DefaultXtendOutlineContext() {
  this.inheritanceDepth = 0;
  this.showInherited = false;
  this.processedMembers = CollectionLiterals.<JvmMember>newHashSet();
}
 
Example 18
Source File: AbstractFeatureCallTypeTest.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@BeforeClass
public static void createSeenExpressionsSet() {
  AbstractFeatureCallTypeTest.seenExpressions = CollectionLiterals.<String>newHashSet();
}
 
Example 19
Source File: AbstractIdentifiableTypeTest.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@BeforeClass
public static void createSeenExpressionsSet() {
  AbstractIdentifiableTypeTest.seenExpressions = CollectionLiterals.<String>newHashSet();
}
 
Example 20
Source File: AbstractClosureTypeTest2.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@BeforeClass
public static void createSeenExpressionsSet() {
  AbstractClosureTypeTest2.seenExpressions = CollectionLiterals.<String>newHashSet();
}