Java Code Examples for org.eclipse.xtext.xbase.lib.Pair#of()

The following examples show how to use org.eclipse.xtext.xbase.lib.Pair#of() . 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: NewLanguageFeaturesCompilerTest.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testUnderscoreInNumericLiteral() throws Exception {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("{");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("val x = 123_456_789");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  StringConcatenation _builder_1 = new StringConcatenation();
  _builder_1.append("final int x = 123_456_789;");
  _builder_1.newLine();
  Pair<JavaVersion, JavaVersion> _mappedTo = Pair.<JavaVersion, JavaVersion>of(JavaVersion.JAVA7, JavaVersion.JAVA8);
  this.compilesTo(_builder, _builder_1, _mappedTo);
}
 
Example 2
Source File: SuperCallScopeTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testGetElementsByName_06() throws Exception {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("grammar test.Lang with org.eclipse.xtext.common.Terminals");
  _builder.newLine();
  _builder.append("generate test \'http://test\'");
  _builder.newLine();
  _builder.append("Rule: name=ID;");
  _builder.newLine();
  _builder.append("terminal ID: super;");
  _builder.newLine();
  final String grammarAsString = _builder.toString();
  EObject _model = this.getModel(grammarAsString);
  final Grammar grammar = ((Grammar) _model);
  final SuperCallScope scope = new SuperCallScope(grammar);
  Iterable<IEObjectDescription> _elements = scope.getElements(QualifiedName.create("Lang", "ID"));
  AbstractRule _findRuleForName = GrammarUtil.findRuleForName(grammar, "test.Lang.ID");
  Pair<String, AbstractRule> _mappedTo = Pair.<String, AbstractRule>of("Lang.ID", _findRuleForName);
  this.assertElements(_elements, _mappedTo);
}
 
Example 3
Source File: PartialSerializerTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
private <T extends EObject> ITextRegionAccess recordDiff(final Class<T> modelType, final CharSequence modelText, final IChangeSerializer.IModification<T> modification) {
  final InMemoryURIHandler fs = new InMemoryURIHandler();
  String _string = modelText.toString();
  Pair<String, String> _mappedTo = Pair.<String, String>of("inmemory:/file1.pstl", _string);
  this._changeSerializerTestHelper.operator_add(fs, _mappedTo);
  final ResourceSet rs = this._changeSerializerTestHelper.createResourceSet(fs);
  final T model = this._changeSerializerTestHelper.<T>contents(rs, "inmemory:/file1.pstl", modelType);
  final ChangeSerializer serializer = this.serializerProvider.get();
  serializer.<T>addModification(model, modification);
  return this._changeSerializerTestHelper.endRecordChangesToTextRegions(serializer);
}
 
Example 4
Source File: SuperCallScopeTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testGetElementsByEObject_03() throws Exception {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("grammar test.Lang with org.eclipse.xtext.common.Terminals");
  _builder.newLine();
  _builder.append("generate test \'http://test\'");
  _builder.newLine();
  _builder.append("Rule: name=ID;");
  _builder.newLine();
  _builder.append("terminal ID: super;");
  _builder.newLine();
  final String grammarAsString = _builder.toString();
  EObject _model = this.getModel(grammarAsString);
  final Grammar grammar = ((Grammar) _model);
  AbstractRule _last = IterableExtensions.<AbstractRule>last(grammar.getRules());
  final SuperCallScope scope = new SuperCallScope(_last);
  final AbstractRule id = GrammarUtil.findRuleForName(grammar, "org.eclipse.xtext.common.Terminals.ID");
  Iterable<IEObjectDescription> _elements = scope.getElements(id);
  AbstractRule _findRuleForName = GrammarUtil.findRuleForName(grammar, "org.eclipse.xtext.common.Terminals.ID");
  Pair<String, AbstractRule> _mappedTo = Pair.<String, AbstractRule>of("super", _findRuleForName);
  AbstractRule _findRuleForName_1 = GrammarUtil.findRuleForName(grammar, "org.eclipse.xtext.common.Terminals.ID");
  Pair<String, AbstractRule> _mappedTo_1 = Pair.<String, AbstractRule>of("super.ID", _findRuleForName_1);
  AbstractRule _findRuleForName_2 = GrammarUtil.findRuleForName(grammar, "org.eclipse.xtext.common.Terminals.ID");
  Pair<String, AbstractRule> _mappedTo_2 = Pair.<String, AbstractRule>of("Lang.ID", _findRuleForName_2);
  AbstractRule _findRuleForName_3 = GrammarUtil.findRuleForName(grammar, "org.eclipse.xtext.common.Terminals.ID");
  Pair<String, AbstractRule> _mappedTo_3 = Pair.<String, AbstractRule>of("test.Lang.ID", _findRuleForName_3);
  this.assertElements(_elements, _mappedTo, _mappedTo_1, _mappedTo_2, _mappedTo_3);
}
 
Example 5
Source File: BoundTypeArgumentMergerTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testArgumentTypeUsedTwice_01_a() {
  Pair<String, VarianceInfo> _mappedTo = Pair.<String, VarianceInfo>of("String", VarianceInfo.INVARIANT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_1 = this.operator_mappedTo(_mappedTo, VarianceInfo.INVARIANT);
  Pair<String, VarianceInfo> _mappedTo_2 = Pair.<String, VarianceInfo>of("String", VarianceInfo.INVARIANT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_3 = this.operator_mappedTo(_mappedTo_2, VarianceInfo.INVARIANT);
  this.to(this.merge(_mappedTo_1, _mappedTo_3), "String", VarianceInfo.INVARIANT);
}
 
Example 6
Source File: ResourceDescriptionProviderTest.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected void resultsIn(final CharSequence javaCode, final Procedure1<? super IResourceDescription> assertion) {
  String _string = javaCode.toString();
  Pair<String, String> _mappedTo = Pair.<String, String>of("SomeJava.java", _string);
  final XtextResourceSet resourceSet = this.resourceSet(_mappedTo);
  this.compilerPhases.setIndexing(resourceSet, true);
  final Resource resource = IterableExtensions.<Resource>head(resourceSet.getResources());
  final IResourceDescription description = this.resourceDesriptionManager.getResourceDescription(resource);
  assertion.apply(description);
}
 
Example 7
Source File: BoundTypeArgumentMergerTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testArgumentTypeUsedTwice_02_d() {
  Pair<String, VarianceInfo> _mappedTo = Pair.<String, VarianceInfo>of("String", VarianceInfo.INVARIANT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_1 = this.operator_mappedTo(_mappedTo, VarianceInfo.INVARIANT);
  Pair<String, VarianceInfo> _mappedTo_2 = Pair.<String, VarianceInfo>of("String", VarianceInfo.OUT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_3 = this.operator_mappedTo(_mappedTo_2, VarianceInfo.OUT);
  this.to(this.merge(_mappedTo_1, _mappedTo_3), "String", VarianceInfo.INVARIANT);
}
 
Example 8
Source File: BoundTypeArgumentMergerTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testArgumentTypeUsedTwice_02_b() {
  Pair<String, VarianceInfo> _mappedTo = Pair.<String, VarianceInfo>of("String", VarianceInfo.INVARIANT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_1 = this.operator_mappedTo(_mappedTo, VarianceInfo.OUT);
  Pair<String, VarianceInfo> _mappedTo_2 = Pair.<String, VarianceInfo>of("String", VarianceInfo.OUT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_3 = this.operator_mappedTo(_mappedTo_2, VarianceInfo.INVARIANT);
  this.to(this.merge(_mappedTo_1, _mappedTo_3), "String", null);
}
 
Example 9
Source File: ActualTypeArgumentCollectorTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testUnambiguousMapping_01() {
  Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> _mappedBy = this.mappedBy("T", "java.util.List<T>", "java.util.List<String>");
  Pair<String, VarianceInfo> _mappedTo = Pair.<String, VarianceInfo>of("String", VarianceInfo.INVARIANT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_1 = this.operator_mappedTo(_mappedTo, VarianceInfo.INVARIANT);
  this.assertMapping(_mappedBy, "T", _mappedTo_1);
}
 
Example 10
Source File: ActualTypeArgumentCollectorTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testCircularTypeParams_11() {
  Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> _mappedBy = this.mappedBy("T extends (Object)=>T", "T", "Object");
  Pair<String, VarianceInfo> _mappedTo = Pair.<String, VarianceInfo>of("Object", VarianceInfo.OUT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_1 = this.operator_mappedTo(_mappedTo, VarianceInfo.OUT);
  this.assertMapping(_mappedBy, "T", _mappedTo_1);
}
 
Example 11
Source File: ActualTypeArgumentCollectorTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testUpperBound_03() {
  Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> _mappedBy = this.mappedBy("T", "Iterable<? extends T>", "Iterable<? super String>");
  Pair<String, VarianceInfo> _mappedTo = Pair.<String, VarianceInfo>of("Object", VarianceInfo.OUT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_1 = this.operator_mappedTo(_mappedTo, VarianceInfo.OUT);
  Pair<String, VarianceInfo> _mappedTo_2 = Pair.<String, VarianceInfo>of("String", VarianceInfo.OUT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_3 = this.operator_mappedTo(_mappedTo_2, VarianceInfo.IN);
  this.assertOrigins(this.assertMapping(_mappedBy, "T", _mappedTo_1, _mappedTo_3), "T", 1);
}
 
Example 12
Source File: ActualTypeArgumentCollectorTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testUpperBound_11() {
  Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> _mappedBy = this.mappedBy("T", "java.util.Map<? extends T, ? extends T>", "java.util.Map<String, Integer>");
  Pair<String, VarianceInfo> _mappedTo = Pair.<String, VarianceInfo>of("String", VarianceInfo.OUT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_1 = this.operator_mappedTo(_mappedTo, VarianceInfo.INVARIANT);
  Pair<String, VarianceInfo> _mappedTo_2 = Pair.<String, VarianceInfo>of("Integer", VarianceInfo.OUT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_3 = this.operator_mappedTo(_mappedTo_2, VarianceInfo.INVARIANT);
  this.assertOrigins(this.assertMapping(_mappedBy, "T", _mappedTo_1, _mappedTo_3), "T", 2);
}
 
Example 13
Source File: ActualTypeArgumentCollectorTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testBestEffortMapping_01() {
  Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> _mappedBy = this.mappedBy("T", "java.util.List<T>", "java.util.Set<String>");
  Pair<String, VarianceInfo> _mappedTo = Pair.<String, VarianceInfo>of("String", VarianceInfo.INVARIANT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_1 = this.operator_mappedTo(_mappedTo, VarianceInfo.INVARIANT);
  this.assertMapping(_mappedBy, "T", _mappedTo_1);
}
 
Example 14
Source File: BoundTypeArgumentMergerTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testArgumentTypeUsedTwice_09_a() {
  Pair<String, VarianceInfo> _mappedTo = Pair.<String, VarianceInfo>of("String", VarianceInfo.IN);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_1 = this.operator_mappedTo(_mappedTo, VarianceInfo.INVARIANT);
  Pair<String, VarianceInfo> _mappedTo_2 = Pair.<String, VarianceInfo>of("String", VarianceInfo.IN);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_3 = this.operator_mappedTo(_mappedTo_2, VarianceInfo.INVARIANT);
  this.to(this.merge(_mappedTo_1, _mappedTo_3), "String", VarianceInfo.INVARIANT);
}
 
Example 15
Source File: ActualTypeArgumentCollectorTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testLowerBound_06() {
  Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> _mappedBy = this.mappedBy("T", "Iterable<T>", "Iterable<? super String>");
  Pair<String, VarianceInfo> _mappedTo = Pair.<String, VarianceInfo>of("String", VarianceInfo.INVARIANT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_1 = this.operator_mappedTo(_mappedTo, VarianceInfo.IN);
  this.assertMapping(_mappedBy, "T", _mappedTo_1);
}
 
Example 16
Source File: BoundTypeArgumentMergerTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testArgumentTypeUsedTwice_01_f() {
  Pair<String, VarianceInfo> _mappedTo = Pair.<String, VarianceInfo>of("String", VarianceInfo.INVARIANT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_1 = this.operator_mappedTo(_mappedTo, VarianceInfo.IN);
  Pair<String, VarianceInfo> _mappedTo_2 = Pair.<String, VarianceInfo>of("String", VarianceInfo.INVARIANT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_3 = this.operator_mappedTo(_mappedTo_2, VarianceInfo.OUT);
  this.to(this.merge(_mappedTo_1, _mappedTo_3), "String", null);
}
 
Example 17
Source File: ActualTypeArgumentCollectorTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testBestEffortMapping_02() {
  Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> _mappedBy = this.mappedBy("T", "java.util.ArrayList<T>", "java.util.HashSet<String>");
  Pair<String, VarianceInfo> _mappedTo = Pair.<String, VarianceInfo>of("String", VarianceInfo.INVARIANT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_1 = this.operator_mappedTo(_mappedTo, VarianceInfo.INVARIANT);
  this.assertMapping(_mappedBy, "T", _mappedTo_1);
}
 
Example 18
Source File: ChangeSerializerWithEmfTest.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void testChangeRefToXML() {
  final InMemoryURIHandler fs = new InMemoryURIHandler();
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("#21 MyPackage.MyClass1");
  Pair<String, String> _mappedTo = Pair.<String, String>of("inmemory:/file1.pstl", _builder.toString());
  this._changeSerializerTestHelper.operator_add(fs, _mappedTo);
  StringConcatenation _builder_1 = new StringConcatenation();
  _builder_1.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
  _builder_1.newLine();
  _builder_1.append("<ecore:EPackage xmi:version=\"2.0\" xmlns:xmi=\"http://www.omg.org/XMI\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
  _builder_1.newLine();
  _builder_1.append("    ");
  _builder_1.append("xmlns:ecore=\"http://www.eclipse.org/emf/2002/Ecore\" name=\"MyPackage\">");
  _builder_1.newLine();
  _builder_1.append("  ");
  _builder_1.append("<eClassifiers xsi:type=\"ecore:EClass\" name=\"MyClass1\" eSuperTypes=\"#//MyClass2\"/>");
  _builder_1.newLine();
  _builder_1.append("  ");
  _builder_1.append("<eClassifiers xsi:type=\"ecore:EClass\" name=\"MyClass2\"/>");
  _builder_1.newLine();
  _builder_1.append("</ecore:EPackage>");
  _builder_1.newLine();
  Pair<String, String> _mappedTo_1 = Pair.<String, String>of("inmemory:/file2.ecore", _builder_1.toString());
  this._changeSerializerTestHelper.operator_add(fs, _mappedTo_1);
  final ResourceSet rs = this._changeSerializerTestHelper.createResourceSet(fs);
  final EClassRef model = this._changeSerializerTestHelper.<EClassRef>contents(rs, "inmemory:/file1.pstl", EClassRef.class);
  final ChangeSerializer serializer = this.serializerProvider.get();
  final IChangeSerializer.IModification<EClassRef> _function = (EClassRef it) -> {
    EClassifier _get = model.getRef().getEPackage().getEClassifiers().get(1);
    model.setRef(((EClass) _get));
  };
  serializer.<EClassRef>addModification(model, _function);
  Collection<IEmfResourceChange> _endRecordChangesToTextDocuments = this._changeSerializerTestHelper.endRecordChangesToTextDocuments(serializer);
  StringConcatenation _builder_2 = new StringConcatenation();
  _builder_2.append("----------------- inmemory:/file1.pstl (syntax: <offset|text>) -----------------");
  _builder_2.newLine();
  _builder_2.append("#21 <4:18|MyPackage.MyClass2>");
  _builder_2.newLine();
  _builder_2.append("--------------------------------------------------------------------------------");
  _builder_2.newLine();
  _builder_2.append("4 18 \"MyPackage.MyClass1\" -> \"MyPackage.MyClass2\"");
  _builder_2.newLine();
  this._changeSerializerTestHelper.operator_tripleEquals(_endRecordChangesToTextDocuments, _builder_2);
}
 
Example 19
Source File: ConstantExpressionsInterpreterTest.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
protected void evaluatesTo(final String expression, final Procedure1<? super Object> assertions) {
  Pair<String, String> _mappedTo = Pair.<String, String>of(null, expression);
  this.evaluatesTo(_mappedTo, assertions);
}
 
Example 20
Source File: UIResourceChangeRegistryTest.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
public static String toReadableString(final IResourceDelta delta) {
  StringConcatenation _builder = new StringConcatenation();
  IPath _fullPath = delta.getFullPath();
  _builder.append(_fullPath);
  _builder.append(" ");
  String _switchResult = null;
  int _kind = delta.getKind();
  switch (_kind) {
    case IResourceDelta.ADDED:
      _switchResult = "ADDED";
      break;
    case IResourceDelta.REMOVED:
      _switchResult = "REMOVED";
      break;
    case IResourceDelta.CHANGED:
      _switchResult = "CHANGED";
      break;
  }
  _builder.append(_switchResult);
  _builder.append(" ");
  Pair<Integer, String> _mappedTo = Pair.<Integer, String>of(Integer.valueOf(IResourceDelta.CONTENT), "CONTENT");
  Pair<Integer, String> _mappedTo_1 = Pair.<Integer, String>of(Integer.valueOf(IResourceDelta.DERIVED_CHANGED), "DERIVED_CHANGED");
  Pair<Integer, String> _mappedTo_2 = Pair.<Integer, String>of(Integer.valueOf(IResourceDelta.DESCRIPTION), "DESCRIPTION");
  Pair<Integer, String> _mappedTo_3 = Pair.<Integer, String>of(Integer.valueOf(IResourceDelta.ENCODING), "ENCODING");
  Pair<Integer, String> _mappedTo_4 = Pair.<Integer, String>of(Integer.valueOf(IResourceDelta.LOCAL_CHANGED), "LOCAL_CHANGED");
  Pair<Integer, String> _mappedTo_5 = Pair.<Integer, String>of(Integer.valueOf(IResourceDelta.OPEN), "OPEN");
  Pair<Integer, String> _mappedTo_6 = Pair.<Integer, String>of(Integer.valueOf(IResourceDelta.MOVED_TO), "MOVED_TO");
  Pair<Integer, String> _mappedTo_7 = Pair.<Integer, String>of(Integer.valueOf(IResourceDelta.MOVED_FROM), "MOVED_FROM");
  Pair<Integer, String> _mappedTo_8 = Pair.<Integer, String>of(Integer.valueOf(IResourceDelta.COPIED_FROM), "COPIED_FROM");
  Pair<Integer, String> _mappedTo_9 = Pair.<Integer, String>of(Integer.valueOf(IResourceDelta.TYPE), "TYPE");
  Pair<Integer, String> _mappedTo_10 = Pair.<Integer, String>of(Integer.valueOf(IResourceDelta.SYNC), "SYNC");
  Pair<Integer, String> _mappedTo_11 = Pair.<Integer, String>of(Integer.valueOf(IResourceDelta.MARKERS), "MARKERS");
  Pair<Integer, String> _mappedTo_12 = Pair.<Integer, String>of(Integer.valueOf(IResourceDelta.REPLACED), "REPLACED");
  final Function1<Pair<Integer, String>, String> _function = (Pair<Integer, String> it) -> {
    String _xifexpression = null;
    if (((delta.getFlags() & (it.getKey()).intValue()) != 0)) {
      _xifexpression = it.getValue();
    } else {
      _xifexpression = null;
    }
    return _xifexpression;
  };
  String _join = IterableExtensions.join(IterableExtensions.<String>filterNull(ListExtensions.<Pair<Integer, String>, String>map(Collections.<Pair<Integer, String>>unmodifiableList(CollectionLiterals.<Pair<Integer, String>>newArrayList(_mappedTo, _mappedTo_1, _mappedTo_2, _mappedTo_3, _mappedTo_4, _mappedTo_5, _mappedTo_6, _mappedTo_7, _mappedTo_8, _mappedTo_9, _mappedTo_10, _mappedTo_11, _mappedTo_12)), _function)), ",");
  _builder.append(_join);
  _builder.append(" {");
  _builder.newLineIfNotEmpty();
  {
    IResourceDelta[] _affectedChildren = delta.getAffectedChildren();
    for(final IResourceDelta child : _affectedChildren) {
      _builder.append("\t");
      String _readableString = UIResourceChangeRegistryTest.TestUiResourceChangeRegistry.toReadableString(child);
      _builder.append(_readableString, "\t");
      _builder.newLineIfNotEmpty();
    }
  }
  _builder.append("}");
  _builder.newLine();
  return _builder.toString();
}