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


Java IterableExtensions.head方法代码示例

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


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

示例1: 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

示例2: testFindCurrentType_03

import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入方法依赖的package包/类
@Test
public void testFindCurrentType_03() throws Exception {
  this.with(XtextStandaloneSetup.class);
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("grammar myLang with org.eclipse.xtext.common.Terminals");
  _builder.newLine();
  _builder.append("generate g \'http://1\'");
  _builder.newLine();
  _builder.append("Rule:");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("Fragment;");
  _builder.newLine();
  _builder.append("fragment Fragment: name=ID SecondFragment;");
  _builder.newLine();
  _builder.append("fragment SecondFragment: {SubRule.named=current} value=ID;");
  _builder.newLine();
  String model = _builder.toString();
  final XtextResource r = this.getResourceFromString(model);
  EObject _get = r.getContents().get(0);
  final Grammar grammar = ((Grammar) _get);
  final AbstractRule rule = IterableExtensions.<AbstractRule>head(grammar.getRules());
  final AbstractElement fragmentCall = rule.getAlternatives();
  final EClassifier currentType = GrammarUtil.findCurrentType(fragmentCall);
  Assert.assertEquals("SubRule", currentType.getName());
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:27,代码来源:GrammarUtilTest.java

示例3: before

import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入方法依赖的package包/类
@Before
public void before() {
  try {
    final Path tmpPath = Paths.get(StandardSystemProperty.JAVA_IO_TMPDIR.value());
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("tempFolder_");
    UUID _randomUUID = UUID.randomUUID();
    _builder.append(_randomUUID);
    final Path output = Files.createTempDirectory(tmpPath, _builder.toString());
    final Path resource = Files.createFile(output.resolve(URIBasedFileSystemAccessTest.EXISTING_RESOURCE_NAME));
    resource.toFile().deleteOnExit();
    output.toFile().deleteOnExit();
    final OutputConfiguration config = IterableExtensions.<OutputConfiguration>head(this.configProvider.getOutputConfigurations());
    config.setOutputDirectory(output.toString());
    Pair<String, OutputConfiguration> _mappedTo = Pair.<String, OutputConfiguration>of(IFileSystemAccess.DEFAULT_OUTPUT, config);
    this.fsa.setOutputConfigurations(Collections.<String, OutputConfiguration>unmodifiableMap(CollectionLiterals.<String, OutputConfiguration>newHashMap(_mappedTo)));
    this.fsa.setConverter(this.uriConverter);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:22,代码来源:URIBasedFileSystemAccessTest.java

示例4: findEPackagesInGenPackages

import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入方法依赖的package包/类
private Map<String, EPackage> findEPackagesInGenPackages(final Collection<String> packageNsURIs, final ResourceSet resourceSet) {
  final HashMap<String, EPackage> result = CollectionLiterals.<String, EPackage>newHashMap();
  for (final String nsURI : packageNsURIs) {
    {
      final Resource resource = GenModelUtil2.getGenModelResource(null, nsURI, resourceSet);
      if ((resource != null)) {
        final GenModel loadedGenModel = IterableExtensions.<GenModel>head(Iterables.<GenModel>filter(resource.getContents(), GenModel.class));
        if ((loadedGenModel != null)) {
          final GenPackage genPackage = this.findGenPackageByNsURI(loadedGenModel, nsURI);
          result.put(nsURI, genPackage.getEcorePackage());
        }
      }
    }
  }
  return result;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:17,代码来源:EMFGeneratorFragment2.java

示例5: testIntegerAnnotation

import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入方法依赖的package包/类
@Test
public void testIntegerAnnotation() {
  try {
    final XAnnotationsFactory f = XAnnotationsFactory.eINSTANCE;
    final XExpression e = this.expression("\'Foo\'");
    final XAnnotation anno = f.createXAnnotation();
    JvmType _findDeclaredType = this.references.findDeclaredType(TestAnnotation3.class, e);
    final JvmAnnotationType annotatiomType = ((JvmAnnotationType) _findDeclaredType);
    anno.setAnnotationType(annotatiomType);
    final XAnnotationElementValuePair pair = f.createXAnnotationElementValuePair();
    pair.setElement(IterableExtensions.<JvmOperation>head(annotatiomType.getDeclaredOperations()));
    pair.setValue(this.expression("10"));
    EList<XAnnotationElementValuePair> _elementValuePairs = anno.getElementValuePairs();
    this._jvmTypesBuilder.<XAnnotationElementValuePair>operator_add(_elementValuePairs, pair);
    final JvmGenericType type = this.typesFactory.createJvmGenericType();
    this._jvmTypesBuilder.addAnnotation(type, anno);
    Assert.assertEquals(anno.getAnnotationType(), IterableExtensions.<JvmAnnotationReference>head(type.getAnnotations()).getAnnotation());
    Assert.assertEquals(1, IterableExtensions.<JvmAnnotationReference>head(type.getAnnotations()).getValues().size());
    JvmAnnotationValue _head = IterableExtensions.<JvmAnnotationValue>head(IterableExtensions.<JvmAnnotationReference>head(type.getAnnotations()).getValues());
    final JvmCustomAnnotationValue value = ((JvmCustomAnnotationValue) _head);
    EObject _head_1 = IterableExtensions.<EObject>head(value.getValues());
    Assert.assertTrue((_head_1 instanceof XNumberLiteral));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:27,代码来源:JvmTypesBuilderTest.java

示例6: readNodeModel

import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入方法依赖的package包/类
protected void readNodeModel(final StorageAwareResource resource, final InputStream inputStream) throws IOException {
  final SerializableNodeModel serializableNodeModel = new SerializableNodeModel(resource);
  boolean _exists = resource.getResourceSet().getURIConverter().exists(resource.getURI(), resource.getResourceSet().getLoadOptions());
  boolean _not = (!_exists);
  if (_not) {
    URI _uRI = resource.getURI();
    String _plus = ("Skipping loading node model for synthetic resource " + _uRI);
    ResourceStorageLoadable.LOG.info(_plus);
    return;
  }
  final InputStream stream = resource.getResourceSet().getURIConverter().createInputStream(resource.getURI());
  String _encoding = resource.getEncoding();
  final InputStreamReader in = new InputStreamReader(stream, _encoding);
  final String completeContent = CharStreams.toString(in);
  final DeserializationConversionContext deserializationContext = new DeserializationConversionContext(resource, completeContent);
  final DataInputStream dataIn = new DataInputStream(inputStream);
  serializableNodeModel.readObjectData(dataIn, deserializationContext);
  EObject _head = IterableExtensions.<EObject>head(resource.getContents());
  boolean _hasErrors = deserializationContext.hasErrors();
  ParseResult _parseResult = new ParseResult(_head, serializableNodeModel.root, _hasErrors);
  resource.setParseResult(_parseResult);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:23,代码来源:ResourceStorageLoadable.java

示例7: testGenerateTwoModels

import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入方法依赖的package包/类
@Test
public void testGenerateTwoModels() throws Exception {
  String grammar = "";
  String _grammar = grammar;
  grammar = (_grammar + " grammar test with org.eclipse.xtext.common.Terminals");
  String _grammar_1 = grammar;
  grammar = (_grammar_1 + " generate t1 \'http://t1\'");
  String _grammar_2 = grammar;
  grammar = (_grammar_2 + " generate t2 \'http://t2\' as t2");
  String _grammar_3 = grammar;
  grammar = (_grammar_3 + " RuleA: featureA=ID;");
  String _grammar_4 = grammar;
  grammar = (_grammar_4 + " RuleB returns t2::TypeB: featureB=ID;");
  List<EPackage> ePackages = this.getEPackagesFromGrammar(grammar, 0);
  Assert.assertEquals(2, ePackages.size());
  EPackage t1 = IterableExtensions.<EPackage>head(ePackages);
  Assert.assertEquals("t1", t1.getName());
  Assert.assertEquals(1, t1.getEClassifiers().size());
  final EClassifier ruleA = this.<EClassifier>type(t1, "RuleA");
  Assert.assertNotNull(ruleA);
  EPackage t2 = ePackages.get(1);
  Assert.assertEquals(1, t2.getEClassifiers().size());
  Assert.assertEquals("t2", t2.getName());
  final EClassifier typeB = this.<EClassifier>type(t2, "TypeB");
  Assert.assertNotNull(typeB);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:27,代码来源:Xtext2EcoreTransformerTest.java

示例8: testParserRuleFragment_07

import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入方法依赖的package包/类
@Test
public void testParserRuleFragment_07() 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("Middle1: Top;");
  _builder.newLine();
  _builder.append("Middle2: Top;");
  _builder.newLine();
  _builder.append("fragment Top: name=ID ({Bottom.prev=current} name=ID)*;");
  _builder.newLine();
  final String grammar = _builder.toString();
  EPackage ePackage = this.getEPackageFromGrammar(grammar);
  final EList<EClassifier> classifiers = ePackage.getEClassifiers();
  Assert.assertEquals(4, classifiers.size());
  final EClassifier middleType1 = IterableExtensions.<EClassifier>head(classifiers);
  Assert.assertEquals("Middle1", middleType1.getName());
  Assert.assertTrue(this.features(middleType1).isEmpty());
  final EClassifier middleType2 = classifiers.get(1);
  Assert.assertEquals("Middle2", middleType2.getName());
  Assert.assertTrue(this.features(middleType2).isEmpty());
  final EClassifier topType = classifiers.get(2);
  Assert.assertEquals("EString", this.<EStructuralFeature>feature(topType, "name").getEType().getName());
  Assert.assertTrue(this.superTypes(middleType1).contains(topType));
  Assert.assertTrue(this.superTypes(middleType2).contains(topType));
  final EClassifier bottomType = IterableExtensions.<EClassifier>last(classifiers);
  Assert.assertEquals("Top", this.<EStructuralFeature>feature(bottomType, "prev").getEType().getName());
  Assert.assertTrue(this.superTypes(bottomType).contains(middleType1));
  Assert.assertTrue(this.superTypes(bottomType).contains(middleType2));
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:33,代码来源:Xtext2EcoreTransformerTest.java

示例9: testMemberOnIt_02

import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入方法依赖的package包/类
@Test
public void testMemberOnIt_02() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("{ var it = \"\" }");
    XExpression _expression = this.expression(_builder, false);
    final XExpression varDecl = IterableExtensions.<XExpression>head(((XBlockExpression) _expression).getExpressions());
    final IExpressionScope expressionScope = this._iBatchTypeResolver.resolveTypes(varDecl).getExpressionScope(varDecl, IExpressionScope.Anchor.BEFORE);
    this.containsNot(expressionScope, "charAt");
    this.containsNot(expressionScope, "it");
    this.containsNot(expressionScope, "operator_lessThan");
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:16,代码来源:ExpressionScopeTest.java

示例10: testImplicitLambdaParameter

import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入方法依赖的package包/类
@Test
public void testImplicitLambdaParameter() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("{");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("val Comparable<String> c = [ length ]");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("c.toString");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    XExpression _parse = this._parseHelper.parse(_builder);
    final XBlockExpression block = ((XBlockExpression) _parse);
    Resource _eResource = block.eResource();
    final BatchLinkableResource resource = ((BatchLinkableResource) _eResource);
    resource.resolveLazyCrossReferences(null);
    XExpression _head = IterableExtensions.<XExpression>head(block.getExpressions());
    final XVariableDeclaration assignment = ((XVariableDeclaration) _head);
    XExpression _right = assignment.getRight();
    final XClosure lambda = ((XClosure) _right);
    final JvmFormalParameter implicitParameter = IterableExtensions.<JvmFormalParameter>head(lambda.getImplicitFormalParameters());
    Assert.assertEquals("String", implicitParameter.getParameterType().getSimpleName());
    resource.update(0, 0, "");
    Assert.assertNull(implicitParameter.eResource());
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:32,代码来源:BeforeLinkingTest.java

示例11: withExactDetails

import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入方法依赖的package包/类
protected void withExactDetails(final IResolvedOperation operation, final IOverrideCheckResult.OverrideCheckDetails... details) {
  Assert.assertEquals(1, operation.getOverriddenAndImplementedMethodCandidates().size());
  final JvmOperation candidate = IterableExtensions.<JvmOperation>head(operation.getOverriddenAndImplementedMethodCandidates());
  final EnumSet<IOverrideCheckResult.OverrideCheckDetails> expectation = EnumSet.<IOverrideCheckResult.OverrideCheckDetails>copyOf(((Collection<IOverrideCheckResult.OverrideCheckDetails>)Conversions.doWrapArray(details)));
  final IOverrideCheckResult checkResult = operation.isOverridingOrImplementing(candidate);
  final EnumSet<IOverrideCheckResult.OverrideCheckDetails> actual = checkResult.getDetails();
  Assert.assertEquals(expectation.toString(), actual.toString());
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:9,代码来源:ResolvedOperationTest.java

示例12: register

import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入方法依赖的package包/类
@Inject
protected void register(final EValidatorRegistrar registrar, final IGrammarAccess grammarAccess) {
  final AbstractRule entryRule = IterableExtensions.<AbstractRule>head(grammarAccess.getGrammar().getRules());
  if ((entryRule instanceof ParserRule)) {
    registrar.register(((ParserRule)entryRule).getType().getClassifier().getEPackage(), this);
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:8,代码来源:UniqueClassNameValidator.java

示例13: notVoid

import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入方法依赖的package包/类
public AbstractExpectationTest notVoid() {
  Assert.assertTrue(this.pendingAssert);
  this.pendingAssert = false;
  Assert.assertEquals(1, this.finalExpectations.size());
  final ITypeExpectation expectation = IterableExtensions.<ITypeExpectation>head(this.finalExpectations);
  Assert.assertFalse(expectation.isNoTypeExpectation());
  Assert.assertFalse(expectation.isVoidTypeAllowed());
  Assert.assertNull(expectation.getExpectedType());
  return this;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:11,代码来源:AbstractExpectationTest.java

示例14: testMemberOnIt_03

import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入方法依赖的package包/类
@Test
public void testMemberOnIt_03() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("{ var (int)=>int it = [] }");
    XExpression _expression = this.expression(_builder, false);
    XExpression _head = IterableExtensions.<XExpression>head(((XBlockExpression) _expression).getExpressions());
    final XExpression varInit = ((XVariableDeclaration) _head).getRight();
    final IExpressionScope expressionScope = this._iBatchTypeResolver.resolveTypes(varInit).getExpressionScope(varInit, IExpressionScope.Anchor.BEFORE);
    this.contains(expressionScope, "it");
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:15,代码来源:ExpressionScopeTest.java

示例15: testRemoveSpace

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


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