本文整理汇总了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");
}
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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));
}
示例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);
}
示例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);
}
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}