Java Code Examples for org.eclipse.xtext.xbase.lib.ListExtensions#reverseView()

The following examples show how to use org.eclipse.xtext.xbase.lib.ListExtensions#reverseView() . 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_004.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
public static void main(final String[] args) {
  int result = 0;
  IntegerRange _upTo = new IntegerRange(100, 999);
  for (final Integer left : _upTo) {
    IntegerRange _upTo_1 = new IntegerRange((left).intValue(), 999);
    for (final Integer right : _upTo_1) {
      {
        int candidate = ((left).intValue() * (right).intValue());
        if ((candidate > result)) {
          List<Character> charList = (List<Character>)Conversions.doWrapArray(Integer.valueOf(candidate).toString().toCharArray());
          List<Character> _reverseView = ListExtensions.<Character>reverseView(charList);
          boolean _equals = Objects.equal(_reverseView, charList);
          if (_equals) {
            result = candidate;
          }
        }
      }
    }
  }
  InputOutput.<Integer>println(Integer.valueOf(result));
}
 
Example 2
Source File: RichStringPartionIndentationStrategy.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void customizeDocumentCommand(final IDocument d, final DocumentCommand c) {
  if (((c.text.length() > 1) && (!ArrayExtensions.contains(d.getLegalLineDelimiters(), c.text)))) {
    try {
      final String lineIndentation = this.getLineIndentation(d, c.offset);
      final Function1<String, Integer> _function = (String s) -> {
        return Integer.valueOf(s.length());
      };
      final List<String> legalLineDelimiters = ListExtensions.<String>reverseView(IterableExtensions.<String, Integer>sortBy(((Iterable<String>)Conversions.doWrapArray(d.getLegalLineDelimiters())), _function));
      final String defaultLineDelimiter = TextUtilities.getDefaultLineDelimiter(d);
      final Function1<String, CharSequence> _function_1 = (String delimiter) -> {
        return Pattern.quote(delimiter);
      };
      final String regex = IterableExtensions.<String>join(legalLineDelimiters, "(", ")|(", ")", _function_1);
      final Pattern pattern = Pattern.compile(regex);
      final Matcher matcher = pattern.matcher(c.text);
      final StringBuilder convertedText = new StringBuilder();
      int currentStart = 0;
      int currentEnd = 0;
      while (matcher.find()) {
        {
          currentEnd = matcher.start();
          if ((currentStart != 0)) {
            convertedText.append(lineIndentation);
          }
          convertedText.append(c.text.substring(currentStart, currentEnd));
          convertedText.append(defaultLineDelimiter);
          currentStart = matcher.end();
        }
      }
      int _length = c.text.length();
      boolean _lessThan = (currentStart < _length);
      if (_lessThan) {
        if ((currentStart != 0)) {
          convertedText.append(lineIndentation);
        }
        convertedText.append(c.text.substring(currentStart));
      }
      c.text = convertedText.toString();
    } catch (final Throwable _t) {
      if (_t instanceof BadLocationException) {
        super.customizeDocumentCommand(d, c);
      } else {
        throw Exceptions.sneakyThrow(_t);
      }
    }
  }
  super.customizeDocumentCommand(d, c);
}
 
Example 3
Source File: RuntimeInjectorProviderWithReversedCandidates.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected ILinkingCandidate getBestCandidate(List<? extends ILinkingCandidate> candidates) {
	return super.getBestCandidate(ListExtensions.reverseView(candidates));
}