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


Java CollectionLiterals类代码示例

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


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

示例1: _toJavaExpression

import org.eclipse.xtext.xbase.lib.CollectionLiterals; //导入依赖的package包/类
protected void _toJavaExpression(XSetLiteral literal, ITreeAppendable b) {
	LightweightTypeReference literalType = batchTypeResolver.resolveTypes(literal).getActualType(literal);
	if (literalType == null) {
		b.append("error - couldn't compute type for literal : "+literal);
		return;
	} 
	if (literalType.isType(Map.class)) {
		LightweightTypeReference keyType = literalType.getTypeArguments().get(0);
		LightweightTypeReference valueType = literalType.getTypeArguments().get(1);
		b.append(Collections.class)
			.append(".<").append(keyType).append(", ").append(valueType)
			.append(">unmodifiableMap(");
		b.append(CollectionLiterals.class).append(".<").append(keyType).append(", ").append(valueType).append(">newHashMap(");
		Iterator<XExpression> elements = literal.getElements().iterator();
		while(elements.hasNext())  {
			XExpression element = elements.next();
			internalToJavaExpression(element, b);
			if (elements.hasNext()) {
				b.append(", ");
			}
		}
		b.append("))");
	} else {
		appendImmutableCollectionExpression(literal, b, "unmodifiableSet", CollectionLiterals.class, "newHashSet");
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:27,代码来源:XbaseCompiler.java

示例2: generateJavaDoc

import org.eclipse.xtext.xbase.lib.CollectionLiterals; //导入依赖的package包/类
public void generateJavaDoc(final EObject it, final ITreeAppendable appendable, final GeneratorConfig config) {
  final DocumentationAdapter adapter = IterableExtensions.<DocumentationAdapter>head(Iterables.<DocumentationAdapter>filter(it.eAdapters(), DocumentationAdapter.class));
  String _documentation = null;
  if (adapter!=null) {
    _documentation=adapter.getDocumentation();
  }
  boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(_documentation);
  boolean _not = (!_isNullOrEmpty);
  if (_not) {
    final Set<EObject> sourceElements = this.getSourceElements(it);
    if (((sourceElements.size() == 1) && (this.documentationProvider instanceof IEObjectDocumentationProviderExtension))) {
      final List<INode> documentationNodes = ((IEObjectDocumentationProviderExtension) this.documentationProvider).getDocumentationNodes(IterableExtensions.<EObject>head(sourceElements));
      this.addJavaDocImports(it, appendable, documentationNodes);
      this.generateDocumentation(adapter.getDocumentation(), documentationNodes, appendable, config);
    } else {
      this.generateDocumentation(adapter.getDocumentation(), CollectionLiterals.<INode>emptyList(), appendable, config);
    }
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:20,代码来源:JvmModelGenerator.java

示例3: findNextHiddenLeafs

import org.eclipse.xtext.xbase.lib.CollectionLiterals; //导入依赖的package包/类
protected List<ILeafNode> findNextHiddenLeafs(final INode node) {
  ArrayList<ILeafNode> _xblockexpression = null;
  {
    final ArrayList<ILeafNode> result = CollectionLiterals.<ILeafNode>newArrayList();
    final NodeIterator ni = new NodeIterator(node);
    while (ni.hasNext()) {
      {
        final INode next = ni.next();
        if ((next instanceof ILeafNode)) {
          boolean _isHidden = ((ILeafNode)next).isHidden();
          if (_isHidden) {
            result.add(((ILeafNode)next));
          } else {
            return result;
          }
        }
      }
    }
    _xblockexpression = result;
  }
  return _xblockexpression;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:23,代码来源:HiddenLeafAccess.java

示例4: getSymbols

import org.eclipse.xtext.xbase.lib.CollectionLiterals; //导入依赖的package包/类
public List<? extends SymbolInformation> getSymbols(final IResourceDescription resourceDescription, final String query, final IReferenceFinder.IResourceAccess resourceAccess, final CancelIndicator cancelIndicator) {
  final LinkedList<SymbolInformation> symbols = CollectionLiterals.<SymbolInformation>newLinkedList();
  Iterable<IEObjectDescription> _exportedObjects = resourceDescription.getExportedObjects();
  for (final IEObjectDescription description : _exportedObjects) {
    {
      this.operationCanceledManager.checkCanceled(cancelIndicator);
      boolean _filter = this.filter(description, query);
      if (_filter) {
        final Procedure1<SymbolInformation> _function = (SymbolInformation symbol) -> {
          symbols.add(symbol);
        };
        this.createSymbol(description, resourceAccess, _function);
      }
    }
  }
  return symbols;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:18,代码来源:DocumentSymbolService.java

示例5: withNull

import org.eclipse.xtext.xbase.lib.CollectionLiterals; //导入依赖的package包/类
@Test
public void withNull() {
  final List<? extends DocumentHighlight> input = this.sort(CollectionLiterals.<DocumentHighlight>newArrayList(null, this.newHighlight(DocumentHighlightKind.Text, this.newRange(1, 1, 1, 1)), 
    this.newHighlight(DocumentHighlightKind.Write, this.newRange(1, 1, 1, 1)), this.newHighlight(DocumentHighlightKind.Read, this.newRange(1, 1, 1, 1))));
  Assert.assertEquals(1, input.get(0).getRange().getStart().getLine());
  Assert.assertEquals(1, input.get(0).getRange().getStart().getCharacter());
  Assert.assertEquals(1, input.get(0).getRange().getEnd().getLine());
  Assert.assertEquals(1, input.get(0).getRange().getEnd().getCharacter());
  Assert.assertEquals(DocumentHighlightKind.Text, input.get(0).getKind());
  Assert.assertEquals(1, input.get(1).getRange().getStart().getLine());
  Assert.assertEquals(1, input.get(1).getRange().getStart().getCharacter());
  Assert.assertEquals(1, input.get(1).getRange().getEnd().getLine());
  Assert.assertEquals(1, input.get(1).getRange().getEnd().getCharacter());
  Assert.assertEquals(DocumentHighlightKind.Read, input.get(1).getKind());
  Assert.assertEquals(1, input.get(2).getRange().getStart().getLine());
  Assert.assertEquals(1, input.get(2).getRange().getStart().getCharacter());
  Assert.assertEquals(1, input.get(2).getRange().getEnd().getLine());
  Assert.assertEquals(1, input.get(2).getRange().getEnd().getCharacter());
  Assert.assertEquals(DocumentHighlightKind.Write, input.get(2).getKind());
  Assert.assertNull(IterableExtensions.last(input));
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:22,代码来源:DocumentHighlightComparatorTest.java

示例6: references

import org.eclipse.xtext.xbase.lib.CollectionLiterals; //导入依赖的package包/类
@Override
public CompletableFuture<List<? extends Location>> references(final ReferenceParams params) {
  final Function1<CancelIndicator, List<? extends Location>> _function = (CancelIndicator cancelIndicator) -> {
    final URI uri = this._uriExtensions.toUri(params.getTextDocument().getUri());
    final IResourceServiceProvider resourceServiceProvider = this.languagesRegistry.getResourceServiceProvider(uri);
    DocumentSymbolService _get = null;
    if (resourceServiceProvider!=null) {
      _get=resourceServiceProvider.<DocumentSymbolService>get(DocumentSymbolService.class);
    }
    final DocumentSymbolService documentSymbolService = _get;
    if ((documentSymbolService == null)) {
      return CollectionLiterals.<Location>emptyList();
    }
    final Function2<Document, XtextResource, List<? extends Location>> _function_1 = (Document document, XtextResource resource) -> {
      return documentSymbolService.getReferences(document, resource, params, this.resourceAccess, this.workspaceManager.getIndex(), cancelIndicator);
    };
    return this.workspaceManager.<List<? extends Location>>doRead(uri, _function_1);
  };
  return this.requestManager.<List<? extends Location>>runRead(_function);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:21,代码来源:LanguageServerImpl.java

示例7: test1

import org.eclipse.xtext.xbase.lib.CollectionLiterals; //导入依赖的package包/类
@Test
public void test1() {
  try {
    this.with(ReferenceGrammarTestLanguageStandaloneSetup.class);
    final String model = "kind (Hugo 13)";
    final ParserRule kindRule = this.<ReferenceGrammarTestLanguageGrammarAccess>get(ReferenceGrammarTestLanguageGrammarAccess.class).getKindRule();
    final XtextResource resource = this.createResource();
    resource.setEntryPoint(kindRule);
    StringInputStream _stringInputStream = new StringInputStream(model);
    resource.load(_stringInputStream, CollectionLiterals.<Object, Object>emptyMap());
    Assert.assertTrue(resource.getErrors().isEmpty());
    Assert.assertEquals(kindRule, NodeModelUtils.getEntryParserRule(resource.getParseResult().getRootNode()));
    final String originalNodeModel = NodeModelUtils.compactDump(resource.getParseResult().getRootNode(), false);
    resource.update(0, model.length(), ((" " + model) + " "));
    final String reparsedNodeModel = NodeModelUtils.compactDump(resource.getParseResult().getRootNode(), false);
    Assert.assertEquals(originalNodeModel, reparsedNodeModel);
    final ParserRule erwachsenerRule = this.<ReferenceGrammarTestLanguageGrammarAccess>get(ReferenceGrammarTestLanguageGrammarAccess.class).getErwachsenerRule();
    resource.setEntryPoint(erwachsenerRule);
    resource.update(0, model.length(), "erwachsener (Peter 30)");
    Assert.assertEquals(erwachsenerRule, NodeModelUtils.getEntryParserRule(resource.getParseResult().getRootNode()));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:25,代码来源:SetEntryPointOnXtextResourceTest.java

示例8: initialHiddenTokens

import org.eclipse.xtext.xbase.lib.CollectionLiterals; //导入依赖的package包/类
public List<String> initialHiddenTokens(final Grammar it) {
  List<String> _xblockexpression = null;
  {
    boolean _isDefinesHiddenTokens = it.isDefinesHiddenTokens();
    if (_isDefinesHiddenTokens) {
      final Function1<AbstractRule, String> _function = (AbstractRule it_1) -> {
        return this.ruleName(it_1);
      };
      return IterableExtensions.<String>toList(ListExtensions.<AbstractRule, String>map(it.getHiddenTokens(), _function));
    }
    int _size = it.getUsedGrammars().size();
    boolean _equals = (_size == 1);
    if (_equals) {
      return this.initialHiddenTokens(IterableExtensions.<Grammar>head(it.getUsedGrammars()));
    }
    _xblockexpression = CollectionLiterals.<String>emptyList();
  }
  return _xblockexpression;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:20,代码来源:GrammarAccessExtensions.java

示例9: rangeFormatting

import org.eclipse.xtext.xbase.lib.CollectionLiterals; //导入依赖的package包/类
@Override
public CompletableFuture<List<? extends TextEdit>> rangeFormatting(final DocumentRangeFormattingParams params) {
  final Function1<CancelIndicator, List<? extends TextEdit>> _function = (CancelIndicator cancelIndicator) -> {
    final URI uri = this._uriExtensions.toUri(params.getTextDocument().getUri());
    final IResourceServiceProvider resourceServiceProvider = this.languagesRegistry.getResourceServiceProvider(uri);
    FormattingService _get = null;
    if (resourceServiceProvider!=null) {
      _get=resourceServiceProvider.<FormattingService>get(FormattingService.class);
    }
    final FormattingService formatterService = _get;
    if ((formatterService == null)) {
      return CollectionLiterals.<TextEdit>emptyList();
    }
    final Function2<Document, XtextResource, List<? extends TextEdit>> _function_1 = (Document document, XtextResource resource) -> {
      return formatterService.format(document, resource, params, cancelIndicator);
    };
    return this.workspaceManager.<List<? extends TextEdit>>doRead(uri, _function_1);
  };
  return this.requestManager.<List<? extends TextEdit>>runRead(_function);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:21,代码来源:LanguageServerImpl.java

示例10: getExternalDependencies

import org.eclipse.xtext.xbase.lib.CollectionLiterals; //导入依赖的package包/类
@Override
public Set<ExternalDependency> getExternalDependencies() {
  final LinkedHashSet<ExternalDependency> deps = CollectionLiterals.<ExternalDependency>newLinkedHashSet();
  Set<ExternalDependency> _externalDependencies = super.getExternalDependencies();
  Iterables.<ExternalDependency>addAll(deps, _externalDependencies);
  ExternalDependency _externalDependency = new ExternalDependency();
  final Procedure1<ExternalDependency> _function = (ExternalDependency it) -> {
    ExternalDependency.P2Coordinates _p2 = it.getP2();
    _p2.setBundleId("org.junit");
    ExternalDependency.P2Coordinates _p2_1 = it.getP2();
    _p2_1.setVersion("4.12.0");
    ExternalDependency.MavenCoordinates _maven = it.getMaven();
    _maven.setGroupId("junit");
    ExternalDependency.MavenCoordinates _maven_1 = it.getMaven();
    _maven_1.setArtifactId("junit");
    ExternalDependency.MavenCoordinates _maven_2 = it.getMaven();
    _maven_2.setVersion("4.12");
    ExternalDependency.MavenCoordinates _maven_3 = it.getMaven();
    _maven_3.setScope(Scope.TESTCOMPILE);
  };
  ExternalDependency _doubleArrow = ObjectExtensions.<ExternalDependency>operator_doubleArrow(_externalDependency, _function);
  deps.add(_doubleArrow);
  return deps;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:25,代码来源:TestProjectDescriptor.java

示例11: getSymbols

import org.eclipse.xtext.xbase.lib.CollectionLiterals; //导入依赖的package包/类
public List<? extends SymbolInformation> getSymbols(final String query, final IReferenceFinder.IResourceAccess resourceAccess, final IResourceDescriptions indexData, final CancelIndicator cancelIndicator) {
  final LinkedList<SymbolInformation> result = CollectionLiterals.<SymbolInformation>newLinkedList();
  Iterable<IResourceDescription> _allResourceDescriptions = indexData.getAllResourceDescriptions();
  for (final IResourceDescription resourceDescription : _allResourceDescriptions) {
    {
      this.operationCanceledManager.checkCanceled(cancelIndicator);
      final IResourceServiceProvider resourceServiceProvider = this._registry.getResourceServiceProvider(resourceDescription.getURI());
      DocumentSymbolService _get = null;
      if (resourceServiceProvider!=null) {
        _get=resourceServiceProvider.<DocumentSymbolService>get(DocumentSymbolService.class);
      }
      final DocumentSymbolService documentSymbolService = _get;
      if ((documentSymbolService != null)) {
        List<? extends SymbolInformation> _symbols = documentSymbolService.getSymbols(resourceDescription, query, resourceAccess, cancelIndicator);
        Iterables.<SymbolInformation>addAll(result, _symbols);
      }
    }
  }
  return result;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:21,代码来源:WorkspaceSymbolService.java

示例12: getSourceFolders

import org.eclipse.xtext.xbase.lib.CollectionLiterals; //导入依赖的package包/类
@Override
public Set<String> getSourceFolders() {
  LinkedHashSet<String> _xblockexpression = null;
  {
    final LinkedHashSet<String> sourceFolders = CollectionLiterals.<String>newLinkedHashSet();
    Set<String> _sourceFolders = super.getSourceFolders();
    Iterables.<String>addAll(sourceFolders, _sourceFolders);
    boolean _isInlined = this.getTestProject().isInlined();
    if (_isInlined) {
      Set<String> _sourceFolders_1 = this.getTestProject().getSourceFolders();
      Iterables.<String>addAll(sourceFolders, _sourceFolders_1);
    }
    _xblockexpression = sourceFolders;
  }
  return _xblockexpression;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:17,代码来源:TestedProjectDescriptor.java

示例13: testClasspathScanning

import org.eclipse.xtext.xbase.lib.CollectionLiterals; //导入依赖的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

示例14: getURIs

import org.eclipse.xtext.xbase.lib.CollectionLiterals; //导入依赖的package包/类
public static List<URI> getURIs(final EStructuralFeature.Setting setting) {
  List<URI> _switchResult = null;
  Object _get = setting.get(false);
  final Object it = _get;
  boolean _matched = false;
  if (it instanceof EObject) {
    _matched=true;
    _switchResult = CollectionLiterals.<URI>newImmutableList(EcoreUtil.getURI(((EObject)it)));
  }
  if (!_matched) {
    if (it instanceof List) {
      _matched=true;
      final Function1<EObject, URI> _function = (EObject it_1) -> {
        return EcoreUtil.getURI(it_1);
      };
      _switchResult = ListExtensions.<EObject, URI>map(((List<EObject>)it), _function);
    }
  }
  return _switchResult;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:21,代码来源:UnexpectedProxiesException.java

示例15: definition

import org.eclipse.xtext.xbase.lib.CollectionLiterals; //导入依赖的package包/类
protected List<? extends Location> definition(final CancelIndicator cancelIndicator, final TextDocumentPositionParams params) {
  final URI uri = this._uriExtensions.toUri(params.getTextDocument().getUri());
  final IResourceServiceProvider resourceServiceProvider = this.languagesRegistry.getResourceServiceProvider(uri);
  DocumentSymbolService _get = null;
  if (resourceServiceProvider!=null) {
    _get=resourceServiceProvider.<DocumentSymbolService>get(DocumentSymbolService.class);
  }
  final DocumentSymbolService documentSymbolService = _get;
  if ((documentSymbolService == null)) {
    return CollectionLiterals.<Location>emptyList();
  }
  final Function2<Document, XtextResource, List<? extends Location>> _function = (Document document, XtextResource resource) -> {
    return documentSymbolService.getDefinitions(document, resource, params, this.resourceAccess, cancelIndicator);
  };
  return this.workspaceManager.<List<? extends Location>>doRead(uri, _function);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:17,代码来源:LanguageServerImpl.java


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