当前位置: 首页>>代码示例>>Java>>正文


Java IterableExtensions类代码示例

本文整理汇总了Java中org.eclipse.xtext.xbase.lib.IterableExtensions的典型用法代码示例。如果您正苦于以下问题:Java IterableExtensions类的具体用法?Java IterableExtensions怎么用?Java IterableExtensions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IterableExtensions类属于org.eclipse.xtext.xbase.lib包,在下文中一共展示了IterableExtensions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTypeAsString

import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入依赖的package包/类
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public String getTypeAsString() {
	String _xifexpression = null;
	boolean _isGeneric = this.isGeneric();
	if (_isGeneric) {
		String _name = this.getName();
		String _plus = (_name + "<");
		final Function1<TypeVariable, String> _function = new Function1<TypeVariable, String>() {
			public String apply(final TypeVariable it) {
				return it.getTypeAsString();
			}
		};
		String _join = IterableExtensions.join(XcoreEListExtensions.<TypeVariable, String>map(this.getTypeVars(), _function), ",");
		String _plus_1 = (_plus + _join);
		_xifexpression = (_plus_1 + ">");
	}
	else {
		_xifexpression = this.getName();
	}
	return _xifexpression;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:26,代码来源:TypeImpl.java

示例2: setMarker

import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入依赖的package包/类
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setMarker(final String theKey, final String value) {
	final Function1<Marker, Boolean> _function = new Function1<Marker, Boolean>() {
		public Boolean apply(final Marker it) {
			String _key = it.getKey();
			String _key_1 = it.getKey();
			return Boolean.valueOf(Objects.equal(_key, _key_1));
		}
	};
	Marker marker = IterableExtensions.<Marker>findFirst(this.getMarkers(), _function);
	if ((marker == null)) {
		marker = DomFactory.eINSTANCE.createMarker();
		marker.setKey(theKey);
		this.getMarkers().add(marker);
	}
	marker.setValue(value);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:22,代码来源:JSDocNodeImpl.java

示例3: _privk3_step

import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入依赖的package包/类
protected static void _privk3_step(final StateAspectStateAspectProperties _self_, final State _self, final String inputString) {
  try {
    final Function1<Transition, Boolean> _function = (Transition t) -> {
      return Boolean.valueOf(inputString.startsWith(t.getInput()));
    };
    final Iterable<Transition> validTransitions = IterableExtensions.<Transition>filter(_self.getOutgoingTransitions(), _function);
    boolean _isEmpty = IterableExtensions.isEmpty(validTransitions);
    if (_isEmpty) {
      throw new Exception("No Transition");
    }
    int _size = IterableExtensions.size(validTransitions);
    boolean _greaterThan = (_size > 1);
    if (_greaterThan) {
      throw new Exception("Non Determinism");
    }
    TransitionAspect.fire(((Transition[])Conversions.unwrapArray(validTransitions, Transition.class))[0]);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
开发者ID:eclipse,项目名称:gemoc-studio,代码行数:21,代码来源:StateAspect.java

示例4: discardDerivedState

import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入依赖的package包/类
@Override
public void discardDerivedState(final DerivedStateAwareResource resource) {
  boolean _isEmpty = resource.getContents().isEmpty();
  boolean _not = (!_isEmpty);
  if (_not) {
    EObject _head = IterableExtensions.<EObject>head(resource.getContents());
    if ((_head instanceof Configuration)) {
      EObject _head_1 = IterableExtensions.<EObject>head(resource.getContents());
      final Configuration configuration = ((Configuration) _head_1);
      EList<Resource> _resources = configuration.getResources();
      for (final Resource resourceOcci : _resources) {
        resourceOcci.getRlinks().clear();
      }
    }
  }
}
 
开发者ID:occiware,项目名称:OCCI-Studio,代码行数:17,代码来源:OCCIDerivedStateComputer.java

示例5: resolvesIdentifiablesTo

import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入依赖的package包/类
@Override
public void resolvesIdentifiablesTo(final String expression, final String... types) {
  try {
    final String expressionWithQualifiedNames = expression.replace("$$", "org::eclipse::xtext::xbase::lib::");
    final XExpression xExpression = this.expression(expressionWithQualifiedNames, false);
    final IResolvedTypes resolvedTypes = this.getTypeResolver().resolveTypes(xExpression);
    final List<JvmIdentifiableElement> identifiables = this.findIdentifiables(xExpression);
    Assert.assertFalse(identifiables.isEmpty());
    Assert.assertEquals(((List<String>)Conversions.doWrapArray(types)).size(), identifiables.size());
    final Procedure2<JvmIdentifiableElement, Integer> _function = (JvmIdentifiableElement identifiable, Integer index) -> {
      final LightweightTypeReference type = resolvedTypes.getActualType(identifiable);
      Assert.assertNotNull(type);
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("failed for identifiable at ");
      _builder.append(index);
      Assert.assertEquals(_builder.toString(), types[(index).intValue()], type.getSimpleName());
    };
    IterableExtensions.<JvmIdentifiableElement>forEach(identifiables, _function);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:23,代码来源:BatchIdentifiableTypeTest.java

示例6: testBrokenInput_01

import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入依赖的package包/类
@Test
public void testBrokenInput_01() {
  try {
    final ContentAssistFragmentTestLanguageRoot result = this.parseHelper.parse("}");
    Resource _eResource = result.eResource();
    final XtextResource res = ((XtextResource) _eResource);
    final InvariantChecker invariantChecker = new InvariantChecker();
    invariantChecker.checkInvariant(res.getParseResult().getRootNode());
    res.update(0, 0, "newArrayList()");
    invariantChecker.checkInvariant(res.getParseResult().getRootNode());
    final EObject first = IterableExtensions.<EObject>head(res.getContents());
    Assert.assertTrue(first.eClass().getName(), (first instanceof ContentAssistFragmentTestLanguageRoot));
    res.update("newArrayList(".length(), 0, "1");
    invariantChecker.checkInvariant(res.getParseResult().getRootNode());
    final EObject second = IterableExtensions.<EObject>head(res.getContents());
    Assert.assertTrue(second.eClass().getName(), (second instanceof ContentAssistFragmentTestLanguageRoot));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:21,代码来源:Bug480686Test.java

示例7: resolvesTo

import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入依赖的package包/类
@Override
public LightweightTypeReference resolvesTo(final String expression, final String type) {
  try {
    final String replacedExpressionText = expression.replace("$$", "org::eclipse::xtext::xbase::lib::");
    final XExpression xExpression = this.expression(replacedExpressionText, false);
    Assert.assertTrue(xExpression.eResource().getErrors().toString(), xExpression.eResource().getErrors().isEmpty());
    Assert.assertTrue(xExpression.eResource().getWarnings().toString(), xExpression.eResource().getWarnings().isEmpty());
    final IResolvedTypes resolvedTypes = this.getTypeResolver().resolveTypes(xExpression);
    final LightweightTypeReference resolvedType = resolvedTypes.getReturnType(xExpression);
    Assert.assertEquals(replacedExpressionText, type, resolvedType.getSimpleName());
    Assert.assertTrue(this.getLinkingAndSyntaxErrors(xExpression.eResource()).toString(), IterableExtensions.isEmpty(this.getLinkingAndSyntaxErrors(xExpression.eResource())));
    Assert.assertTrue(xExpression.eResource().getWarnings().toString(), xExpression.eResource().getWarnings().isEmpty());
    return resolvedType;
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:18,代码来源:AbstractBatchReturnTypeTest.java

示例8: isSupportedGetter

import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入依赖的package包/类
public boolean isSupportedGetter(final ResolvedMethod it) {
  boolean _isEmpty = IterableExtensions.isEmpty(it.getDeclaration().getParameters());
  boolean _not = (!_isEmpty);
  if (_not) {
    return false;
  }
  boolean _isStatic = it.getDeclaration().isStatic();
  if (_isStatic) {
    return false;
  }
  final String n = it.getDeclaration().getSimpleName();
  String _qualifiedName = it.getDeclaration().getDeclaringType().getQualifiedName();
  String _name = Object.class.getName();
  boolean _equals = Objects.equal(_qualifiedName, _name);
  if (_equals) {
    return false;
  }
  return (n.startsWith("get") || n.startsWith("is"));
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:20,代码来源:TracedAccessorsProcessor.java

示例9: toString

import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入依赖的package包/类
@Override
public String toString() {
  String _xifexpression = null;
  if ((this.first != null)) {
    String _xblockexpression = null;
    {
      final ArrayList<String> list = CollectionLiterals.<String>newArrayList();
      Entry<T, R> current = this.first.getLeadingSeparator();
      while ((current != null)) {
        {
          String _string = current.toString();
          list.add(_string);
          current = current.next;
        }
      }
      _xblockexpression = IterableExtensions.join(list, "\n");
    }
    _xifexpression = _xblockexpression;
  } else {
    _xifexpression = "empty";
  }
  return _xifexpression;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:24,代码来源:SeparatorRegions.java

示例10: testClasspathScanning

import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入依赖的package包/类
@Test
public void testClasspathScanning() {
  try {
    final File bootstrapJar = new File("./somelib/sample.jar");
    URL _uRL = bootstrapJar.toURI().toURL();
    final URLClassLoader classloader = new URLClassLoader(new URL[] { _uRL });
    final Iterable<ITypeDescriptor> utilPackage = this.scanner.getDescriptors(classloader, Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("sample")));
    final Function1<ITypeDescriptor, Boolean> _function = (ITypeDescriptor it) -> {
      String _name = it.getName();
      return Boolean.valueOf(Objects.equal(_name, "sample.Sample"));
    };
    Assert.assertTrue(IterableExtensions.<ITypeDescriptor>exists(utilPackage, _function));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:17,代码来源:ClasspathScannerTest.java

示例11: forEachWithShortcut

import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入依赖的package包/类
/**
 * 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("}");
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:21,代码来源:LoopExtensions.java

示例12: testParserRuleFragment_02

import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入依赖的package包/类
@Test
public void testParserRuleFragment_02() throws Exception {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("grammar test with org.eclipse.xtext.common.Terminals");
  _builder.newLine();
  _builder.append("generate test \'http://test\'");
  _builder.newLine();
  _builder.append("MyRule: IntFeatureHolder;");
  _builder.newLine();
  _builder.append("fragment IntFeatureHolder: myFeature=INT;");
  _builder.newLine();
  final String grammar = _builder.toString();
  EPackage ePackage = this.getEPackageFromGrammar(grammar);
  final EList<EClassifier> classifiers = ePackage.getEClassifiers();
  Assert.assertEquals(2, classifiers.size());
  final EClassifier myRuleType = IterableExtensions.<EClassifier>head(classifiers);
  Assert.assertEquals("MyRule", myRuleType.getName());
  Assert.assertTrue(this.features(myRuleType).isEmpty());
  final EClassifier intFeatureHolder = IterableExtensions.<EClassifier>last(classifiers);
  Assert.assertEquals("EInt", this.<EStructuralFeature>feature(intFeatureHolder, "myFeature").getEType().getName());
  Assert.assertTrue(this.superTypes(myRuleType).contains(intFeatureHolder));
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:23,代码来源:Xtext2EcoreTransformerTest.java

示例13: uninstallURI

import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入依赖的package包/类
private URI uninstallURI(final CodeLens lens) {
  URI result = null;
  Object _data = lens.getData();
  if ((_data instanceof String)) {
    result = URI.createURI(lens.getData().toString());
    lens.setData(null);
  } else {
    Object _data_1 = lens.getData();
    if ((_data_1 instanceof List<?>)) {
      Object _data_2 = lens.getData();
      final List<?> l = ((List<?>) _data_2);
      result = URI.createURI(IterableExtensions.head(l).toString());
      lens.setData(l.get(1));
    }
  }
  return result;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:18,代码来源:LanguageServerImpl.java

示例14: testDeleteElement

import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入依赖的package包/类
@Test
public void testDeleteElement() {
  try {
    this._parseHelper.parse("foo", this.fooURI, this.rs1).eResource().getContents().clear();
    final Function1<IEObjectDescription, String> _function = (IEObjectDescription it) -> {
      return it.getQualifiedName().toString();
    };
    Assert.assertEquals("", IterableExtensions.join(IterableExtensions.<IEObjectDescription, String>map(this.fooContainer.getExportedObjects(), _function), ","));
    Assert.assertEquals(1, IterableExtensions.size(this.fooContainer.getResourceDescriptions()));
    Assert.assertEquals(1, this.fooContainer.getResourceDescriptionCount());
    Assert.assertEquals(0, IterableExtensions.size(this.fooContainer.getExportedObjects()));
    Assert.assertEquals(1, IterableExtensions.size(this.barContainer.getResourceDescriptions()));
    Assert.assertEquals(1, this.barContainer.getResourceDescriptionCount());
    this.assertGlobalDescriptionsAreUnaffected();
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:19,代码来源:LiveShadowedChunkedContainerTest.java

示例15: _isMultiParamInOwnLine

import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入依赖的package包/类
protected boolean _isMultiParamInOwnLine(final XFeatureCall fc, final FormattableDocument doc) {
  final ILeafNode closingBracket = this._nodeModelAccess.nodeForKeyword(fc, ")");
  HiddenLeafs _hiddenLeafsBefore = null;
  if (closingBracket!=null) {
    _hiddenLeafsBefore=this._hiddenLeafAccess.getHiddenLeafsBefore(closingBracket);
  }
  boolean _tripleNotEquals = (_hiddenLeafsBefore != null);
  if (_tripleNotEquals) {
    int _newLines = this._hiddenLeafAccess.getHiddenLeafsBefore(closingBracket).getNewLines();
    return (_newLines > 0);
  }
  final Iterable<XExpression> params = this.explicitParams(fc.getFeatureCallArguments());
  return ((IterableExtensions.size(params) > 1) && this.isEachExpressionInOwnLine(params));
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:15,代码来源:XbaseFormatter2.java


注:本文中的org.eclipse.xtext.xbase.lib.IterableExtensions类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。