本文整理汇总了Java中org.eclipse.lsp4j.SignatureHelp类的典型用法代码示例。如果您正苦于以下问题:Java SignatureHelp类的具体用法?Java SignatureHelp怎么用?Java SignatureHelp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SignatureHelp类属于org.eclipse.lsp4j包,在下文中一共展示了SignatureHelp类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: constructorHelp
import org.eclipse.lsp4j.SignatureHelp; //导入依赖的package包/类
private SignatureHelp constructorHelp(NewClassTree leaf) {
Trees trees = Trees.instance(task);
TreePath identifierPath =
TreePath.getPath(cursor.getCompilationUnit(), leaf.getIdentifier());
Element classElement = trees.getElement(identifierPath);
List<ExecutableElement> candidates =
classElement
.getEnclosedElements()
.stream()
.filter(member -> member.getKind() == ElementKind.CONSTRUCTOR)
.map(method -> (ExecutableElement) method)
.collect(Collectors.toList());
List<SignatureInformation> signatures =
candidates
.stream()
.map(member -> constructorInfo(member))
.collect(Collectors.toList());
int activeSignature = candidates.indexOf(classElement);
return new SignatureHelp(
signatures,
activeSignature < 0 ? null : activeSignature,
activeParameter(leaf.getArguments()));
}
开发者ID:georgewfraser,项目名称:vscode-javac,代码行数:25,代码来源:Signatures.java
示例2: methodHelp
import org.eclipse.lsp4j.SignatureHelp; //导入依赖的package包/类
private SignatureHelp methodHelp(MethodInvocationTree leaf) {
Trees trees = Trees.instance(task);
TreePath methodPath = TreePath.getPath(cursor.getCompilationUnit(), leaf.getMethodSelect());
Element methodElement = trees.getElement(methodPath);
Name name = methodElement.getSimpleName();
List<ExecutableElement> candidates =
methodElement
.getEnclosingElement()
.getEnclosedElements()
.stream()
.filter(
member ->
member.getKind() == ElementKind.METHOD
&& member.getSimpleName().equals(name))
.map(method -> (ExecutableElement) method)
.collect(Collectors.toList());
List<SignatureInformation> signatures =
candidates.stream().map(member -> methodInfo(member)).collect(Collectors.toList());
int activeSignature = candidates.indexOf(methodElement);
return new SignatureHelp(
signatures,
activeSignature < 0 ? null : activeSignature,
activeParameter(leaf.getArguments()));
}
开发者ID:georgewfraser,项目名称:vscode-javac,代码行数:26,代码来源:Signatures.java
示例3: doHelp
import org.eclipse.lsp4j.SignatureHelp; //导入依赖的package包/类
private SignatureHelp doHelp(String file, int row, int column) throws IOException {
TextDocumentIdentifier document = new TextDocumentIdentifier();
document.setUri(FindResource.uri(file).toString());
Position position = new Position();
position.setLine(row - 1);
position.setCharacter(column - 1);
TextDocumentPositionParams p = new TextDocumentPositionParams();
p.setTextDocument(document);
p.setPosition(position);
try {
return server.getTextDocumentService().signatureHelp(p).get();
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}
}
开发者ID:georgewfraser,项目名称:vscode-javac,代码行数:22,代码来源:SignatureHelpTest.java
示例4: getSignatureHelp
import org.eclipse.lsp4j.SignatureHelp; //导入依赖的package包/类
public SignatureHelp getSignatureHelp(IProgressMonitor monitor) {
SignatureHelp signatureHelp = new SignatureHelp();
response.setProposals(proposals);
CompletionResponses.store(response);
List<SignatureInformation> infos = new ArrayList<>();
for (int i = 0; i < proposals.size(); i++) {
if (!monitor.isCanceled()) {
infos.add(this.toSignatureInformation(proposals.get(i)));
} else {
return signatureHelp;
}
}
infos.sort((SignatureInformation a, SignatureInformation b) -> a.getParameters().size() - b.getParameters().size());
signatureHelp.getSignatures().addAll(infos);
return signatureHelp;
}
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:19,代码来源:SignatureHelpRequestor.java
示例5: testSignatureHelp_singleMethod
import org.eclipse.lsp4j.SignatureHelp; //导入依赖的package包/类
@Test
public void testSignatureHelp_singleMethod() throws JavaModelException {
IPackageFragment pack1 = sourceFolder.createPackageFragment("test1", false, null);
StringBuilder buf = new StringBuilder();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" /** This is a method */\n");
buf.append(" public int foo(String s) { }\n");
buf.append(" public int bar(String s) { this.foo() }\n");
buf.append("}\n");
ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null);
SignatureHelp help = getSignatureHelp(cu, 4, 39);
assertNotNull(help);
assertEquals(help.getSignatures().size(), 1);
assertEquals(help.getSignatures().get(0).getLabel(), "foo(String s) : int");
assertTrue(help.getSignatures().get(0).getDocumentation().length() > 0);
}
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:19,代码来源:SignatureHelpHandlerTest.java
示例6: testSignatureHelp_multipeMethod
import org.eclipse.lsp4j.SignatureHelp; //导入依赖的package包/类
@Test
public void testSignatureHelp_multipeMethod() throws JavaModelException {
IPackageFragment pack1 = sourceFolder.createPackageFragment("test1", false, null);
StringBuilder buf = new StringBuilder();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public int foo(String s) { }\n");
buf.append(" public int foo(int s) { }\n");
buf.append(" public int foo(int s, String s) { }\n");
buf.append(" public int bar(String s) { this.foo(2, ) }\n");
buf.append("}\n");
ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null);
SignatureHelp help = getSignatureHelp(cu, 5, 42);
assertNotNull(help);
assertEquals(help.getSignatures().size(), 3);
assertEquals(help.getActiveParameter(), (Integer) 1);
assertEquals(help.getSignatures().get(help.getActiveSignature()).getLabel(), "foo(int s, String s) : int");
}
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:20,代码来源:SignatureHelpHandlerTest.java
示例7: signatureHelp
import org.eclipse.lsp4j.SignatureHelp; //导入依赖的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
示例8: get
import org.eclipse.lsp4j.SignatureHelp; //导入依赖的package包/类
private Optional<SignatureHelp> get() {
if (cursor.getLeaf().getKind() == Tree.Kind.METHOD_INVOCATION)
return Optional.of(methodHelp((MethodInvocationTree) cursor.getLeaf()));
if (cursor.getLeaf().getKind() == Tree.Kind.NEW_CLASS)
return Optional.of(constructorHelp((NewClassTree) cursor.getLeaf()));
if (cursor.getParentPath().getLeaf().getKind() == Tree.Kind.METHOD_INVOCATION)
return Optional.of(methodHelp((MethodInvocationTree) cursor.getParentPath().getLeaf()));
if (cursor.getParentPath().getLeaf().getKind() == Tree.Kind.NEW_CLASS)
return Optional.of(constructorHelp((NewClassTree) cursor.getParentPath().getLeaf()));
else return Optional.empty();
}
开发者ID:georgewfraser,项目名称:vscode-javac,代码行数:12,代码来源:Signatures.java
示例9: partlyFilledIn
import org.eclipse.lsp4j.SignatureHelp; //导入依赖的package包/类
@Test
public void partlyFilledIn() throws IOException {
SignatureHelp help = doHelp("/org/javacs/example/SignatureHelp.java", 8, 39);
assertThat(help.getSignatures(), hasSize(2));
assertThat(help.getActiveSignature(), equalTo(1));
assertThat(help.getActiveParameter(), equalTo(1));
}
开发者ID:georgewfraser,项目名称:vscode-javac,代码行数:9,代码来源:SignatureHelpTest.java
示例10: constructor
import org.eclipse.lsp4j.SignatureHelp; //导入依赖的package包/类
@Test
public void constructor() throws IOException {
SignatureHelp help = doHelp("/org/javacs/example/SignatureHelp.java", 9, 27);
assertThat(help.getSignatures(), hasSize(1));
assertThat(help.getSignatures().get(0).getLabel(), startsWith("SignatureHelp"));
}
开发者ID:georgewfraser,项目名称:vscode-javac,代码行数:8,代码来源:SignatureHelpTest.java
示例11: platformConstructor
import org.eclipse.lsp4j.SignatureHelp; //导入依赖的package包/类
@Test
public void platformConstructor() throws IOException {
SignatureHelp help = doHelp("/org/javacs/example/SignatureHelp.java", 10, 26);
assertThat(help.getSignatures(), not(empty()));
assertThat(help.getSignatures().get(0).getLabel(), startsWith("ArrayList"));
assertThat(help.getSignatures().get(0).getDocumentation(), not(nullValue()));
}
开发者ID:georgewfraser,项目名称:vscode-javac,代码行数:9,代码来源:SignatureHelpTest.java
示例12: signatureHelp
import org.eclipse.lsp4j.SignatureHelp; //导入依赖的package包/类
public SignatureHelp signatureHelp(TextDocumentPositionParams position, IProgressMonitor monitor) {
SignatureHelp help = new SignatureHelp();
if (!preferenceManager.getPreferences(null).isSignatureHelpEnabled()) {
return help;
}
try {
ICompilationUnit unit = JDTUtils.resolveCompilationUnit(position.getTextDocument().getUri());
final int offset = JsonRpcHelpers.toOffset(unit.getBuffer(), position.getPosition().getLine(), position.getPosition().getCharacter());
int[] contextInfomation = getContextInfomation(unit.getBuffer(), offset);
if (contextInfomation[0] == -1) {
return help;
}
SignatureHelpRequestor collector = new SignatureHelpRequestor(unit, contextInfomation[0] + 1);
if (offset > -1 && !monitor.isCanceled()) {
unit.codeComplete(contextInfomation[0] + 1, collector, monitor);
help = collector.getSignatureHelp(monitor);
if (help != null) {
int currentParameter = contextInfomation[1];
List<SignatureInformation> infos = help.getSignatures();
for (int i = 0; i < infos.size(); i++) {
if (infos.get(i).getParameters().size() >= currentParameter + 1) {
help.setActiveSignature(i);
help.setActiveParameter(currentParameter);
break;
}
}
}
}
} catch (CoreException ex) {
JavaLanguageServerPlugin.logException("Find signatureHelp failure ", ex);
}
return help;
}
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:39,代码来源:SignatureHelpHandler.java
示例13: testSignatureHelp_binary
import org.eclipse.lsp4j.SignatureHelp; //导入依赖的package包/类
@Test
public void testSignatureHelp_binary() throws JavaModelException {
IPackageFragment pack1 = sourceFolder.createPackageFragment("test1", false, null);
StringBuilder buf = new StringBuilder();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public int bar(String s) { System.out.println( }\n");
buf.append("}\n");
ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null);
SignatureHelp help = getSignatureHelp(cu, 2, 50);
assertNotNull(help);
assertTrue(help.getSignatures().size() >= 10);
assertTrue(help.getSignatures().get(help.getActiveSignature()).getLabel().matches("println\\(\\w+ \\w+\\) : void"));
}
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:16,代码来源:SignatureHelpHandlerTest.java
示例14: getSignatureHelp
import org.eclipse.lsp4j.SignatureHelp; //导入依赖的package包/类
@Override
public SignatureHelp getSignatureHelp(final XtextResource resource, final int offset) {
Preconditions.<XtextResource>checkNotNull(resource, "resource");
Preconditions.checkArgument((offset >= 0), ("offset >= 0. Was: " + Integer.valueOf(offset)));
final EObject object = this.offsetHelper.resolveContainedElementAt(resource, offset);
if ((object instanceof OperationCall)) {
final String operationName = this.getOperationName(((OperationCall)object));
boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(operationName);
boolean _not = (!_isNullOrEmpty);
if (_not) {
return this.getSignatureHelp(((OperationCall)object), operationName, offset);
}
}
return ISignatureHelpService.EMPTY;
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:16,代码来源:SignatureHelpServiceImpl.java
示例15: _toExpectation
import org.eclipse.lsp4j.SignatureHelp; //导入依赖的package包/类
protected String _toExpectation(final SignatureHelp it) {
String _xblockexpression = null;
{
int _size = it.getSignatures().size();
boolean _tripleEquals = (_size == 0);
if (_tripleEquals) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("Signature index is expected to be null when no signatures are available. Was: ");
Integer _activeSignature = it.getActiveSignature();
_builder.append(_activeSignature);
_builder.append(".");
Assert.assertNull(_builder.toString(),
it.getActiveSignature());
return "<empty>";
}
Assert.assertNotNull("Active signature index must not be null when signatures are available.", it.getActiveSignature());
String _xifexpression = null;
Integer _activeParameter = it.getActiveParameter();
boolean _tripleEquals_1 = (_activeParameter == null);
if (_tripleEquals_1) {
_xifexpression = "<empty>";
} else {
_xifexpression = it.getSignatures().get((it.getActiveSignature()).intValue()).getParameters().get(
(it.getActiveParameter()).intValue()).getLabel();
}
final String param = _xifexpression;
StringConcatenation _builder_1 = new StringConcatenation();
final Function1<SignatureInformation, String> _function = (SignatureInformation it_1) -> {
return it_1.getLabel();
};
String _join = IterableExtensions.join(ListExtensions.<SignatureInformation, String>map(it.getSignatures(), _function), " | ");
_builder_1.append(_join);
_builder_1.append(" | ");
_builder_1.append(param);
_xblockexpression = _builder_1.toString();
}
return _xblockexpression;
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:39,代码来源:AbstractLanguageServerTest.java
示例16: signatureHelp
import org.eclipse.lsp4j.SignatureHelp; //导入依赖的package包/类
@Override
public CompletableFuture<SignatureHelp> signatureHelp(TextDocumentPositionParams position) {
LOGGER.info("signatureHelp: " + position.getTextDocument());
return CompletableFuture.completedFuture(null);
}
开发者ID:lhein,项目名称:camel-language-server,代码行数:6,代码来源:CamelTextDocumentService.java
示例17: help
import org.eclipse.lsp4j.SignatureHelp; //导入依赖的package包/类
static Optional<SignatureHelp> help(
FocusedResult compiled, int line, int column, Javadocs docs) {
long offset = compiled.compilationUnit.getLineMap().getPosition(line, column);
return compiled.cursor.flatMap(c -> new Signatures(c, offset, compiled.task, docs).get());
}
开发者ID:georgewfraser,项目名称:vscode-javac,代码行数:7,代码来源:Signatures.java
示例18: signatureHelp
import org.eclipse.lsp4j.SignatureHelp; //导入依赖的package包/类
@Test
public void signatureHelp() throws IOException {
SignatureHelp help = doHelp("/org/javacs/example/SignatureHelp.java", 7, 36);
assertThat(help.getSignatures(), hasSize(2));
}
开发者ID:georgewfraser,项目名称:vscode-javac,代码行数:7,代码来源:SignatureHelpTest.java
示例19: signatureHelp
import org.eclipse.lsp4j.SignatureHelp; //导入依赖的package包/类
@Override
public CompletableFuture<SignatureHelp> signatureHelp(
final TextDocumentPositionParams position) {
// TODO Auto-generated method stub
return null;
}
开发者ID:smarr,项目名称:SOMns-vscode,代码行数:7,代码来源:SomLanguageServer.java
示例20: signatureHelp
import org.eclipse.lsp4j.SignatureHelp; //导入依赖的package包/类
@Override
public CompletableFuture<SignatureHelp> signatureHelp(TextDocumentPositionParams position) {
logInfo(">> document/signatureHelp");
SignatureHelpHandler handler = new SignatureHelpHandler(preferenceManager);
return computeAsync((cc) -> handler.signatureHelp(position, toMonitor(cc)));
}
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:7,代码来源:JDTLanguageServer.java
注:本文中的org.eclipse.lsp4j.SignatureHelp类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论