Java 类org.eclipse.xtext.xbase.lib.Procedures.Procedure1 实例源码

项目:xtext-extras    文件:ResourceDescriptionProviderTest.java   
@Test
public void testStubGeneration_01() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("public class MyTest {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("public String helloWorld() {");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("return \"Hello\";");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("}");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  final Procedure1<IResourceDescription> _function = (IResourceDescription it) -> {
    Assert.assertEquals("MyTest", IterableExtensions.<IEObjectDescription>head(it.getExportedObjects()).getQualifiedName().toString());
    EObject _eObjectOrProxy = IterableExtensions.<IEObjectDescription>head(it.getExportedObjects()).getEObjectOrProxy();
    Assert.assertFalse(((JvmGenericType) _eObjectOrProxy).isInterface());
    Assert.assertEquals(1, IterableExtensions.size(it.getExportedObjects()));
  };
  this.resultsIn(_builder, _function);
}
项目:xtext-extras    文件:XbaseFormatterTest.java   
@Test
public void formatMemberFeatureCallBuilderMultiline2() {
  final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("newArrayList(\"x\").map(length) [");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("length");
    _builder.newLine();
    _builder.append("]");
    _builder.newLine();
    it.setExpectation(_builder);
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("newArrayList(\"x\")  .  map  (  length   )  [  length  ");
    _builder_1.newLine();
    _builder_1.append("]");
    _builder_1.newLine();
    it.setToBeFormatted(_builder_1);
  };
  this._xbaseFormatterTester.assertFormattedExpression(_function);
}
项目:xtext-extras    文件:XbaseFormatterTest.java   
@Test
public void formatIfElse2() {
  final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("if (true) {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("println(\"foo\")");
    _builder.newLine();
    _builder.append("} else {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("println(\"bar\")");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    it.setToBeFormatted(_builder);
  };
  this._xbaseFormatterTester.assertFormattedExpression(_function);
}
项目:xtext-extras    文件:XbaseFormatterTest.java   
@Test
public void formatFor2() {
  final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> {
    final Procedure1<MapBasedPreferenceValues> _function_1 = (MapBasedPreferenceValues it_1) -> {
      it_1.<Boolean>put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(false));
    };
    it.preferences(_function_1);
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("for (i : 1 .. 2) {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("println(i)");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    it.setToBeFormatted(_builder);
  };
  this._xbaseFormatterTester.assertFormattedExpression(_function);
}
项目:xtext-core    文件:ReferenceTest.java   
@Test
public void testReferences_02() {
  final Procedure1<ReferenceTestConfiguration> _function = (ReferenceTestConfiguration it) -> {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("type Foo {}");
    _builder.newLine();
    _builder.append("type Bar {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("Foo foo");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    it.setModel(_builder.toString());
    it.setColumn("type F".length());
    it.setIncludeDeclaration(true);
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("MyModel.testlang [[0, 5] .. [0, 8]]");
    _builder_1.newLine();
    _builder_1.append("MyModel.testlang [[2, 1] .. [2, 4]]");
    _builder_1.newLine();
    it.setExpectedReferences(_builder_1.toString());
  };
  this.testReferences(_function);
}
项目:xtext-core    文件:WizardConfigTest.java   
@Test
public void testMavenProjectNames() {
  StandardProjectConfig _standardProjectConfig = new StandardProjectConfig();
  final Procedure1<StandardProjectConfig> _function = (StandardProjectConfig it) -> {
    it.setBaseName("com.acme");
    it.setMavenLayout(true);
    BundleProjectConfig _runtimeTest = it.getRuntimeTest();
    _runtimeTest.setEnabled(true);
    BundleProjectConfig _eclipsePlugin = it.getEclipsePlugin();
    _eclipsePlugin.setEnabled(true);
    BundleProjectConfig _eclipsePluginTest = it.getEclipsePluginTest();
    _eclipsePluginTest.setEnabled(true);
  };
  final StandardProjectConfig cfg = ObjectExtensions.<StandardProjectConfig>operator_doubleArrow(_standardProjectConfig, _function);
  cfg.initialize(this.injector);
  Assert.assertEquals("com.acme", cfg.getRuntimeTest().getName());
  Assert.assertEquals("com.acme.ui", cfg.getEclipsePluginTest().getName());
}
项目:xtext-core    文件:FormattingTest.java   
@Test
public void testFormattingClosedFile() {
  final Procedure1<FormattingConfiguration> _function = (FormattingConfiguration it) -> {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("type Foo{int bar} type Bar{Foo foo}");
    Pair<String, String> _mappedTo = Pair.<String, String>of("foo.testlang", _builder.toString());
    it.setFilesInScope(Collections.<String, CharSequence>unmodifiableMap(CollectionLiterals.<String, CharSequence>newHashMap(_mappedTo)));
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("type Foo{");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("int bar");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("type Bar{");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("Foo foo");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    it.setExpectedText(_builder_1.toString());
  };
  this.testFormatting(_function);
}
项目:xtext-extras    文件:XbaseFormatterTest.java   
@Test
public void formatDoWhile12() {
  final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> {
    final Procedure1<MapBasedPreferenceValues> _function_1 = (MapBasedPreferenceValues it_1) -> {
      it_1.<Boolean>put(XbaseFormatterPreferenceKeys.whitespaceBetweenKeywordAndParenthesisML, Boolean.valueOf(false));
    };
    it.preferences(_function_1);
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("do");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("println(\"x\")");
    _builder.newLine();
    _builder.append("while(true)");
    _builder.newLine();
    it.setToBeFormatted(_builder);
  };
  this._xbaseFormatterTester.assertFormattedExpression(_function);
}
项目:xtext-extras    文件:XbaseFormatterTest.java   
@Test
public void formatTryCatchExpression2() {
  final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("try {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("println(\"x\")");
    _builder.newLine();
    _builder.append("} catch (Exception e) {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("println(\"y\")");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    it.setExpectation(_builder);
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("try  {   println(\"x\")  }  catch (  Exception   e  )  {  println(\"y\")  }");
    _builder_1.newLine();
    it.setToBeFormatted(_builder_1);
  };
  this._xbaseFormatterTester.assertFormattedExpression(_function);
}
项目:xtext-extras    文件:XbaseFormatterTest.java   
@Test
public void formatFeatureCall2() {
  final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("val ML2 = newArrayList(newArrayList(1, 2, 3, 4),");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("newArrayList(5, 6, 7, 8, 101, 102, 103, 104, 105, 106, 107, 108, 109,");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120),");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("newArrayList(9, 10, 11, 12), newArrayList(13, 14, 15, 16))");
    _builder.newLine();
    it.setExpectation(_builder);
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("val ML2 = newArrayList(newArrayList(1, 2, 3, 4), newArrayList(5, 6, 7, 8, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120), newArrayList(9, 10, 11, 12), newArrayList(13, 14, 15, 16))");
    _builder_1.newLine();
    it.setToBeFormatted(_builder_1);
  };
  this._xbaseFormatterTester.assertFormattedExpression(_function);
}
项目:xtext-core    文件:FormattingTest.java   
@Test
public void testFormattingService() {
  final Procedure1<FormattingConfiguration> _function = (FormattingConfiguration it) -> {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("type Foo{int bar} type Bar{Foo foo}");
    it.setModel(_builder.toString());
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("type Foo{");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("int bar");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("type Bar{");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("Foo foo");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    it.setExpectedText(_builder_1.toString());
  };
  this.testFormatting(_function);
}
项目:xtext-extras    文件:IndentOnceAutowrapFormatter.java   
@Override
public void format(final ITextSegment region, final IHiddenRegionFormatting wrapped, @Extension final IFormattableDocument document) {
  if ((!this.hasWrapped)) {
    IHiddenRegion _switchResult = null;
    boolean _matched = false;
    if (region instanceof IHiddenRegion) {
      _matched=true;
      _switchResult = ((IHiddenRegion)region);
    }
    if (!_matched) {
      if (region instanceof IHiddenRegionPart) {
        _matched=true;
        _switchResult = ((IHiddenRegionPart)region).getHiddenRegion();
      }
    }
    final IHiddenRegion hiddenRegion = _switchResult;
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.indent();
    };
    document.set(hiddenRegion, this.last, _function);
    this.hasWrapped = true;
  }
}
项目:xtext-extras    文件:LoopExtensions.java   
/**
 * Iterates elements and execute the procedure.
 * A prefix, a separator and a suffix can be initialized with the loopInitializer lambda.
 */
public <T extends Object> void forEach(final ITreeAppendable appendable, final Iterable<T> elements, final Procedure1<? super LoopParams> loopInitializer, final Procedure1<? super T> procedure) {
  boolean _isEmpty = IterableExtensions.isEmpty(elements);
  if (_isEmpty) {
    return;
  }
  LoopParams _loopParams = new LoopParams();
  final LoopParams params = ObjectExtensions.<LoopParams>operator_doubleArrow(_loopParams, loopInitializer);
  params.appendPrefix(appendable);
  T _head = IterableExtensions.<T>head(elements);
  ObjectExtensions.<T>operator_doubleArrow(_head, procedure);
  final Consumer<T> _function = (T it) -> {
    params.appendSeparator(appendable);
    ObjectExtensions.<T>operator_doubleArrow(it, procedure);
  };
  IterableExtensions.<T>tail(elements).forEach(_function);
  params.appendSuffix(appendable);
}
项目:xtext-extras    文件:LoopExtensions.java   
/**
 * Uses curly braces and comma as delimiters. Doesn't use them for single valued iterables.
 */
public <T extends Object> void forEachWithShortcut(final ITreeAppendable appendable, final Iterable<T> elements, final Procedure1<? super T> procedure) {
  int _size = IterableExtensions.size(elements);
  boolean _equals = (_size == 1);
  if (_equals) {
    T _head = IterableExtensions.<T>head(elements);
    ObjectExtensions.<T>operator_doubleArrow(_head, procedure);
  } else {
    appendable.append("{");
    final Procedure1<LoopParams> _function = (LoopParams it) -> {
      it.setPrefix(" ");
      it.setSeparator(", ");
      it.setSuffix(" ");
    };
    this.<T>forEach(appendable, elements, _function, procedure);
    appendable.append("}");
  }
}
项目:xtext-core    文件:ProjectManager.java   
protected BuildRequest newBuildRequest(final List<URI> changedFiles, final List<URI> deletedFiles, final List<IResourceDescription.Delta> externalDeltas, final CancelIndicator cancelIndicator) {
  BuildRequest _buildRequest = new BuildRequest();
  final Procedure1<BuildRequest> _function = (BuildRequest it) -> {
    it.setBaseDir(this.baseDir);
    ResourceDescriptionsData _copy = this.indexState.getResourceDescriptions().copy();
    Source2GeneratedMapping _copy_1 = this.indexState.getFileMappings().copy();
    IndexState _indexState = new IndexState(_copy, _copy_1);
    it.setState(_indexState);
    it.setResourceSet(this.createFreshResourceSet(it.getState().getResourceDescriptions()));
    it.setDirtyFiles(changedFiles);
    it.setDeletedFiles(deletedFiles);
    it.setExternalDeltas(externalDeltas);
    final BuildRequest.IPostValidationCallback _function_1 = (URI uri, Iterable<Issue> issues) -> {
      this.issueAcceptor.apply(uri, issues);
      return true;
    };
    it.setAfterValidate(_function_1);
    it.setCancelIndicator(cancelIndicator);
  };
  return ObjectExtensions.<BuildRequest>operator_doubleArrow(_buildRequest, _function);
}
项目:xtext-extras    文件:XbaseFormatterTest.java   
@Test
public void formatBasicFor5() {
  final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("val x = 1");
    _builder.newLine();
    _builder.append("for (;; x = x + 1, x = x + 2)");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("println(x)");
    _builder.newLine();
    it.setExpectation(_builder);
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("val x = 1");
    _builder_1.newLine();
    _builder_1.append("for  (       ;     ;     x     =      x \t+      1  ,  x  =   x   +    2 )          println(x)");
    _builder_1.newLine();
    it.setToBeFormatted(_builder_1);
  };
  this._xbaseFormatterTester.assertFormattedExpression(_function);
}
项目:xtext-extras    文件:XbaseFormatterTest.java   
@Test
public void formatMemberFeatureCall4() {
  final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("val ML1 = \"x\".substring(0, 1, 2)");
    _builder.newLine();
    it.setExpectation(_builder);
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("val ML1 = \"x\".substring (");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("0, ");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("1, ");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("2)");
    _builder_1.newLine();
    it.setToBeFormatted(_builder_1);
  };
  this._xbaseFormatterTester.assertFormattedExpression(_function);
}
项目:xtext-core    文件:IncrementalBuilderTest.java   
@Test
public void testSimpleFullBuild() {
  final Procedure1<BuildRequest> _function = (BuildRequest it) -> {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("entity B {}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("entity A { foo.B myReference }");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    URI _minus = this.operator_minus(
      "src/MyFile.indextestlanguage", _builder.toString());
    it.setDirtyFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(_minus)));
  };
  final BuildRequest buildRequest = this.newBuildRequest(_function);
  this.build(buildRequest);
  Assert.assertTrue(this.issues.toString(), this.issues.isEmpty());
  Assert.assertEquals(2, this.generated.size());
  Assert.assertTrue(this.containsSuffix(this.generated.values(), "src-gen/B.txt"));
  Assert.assertTrue(this.containsSuffix(this.generated.values(), "src-gen/A.txt"));
}
项目:xtext-core    文件:RegionSetTest.java   
@Test
public void testAddValid() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("issues=");
  _builder.newLine();
  _builder.append("set=[[10,0], [10,1], [11,1], [12,1], [99,1], [100,0]]");
  _builder.newLine();
  final Procedure1<TestableTextSegmentSet> _function = (TestableTextSegmentSet it) -> {
    TextSegment _textSegment = new TextSegment(null, 10, 0);
    it.add(_textSegment);
    TextSegment _textSegment_1 = new TextSegment(null, 11, 1);
    it.add(_textSegment_1);
    TextSegment _textSegment_2 = new TextSegment(null, 99, 1);
    it.add(_textSegment_2);
    TextSegment _textSegment_3 = new TextSegment(null, 10, 1);
    it.add(_textSegment_3);
    TextSegment _textSegment_4 = new TextSegment(null, 100, 0);
    it.add(_textSegment_4);
    TextSegment _textSegment_5 = new TextSegment(null, 12, 1);
    it.add(_textSegment_5);
  };
  this.test(_builder, _function);
}
项目:xtext-extras    文件:XbaseFormatterTest.java   
@Test
public void formatBasicFor6() {
  final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("for (val x = 1;; x = x + 1, x = x + 2)");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("println(x)");
    _builder.newLine();
    it.setExpectation(_builder);
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("for  (\t\t\tval \t\tx \t\t= \t\t1\t\t;     ;     x     =      x \t+      1  ,  x  =   x   +    2 )          println(x)");
    _builder_1.newLine();
    it.setToBeFormatted(_builder_1);
  };
  this._xbaseFormatterTester.assertFormattedExpression(_function);
}
项目:xtext-extras    文件:JvmModelGeneratorTest.java   
@Test
public void testEnumerationWithCompleter() {
  try {
    final XExpression expression = this.expression("null", false);
    final Procedure1<JvmEnumerationType> _function = (JvmEnumerationType it) -> {
      EList<JvmMember> _members = it.getMembers();
      JvmEnumerationLiteral _enumerationLiteral = this.builder.toEnumerationLiteral(expression, "BAR");
      this.builder.<JvmEnumerationLiteral>operator_add(_members, _enumerationLiteral);
      EList<JvmMember> _members_1 = it.getMembers();
      JvmEnumerationLiteral _enumerationLiteral_1 = this.builder.toEnumerationLiteral(expression, "BAZ");
      this.builder.<JvmEnumerationLiteral>operator_add(_members_1, _enumerationLiteral_1);
    };
    final JvmEnumerationType enumeration = this.builder.toEnumerationType(expression, "my.test.Foo", _function);
    expression.eResource().getContents().add(enumeration);
    this.completer.complete(enumeration);
    final Class<?> compiled = this.compile(expression.eResource(), enumeration);
    final Method valuesMethod = compiled.getMethod("values");
    Object _invoke = valuesMethod.invoke(null);
    final Object[] values = ((Object[]) _invoke);
    Assert.assertEquals("BAR", values[0].toString());
    Assert.assertEquals("BAZ", values[1].toString());
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
项目:xtext-extras    文件:XbaseFormatterTest.java   
@Test
public void formatWhile21() {
  final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> {
    final Procedure1<MapBasedPreferenceValues> _function_1 = (MapBasedPreferenceValues it_1) -> {
      it_1.<Boolean>put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(true));
    };
    it.preferences(_function_1);
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("while (true)");
    _builder.newLine();
    _builder.append("{");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("println(\"x\")");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    it.setToBeFormatted(_builder);
  };
  this._xbaseFormatterTester.assertFormattedExpression(_function);
}
项目:xtext-extras    文件:XbaseFormatterTest.java   
@Test
public void formatXReturnExpression2() {
  final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("\"foo\"");
    _builder.newLine();
    _builder.append("return");
    _builder.newLine();
    it.setExpectation(_builder);
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("\"foo\"  return");
    _builder_1.newLine();
    it.setToBeFormatted(_builder_1);
  };
  this._xbaseFormatterTester.assertFormattedExpression(_function);
}
项目:xtext-extras    文件:XbaseFormatterTest.java   
@Test
public void formatMemberFeatureCall21() {
  final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("val ML1 = \"x\".toString.toString");
    _builder.newLine();
    it.setExpectation(_builder);
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("val ML1 = \"x\"");
    _builder_1.newLine();
    _builder_1.append(".");
    _builder_1.newLine();
    _builder_1.append("toString");
    _builder_1.newLine();
    _builder_1.append(".");
    _builder_1.newLine();
    _builder_1.append("toString");
    _builder_1.newLine();
    it.setToBeFormatted(_builder_1);
  };
  this._xbaseFormatterTester.assertFormattedExpression(_function);
}
项目:OCCI-Studio    文件:OCCIFormatter.java   
protected void _format(final AttributeState attributeState, @Extension final IFormattableDocument document) {
  final ISemanticRegion kvalue = this.textRegionExtensions.regionFor(attributeState).feature(OCCIPackage.Literals.ATTRIBUTE_STATE__VALUE);
  final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
    it.setNewLines(1);
  };
  document.append(kvalue, _function);
}
项目:mochalog-sarl-beliefs    文件:BasicBeliefSocialisation.java   
@Override
public SocialPoll isBelievedByAny(EventSpace space, Scope<Address> scope, BeliefQuery query, 
    long timeout, Procedure1<? super Boolean> plan)
{
    // Conduct poll, evaluating based on whether
    // query is believed by any participants
    return conductPoll(
        space, scope, query, timeout,
        (e, r) -> isBelievedByAnyEvaluator(space, e, r), plan
    );
}
项目:mochalog-sarl-beliefs    文件:BasicBeliefSocialisation.java   
@Override
public SocialPoll allBelieveThat(EventSpace space, Scope<Address> scope, BeliefQuery query, 
    boolean isTrue, long timeout, Procedure1<? super Boolean> plan)
{
    // Conduct poll, evaluating based on whether
    // all participants agree that a given query is either true or false
    return conductPoll(
        space, scope, query, timeout,
        (e, r) -> allBelieveThatEvaluator(isTrue, e, r), plan
    );
}
项目:mochalog-sarl-beliefs    文件:BasicBeliefSocialisation.java   
@Override
public SocialPoll conductPoll(EventSpace space, Scope<Address> scope, BeliefQuery query, 
    long timeout, ExperimentEvaluator<SocialPollBallot> evaluator, Procedure1<? super Boolean> onResult)
{
    return new SocialPollImpl.Executor()
        .setSpace(space)
        .setAccessPrincipal(principal)
        .addSurveys(query)
        .setSurveyScope(scope)
        .setEvaluator(evaluator)
        .onPollResult(onResult)
        .endExperimentAfter(timeout)
        .execute();
}
项目:xtext-core    文件:DocumentTest.java   
private Position position(final int l, final int c) {
  Position _position = new Position();
  final Procedure1<Position> _function = (Position it) -> {
    it.setLine(l);
    it.setCharacter(c);
  };
  return ObjectExtensions.<Position>operator_doubleArrow(_position, _function);
}
项目:xtext-extras    文件:PureXbaseFormatter.java   
@Override
protected void _format(final XBlockExpression xBlockExpression, @Extension final IFormattableDocument document) {
  final Consumer<ISemanticRegion> _function = (ISemanticRegion it) -> {
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it_1) -> {
      it_1.newLine();
    };
    document.append(it, _function_1);
  };
  this.textRegionExtensions.regionFor(xBlockExpression).keywords(this._pureXbaseGrammarAccess.getSpecialBlockExpressionAccess().getSemicolonKeyword_1_1()).forEach(_function);
  EList<XExpression> _expressions = xBlockExpression.getExpressions();
  for (final XExpression xExpression : _expressions) {
    document.<XExpression>format(xExpression);
  }
}
项目:xtext-extras    文件:XbaseFormatterTest.java   
@Test
public void formatClosuresWrapIfNeeded() {
  final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("val x = newArrayList(\"A\", \"b\")");
    _builder.newLine();
    _builder.append("val y = x.filter [");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("val z = it");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("z.toUpperCase == z");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("z.toUpperCase == z");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("z.toUpperCase == z");
    _builder.newLine();
    _builder.append("]");
    _builder.newLine();
    _builder.append("y.join");
    _builder.newLine();
    it.setExpectation(_builder);
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("val x = newArrayList(\"A\", \"b\") val y = x.filter [ val z = it z.toUpperCase == z z.toUpperCase == z z.toUpperCase == z ] y.join");
    _builder_1.newLine();
    it.setToBeFormatted(_builder_1);
  };
  this._xbaseFormatterTester.assertFormattedExpression(_function);
}
项目:xtext-core    文件:DocumentSymbolService.java   
protected void createSymbol(final IEObjectDescription description, final IReferenceFinder.IResourceAccess resourceAccess, final Procedure1<? super SymbolInformation> acceptor) {
  final String name = this.getSymbolName(description);
  if ((name == null)) {
    return;
  }
  final SymbolKind kind = this.getSymbolKind(description);
  if ((kind == null)) {
    return;
  }
  final Procedure1<Location> _function = (Location location) -> {
    final SymbolInformation symbol = new SymbolInformation(name, kind, location);
    acceptor.apply(symbol);
  };
  this.getSymbolLocation(description, resourceAccess, _function);
}
项目:chariot    文件:DM_GoalDescription.java   
/**
 * Method to add an objective.
 * 
 * @param initializer   DM_Objective entity to be added.
 */
public void addObjective(final Procedure1<? super DM_Objective> initializer) {
  DM_Objective _dM_Objective = new DM_Objective();
  final DM_Objective objectiveToAdd = ObjectExtensions.<DM_Objective>operator_doubleArrow(_dM_Objective, initializer);
  List<DM_Objective> _objectives = this.getObjectives();
  _objectives.add(objectiveToAdd);
}
项目:xtext-extras    文件:JvmTypesBuilder.java   
/**
 * Creates a public annotation declaration, associated to the given sourceElement. It sets the given name, which might be
 * fully qualified using the standard Java notation.
 * 
 * @param sourceElement
 *            the sourceElement the resulting element is associated with.
 * @param name
 *            the qualified name of the resulting class.
 * @param initializer
 *            the initializer to apply on the created annotation. If <code>null</code>, the annotation won't be initialized.
 * 
 * @return a {@link JvmAnnotationType} representing a Java annotation of the given name, <code>null</code> 
 *            if sourceElement or name are <code>null</code>.
 */
/* @Nullable */ 
public JvmAnnotationType toAnnotationType(/* @Nullable */ EObject sourceElement, /* @Nullable */ String name, 
        /* @Nullable */ Procedure1<? super JvmAnnotationType> initializer) {
    if (sourceElement == null || name == null)
        return null;
    Pair<String, String> fullName = splitQualifiedName(name);
    JvmAnnotationType annotationType = typesFactory.createJvmAnnotationType();
    annotationType.setSimpleName(fullName.getSecond());
    annotationType.setAbstract(true);
    if (fullName.getFirst() != null)
        annotationType.setPackageName(fullName.getFirst());
    associate(sourceElement, annotationType);
    return initializeSafely(annotationType, initializer);
}
项目:xtext-extras    文件:JvmTypesBuilder.java   
/**
 * Creates a public enum declaration, associated to the given sourceElement. It sets the given name, which might be
 * fully qualified using the standard Java notation.
 * 
 * @param sourceElement
 *            the sourceElement the resulting element is associated with.
 * @param name
 *            the qualified name of the resulting enum type.
 * @param initializer
 *            the initializer to apply on the created enumeration type. If <code>null</code>, the enum won't be initialized.
 * 
 * @return a result representing a Java enum type with the given name, <code>null</code> 
 *            if sourceElement or name are <code>null</code>.
 */
/* @Nullable */ 
public JvmEnumerationType toEnumerationType(/* @Nullable */ EObject sourceElement, /* @Nullable */ String name, 
        /* @Nullable */ Procedure1<? super JvmEnumerationType> initializer) {
    if (sourceElement == null || name == null)
        return null;
    Pair<String, String> fullName = splitQualifiedName(name);
    JvmEnumerationType result = typesFactory.createJvmEnumerationType();
    result.setSimpleName(fullName.getSecond());
    result.setVisibility(JvmVisibility.PUBLIC);
    if (fullName.getFirst() != null)
        result.setPackageName(fullName.getFirst());
    associate(sourceElement, result);
    return initializeSafely(result, initializer);
}
项目:xtext-extras    文件:JvmTypesBuilder.java   
/**
 * Same as {@link #toEnumerationLiteral(EObject, String)} but with an initializer passed as the last argument.
 */
/* @Nullable */ 
public JvmEnumerationLiteral toEnumerationLiteral(/* @Nullable */ EObject sourceElement, /* @Nullable */ String name, 
        /* @Nullable */ Procedure1<? super JvmEnumerationLiteral> initializer) {
    if (sourceElement == null || name == null)
        return null;
    JvmEnumerationLiteral result = typesFactory.createJvmEnumerationLiteral();
    result.setSimpleName(name);
    result.setVisibility(JvmVisibility.PUBLIC);
    associate(sourceElement, result);
    return initializeSafely(result, initializer);
}
项目:xtext-extras    文件:JvmTypesBuilder.java   
/**
 * Same as {@link #toField(EObject, String, JvmTypeReference)} but with an initializer passed as the last argument.
 */
/* @Nullable */ 
public JvmField toField(/* @Nullable */ EObject sourceElement, /* @Nullable */ String name, /* @Nullable */ JvmTypeReference typeRef, 
        /* @Nullable */ Procedure1<? super JvmField> initializer) {
    if(sourceElement == null || name == null) 
        return null;
    JvmField result = typesFactory.createJvmField();
    result.setSimpleName(name);
    result.setVisibility(JvmVisibility.PRIVATE);
    result.setType(cloneWithProxies(typeRef));
    associate(sourceElement, result);
    return initializeSafely(result, initializer);
}
项目:xtext-extras    文件:XbaseFormatterTest.java   
@Test
public void formatIfElseIf2() {
  final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("if (true) {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("println(\"foo\")");
    _builder.newLine();
    _builder.append("} else if (false) {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("println(\"bar\")");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    it.setExpectation(_builder);
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("if(true) {");
    _builder_1.newLine();
    _builder_1.append("println(\"foo\")");
    _builder_1.newLine();
    _builder_1.append("} else if(false) {");
    _builder_1.newLine();
    _builder_1.append("println(\"bar\")");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    it.setToBeFormatted(_builder_1);
  };
  this._xbaseFormatterTester.assertFormattedExpression(_function);
}
项目:xtext-core    文件:IdeCrossrefProposalProvider.java   
protected ContentAssistEntry createProposal(final IEObjectDescription candidate, final CrossReference crossRef, final ContentAssistContext context) {
  final Procedure1<ContentAssistEntry> _function = (ContentAssistEntry it) -> {
    it.setSource(candidate);
    EClass _eClass = candidate.getEClass();
    String _name = null;
    if (_eClass!=null) {
      _name=_eClass.getName();
    }
    it.setDescription(_name);
  };
  return this.proposalCreator.createProposal(this.qualifiedNameConverter.toString(candidate.getName()), context, _function);
}
项目:xtext-core    文件:IncrementalBuilderTest.java   
@Test(expected = OperationCanceledException.class)
public void testCancellation() {
  final IncrementalBuilderTest.CancelOnFirstModel cancelOnFirstModel = new IncrementalBuilderTest.CancelOnFirstModel();
  final Procedure1<BuildRequest> _function = (BuildRequest it) -> {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("entity A { foo.B myReference }");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    URI _minus = this.operator_minus(
      "src/MyFile.indextestlanguage", _builder.toString());
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("foo {");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("entity B {}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    URI _minus_1 = this.operator_minus(
      "src/MyFile2.indextestlanguage", _builder_1.toString());
    it.setDirtyFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(_minus, _minus_1)));
    it.setCancelIndicator(cancelOnFirstModel);
    it.setAfterValidate(cancelOnFirstModel);
  };
  final BuildRequest buildRequest = this.newBuildRequest(_function);
  this.build(buildRequest);
}