• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CompletionItem类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: apply

import org.eclipse.lsp4j.CompletionItem; //导入依赖的package包/类
@Override
public List<CompletionItem> apply(CamelCatalog catalog) {
	Stream<EndpointOptionModel> endpointOptions = ModelHelper.generateComponentModel(catalog.componentJSonSchema(camelComponentName), true).getEndpointOptions().stream();
	return endpointOptions
			.filter(endpoint -> "parameter".equals(endpoint.getKind()))
			.filter(endpoint -> {
				String group = endpoint.getGroup();
				if (isProducer) {
					return !"consumer".equals(group);
				} else {
					return !"producer".equals(group);
				}
			})
			.map(parameter -> {
				CompletionItem completionItem = new CompletionItem(parameter.getName());
				String insertText = parameter.getName() + "=";
				if(parameter.getDefaultValue() != null) {
					insertText += parameter.getDefaultValue();
				}
				completionItem.setInsertText(insertText);
				return completionItem;
			})
			.collect(Collectors.toList());
}
 
开发者ID:lhein,项目名称:camel-language-server,代码行数:25,代码来源:CamelOptionSchemaCompletionsFuture.java


示例2: getCompletions

import org.eclipse.lsp4j.CompletionItem; //导入依赖的package包/类
public CompletableFuture<List<CompletionItem>> getCompletions(Position position) {
	if(textDocumentItem != null) {
		try {
			Node correspondingCamelNode = parserFileHelper.getCorrespondingCamelNodeForCompletion(textDocumentItem, position.getLine());
			if (correspondingCamelNode != null) {
				String line = parserFileHelper.getLine(textDocumentItem, position);
				String camelComponentUri = parserFileHelper.getCamelComponentUri(textDocumentItem, position);
				CamelURIInstance camelURIInstance = new CamelURIInstance(camelComponentUri, correspondingCamelNode);
				int positionInCamelUri = position.getCharacter() - line.indexOf("uri=") - 5;
				CamelUriElementInstance camelUriElementInstance = camelURIInstance.getSpecificElement(positionInCamelUri);
				return camelUriElementInstance.getCompletions(camelCatalog, positionInCamelUri);
			}
		} catch (Exception e) {
			LOGGER.error("Error searching for corresponding node elements", e);
		}
	}
	return CompletableFuture.completedFuture(Collections.emptyList());
}
 
开发者ID:lhein,项目名称:camel-language-server,代码行数:19,代码来源:CamelEndpointCompletionProcessor.java


示例3: testChangeEventUpdatesStoredText

import org.eclipse.lsp4j.CompletionItem; //导入依赖的package包/类
@Test
public void testChangeEventUpdatesStoredText() throws Exception {
	CamelLanguageServer camelLanguageServer = initializeLanguageServer("<to uri=\"\" xmlns=\"http://camel.apache.org/schema/blueprint\"></to>\n");
	
	DidChangeTextDocumentParams changeEvent = new DidChangeTextDocumentParams();
	VersionedTextDocumentIdentifier textDocument = new VersionedTextDocumentIdentifier();
	textDocument.setUri(DUMMY_URI);
	changeEvent.setTextDocument(textDocument);
	TextDocumentContentChangeEvent contentChange = new TextDocumentContentChangeEvent("<to xmlns=\"http://camel.apache.org/schema/blueprint\" uri=\"\"></to>\n");
	changeEvent.setContentChanges(Collections.singletonList(contentChange));
	camelLanguageServer.getTextDocumentService().didChange(changeEvent);
	
	//check old position doesn't provide completion
	CompletableFuture<Either<List<CompletionItem>, CompletionList>> completionsAtOldPosition = getCompletionFor(camelLanguageServer, new Position(0, 11));
	assertThat(completionsAtOldPosition.get().getLeft()).isEmpty();
	
	//check new position provides completion
	CompletableFuture<Either<List<CompletionItem>, CompletionList>> completionsAtNewPosition = getCompletionFor(camelLanguageServer, new Position(0, 58));
	assertThat(completionsAtNewPosition.get().getLeft()).isNotEmpty();
	
}
 
开发者ID:lhein,项目名称:camel-language-server,代码行数:22,代码来源:CamelTextDocumentServiceTest.java


示例4: completeConstructor

import org.eclipse.lsp4j.CompletionItem; //导入依赖的package包/类
/**
 * Complete constructor with minimal type information.
 *
 * <p>This is important when we're autocompleting new ? with a class that we haven't yet
 * imported. We don't yet have detailed type information or javadocs, and it's expensive to
 * retrieve them. So we autocomplete a minimal constructor, and let signature-help fill in the
 * details.
 */
private CompletionItem completeConstructor(
        String packageName, String className, boolean hasTypeParameters) {
    CompletionItem item = new CompletionItem();
    String qualifiedName = packageName.isEmpty() ? className : packageName + "." + className;
    String key = String.format("%s#<init>", className);
    String insertText = className;

    if (hasTypeParameters) insertText += "<>";

    insertText += "($0)";

    item.setKind(CompletionItemKind.Constructor);
    item.setLabel(className);
    item.setDetail(packageName);
    item.setInsertText(insertText);
    item.setInsertTextFormat(InsertTextFormat.Snippet);
    item.setCommand(TRIGGER_SIGNATURE_HELP);
    item.setFilterText(className);
    item.setAdditionalTextEdits(addImport(qualifiedName));
    item.setSortText("3/" + className);
    item.setData(key);

    return item;
}
 
开发者ID:georgewfraser,项目名称:vscode-javac,代码行数:33,代码来源:Completions.java


示例5: addImport

import org.eclipse.lsp4j.CompletionItem; //导入依赖的package包/类
@Test
public void addImport() {
    String file = "/org/javacs/example/AutocompleteOther.java";

    // Name of class
    List<? extends CompletionItem> items = items(file, 9, 17);

    for (CompletionItem item : items) {
        if ("ArrayList".equals(item.getLabel())) {
            assertThat(item.getAdditionalTextEdits(), not(nullValue()));
            assertThat(item.getAdditionalTextEdits(), not(empty()));

            return;
        }
    }

    fail("No ArrayList in " + items);
}
 
开发者ID:georgewfraser,项目名称:vscode-javac,代码行数:19,代码来源:CompletionsTest.java


示例6: dontImportSamePackage

import org.eclipse.lsp4j.CompletionItem; //导入依赖的package包/类
@Test
public void dontImportSamePackage() {
    String file = "/org/javacs/example/AutocompleteOther.java";

    // Name of class
    List<? extends CompletionItem> items = items(file, 6, 10);

    for (CompletionItem item : items) {
        if ("AutocompleteMember".equals(item.getLabel())) {
            assertThat(item.getAdditionalTextEdits(), either(empty()).or(nullValue()));

            return;
        }
    }

    fail("No AutocompleteMember in " + items);
}
 
开发者ID:georgewfraser,项目名称:vscode-javac,代码行数:18,代码来源:CompletionsTest.java


示例7: dontImportJavaLang

import org.eclipse.lsp4j.CompletionItem; //导入依赖的package包/类
@Test
public void dontImportJavaLang() {
    String file = "/org/javacs/example/AutocompleteOther.java";

    // Name of class
    List<? extends CompletionItem> items = items(file, 11, 38);

    for (CompletionItem item : items) {
        if ("ArrayIndexOutOfBoundsException".equals(item.getLabel())) {
            assertThat(item.getAdditionalTextEdits(), either(empty()).or(nullValue()));

            return;
        }
    }

    fail("No ArrayIndexOutOfBoundsException in " + items);
}
 
开发者ID:georgewfraser,项目名称:vscode-javac,代码行数:18,代码来源:CompletionsTest.java


示例8: dontImportSelf

import org.eclipse.lsp4j.CompletionItem; //导入依赖的package包/类
@Test
public void dontImportSelf() {
    String file = "/org/javacs/example/AutocompleteOther.java";

    // Name of class
    List<? extends CompletionItem> items = items(file, 6, 10);

    for (CompletionItem item : items) {
        if ("AutocompleteOther".equals(item.getLabel())) {
            assertThat(item.getAdditionalTextEdits(), either(empty()).or(nullValue()));

            return;
        }
    }

    fail("No AutocompleteOther in " + items);
}
 
开发者ID:georgewfraser,项目名称:vscode-javac,代码行数:18,代码来源:CompletionsTest.java


示例9: dontImportAlreadyImported

import org.eclipse.lsp4j.CompletionItem; //导入依赖的package包/类
@Test
public void dontImportAlreadyImported() {
    String file = "/org/javacs/example/AutocompleteOther.java";

    // Name of class
    List<? extends CompletionItem> items = items(file, 12, 14);

    for (CompletionItem item : items) {
        if ("Arrays".equals(item.getLabel())) {
            assertThat(item.getAdditionalTextEdits(), either(empty()).or(nullValue()));

            return;
        }
    }

    fail("No Arrays in " + items);
}
 
开发者ID:georgewfraser,项目名称:vscode-javac,代码行数:18,代码来源:CompletionsTest.java


示例10: dontImportAlreadyImportedStar

import org.eclipse.lsp4j.CompletionItem; //导入依赖的package包/类
@Test
public void dontImportAlreadyImportedStar() {
    String file = "/org/javacs/example/AutocompleteOther.java";

    // Name of class
    List<? extends CompletionItem> items = items(file, 10, 26);

    for (CompletionItem item : items) {
        if ("ArrayBlockingQueue".equals(item.getLabel())) {
            assertThat(item.getAdditionalTextEdits(), either(empty()).or(nullValue()));

            return;
        }
    }

    fail("No ArrayBlockingQueue in " + items);
}
 
开发者ID:georgewfraser,项目名称:vscode-javac,代码行数:18,代码来源:CompletionsTest.java


示例11: autoImportConstructor

import org.eclipse.lsp4j.CompletionItem; //导入依赖的package包/类
@Test
public void autoImportConstructor() throws IOException {
    String file = "/org/javacs/example/AutocompleteConstructor.java";

    // Static methods
    List<? extends CompletionItem> items = items(file, 6, 19);
    List<String> suggestions = Lists.transform(items, i -> i.getInsertText());

    assertThat(suggestions, hasItems("ArrayList<>($0)"));

    for (CompletionItem each : items) {
        if (each.getInsertText().equals("ArrayList<>"))
            assertThat(
                    "new ? auto-imports",
                    each.getAdditionalTextEdits(),
                    both(not(empty())).and(not(nullValue())));
    }
}
 
开发者ID:georgewfraser,项目名称:vscode-javac,代码行数:19,代码来源:CompletionsTest.java


示例12: importClass

import org.eclipse.lsp4j.CompletionItem; //导入依赖的package包/类
@Test
public void importClass() throws IOException {
    String file = "/org/javacs/example/AutocompletePackage.java";

    // Static methods
    List<? extends CompletionItem> items = items(file, 4, 25);
    List<String> suggestions = Lists.transform(items, i -> i.getLabel());

    assertThat(suggestions, hasItems("OtherPackagePublic"));
    assertThat(suggestions, not(hasItems("OtherPackagePrivate")));

    for (CompletionItem item : items) {
        if (item.getLabel().equals("OtherPackagePublic"))
            assertThat(
                    "Don't import when completing imports",
                    item.getAdditionalTextEdits(),
                    either(empty()).or(nullValue()));
    }
}
 
开发者ID:georgewfraser,项目名称:vscode-javac,代码行数:20,代码来源:CompletionsTest.java


示例13: otherPackageId

import org.eclipse.lsp4j.CompletionItem; //导入依赖的package包/类
@Test
public void otherPackageId() throws IOException {
    String file = "/org/javacs/example/AutocompleteOtherPackage.java";

    // Static methods
    List<? extends CompletionItem> items = items(file, 5, 14);
    List<String> suggestions = Lists.transform(items, i -> i.getLabel());

    assertThat(suggestions, hasItems("OtherPackagePublic"));
    assertThat(suggestions, not(hasItems("OtherPackagePrivate")));

    for (CompletionItem item : items) {
        if (item.getLabel().equals("OtherPackagePublic"))
            assertThat(
                    "Auto-import OtherPackagePublic",
                    item.getAdditionalTextEdits(),
                    not(empty()));
    }
}
 
开发者ID:georgewfraser,项目名称:vscode-javac,代码行数:20,代码来源:CompletionsTest.java


示例14: getCompletions

import org.eclipse.lsp4j.CompletionItem; //导入依赖的package包/类
public synchronized void getCompletions(final SSymbol name,
    final Set<CompletionItem> results) {
  for (Variable v : variables) {
    matchAndAdd(name, v.name, results, CompletionItemKind.Variable);
  }

  for (SInvokable m : methods) {
    matchAndAdd(name, m.getSignature(), results, CompletionItemKind.Method);
  }

  for (SlotDefinition s : slots) {
    matchAndAdd(name, s.getName(), results, CompletionItemKind.Field);
  }

  for (MixinDefinition c : classes) {
    matchAndAdd(name, c.getName(), results, CompletionItemKind.Class);
    matchAndAdd(name, c.getPrimaryFactorySelector(), results,
        CompletionItemKind.Constructor);
  }
}
 
开发者ID:smarr,项目名称:SOMns-vscode,代码行数:21,代码来源:SomStructures.java


示例15: createTypeProposalLabel

import org.eclipse.lsp4j.CompletionItem; //导入依赖的package包/类
void createTypeProposalLabel(char[] fullName, CompletionItem item) {
	// only display innermost type name as type name, using any
	// enclosing types as qualification
	int qIndex= findSimpleNameStart(fullName);

	String name = new String(fullName, qIndex, fullName.length - qIndex);
	StringBuilder nameBuffer= new StringBuilder();
	nameBuffer.append(name);
	if (qIndex > 0) {
		nameBuffer.append(PACKAGE_NAME_SEPARATOR);
		nameBuffer.append(new String(fullName,0,qIndex-1));
	}
	item.setFilterText(name);
	item.setInsertText(name);
	item.setLabel(nameBuffer.toString());
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:17,代码来源:CompletionProposalDescriptionProvider.java


示例16: createJavadocTypeProposalLabel

import org.eclipse.lsp4j.CompletionItem; //导入依赖的package包/类
private void createJavadocTypeProposalLabel(char[] fullName, CompletionItem item) {
	// only display innermost type name as type name, using any
	// enclosing types as qualification
	int qIndex= findSimpleNameStart(fullName);

	StringBuilder nameBuffer= new StringBuilder();

	String name = new String(fullName, qIndex, fullName.length - qIndex);
	nameBuffer.append("{@link "); //$NON-NLS-1$
	nameBuffer.append(name);
	nameBuffer.append('}');
	item.setLabel(nameBuffer.toString());
	item.setFilterText(name);
	if (qIndex > 0) {
		item.setDetail(new String(fullName, 0, qIndex - 1));
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:18,代码来源:CompletionProposalDescriptionProvider.java


示例17: testRequest

import org.eclipse.lsp4j.CompletionItem; //导入依赖的package包/类
@Test public void testRequest() throws Exception {
	
	TextDocumentPositionParams p = new TextDocumentPositionParams();
	p.setPosition(new Position(1,1));
	p.setTextDocument(new TextDocumentIdentifier("test/foo.txt"));
	
	CompletionList result = new CompletionList();
	result.setIsIncomplete(true);
	result.setItems(new ArrayList<>());
	
	CompletionItem item = new CompletionItem();
	item.setDetail("test");
	item.setDocumentation("doc");
	item.setFilterText("filter");
	item.setInsertText("insert");
	item.setKind(CompletionItemKind.Field);
	result.getItems().add(item);
	
	server.expectedRequests.put("textDocument/completion", new Pair<>(p, result));
	CompletableFuture<Either<List<CompletionItem>, CompletionList>> future = clientLauncher.getRemoteProxy().getTextDocumentService().completion(p);
	Assert.assertEquals(Either.forRight(result).toString(), future.get(TIMEOUT, TimeUnit.MILLISECONDS).toString());
	client.joinOnEmpty();
}
 
开发者ID:eclipse,项目名称:lsp4j,代码行数:24,代码来源:LauncherTest.java


示例18: createAnonymousTypeLabel

import org.eclipse.lsp4j.CompletionItem; //导入依赖的package包/类
private void createAnonymousTypeLabel(CompletionProposal proposal, CompletionItem item) {
	char[] declaringTypeSignature= proposal.getDeclarationSignature();
	declaringTypeSignature= Signature.getTypeErasure(declaringTypeSignature);
	String name = new String(Signature.getSignatureSimpleName(declaringTypeSignature));
	item.setInsertText(name);
	StringBuilder buf= new StringBuilder();
	buf.append(name);
	buf.append('(');
	appendUnboundedParameterList(buf, proposal);
	buf.append(')');
	buf.append("  "); //$NON-NLS-1$
	buf.append("Anonymous Inner Type"); //TODO: consider externalization
	item.setLabel(buf.toString());

	if (proposal.getRequiredProposals() != null) {
		char[] signatureQualifier= Signature.getSignatureQualifier(declaringTypeSignature);
		if (signatureQualifier.length > 0) {
			item.setDetail(String.valueOf(signatureQualifier));
		}
	}
	setDeclarationSignature(item, String.valueOf(declaringTypeSignature));
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:23,代码来源:CompletionProposalDescriptionProvider.java


示例19: completion

import org.eclipse.lsp4j.CompletionItem; //导入依赖的package包/类
Either<List<CompletionItem>, CompletionList> completion(TextDocumentPositionParams position,
		IProgressMonitor monitor) {
	List<CompletionItem> completionItems = null;
	try {
		ICompilationUnit unit = JDTUtils.resolveCompilationUnit(position.getTextDocument().getUri());
		completionItems = this.computeContentAssist(unit,
				position.getPosition().getLine(),
				position.getPosition().getCharacter(), monitor);
	} catch (OperationCanceledException ignorable) {
		// No need to pollute logs when query is cancelled
		monitor.setCanceled(true);
	} catch (Exception e) {
		JavaLanguageServerPlugin.logException("Problem with codeComplete for " +  position.getTextDocument().getUri(), e);
		monitor.setCanceled(true);
	}
	CompletionList $ = new CompletionList();
	if (monitor.isCanceled()) {
		$.setIsIncomplete(true);
		completionItems = null;
		JavaLanguageServerPlugin.logInfo("Completion request cancelled");
	} else {
		JavaLanguageServerPlugin.logInfo("Completion request completed");
	}
	$.setItems(completionItems == null ? Collections.emptyList() : completionItems);
	return Either.forRight($);
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:27,代码来源:CompletionHandler.java


示例20: completion

import org.eclipse.lsp4j.CompletionItem; //导入依赖的package包/类
@Override
public CompletableFuture<Either<List<CompletionItem>, CompletionList>> completion(TextDocumentPositionParams position) {
	logInfo(">> document/completion");
	CompletionHandler handler = new CompletionHandler();
	final IProgressMonitor[] monitors = new IProgressMonitor[1];
	CompletableFuture<Either<List<CompletionItem>, CompletionList>> result = computeAsync((cc) -> {
		monitors[0] = toMonitor(cc);
		if (Boolean.getBoolean(JAVA_LSP_JOIN_ON_COMPLETION)) {
			try {
				Job.getJobManager().join(DocumentLifeCycleHandler.DOCUMENT_LIFE_CYCLE_JOBS, monitors[0]);
			} catch (OperationCanceledException ignorable) {
				// No need to pollute logs when query is cancelled
			} catch (InterruptedException e) {
				JavaLanguageServerPlugin.logException(e.getMessage(), e);
			}
		}
		return handler.completion(position, monitors[0]);
	});
	result.join();
	if (monitors[0].isCanceled()) {
		result.cancel(true);
	}
	return result;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:25,代码来源:JDTLanguageServer.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ClientTransportException类代码示例发布时间:2022-05-23
下一篇:
Java Func5类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap