Java Code Examples for org.eclipse.xtext.xbase.lib.InputOutput#println()

The following examples show how to use org.eclipse.xtext.xbase.lib.InputOutput#println() . 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: JavaFileConverterTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
public void writeToFile(final File parent, final String fileName, final String content) {
  try {
    final File targetFile = new File(parent, fileName);
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("Writing to: ");
    _builder.append(fileName);
    InputOutput.<String>println(_builder.toString());
    boolean _exists = targetFile.exists();
    boolean _not = (!_exists);
    if (_not) {
      Files.createParentDirs(targetFile);
      targetFile.createNewFile();
    }
    Files.asCharSink(targetFile, Charset.defaultCharset()).write(content);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 2
Source File: ObservableExample.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
public static void main(final String[] args) {
  ObservableBean _observableBean = new ObservableBean();
  final Procedure1<ObservableBean> _function = (ObservableBean it) -> {
    final PropertyChangeListener _function_1 = (PropertyChangeEvent it_1) -> {
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("property ");
      String _propertyName = it_1.getPropertyName();
      _builder.append(_propertyName);
      _builder.append(" changed from ");
      Object _oldValue = it_1.getOldValue();
      _builder.append(_oldValue);
      _builder.append(" to ");
      Object _newValue = it_1.getNewValue();
      _builder.append(_newValue);
      InputOutput.<String>println(_builder.toString());
    };
    it.addPropertyChangeListener(_function_1);
    it.setFirstName("Max");
    it.setLastName("Mustermann");
    it.setFirstName("John");
    it.setLastName("Doe");
  };
  ObjectExtensions.<ObservableBean>operator_doubleArrow(_observableBean, _function);
}
 
Example 3
Source File: Solution_005.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
public static void main(final String[] args) {
  ArrayList<Integer> result = CollectionLiterals.<Integer>newArrayList();
  IntegerRange _upTo = new IntegerRange(2, 20);
  for (final Integer i : _upTo) {
    {
      Integer j = i;
      for (final Integer k : result) {
        if ((((j).intValue() % (k).intValue()) == 0)) {
          j = Integer.valueOf(((j).intValue() / (k).intValue()));
        }
      }
      if (((j).intValue() != 1)) {
        result.add(j);
      }
    }
  }
  final Function2<Integer, Integer, Integer> _function = (Integer m1, Integer m2) -> {
    return Integer.valueOf(((m1).intValue() * (m2).intValue()));
  };
  InputOutput.<Integer>println(IterableExtensions.<Integer>reduce(result, _function));
}
 
Example 4
Source File: SwtBotProjectHelper.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
protected static void fileNew(final SWTWorkbenchBot it, final String newWhat) {
  int retries = 3;
  ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, retries, true);
  for (final Integer i : _doubleDotLessThan) {
    try {
      it.menu("File").menu("New").menu(newWhat).click();
      return;
    } catch (final Throwable _t) {
      if (_t instanceof WidgetNotFoundException) {
        final WidgetNotFoundException e = (WidgetNotFoundException)_t;
        if (((i).intValue() == (retries - 1))) {
          throw e;
        }
        String _message = e.getMessage();
        String _plus = ("failed: " + _message);
        InputOutput.<String>println(_plus);
        InputOutput.<String>println("retrying...");
        it.sleep(1000);
      } else {
        throw Exceptions.sneakyThrow(_t);
      }
    }
  }
}
 
Example 5
Source File: DebugGraphGenerator.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
private String drawSafe(final GraphvizDotBuilder builder, final Object graph) {
  String _xtrycatchfinallyexpression = null;
  try {
    _xtrycatchfinallyexpression = builder.draw(graph);
  } catch (final Throwable _t) {
    if (_t instanceof Exception) {
      final Exception e = (Exception)_t;
      InputOutput.<String>println("Error rendering");
      e.printStackTrace();
      return Throwables.getStackTraceAsString(e);
    } else {
      throw Exceptions.sneakyThrow(_t);
    }
  }
  return _xtrycatchfinallyexpression;
}
 
Example 6
Source File: Solution_019.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
public static void main(final String[] args) {
  final Calendar calendar = GregorianCalendar.getInstance();
  calendar.set(1901, 1, 1);
  int result = 0;
  do {
    {
      int _get = calendar.get(Calendar.DAY_OF_WEEK);
      boolean _equals = (_get == Calendar.SUNDAY);
      if (_equals) {
        result = (result + 1);
      }
      calendar.add(Calendar.MONTH, 1);
    }
  } while((calendar.get(Calendar.YEAR) <= 2000));
  InputOutput.<Integer>println(Integer.valueOf(result));
}
 
Example 7
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 8
Source File: JunitLibClasspathAdderTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void addJUnit4LibToPluginProjectClasspath() {
  try {
    IJavaProject _create = JavaCore.create(this.workbenchHelper.getProject());
    NullProgressMonitor _nullProgressMonitor = new NullProgressMonitor();
    this.junit4LibAdder.addLibsToClasspath(_create, _nullProgressMonitor);
    final Consumer<IClasspathEntry> _function = (IClasspathEntry it) -> {
      InputOutput.<IPath>println(it.getPath());
    };
    ((List<IClasspathEntry>)Conversions.doWrapArray(JavaCore.create(this.workbenchHelper.getProject()).getRawClasspath())).forEach(_function);
    this.assertRequireBundles(new String[] { Junit4LibClasspathAdder.BUNDLE_ID });
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 9
Source File: JavaConverterTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
public String dump(final String text) {
  String _xifexpression = null;
  if (JavaConverterTest.DUMP) {
    _xifexpression = InputOutput.<String>println(text);
  }
  return _xifexpression;
}
 
Example 10
Source File: Solution_001.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
public static void main(final String[] args) {
  final Function1<Integer, Boolean> _function = (Integer i) -> {
    return Boolean.valueOf(((((i).intValue() % 3) == 0) || (((i).intValue() % 5) == 0)));
  };
  final Function2<Integer, Integer, Integer> _function_1 = (Integer i1, Integer i2) -> {
    return Integer.valueOf(((i1).intValue() + (i2).intValue()));
  };
  InputOutput.<Integer>println(IterableExtensions.<Integer>reduce(IterableExtensions.<Integer>filter(new IntegerRange(1, 999), _function), _function_1));
}
 
Example 11
Source File: Case_0.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
public String foo(final String a, final String b) {
  String _xblockexpression = null;
  {
    ArrayList<String> list = CollectionLiterals.<String>newArrayList();
    int _size = list.size();
    int _minus = (_size - 1);
    IntegerRange _upTo = new IntegerRange(0, _minus);
    for (final Integer i : _upTo) {
      String _string = i.toString();
      String _plus = (_string + " ");
      String _get = list.get((i).intValue());
      String _plus_1 = (_plus + _get);
      InputOutput.<String>println(_plus_1);
    }
    String _xifexpression = null;
    boolean _isUpper = this.isUpper(a);
    if (_isUpper) {
      _xifexpression = this.another(a, (b + "holla"));
    } else {
      String _xblockexpression_1 = null;
      {
        String x = a;
        char[] _charArray = b.toCharArray();
        for (final char y : _charArray) {
          x = (x + Character.valueOf(y));
        }
        _xblockexpression_1 = x;
      }
      _xifexpression = _xblockexpression_1;
    }
    _xblockexpression = _xifexpression;
  }
  return _xblockexpression;
}
 
Example 12
Source File: Solution_022.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
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 13
Source File: Solution_006.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
public static void main(final String[] args) {
  final Function2<Integer, Integer, Integer> _function = (Integer i1, Integer i2) -> {
    return Integer.valueOf(((i1).intValue() + (i2).intValue()));
  };
  Integer result = IterableExtensions.<Integer>reduce(new IntegerRange(1, 100), _function);
  result = Integer.valueOf(((result).intValue() * (result).intValue()));
  final Function2<Integer, Integer, Integer> _function_1 = (Integer r, Integer i) -> {
    return Integer.valueOf(((r).intValue() - ((i).intValue() * (i).intValue())));
  };
  result = IterableExtensions.<Integer, Integer>fold(new IntegerRange(1, 100), result, _function_1);
  InputOutput.<Integer>println(result);
}
 
Example 14
Source File: TestBatchCompiler.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
private boolean createSymLink(final String linkTarget, final String link) {
  try {
    File linkFile = new File(link);
    TestBatchCompiler.abfalleimer.add(linkFile);
    if ((linkFile.exists() && this.isSymlink(linkFile))) {
      return true;
    }
    String[] cmd = { "ln", "-s", linkTarget, link };
    try {
      final String[] _converted_cmd = (String[])cmd;
      String _join = IterableExtensions.join(((Iterable<?>)Conversions.doWrapArray(_converted_cmd)), " ");
      String _plus = ("Exec: " + _join);
      InputOutput.<String>println(_plus);
      final Process proc = Runtime.getRuntime().exec(cmd);
      int _waitFor = proc.waitFor();
      return (_waitFor == 0);
    } catch (final Throwable _t) {
      if (_t instanceof IOException) {
        return false;
      } else {
        throw Exceptions.sneakyThrow(_t);
      }
    }
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 15
Source File: JavaEditorExtension.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
public String waitForElementChangedEvent(final int eventMask, final Procedure0 producer) {
  String _xblockexpression = null;
  {
    if ((JavaEditorExtension.VERBOSE).booleanValue()) {
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("start waiting for an element changed event: ");
      _builder.append(eventMask);
      InputOutput.<String>println(_builder.toString());
    }
    final ArrayList<Boolean> changed = CollectionLiterals.<Boolean>newArrayList(Boolean.valueOf(false));
    final IElementChangedListener _function = new IElementChangedListener() {
      @Override
      public void elementChanged(final ElementChangedEvent it) {
        JavaCore.removeElementChangedListener(this);
        Boolean _head = IterableExtensions.<Boolean>head(changed);
        boolean _not = (!(_head).booleanValue());
        if (_not) {
          changed.set(0, Boolean.valueOf(true));
          if ((JavaEditorExtension.VERBOSE).booleanValue()) {
            InputOutput.<ElementChangedEvent>println(it);
          }
        }
      }
    };
    JavaCore.addElementChangedListener(_function, eventMask);
    producer.apply();
    while ((!(IterableExtensions.<Boolean>head(changed)).booleanValue())) {
    }
    String _xifexpression = null;
    if ((JavaEditorExtension.VERBOSE).booleanValue()) {
      StringConcatenation _builder_1 = new StringConcatenation();
      _builder_1.append("end waiting for an element changed event: ");
      _builder_1.append(eventMask);
      _xifexpression = InputOutput.<String>println(_builder_1.toString());
    }
    _xblockexpression = _xifexpression;
  }
  return _xblockexpression;
}
 
Example 16
Source File: DomExample.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void processDom() {
  final Html dom = this.buildDom();
  InputOutput.<CharSequence>println(this.ds.toText(dom));
}
 
Example 17
Source File: BottleSong.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void singIt() {
  InputOutput.<CharSequence>println(this.singTheSong(99));
}
 
Example 18
Source File: ConstantOperators.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
public static void main(final String[] args) {
  Pair<String, String> _mappedTo = Pair.<String, String>of("Integer", "intValue()");
  Pair<String, String> _mappedTo_1 = Pair.<String, String>of("Short", "shortValue()");
  Pair<String, String> _mappedTo_2 = Pair.<String, String>of("Long", "longValue()");
  Pair<String, String> _mappedTo_3 = Pair.<String, String>of("Float", "floatValue()");
  Pair<String, String> _mappedTo_4 = Pair.<String, String>of("Double", "doubleValue()");
  Pair<String, String> _mappedTo_5 = Pair.<String, String>of("Byte", "byteValue()");
  final Map<String, String> types = Collections.<String, String>unmodifiableMap(CollectionLiterals.<String, String>newHashMap(_mappedTo, _mappedTo_1, _mappedTo_2, _mappedTo_3, _mappedTo_4, _mappedTo_5));
  Pair<String, String> _mappedTo_6 = Pair.<String, String>of("plus", "+");
  Pair<String, String> _mappedTo_7 = Pair.<String, String>of("minus", "-");
  Pair<String, String> _mappedTo_8 = Pair.<String, String>of("divide", "/");
  Pair<String, String> _mappedTo_9 = Pair.<String, String>of("multiply", "*");
  Pair<String, String> _mappedTo_10 = Pair.<String, String>of("modulo", "%");
  Pair<String, String> _mappedTo_11 = Pair.<String, String>of("lessThan", "<");
  Pair<String, String> _mappedTo_12 = Pair.<String, String>of("greaterThan", ">");
  Pair<String, String> _mappedTo_13 = Pair.<String, String>of("lessEquals", "<=");
  Pair<String, String> _mappedTo_14 = Pair.<String, String>of("greaterEquals", ">=");
  Pair<String, String> _mappedTo_15 = Pair.<String, String>of("same", "===");
  Pair<String, String> _mappedTo_16 = Pair.<String, String>of("notSame", "!==");
  final Map<String, String> operators = Collections.<String, String>unmodifiableMap(CollectionLiterals.<String, String>newHashMap(_mappedTo_6, _mappedTo_7, _mappedTo_8, _mappedTo_9, _mappedTo_10, _mappedTo_11, _mappedTo_12, _mappedTo_13, _mappedTo_14, _mappedTo_15, _mappedTo_16));
  final Set<String> booleanOps = Collections.<String>unmodifiableSet(CollectionLiterals.<String>newHashSet("<", "<=", ">", ">=", "===", "!=="));
  Set<Map.Entry<String, String>> _entrySet = operators.entrySet();
  for (final Map.Entry<String, String> op : _entrySet) {
    {
      String _xifexpression = null;
      boolean _contains = booleanOps.contains(op.getValue());
      if (_contains) {
        _xifexpression = "boolean ";
      } else {
        _xifexpression = "Object ";
      }
      final String returnType = _xifexpression;
      StringConcatenation _builder = new StringConcatenation();
      _builder.newLine();
      _builder.append("def dispatch ");
      _builder.append(returnType);
      String _key = op.getKey();
      _builder.append(_key);
      _builder.append("(Object left, Object right) {");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.append("throw new ConstantExpressionEvaluationException(\"Unsupported operator \'");
      String _value = op.getValue();
      _builder.append(_value, "\t");
      _builder.append("\' for operands \"+left+\" and \"+right);");
      _builder.newLineIfNotEmpty();
      _builder.append("}");
      _builder.newLine();
      InputOutput.<String>println(_builder.toString());
      Set<String> _keySet = types.keySet();
      for (final String left : _keySet) {
        {
          InputOutput.<String>println("");
          Set<String> _keySet_1 = types.keySet();
          for (final String right : _keySet_1) {
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("def dispatch ");
            _builder_1.append(returnType);
            String _key_1 = op.getKey();
            _builder_1.append(_key_1);
            _builder_1.append("(");
            _builder_1.append(left);
            _builder_1.append(" left, ");
            _builder_1.append(right);
            _builder_1.append(" right) { left.");
            String _get = types.get(left);
            _builder_1.append(_get);
            _builder_1.append(" ");
            String _value_1 = op.getValue();
            _builder_1.append(_value_1);
            _builder_1.append(" right.");
            String _get_1 = types.get(right);
            _builder_1.append(_get_1);
            _builder_1.append(" }");
            InputOutput.<String>println(_builder_1.toString());
          }
        }
      }
    }
  }
}
 
Example 19
Source File: Solution_017.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
public static void main(final String[] args) {
  InputOutput.<Integer>println(new Solution_017(1000).solve());
}
 
Example 20
Source File: Solution_002.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
public static void main(final String[] args) {
  final Function2<Long, Long, Long> _function = (Long l1, Long l2) -> {
    return Long.valueOf(((l1).longValue() + (l2).longValue()));
  };
  InputOutput.<Long>println(IteratorExtensions.<Long>reduce(new Solution_002(), _function));
}