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


Java Function2类代码示例

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


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

示例1: leafsBackwards

import org.eclipse.xtext.xbase.lib.Functions.Function2; //导入依赖的package包/类
protected Iterable<IGeneratorNode> leafsBackwards(final IGeneratorNode it) {
  Iterable<IGeneratorNode> _switchResult = null;
  boolean _matched = false;
  if (it instanceof CompositeGeneratorNode) {
    _matched=true;
    final Function1<IGeneratorNode, Iterable<IGeneratorNode>> _function = (IGeneratorNode it_1) -> {
      return this.leafsBackwards(it_1);
    };
    final Function2<Iterable<IGeneratorNode>, Iterable<IGeneratorNode>, Iterable<IGeneratorNode>> _function_1 = (Iterable<IGeneratorNode> p1, Iterable<IGeneratorNode> p2) -> {
      return Iterables.<IGeneratorNode>concat(p1, p2);
    };
    _switchResult = IterableExtensions.<Iterable<IGeneratorNode>>reduce(ListExtensions.<IGeneratorNode, Iterable<IGeneratorNode>>map(ListExtensions.<IGeneratorNode>reverseView(((CompositeGeneratorNode)it).getChildren()), _function), _function_1);
  }
  if (!_matched) {
    _switchResult = Collections.<IGeneratorNode>unmodifiableList(CollectionLiterals.<IGeneratorNode>newArrayList(it));
  }
  return _switchResult;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:19,代码来源:TemplateNode.java

示例2: testRunReadAfterWrite

import org.eclipse.xtext.xbase.lib.Functions.Function2; //导入依赖的package包/类
@Test(timeout = 1000)
public void testRunReadAfterWrite() {
  try {
    final Function0<Object> _function = () -> {
      return null;
    };
    final Function2<CancelIndicator, Object, Integer> _function_1 = (CancelIndicator $0, Object $1) -> {
      return Integer.valueOf(this.sharedState.incrementAndGet());
    };
    this.requestManager.<Object, Integer>runWrite(_function, _function_1);
    final Function1<CancelIndicator, Integer> _function_2 = (CancelIndicator it) -> {
      return Integer.valueOf(this.sharedState.get());
    };
    final CompletableFuture<Integer> future = this.requestManager.<Integer>runRead(_function_2);
    Assert.assertEquals(1, (future.get()).intValue());
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:20,代码来源:RequestManagerTest.java

示例3: testRunWriteAfterRead

import org.eclipse.xtext.xbase.lib.Functions.Function2; //导入依赖的package包/类
@Test(timeout = 1000)
public void testRunWriteAfterRead() {
  final Function1<CancelIndicator, Integer> _function = (CancelIndicator it) -> {
    return Integer.valueOf(this.sharedState.incrementAndGet());
  };
  final CompletableFuture<Integer> previsousRead = this.requestManager.<Integer>runRead(_function);
  final Function0<Object> _function_1 = () -> {
    return null;
  };
  final Function2<CancelIndicator, Object, Integer> _function_2 = (CancelIndicator $0, Object $1) -> {
    int _xblockexpression = (int) 0;
    {
      while (((this.sharedState.get() == 0) && (!previsousRead.isCancelled()))) {
      }
      _xblockexpression = this.sharedState.incrementAndGet();
    }
    return Integer.valueOf(_xblockexpression);
  };
  this.requestManager.<Object, Integer>runWrite(_function_1, _function_2).join();
  Assert.assertEquals(2, this.sharedState.get());
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:22,代码来源:RequestManagerTest.java

示例4: testConvertNullInput

import org.eclipse.xtext.xbase.lib.Functions.Function2; //导入依赖的package包/类
@Test
public void testConvertNullInput() throws Exception {
	EClass eClass = EcoreFactory.eINSTANCE.createEClass();
	Function2<String, INode, Object> toValueImpl = new Function2<String, INode, Object>() {

		@Override
		public Object apply(String lexerRule, INode node) {
			if ("foo".equals(lexerRule) ) {
				return "FOO";
			}
			return null;
		}
	};
	DefaultEcoreElementFactory factory = new DefaultEcoreElementFactory();
	factory.setConverterService(new MockedConverterService(toValueImpl));
	factory.set(eClass, "name", null, "foo", null);

	assertEquals("FOO", eClass.getName());
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:20,代码来源:DefaultEcoreElementFactoryTest.java

示例5: completion

import org.eclipse.xtext.xbase.lib.Functions.Function2; //导入依赖的package包/类
protected Either<List<CompletionItem>, CompletionList> completion(final CancelIndicator origialCancelIndicator, final TextDocumentPositionParams params) {
  final LanguageServerImpl.BufferedCancelIndicator cancelIndicator = new LanguageServerImpl.BufferedCancelIndicator(origialCancelIndicator);
  final URI uri = this._uriExtensions.toUri(params.getTextDocument().getUri());
  final IResourceServiceProvider resourceServiceProvider = this.languagesRegistry.getResourceServiceProvider(uri);
  ContentAssistService _get = null;
  if (resourceServiceProvider!=null) {
    _get=resourceServiceProvider.<ContentAssistService>get(ContentAssistService.class);
  }
  final ContentAssistService contentAssistService = _get;
  if ((contentAssistService == null)) {
    CompletionList _completionList = new CompletionList();
    return Either.<List<CompletionItem>, CompletionList>forRight(_completionList);
  }
  final Function2<Document, XtextResource, CompletionList> _function = (Document document, XtextResource resource) -> {
    return contentAssistService.createCompletionList(document, resource, params, cancelIndicator);
  };
  final CompletionList completionList = this.workspaceManager.<CompletionList>doRead(uri, _function);
  return Either.<List<CompletionItem>, CompletionList>forRight(completionList);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:20,代码来源:LanguageServerImpl.java

示例6: definition

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

示例7: references

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

示例8: documentSymbol

import org.eclipse.xtext.xbase.lib.Functions.Function2; //导入依赖的package包/类
@Override
public CompletableFuture<List<? extends SymbolInformation>> documentSymbol(final DocumentSymbolParams params) {
  final Function1<CancelIndicator, List<? extends SymbolInformation>> _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.<SymbolInformation>emptyList();
    }
    final Function2<Document, XtextResource, List<? extends SymbolInformation>> _function_1 = (Document document, XtextResource resource) -> {
      return documentSymbolService.getSymbols(document, resource, params, cancelIndicator);
    };
    return this.workspaceManager.<List<? extends SymbolInformation>>doRead(uri, _function_1);
  };
  return this.requestManager.<List<? extends SymbolInformation>>runRead(_function);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:21,代码来源:LanguageServerImpl.java

示例9: hover

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

示例10: signatureHelp

import org.eclipse.xtext.xbase.lib.Functions.Function2; //导入依赖的package包/类
@Override
public CompletableFuture<SignatureHelp> signatureHelp(final TextDocumentPositionParams params) {
  final Function1<CancelIndicator, SignatureHelp> _function = (CancelIndicator cancelIndicator) -> {
    final URI uri = this._uriExtensions.toUri(params.getTextDocument().getUri());
    final IResourceServiceProvider serviceProvider = this.languagesRegistry.getResourceServiceProvider(uri);
    ISignatureHelpService _get = null;
    if (serviceProvider!=null) {
      _get=serviceProvider.<ISignatureHelpService>get(ISignatureHelpService.class);
    }
    final ISignatureHelpService helper = _get;
    if ((helper == null)) {
      return ISignatureHelpService.EMPTY;
    }
    final Function2<Document, XtextResource, SignatureHelp> _function_1 = (Document doc, XtextResource resource) -> {
      return helper.getSignatureHelp(doc, resource, params, cancelIndicator);
    };
    return this.workspaceManager.<SignatureHelp>doRead(uri, _function_1);
  };
  return this.requestManager.<SignatureHelp>runRead(_function);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:21,代码来源:LanguageServerImpl.java

示例11: documentHighlight

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

示例12: codeAction

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

示例13: codeLens

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

示例14: resolveCodeLens

import org.eclipse.xtext.xbase.lib.Functions.Function2; //导入依赖的package包/类
@Override
public CompletableFuture<CodeLens> resolveCodeLens(final CodeLens unresolved) {
  final URI uri = this.uninstallURI(unresolved);
  if ((uri == null)) {
    return CompletableFuture.<CodeLens>completedFuture(unresolved);
  }
  final Function1<CancelIndicator, CodeLens> _function = (CancelIndicator cancelIndicator) -> {
    final IResourceServiceProvider resourceServiceProvider = this.languagesRegistry.getResourceServiceProvider(uri);
    ICodeLensResolver _get = null;
    if (resourceServiceProvider!=null) {
      _get=resourceServiceProvider.<ICodeLensResolver>get(ICodeLensResolver.class);
    }
    final ICodeLensResolver resolver = _get;
    if ((resolver == null)) {
      return unresolved;
    }
    final Function2<Document, XtextResource, CodeLens> _function_1 = (Document document, XtextResource resource) -> {
      final CodeLens result = resolver.resolveCodeLens(document, resource, unresolved, cancelIndicator);
      return result;
    };
    return this.workspaceManager.<CodeLens>doRead(uri, _function_1);
  };
  return this.requestManager.<CodeLens>runRead(_function);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:25,代码来源:LanguageServerImpl.java

示例15: formatting

import org.eclipse.xtext.xbase.lib.Functions.Function2; //导入依赖的package包/类
@Override
public CompletableFuture<List<? extends TextEdit>> formatting(final DocumentFormattingParams 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


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