Java Code Examples for org.eclipse.xtext.xbase.lib.ArrayExtensions#contains()

The following examples show how to use org.eclipse.xtext.xbase.lib.ArrayExtensions#contains() . 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: Formatter2Fragment2.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
protected String toVarName(final ENamedElement element, final String... reservedNames) {
  String _xblockexpression = null;
  {
    if ((element instanceof EReference)) {
      return this.toVarName(((EReference)element).getEReferenceType(), reservedNames);
    }
    String name = StringExtensions.toFirstLower(element.getName());
    boolean _contains = XtendFileAccess.XTEND_KEYWORDS.contains(name);
    if (_contains) {
      name = ("_" + name);
    }
    boolean _contains_1 = ArrayExtensions.contains(reservedNames, name);
    if (_contains_1) {
      name = ("_" + name);
    }
    _xblockexpression = name;
  }
  return _xblockexpression;
}
 
Example 2
Source File: XImportSectionValidationTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
public void assertFeatureCallError(final XtendFile file, final EClass objectType) {
  final Resource resource = file.eResource();
  final List<Issue> allIssues = this._validationTestHelper.validate(resource);
  final Function1<Issue, Boolean> _function = (Issue it) -> {
    EObject object = resource.getResourceSet().getEObject(it.getUriToProblem(), true);
    final boolean featureCall = ArrayExtensions.contains(it.getData(), UnresolvedFeatureCallTypeAwareMessageProvider.FEATURE_CALL);
    return Boolean.valueOf((((Objects.equal(it.getCode(), Diagnostic.LINKING_DIAGNOSTIC) && (it.getSeverity() == Severity.ERROR)) && 
      objectType.isInstance(object)) && featureCall));
  };
  final Iterable<Issue> match = IterableExtensions.<Issue>filter(allIssues, _function);
  boolean _isEmpty = IterableExtensions.isEmpty(match);
  if (_isEmpty) {
    Assert.fail("No Diagnostic.LINKING_DIAGNOSTIC issue with user data FEATURE_CALL found");
  }
}
 
Example 3
Source File: RichStringPartionIndentationStrategy.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void customizeDocumentCommand(final IDocument d, final DocumentCommand c) {
  if (((c.text.length() > 1) && (!ArrayExtensions.contains(d.getLegalLineDelimiters(), c.text)))) {
    try {
      final String lineIndentation = this.getLineIndentation(d, c.offset);
      final Function1<String, Integer> _function = (String s) -> {
        return Integer.valueOf(s.length());
      };
      final List<String> legalLineDelimiters = ListExtensions.<String>reverseView(IterableExtensions.<String, Integer>sortBy(((Iterable<String>)Conversions.doWrapArray(d.getLegalLineDelimiters())), _function));
      final String defaultLineDelimiter = TextUtilities.getDefaultLineDelimiter(d);
      final Function1<String, CharSequence> _function_1 = (String delimiter) -> {
        return Pattern.quote(delimiter);
      };
      final String regex = IterableExtensions.<String>join(legalLineDelimiters, "(", ")|(", ")", _function_1);
      final Pattern pattern = Pattern.compile(regex);
      final Matcher matcher = pattern.matcher(c.text);
      final StringBuilder convertedText = new StringBuilder();
      int currentStart = 0;
      int currentEnd = 0;
      while (matcher.find()) {
        {
          currentEnd = matcher.start();
          if ((currentStart != 0)) {
            convertedText.append(lineIndentation);
          }
          convertedText.append(c.text.substring(currentStart, currentEnd));
          convertedText.append(defaultLineDelimiter);
          currentStart = matcher.end();
        }
      }
      int _length = c.text.length();
      boolean _lessThan = (currentStart < _length);
      if (_lessThan) {
        if ((currentStart != 0)) {
          convertedText.append(lineIndentation);
        }
        convertedText.append(c.text.substring(currentStart));
      }
      c.text = convertedText.toString();
    } catch (final Throwable _t) {
      if (_t instanceof BadLocationException) {
        super.customizeDocumentCommand(d, c);
      } else {
        throw Exceptions.sneakyThrow(_t);
      }
    }
  }
  super.customizeDocumentCommand(d, c);
}
 
Example 4
Source File: SocketServerLauncher.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
protected PrintWriter getTrace(String... args) {
	if (ArrayExtensions.contains(args, TRACE)) {
		return new PrintWriter(System.out);
	}
	return null;
}
 
Example 5
Source File: SocketServerLauncher.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
protected boolean shouldValidate(String... args) {
	return !ArrayExtensions.contains(args, NO_VALIDATE);
}