Java Code Examples for org.eclipse.xtext.xbase.lib.CollectionLiterals#newArrayList()
The following examples show how to use
org.eclipse.xtext.xbase.lib.CollectionLiterals#newArrayList() .
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: ResolvedMethodImpl.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Override public Iterable<? extends ResolvedTypeParameter> getResolvedTypeParameters() { ArrayList<ResolvedTypeParameterImpl> _xblockexpression = null; { final ArrayList<ResolvedTypeParameterImpl> resolvedTypeParameters = CollectionLiterals.<ResolvedTypeParameterImpl>newArrayList(); for (int i = 0; (i < this.getDelegate().getResolvedTypeParameters().size()); i++) { TypeParameterDeclaration _typeParameterDeclaration = this.getCompilationUnit().toTypeParameterDeclaration(this.getDelegate().getResolvedTypeParameters().get(i)); final Function1<LightweightTypeReference, TypeReference> _function = (LightweightTypeReference it) -> { return this.getCompilationUnit().toTypeReference(it); }; List<TypeReference> _list = IterableExtensions.<TypeReference>toList(ListExtensions.<LightweightTypeReference, TypeReference>map(this.getDelegate().getResolvedTypeParameterConstraints(i), _function)); ResolvedTypeParameterImpl _resolvedTypeParameterImpl = new ResolvedTypeParameterImpl(_typeParameterDeclaration, _list); resolvedTypeParameters.add(_resolvedTypeParameterImpl); } _xblockexpression = resolvedTypeParameters; } return _xblockexpression; }
Example 2
Source File: SyntacticSequencerExtensions.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
public List<EqualAmbiguousTransitions> getAllAmbiguousTransitionsBySyntax() { if ((this.ambiguousTransitions != null)) { return this.ambiguousTransitions; } final Map<GrammarAlias.AbstractElementAlias, EqualAmbiguousTransitions> result = CollectionLiterals.<GrammarAlias.AbstractElementAlias, EqualAmbiguousTransitions>newHashMap(); Set<ISyntacticSequencerPDAProvider.ISynTransition> _allAmbiguousTransitions = this.getAllAmbiguousTransitions(); for (final ISyntacticSequencerPDAProvider.ISynTransition transition : _allAmbiguousTransitions) { List<GrammarAlias.AbstractElementAlias> _ambiguousSyntaxes = transition.getAmbiguousSyntaxes(); for (final GrammarAlias.AbstractElementAlias syntax : _ambiguousSyntaxes) { { EqualAmbiguousTransitions list = result.get(syntax); if ((list == null)) { String _elementAliasToIdentifier = this.elementAliasToIdentifier(syntax); EqualAmbiguousTransitions _equalAmbiguousTransitions = new EqualAmbiguousTransitions(_elementAliasToIdentifier, syntax); list = _equalAmbiguousTransitions; result.put(syntax, list); } list.getTransitions().add(transition); } } } this.ambiguousTransitions = CollectionLiterals.<EqualAmbiguousTransitions>newArrayList(((EqualAmbiguousTransitions[])Conversions.unwrapArray(result.values(), EqualAmbiguousTransitions.class))); ListExtensions.<EqualAmbiguousTransitions>sortInplace(this.ambiguousTransitions); return this.ambiguousTransitions; }
Example 3
Source File: Xbase08_Loops.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
public ArrayList<String> myMethod() throws Throwable { ArrayList<String> _xblockexpression = null; { final ArrayList<String> list = CollectionLiterals.<String>newArrayList("foo", "bar", "baz"); final ArrayList<String> result = new ArrayList<String>(); List<String> _reverse = ListExtensions.<String>reverse(list); for (final String x : _reverse) { String _upperCase = x.toUpperCase(); result.add(_upperCase); } /* result; */ int i = 0; while ((i < list.size())) { { String _get = list.get(i); String _plus = ("whiled-" + _get); result.add(_plus); i = (i + 1); } } _xblockexpression = result; } return _xblockexpression; }
Example 4
Source File: AccessorsProcessor.java From xtext-lib with Eclipse Public License 2.0 | 6 votes |
public List<String> getPossibleGetterNames(final FieldDeclaration it) { final ArrayList<String> names = CollectionLiterals.<String>newArrayList(); if ((((this.isBooleanType(this.orObject(it.getType())) && it.getSimpleName().startsWith("is")) && (it.getSimpleName().length() > 2)) && Character.isUpperCase(it.getSimpleName().charAt(2)))) { String _simpleName = it.getSimpleName(); names.add(_simpleName); } List<String> _xifexpression = null; boolean _isBooleanType = this.isBooleanType(this.orObject(it.getType())); if (_isBooleanType) { _xifexpression = Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("is", "get")); } else { _xifexpression = Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("get")); } final Function1<String, String> _function = (String prefix) -> { String _firstUpper = StringExtensions.toFirstUpper(it.getSimpleName()); return (prefix + _firstUpper); }; names.addAll(ListExtensions.<String, String>map(_xifexpression, _function)); return names; }
Example 5
Source File: GrammarAccessExtensions.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected List<AbstractElement> _contentsAsList(final UnorderedGroup it) { ArrayList<AbstractElement> _xblockexpression = null; { final ArrayList<AbstractElement> result = CollectionLiterals.<AbstractElement>newArrayList(it); final Function1<AbstractElement, List<AbstractElement>> _function = (AbstractElement it_1) -> { return this.contentsAsList(it_1); }; List<AbstractElement> _list = IterableExtensions.<AbstractElement>toList(Iterables.<AbstractElement>concat(ListExtensions.<AbstractElement, List<AbstractElement>>map(it.getElements(), _function))); Iterables.<AbstractElement>addAll(result, _list); _xblockexpression = result; } return _xblockexpression; }
Example 6
Source File: AbstractIncrementalBuilderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected List<Issue> clean() { List<Issue> _xblockexpression = null; { this.generated = ArrayListMultimap.<URI, URI>create(); this.deleted = CollectionLiterals.<URI>newArrayList(); _xblockexpression = this.issues = CollectionLiterals.<Issue>newArrayList(); } return _xblockexpression; }
Example 7
Source File: JvmTypesBuilderTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Test public void testAddAllNull() { final BasicEList<String> list = new BasicEList<String>(); final List<String> otherList = CollectionLiterals.<String>newArrayList(null, null, null); this._jvmTypesBuilder.<String>operator_add(list, otherList); Assert.assertTrue(list.isEmpty()); }
Example 8
Source File: FjFirstTypeSystem.java From xsemantics with Eclipse Public License 1.0 | 5 votes |
protected Result<List<Field>> applyRuleFields(final RuleEnvironment G, final RuleApplicationTrace _trace_, final org.eclipse.xsemantics.example.fj.fj.Class cl) throws RuleFailedException { List<Field> fields = null; // output parameter final List<org.eclipse.xsemantics.example.fj.fj.Class> superclasses = this.superclassesInternal(_trace_, cl); Collections.reverse(superclasses); fields = CollectionLiterals.<Field>newArrayList(); for (final org.eclipse.xsemantics.example.fj.fj.Class superclass : superclasses) { List<Field> _typeSelect = EcoreUtil2.<Field>typeSelect( superclass.getMembers(), Field.class); Iterables.<Field>addAll(fields, _typeSelect); } /* fields += EcoreUtil2::typeSelect( cl.members, typeof(Field) ) or true */ { RuleFailedException previousFailure = null; try { List<Field> _typeSelect_1 = EcoreUtil2.<Field>typeSelect( cl.getMembers(), Field.class); boolean _add = Iterables.<Field>addAll(fields, _typeSelect_1); /* fields += EcoreUtil2::typeSelect( cl.members, typeof(Field) ) */ if (!_add) { sneakyThrowRuleFailedException("fields += EcoreUtil2::typeSelect( cl.members, typeof(Field) )"); } } catch (Exception e) { previousFailure = extractRuleFailedException(e); /* true */ } } return new Result<List<Field>>(fields); }
Example 9
Source File: Solution_022.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
public static void main(final String[] args) { try { InputStream _resourceAsStream = Solution_022.class.getResourceAsStream("names.txt"); InputStreamReader _inputStreamReader = new InputStreamReader(_resourceAsStream); final BufferedReader reader = new BufferedReader(_inputStreamReader); try { final String line = reader.readLine(); final Matcher matcher = Pattern.compile("\"(\\w+)\"").matcher(line); final ArrayList<String> names = CollectionLiterals.<String>newArrayList(); while (matcher.find()) { names.add(matcher.group(1)); } final AtomicLong result = new AtomicLong(); final Procedure2<String, Integer> _function = (String name, Integer i) -> { final Function1<Character, Integer> _function_1 = (Character it) -> { int _numericValue = Character.getNumericValue((it).charValue()); return Integer.valueOf((_numericValue - 9)); }; final Function2<Integer, Integer, Integer> _function_2 = (Integer i1, Integer i2) -> { return Integer.valueOf(((i1).intValue() + (i2).intValue())); }; Integer _reduce = IterableExtensions.<Integer>reduce(ListExtensions.<Character, Integer>map(((List<Character>)Conversions.doWrapArray(name.toCharArray())), _function_1), _function_2); int _multiply = ((_reduce).intValue() * ((i).intValue() + 1)); result.addAndGet(_multiply); }; IterableExtensions.<String>forEach(IterableExtensions.<String>sort(names), _function); InputOutput.<AtomicLong>println(result); } finally { reader.close(); } } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example 10
Source File: Solution_007.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
public static void main(final String[] args) { int n = 10001; ArrayList<Integer> seenPrimes = CollectionLiterals.<Integer>newArrayList(); int slice = 0; while (true) { { List<Integer> numbers = IterableExtensions.<Integer>toList(new IntegerRange(((slice * n) + 1), ((slice + 1) * n))); for (final Integer prime : seenPrimes) { Solution_007.markAsNotPrime((prime).intValue(), numbers); } slice = (slice + 1); while ((!numbers.isEmpty())) { { Integer nextPrime = numbers.remove(0); if (((nextPrime).intValue() != 1)) { seenPrimes.add(nextPrime); int _size = seenPrimes.size(); boolean _equals = (_size == n); if (_equals) { InputOutput.<Integer>println(nextPrime); return; } Solution_007.markAsNotPrime((nextPrime).intValue(), numbers); } } } } } }
Example 11
Source File: FormattingDataFactory.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
public Function1<? super FormattableDocument, ? extends Iterable<FormattingData>> surround(final INode node, final Procedure1<? super FormattingDataInit> before, final Procedure1<? super FormattingDataInit> after) { final Function1<FormattableDocument, Iterable<FormattingData>> _function = (FormattableDocument doc) -> { ArrayList<FormattingData> _xblockexpression = null; { final ArrayList<FormattingData> result = CollectionLiterals.<FormattingData>newArrayList(); if ((node != null)) { Iterable<FormattingData> _elvis = null; Function1<? super FormattableDocument, ? extends Iterable<FormattingData>> _newFormattingData = this.newFormattingData(this._hiddenLeafAccess.getHiddenLeafsBefore(node), before); Iterable<FormattingData> _apply = null; if (_newFormattingData!=null) { _apply=_newFormattingData.apply(doc); } if (_apply != null) { _elvis = _apply; } else { List<FormattingData> _emptyList = CollectionLiterals.<FormattingData>emptyList(); _elvis = _emptyList; } Iterables.<FormattingData>addAll(result, _elvis); Iterable<FormattingData> _elvis_1 = null; Function1<? super FormattableDocument, ? extends Iterable<FormattingData>> _newFormattingData_1 = this.newFormattingData(this._hiddenLeafAccess.getHiddenLeafsAfter(node), after); Iterable<FormattingData> _apply_1 = null; if (_newFormattingData_1!=null) { _apply_1=_newFormattingData_1.apply(doc); } if (_apply_1 != null) { _elvis_1 = _apply_1; } else { List<FormattingData> _emptyList_1 = CollectionLiterals.<FormattingData>emptyList(); _elvis_1 = _emptyList_1; } Iterables.<FormattingData>addAll(result, _elvis_1); } _xblockexpression = result; } return _xblockexpression; }; return _function; }
Example 12
Source File: Case_7.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
public Map.Entry<String, List<String>> bug345449() { Map.Entry<String, List<String>> _xblockexpression = null; { final ArrayList<Map.Entry<String, List<String>>> result = CollectionLiterals.<Map.Entry<String, List<String>>>newArrayList(); Map.Entry<String, List<String>> _head = null; if (result!=null) { _head=IterableExtensions.<Map.Entry<String, List<String>>>head(result); } _xblockexpression = _head; } return _xblockexpression; }
Example 13
Source File: SemanticSequencerExtensions.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
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 14
Source File: TypeReference.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
public TypeReference(final Class<?> clazz, final List<TypeReference> arguments) { boolean _isPrimitive = clazz.isPrimitive(); if (_isPrimitive) { String _name = clazz.getName(); String _plus = ("Type is primitive: " + _name); throw new IllegalArgumentException(_plus); } boolean _isAnonymousClass = clazz.isAnonymousClass(); if (_isAnonymousClass) { String _name_1 = clazz.getName(); String _plus_1 = ("Class is anonymous: " + _name_1); throw new IllegalArgumentException(_plus_1); } boolean _isLocalClass = clazz.isLocalClass(); if (_isLocalClass) { String _name_2 = clazz.getName(); String _plus_2 = ("Class is local: " + _name_2); throw new IllegalArgumentException(_plus_2); } this.packageName = clazz.getPackage().getName(); this.simpleNames = CollectionLiterals.<String>newArrayList(); List<TypeReference> _elvis = null; if (arguments != null) { _elvis = arguments; } else { List<TypeReference> _emptyList = Collections.<TypeReference>emptyList(); _elvis = _emptyList; } this.typeArguments = _elvis; Class<?> c = clazz; do { { this.simpleNames.add(0, c.getSimpleName()); c = c.getDeclaringClass(); } } while((c != null)); }
Example 15
Source File: AbstractXtextResourceSetTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Test public void testResourcesAreInMapWithNormalizedURI_02() { final XtextResourceSet rs = this.createEmptyResourceSet(); Assert.assertEquals(0, rs.getURIResourceMap().size()); final XtextResource resource = new XtextResource(); resource.setURI(URI.createURI("/a/../foo")); EList<Resource> _resources = rs.getResources(); ArrayList<Resource> _newArrayList = CollectionLiterals.<Resource>newArrayList(resource); Iterables.<Resource>addAll(_resources, _newArrayList); Assert.assertEquals(2, rs.getURIResourceMap().size()); rs.getResources().remove(resource); Assert.assertTrue(resource.eAdapters().isEmpty()); Assert.assertEquals(0, rs.getURIResourceMap().size()); }
Example 16
Source File: AbstractExpectationTest.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
public void clearData() { this.resolvedTypes = null; this.expectations = CollectionLiterals.<String>newArrayList(); this.finalExpectations = CollectionLiterals.<ITypeExpectation>newArrayList(); this.expressions = CollectionLiterals.<XExpression>newArrayList(); }
Example 17
Source File: JsonRpcDataProcessor.java From lsp4j with Eclipse Public License 2.0 | 4 votes |
protected MutableMethodDeclaration generateToString(final MutableClassDeclaration impl, @Extension final TransformationContext context) { MutableMethodDeclaration _xblockexpression = null; { final ArrayList<FieldDeclaration> toStringFields = CollectionLiterals.<FieldDeclaration>newArrayList(); ClassDeclaration c = impl; do { { Iterable<? extends FieldDeclaration> _declaredFields = c.getDeclaredFields(); Iterables.<FieldDeclaration>addAll(toStringFields, _declaredFields); TypeReference _extendedClass = c.getExtendedClass(); Type _type = null; if (_extendedClass!=null) { _type=_extendedClass.getType(); } c = ((ClassDeclaration) _type); } } while(((c != null) && (!Objects.equal(c, context.getObject())))); final Procedure1<MutableMethodDeclaration> _function = (MutableMethodDeclaration it) -> { it.setReturnType(context.getString()); it.addAnnotation(context.newAnnotationReference(Override.class)); it.addAnnotation(context.newAnnotationReference(Pure.class)); final AccessorsProcessor.Util accessorsUtil = new AccessorsProcessor.Util(context); StringConcatenationClient _client = new StringConcatenationClient() { @Override protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { _builder.append(ToStringBuilder.class); _builder.append(" b = new "); _builder.append(ToStringBuilder.class); _builder.append("(this);"); _builder.newLineIfNotEmpty(); { for(final FieldDeclaration field : toStringFields) { _builder.append("b.add(\""); String _simpleName = field.getSimpleName(); _builder.append(_simpleName); _builder.append("\", "); { TypeDeclaration _declaringType = field.getDeclaringType(); boolean _equals = Objects.equal(_declaringType, impl); if (_equals) { _builder.append("this."); String _simpleName_1 = field.getSimpleName(); _builder.append(_simpleName_1); } else { String _getterName = accessorsUtil.getGetterName(field); _builder.append(_getterName); _builder.append("()"); } } _builder.append(");"); _builder.newLineIfNotEmpty(); } } _builder.append("return b.toString();"); _builder.newLine(); } }; it.setBody(_client); }; _xblockexpression = impl.addMethod("toString", _function); } return _xblockexpression; }
Example 18
Source File: FormattingDataFactory.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
protected Iterable<FormattingData> newWhitespaceData(final HiddenLeafs leafs, final String space, final int increaseIndentationChange, final int decreaseIndentationChange, final boolean trace) { ArrayList<FormattingData> _xblockexpression = null; { final ArrayList<FormattingData> result = CollectionLiterals.<FormattingData>newArrayList(); boolean isFirst = true; List<LeafInfo> _leafs = leafs.getLeafs(); for (final LeafInfo leaf : _leafs) { boolean _matched = false; if (leaf instanceof WhitespaceInfo) { _matched=true; int _offset = ((WhitespaceInfo)leaf).getOffset(); int _length = ((WhitespaceInfo)leaf).getLength(); int _xifexpression = (int) 0; if (isFirst) { _xifexpression = increaseIndentationChange; } else { _xifexpression = 0; } int _xifexpression_1 = (int) 0; if (isFirst) { _xifexpression_1 = decreaseIndentationChange; } else { _xifexpression_1 = 0; } RuntimeException _xifexpression_2 = null; if (trace) { _xifexpression_2 = new RuntimeException(); } WhitespaceData _whitespaceData = new WhitespaceData(_offset, _length, _xifexpression, _xifexpression_1, _xifexpression_2, space); result.add(_whitespaceData); isFirst = false; } if (!_matched) { if (leaf instanceof CommentInfo) { _matched=true; } } } _xblockexpression = result; } return _xblockexpression; }
Example 19
Source File: SyntacticSequencerExtensions.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
protected List<ISyntacticSequencerPDAProvider.ISynAbsorberState> getAllPDAs() { final Function1<SerializationContextMap.Entry<ISyntacticSequencerPDAProvider.ISynAbsorberState>, ISyntacticSequencerPDAProvider.ISynAbsorberState> _function = (SerializationContextMap.Entry<ISyntacticSequencerPDAProvider.ISynAbsorberState> it) -> { return it.getValue(); }; return CollectionLiterals.<ISyntacticSequencerPDAProvider.ISynAbsorberState>newArrayList(((ISyntacticSequencerPDAProvider.ISynAbsorberState[])Conversions.unwrapArray(ListExtensions.<SerializationContextMap.Entry<ISyntacticSequencerPDAProvider.ISynAbsorberState>, ISyntacticSequencerPDAProvider.ISynAbsorberState>map(this.pdaProvider.getSyntacticSequencerPDAs(this.grammar).values(), _function), ISyntacticSequencerPDAProvider.ISynAbsorberState.class))); }
Example 20
Source File: NamedSerializationContextProvider.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
public <T extends Object> List<NamedSerializationContexts<T>> getNamedContexts(final SerializationContextMap<T> map) { final ArrayList<NamedSerializationContexts<T>> result = CollectionLiterals.<NamedSerializationContexts<T>>newArrayList(); final HashMap<String, Integer> names = CollectionLiterals.<String, Integer>newHashMap(); List<SerializationContextMap.Entry<T>> _values = map.values(); for (final SerializationContextMap.Entry<T> e : _values) { Set<EClass> _types = e.getTypes(); for (final EClass t : _types) { { final List<ISerializationContext> ctx = e.getContexts(t); String _xifexpression = null; if ((t == null)) { _xifexpression = ""; } else { _xifexpression = t.getName(); } String _plus = (_xifexpression + "_"); String _significantGrammarElement = this.getSignificantGrammarElement(ctx); final String name = (_plus + _significantGrammarElement); final Integer dup = names.get(name); String _xifexpression_1 = null; if ((dup == null)) { String _xblockexpression = null; { names.put(name, Integer.valueOf(1)); _xblockexpression = name; } _xifexpression_1 = _xblockexpression; } else { String _xblockexpression_1 = null; { names.put(name, Integer.valueOf(((dup).intValue() + 1))); _xblockexpression_1 = ((name + "_") + dup); } _xifexpression_1 = _xblockexpression_1; } final String unique = _xifexpression_1; T _value = e.getValue(); NamedSerializationContexts<T> _namedSerializationContexts = new NamedSerializationContexts<T>(unique, t, ctx, _value); result.add(_namedSerializationContexts); } } } return result; }