org.eclipse.xtext.xbase.lib.InputOutput Java Examples

The following examples show how to use org.eclipse.xtext.xbase.lib.InputOutput. 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_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 #2
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 #3
Source File: Solution_012.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
public static void main(final String[] args) {
  long triangle = 0L;
  long i = 1L;
  while (true) {
    {
      triangle = (triangle + i);
      i = (i + 1);
      long _numberOfDivisors = Solution_012.numberOfDivisors(triangle);
      boolean _greaterThan = (_numberOfDivisors > 500);
      if (_greaterThan) {
        InputOutput.<Long>println(Long.valueOf(triangle));
        return;
      }
    }
  }
}
 
Example #4
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 #5
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 #6
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 #7
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 #8
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 #9
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 #10
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 #11
Source File: CliWizardIntegrationTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Use this main method to update the expectations to whatever the wizard
 * currently generates
 */
public static void main(String[] args) {
	try {
		CliProjectsCreator creator = CliWizardIntegrationTest.newProjectCreator();
		for (WizardConfiguration config : CliWizardIntegrationTest.projectConfigs) {
			File targetLocation = new File("testdata/wizard-expectations", config.getBaseName());
			targetLocation.mkdirs();
			Files.sweepFolder(targetLocation);
			config.setRootLocation(targetLocation.getPath());
			creator.createProjects(config);
			InputOutput.println("Updating expectations for " + config.getBaseName());
		}
	} catch (FileNotFoundException e) {
		throw Exceptions.sneakyThrow(e);
	}
}
 
Example #12
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 #13
Source File: ConstantExpressionsInterpreterTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testConstants_RecursionFails() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import static MyConstants.*");
    _builder.newLine();
    _builder.newLine();
    _builder.append("class C { ");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("val someString = MY_CONST");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("class MyConstants {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("static val MY_CONST = STRING_CONSTANT");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("static val STRING_CONSTANT = MY_CONST");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final XtendFile file = this.file(_builder.toString());
    final XtendField stringField = IterableExtensions.<XtendField>head(Iterables.<XtendField>filter(IterableExtensions.<XtendTypeDeclaration>head(file.getXtendTypes()).getMembers(), XtendField.class));
    try {
      InputOutput.<Object>println(this.interpreter.evaluate(stringField.getInitialValue(), null));
      Assert.fail("Exception expected");
    } catch (final Throwable _t) {
      if (_t instanceof ConstantExpressionEvaluationException) {
      } else {
        throw Exceptions.sneakyThrow(_t);
      }
    }
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #14
Source File: DefaultFeatureCallValidator.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isDiscouragedCall(XAbstractFeatureCall call) {
	if (call != null && call.getFeature() != null) {
		final JvmIdentifiableElement feature = call.getFeature();
		final String id = feature.getQualifiedName();
		if (id != null) {
			switch (id) {
			case "java.lang.System.err": //$NON-NLS-1$
			case "java.lang.System.out": //$NON-NLS-1$
			case "java.lang.System.setErr": //$NON-NLS-1$
			case "java.lang.System.setOut": //$NON-NLS-1$
			case "java.lang.System.console": //$NON-NLS-1$
			case "java.lang.System.inheritedChannel": //$NON-NLS-1$
				return true;
			case "java.lang.System.exit": //$NON-NLS-1$
				return isInsideOOTypeDeclaration(call);
			default:
				if (id.startsWith(InputOutput.class.getName())) {
					return true;
				}
				if (id.startsWith(Thread.class.getName())) {
					return true;
				}
			}
		}
	}
	return false;
}
 
Example #15
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 #16
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 #17
Source File: MyMessages.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
public static void main(final String[] args) {
  StringConcatenation _builder = new StringConcatenation();
  String _GREETING = MyMessages.GREETING("World");
  _builder.append(_GREETING);
  _builder.newLineIfNotEmpty();
  Date _date = new Date();
  String _DATE_AND_LOCATION = MyMessages.DATE_AND_LOCATION(_date, "Kiel");
  _builder.append(_DATE_AND_LOCATION);
  _builder.newLineIfNotEmpty();
  InputOutput.<String>println(_builder.toString());
}
 
Example #18
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 #19
Source File: Solution_018.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
public static void main(final String[] args) {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("75");
  _builder.newLine();
  _builder.append("95 64");
  _builder.newLine();
  _builder.append("17 47 82");
  _builder.newLine();
  _builder.append("18 35 87 10");
  _builder.newLine();
  _builder.append("20 04 82 47 65");
  _builder.newLine();
  _builder.append("19 01 23 75 03 34");
  _builder.newLine();
  _builder.append("88 02 77 73 07 63 67");
  _builder.newLine();
  _builder.append("99 65 04 28 06 16 70 92");
  _builder.newLine();
  _builder.append("41 41 26 56 83 40 80 70 33");
  _builder.newLine();
  _builder.append("41 48 72 33 47 32 37 16 94 29");
  _builder.newLine();
  _builder.append("53 71 44 65 25 43 91 52 97 51 14");
  _builder.newLine();
  _builder.append("70 11 33 28 77 73 17 78 39 68 17 57");
  _builder.newLine();
  _builder.append("91 71 52 38 17 14 91 43 58 50 27 29 48");
  _builder.newLine();
  _builder.append("63 66 04 68 89 53 67 30 73 16 69 87 40 31");
  _builder.newLine();
  _builder.append("04 62 98 27 23 09 70 98 73 93 38 53 60 04 23");
  _builder.newLine();
  String _string = _builder.toString();
  SolutionTriangle _solutionTriangle = new SolutionTriangle(_string);
  InputOutput.<SolutionTriangle>println(_solutionTriangle);
}
 
Example #20
Source File: StaticImplicitMethodsFeatureForTypeProvider.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected Collection<String> computeLiteralClassNames() {
	return Lists.newArrayList(
			ArrayLiterals.class.getName(),
			CollectionLiterals.class.getName(),
			InputOutput.class.getName()
	);
}
 
Example #21
Source File: Solution_009.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
public static void main(final String[] args) {
  final Consumer<Integer> _function = (Integer a) -> {
    final Consumer<Integer> _function_1 = (Integer b) -> {
      int c = ((1000 - (a).intValue()) - (b).intValue());
      if ((c >= 0)) {
        if (((((a).intValue() * (a).intValue()) + ((b).intValue() * (b).intValue())) == (c * c))) {
          StringConcatenation _builder = new StringConcatenation();
          _builder.append("a = ");
          _builder.append(a);
          _builder.newLineIfNotEmpty();
          _builder.append("b = ");
          _builder.append(b);
          _builder.newLineIfNotEmpty();
          _builder.append("c = ");
          _builder.append(c);
          _builder.newLineIfNotEmpty();
          _builder.append("product = ");
          _builder.append((((a).intValue() * (b).intValue()) * c));
          _builder.newLineIfNotEmpty();
          InputOutput.<String>println(_builder.toString());
        }
      }
    };
    new IntegerRange(((a).intValue() + 1), (1000 - (a).intValue())).forEach(_function_1);
  };
  new IntegerRange(1, 1000).forEach(_function);
}
 
Example #22
Source File: Solution_016.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<Character, Integer> _function = (Character it) -> {
    return Integer.valueOf(Character.getNumericValue(it.charValue()));
  };
  final Function2<Integer, Integer, Integer> _function_1 = (Integer i1, Integer i2) -> {
    return Integer.valueOf(((i1).intValue() + (i2).intValue()));
  };
  InputOutput.<Integer>println(
    IterableExtensions.<Integer>reduce(ListExtensions.<Character, Integer>map(((List<Character>)Conversions.doWrapArray(BigInteger.valueOf(2L).pow(1000).toString().toCharArray())), _function), _function_1));
}
 
Example #23
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 #24
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 #25
Source File: Solution_007.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
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 #26
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 #27
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 #28
Source File: ImplicitlyImportedFeatures.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
protected List<Class<?>> getStaticImportClasses() {
	return Lists.<Class<?>> newArrayList(
		ArrayLiterals.class,
		CollectionLiterals.class,
		InputOutput.class);
}
 
Example #29
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 #30
Source File: UnicodeTerminalsGenerator.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
public static void main(final String[] args) {
  InputOutput.<CharSequence>println(UnicodeTerminalsGenerator.generateUnicodeRules());
}