Java Code Examples for org.eclipse.xtext.xbase.lib.IterableExtensions#join()

The following examples show how to use org.eclipse.xtext.xbase.lib.IterableExtensions#join() . 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
private String textWithoutComments(final INode node) {
  String _switchResult = null;
  boolean _matched = false;
  if (node instanceof ILeafNode) {
    if (((!((ILeafNode)node).isHidden()) || (((ILeafNode)node).getText().trim().length() == 0))) {
      _matched=true;
      _switchResult = ((ILeafNode)node).getText();
    }
  }
  if (!_matched) {
    if (node instanceof ICompositeNode) {
      _matched=true;
      final Function1<INode, String> _function = (INode it) -> {
        return this.textWithoutComments(it);
      };
      _switchResult = IterableExtensions.join(IterableExtensions.<INode, String>map(((ICompositeNode)node).getChildren(), _function));
    }
  }
  if (!_matched) {
    _switchResult = "";
  }
  return _switchResult;
}
 
Example 2
@Override
public NameEnvironmentAnswer findType(final char[][] compoundTypeName) {
  try {
    final Function1<char[], String> _function = (char[] it) -> {
      return String.valueOf(it);
    };
    String _join = IterableExtensions.join(ListExtensions.<char[], String>map(((List<char[]>)Conversions.doWrapArray(compoundTypeName)), _function), "/");
    final String fileName = (_join + ".class");
    boolean _containsKey = this.cache.containsKey(fileName);
    if (_containsKey) {
      return this.cache.get(fileName);
    }
    final URL url = this.classLoader.getResource(fileName);
    if ((url == null)) {
      this.cache.put(fileName, null);
      return null;
    }
    final ClassFileReader reader = ClassFileReader.read(url.openStream(), fileName);
    final NameEnvironmentAnswer result = new NameEnvironmentAnswer(reader, null);
    this.cache.put(fileName, result);
    return result;
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 3
protected String _toExpectation(final Command it) {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("command : ");
  String _command = it.getCommand();
  _builder.append(_command);
  _builder.newLineIfNotEmpty();
  _builder.append("title : ");
  String _title = it.getTitle();
  _builder.append(_title);
  _builder.newLineIfNotEmpty();
  _builder.append("args : ");
  _builder.newLine();
  _builder.append("\t");
  final Function1<Object, CharSequence> _function = (Object it_1) -> {
    return this.toExpectation(it_1);
  };
  String _join = IterableExtensions.<Object>join(it.getArguments(), ",", _function);
  _builder.append(_join, "\t");
  _builder.newLineIfNotEmpty();
  return _builder.toString();
}
 
Example 4
@Test
public void testDiagnosticAtEndOfLineExcludingNewline() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("type lowercase");
  _builder.newLine();
  _builder.append("{");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  this.writeFile("MyType1.testlang", Strings.toUnixLineSeparator(_builder));
  this.initialize();
  final List<Diagnostic> problems = IterableExtensions.<Map.Entry<String, List<Diagnostic>>>head(this.getDiagnostics().entrySet()).getValue();
  String _join = IterableExtensions.join(problems, "\n");
  String _plus = ("problems found:\n" + _join);
  Assert.assertEquals(_plus, 1, problems.size());
  final Diagnostic problem = IterableExtensions.<Diagnostic>head(problems);
  this.assertEquals("Name should start with a capital", problem.getMessage());
  Assert.assertEquals(TestLanguageValidator.INVALID_NAME, problem.getCode().get());
  final Range range = problem.getRange();
  Assert.assertEquals(0, range.getStart().getLine());
  Assert.assertEquals(5, range.getStart().getCharacter());
  Assert.assertEquals(0, range.getEnd().getLine());
  Assert.assertEquals(14, range.getEnd().getCharacter());
}
 
Example 5
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public String getTypeRefAsString() {
	final Function1<TypeRef, String> _function = new Function1<TypeRef, String>() {
		public String apply(final TypeRef it) {
			return it.getTypeRefAsString();
		}
	};
	String _join = IterableExtensions.join(XcoreEListExtensions.<TypeRef, String>map(this.getTypeRefs(), _function), ",");
	String _plus = ("{" + _join);
	String _plus_1 = (_plus + "}");
	String _modifiersAsString = this.getModifiersAsString();
	return (_plus_1 + _modifiersAsString);
}
 
Example 6
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public String getTypeRefAsString() {
	Type _declaredType = this.getDeclaredType();
	String _rawTypeAsString = null;
	if (_declaredType!=null) {
		_rawTypeAsString=_declaredType.getRawTypeAsString();
	}
	String _xifexpression = null;
	int _version = this.getVersion();
	boolean _greaterThan = (_version > 0);
	if (_greaterThan) {
		int _version_1 = this.getVersion();
		_xifexpression = ("#" + Integer.valueOf(_version_1));
	}
	else {
		String _xifexpression_1 = null;
		boolean _isEmpty = this.getTypeArgs().isEmpty();
		if (_isEmpty) {
			_xifexpression_1 = "";
		}
		else {
			final Function1<TypeArgument, String> _function = new Function1<TypeArgument, String>() {
				public String apply(final TypeArgument it) {
					return it.getTypeRefAsString();
				}
			};
			String _join = IterableExtensions.join(XcoreEListExtensions.<TypeArgument, String>map(this.getTypeArgs(), _function), ",");
			String _plus = ("<" + _join);
			_xifexpression_1 = (_plus + ">");
		}
		String _plus_1 = ("" + _xifexpression_1);
		String _modifiersAsString = this.getModifiersAsString();
		_xifexpression = (_plus_1 + _modifiersAsString);
	}
	return (_rawTypeAsString + _xifexpression);
}
 
Example 7
@Override
public String toString() {
  String _name = this.getName();
  final Function1<TypeReference, CharSequence> _function = (TypeReference it) -> {
    return it.toString();
  };
  String _join = IterableExtensions.<TypeReference>join(this.typeArguments, "<", ", ", ">", _function);
  return (_name + _join);
}
 
Example 8
public String apply() {
  StringConcatenation _builder = new StringConcatenation();
  String _join = IterableExtensions.join(AntlrGrammarComparator.SINGLE_CHAR_TOKENS, "|");
  _builder.append(_join, "");
  _builder.append("|");
  _builder.append(AntlrGrammarComparator.QUOTED_TOKENS, "");
  _builder.append("|[^\\s\'\"");
  String _join_1 = IterableExtensions.join(AntlrGrammarComparator.SINGLE_CHAR_TOKENS);
  _builder.append(_join_1, "");
  _builder.append("]+");
  return _builder.toString();
}
 
Example 9
/**
 * @since 2.9
 */
public static String getDefaultArgumentList(ParserRule rule) {
	String result = IterableExtensions.join(rule.getParameters(), "[", ", ", "]", new Functions.Function1<Parameter, String>() {
		@Override
		public String apply(Parameter p) {
			return Boolean.FALSE.toString();
		}
	});
	return result;
}
 
Example 10
@Override
public NameEnvironmentAnswer findType(final char[] typeName, final char[][] packageName) {
  try {
    final Function1<char[], String> _function = (char[] it) -> {
      return String.valueOf(it);
    };
    String _join = IterableExtensions.join(ListExtensions.<char[], String>map(((List<char[]>)Conversions.doWrapArray(packageName)), _function), "/");
    String _plus = (_join + "/");
    String _valueOf = String.valueOf(typeName);
    String _plus_1 = (_plus + _valueOf);
    final String fileName = (_plus_1 + ".class");
    boolean _containsKey = this.cache.containsKey(fileName);
    if (_containsKey) {
      return this.cache.get(fileName);
    }
    final URL url = this.classLoader.getResource(fileName);
    if ((url == null)) {
      this.cache.put(fileName, null);
      return null;
    }
    final ClassFileReader reader = ClassFileReader.read(url.openStream(), fileName);
    final NameEnvironmentAnswer result = new NameEnvironmentAnswer(reader, null);
    this.cache.put(fileName, result);
    return result;
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 11
protected String _toExpectation(final SignatureHelp it) {
  String _xblockexpression = null;
  {
    int _size = it.getSignatures().size();
    boolean _tripleEquals = (_size == 0);
    if (_tripleEquals) {
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("Signature index is expected to be null when no signatures are available. Was: ");
      Integer _activeSignature = it.getActiveSignature();
      _builder.append(_activeSignature);
      _builder.append(".");
      Assert.assertNull(_builder.toString(), 
        it.getActiveSignature());
      return "<empty>";
    }
    Assert.assertNotNull("Active signature index must not be null when signatures are available.", it.getActiveSignature());
    String _xifexpression = null;
    Integer _activeParameter = it.getActiveParameter();
    boolean _tripleEquals_1 = (_activeParameter == null);
    if (_tripleEquals_1) {
      _xifexpression = "<empty>";
    } else {
      _xifexpression = it.getSignatures().get((it.getActiveSignature()).intValue()).getParameters().get(
        (it.getActiveParameter()).intValue()).getLabel().getLeft();
    }
    final String param = _xifexpression;
    StringConcatenation _builder_1 = new StringConcatenation();
    final Function1<SignatureInformation, String> _function = (SignatureInformation it_1) -> {
      return it_1.getLabel();
    };
    String _join = IterableExtensions.join(ListExtensions.<SignatureInformation, String>map(it.getSignatures(), _function), " | ");
    _builder_1.append(_join);
    _builder_1.append(" | ");
    _builder_1.append(param);
    _xblockexpression = _builder_1.toString();
  }
  return _xblockexpression;
}
 
Example 12
@Override
public String toString() {
	if (isEmpty()) {
		return "";
	}
	
	StringBuilder buffer = new StringBuilder(
		IterableExtensions.join(
			IterableExtensions.map(getEnvironment().entrySet(), 
					new Functions.Function1<Entry<Object, Object>, String>() {
						@Override
						public String apply(Map.Entry<Object,Object> p) {
							return p.getKey() + " -> " + p.getValue();
						}
					}
			),
			", "
		)
	);
	
	if (next != null) {
		buffer.append(" :: [");
		buffer.append(next.toString());
		buffer.append("]");
	}
	return buffer.toString();
}
 
Example 13
@Test
public void testGetWorkspaceChildren() {
  final Function1<Path, CharSequence> _function = (Path it) -> {
    return IterableExtensions.join(it.getSegments(), ".");
  };
  Assert.assertEquals(IterableExtensions.join(this.fs.getChildren(Path.ROOT), "[", ", ", "]", _function), 1, IterableExtensions.size(this.fs.getChildren(Path.ROOT)));
}
 
Example 14
@Test
public void testBug443800() {
  this.batchCompiler.setSourcePath("./batch-compiler-data/bug443800");
  Assert.assertTrue(this.batchCompiler.compile());
  final FilenameFilter _function = (File dir, String name) -> {
    return name.endsWith(".java");
  };
  final String javaFiles = IterableExtensions.join(((Iterable<?>)Conversions.doWrapArray(new File((TestBatchCompiler.OUTPUT_DIRECTORY + "/")).list(_function))), ",");
  Assert.assertEquals("Bug443800.java", javaFiles);
}
 
Example 15
@Override
public NameEnvironmentAnswer findType(final char[] typeName, final char[][] packageName) {
  try {
    final Function1<char[], String> _function = (char[] it) -> {
      return String.valueOf(it);
    };
    String _join = IterableExtensions.join(ListExtensions.<char[], String>map(((List<char[]>)Conversions.doWrapArray(packageName)), _function), "/");
    String _plus = (_join + "/");
    String _valueOf = String.valueOf(typeName);
    String _plus_1 = (_plus + _valueOf);
    final String fileName = (_plus_1 + ".class");
    boolean _containsKey = this.cache.containsKey(fileName);
    if (_containsKey) {
      return this.cache.get(fileName);
    }
    final URL url = this.classLoader.getResource(fileName);
    if ((url == null)) {
      this.cache.put(fileName, null);
      return null;
    }
    final ClassFileReader reader = ClassFileReader.read(url.openStream(), fileName);
    final NameEnvironmentAnswer result = new NameEnvironmentAnswer(reader, null);
    this.cache.put(fileName, result);
    return result;
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 16
public String getConstructorAlreadyExistsMessage(final MutableTypeDeclaration it) {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("Cannot create FinalFieldsConstructor as a constructor with the signature \"new(");
  String _join = IterableExtensions.join(this.getFinalFieldsConstructorArgumentTypes(it), ",");
  _builder.append(_join);
  _builder.append(")\" already exists.");
  return _builder.toString();
}
 
Example 17
private String getUiString(final JvmMember member) {
  String _xblockexpression = null;
  {
    final StringBuilder uiString = new StringBuilder();
    String _switchResult = null;
    boolean _matched = false;
    if (member instanceof JvmConstructor) {
      _matched=true;
      _switchResult = "constructor";
    }
    if (!_matched) {
      if (member instanceof JvmField) {
        _matched=true;
        _switchResult = "field";
      }
    }
    if (!_matched) {
      if (member instanceof JvmOperation) {
        _matched=true;
        _switchResult = "method";
      }
    }
    if (!_matched) {
      if (member instanceof JvmDeclaredType) {
        _matched=true;
        _switchResult = "type";
      }
    }
    final String type = _switchResult;
    uiString.append(type).append(" \'").append(member.getQualifiedName('.'));
    if ((member instanceof JvmExecutable)) {
      final Function1<JvmFormalParameter, CharSequence> _function = (JvmFormalParameter it) -> {
        return it.getParameterType().getSimpleName();
      };
      final String parameterTypes = IterableExtensions.<JvmFormalParameter>join(((JvmExecutable)member).getParameters(), ", ", _function);
      uiString.append("(").append(parameterTypes).append(")");
    }
    uiString.append("\'");
    _xblockexpression = uiString.toString();
  }
  return _xblockexpression;
}
 
Example 18
@Override
public String toString() {
	return IterableExtensions.join(fileExtensions, ",");
}
 
Example 19
protected String elementAliasToIdentifier(final GrammarAlias.AbstractElementAlias alias, final Set<String> rules, final boolean isNested) {
  String _xifexpression = null;
  if ((alias.isMany() && alias.isOptional())) {
    _xifexpression = "a";
  } else {
    String _xifexpression_1 = null;
    boolean _isMany = alias.isMany();
    if (_isMany) {
      _xifexpression_1 = "p";
    } else {
      String _xifexpression_2 = null;
      boolean _isOptional = alias.isOptional();
      if (_isOptional) {
        _xifexpression_2 = "q";
      }
      _xifexpression_1 = _xifexpression_2;
    }
    _xifexpression = _xifexpression_1;
  }
  String card = _xifexpression;
  if ((alias instanceof GrammarAlias.TokenAlias)) {
    rules.add(this.ruleNames.getUniqueRuleName(GrammarUtil.containingRule(((GrammarAlias.TokenAlias)alias).getToken())));
    String _xifexpression_3 = null;
    if ((card == null)) {
      _xifexpression_3 = "";
    } else {
      _xifexpression_3 = ("_" + card);
    }
    card = _xifexpression_3;
    String _gaElementIdentifier = this._grammarAccessExtensions.gaElementIdentifier(((GrammarAlias.TokenAlias)alias).getToken());
    return (_gaElementIdentifier + card);
  } else {
    if ((alias instanceof GrammarAlias.GroupAlias)) {
      final List<String> children = CollectionLiterals.<String>newArrayList();
      List<GrammarAlias.AbstractElementAlias> _children = ((GrammarAlias.GroupAlias)alias).getChildren();
      for (final GrammarAlias.AbstractElementAlias child : _children) {
        children.add(this.elementAliasToIdentifier(child, rules, true));
      }
      final String body = IterableExtensions.join(children, "_");
      if ((isNested || (card != null))) {
        String _elvis = null;
        if (card != null) {
          _elvis = card;
        } else {
          _elvis = "";
        }
        card = _elvis;
        return ((("__" + body) + "__") + card);
      } else {
        return body;
      }
    } else {
      if ((alias instanceof GrammarAlias.AlternativeAlias)) {
        final List<String> children_1 = CollectionLiterals.<String>newArrayList();
        Set<GrammarAlias.AbstractElementAlias> _children_1 = ((GrammarAlias.AlternativeAlias)alias).getChildren();
        for (final GrammarAlias.AbstractElementAlias child_1 : _children_1) {
          children_1.add(this.elementAliasToIdentifier(child_1, rules, true));
        }
        ListExtensions.<String>sortInplace(children_1);
        final String body_1 = IterableExtensions.join(children_1, "_or_");
        if ((isNested || (card != null))) {
          String _elvis_1 = null;
          if (card != null) {
            _elvis_1 = card;
          } else {
            _elvis_1 = "";
          }
          card = _elvis_1;
          return ((("__" + body_1) + "__") + card);
        } else {
          return body_1;
        }
      }
    }
  }
  throw new RuntimeException("unknown element");
}
 
Example 20
@Test public void testJoinWithNull() {
	List<String> list = Lists.newArrayList("a", null, "c");
	String string = IterableExtensions.join(list, ",");
	assertEquals("a,null,c", string);
}