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


Java CompletionItem.setSortText方法代码示例

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

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

示例1: 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


示例2: completeClassNameFromClassPath

import org.eclipse.lsp4j.CompletionItem; //导入方法依赖的package包/类
private CompletionItem completeClassNameFromClassPath(String qualifiedName) {
    CompletionItem item = new CompletionItem();
    String packageName = mostIds(qualifiedName), simpleName = lastId(qualifiedName);

    item.setLabel(simpleName);
    item.setDetail(packageName);
    item.setInsertText(simpleName);
    item.setAdditionalTextEdits(addImport(qualifiedName));
    item.setSortText("3/" + simpleName);
    item.setData(qualifiedName);

    // TODO implement vscode resolve-completion-item

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


示例3: toCompletionItem

import org.eclipse.lsp4j.CompletionItem; //导入方法依赖的package包/类
public CompletionItem toCompletionItem(CompletionProposal proposal, int index) {
	final CompletionItem $ = new CompletionItem();
	$.setKind(mapKind(proposal.getKind()));
	Map<String, String> data = new HashMap<>();
	// append data field so that resolve request can use it.
	data.put(CompletionResolveHandler.DATA_FIELD_URI,unit.getResource().getLocationURI().toString());
	data.put(CompletionResolveHandler.DATA_FIELD_REQUEST_ID,String.valueOf(response.getId()));
	data.put(CompletionResolveHandler.DATA_FIELD_PROPOSAL_ID,String.valueOf(index));
	$.setData(data);
	this.descriptionProvider.updateDescription(proposal, $);
	$.setSortText(SortTextHelper.computeSortText(proposal));
	return $;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:14,代码来源:CompletionProposalRequestor.java


示例4: createCompletionList

import org.eclipse.lsp4j.CompletionItem; //导入方法依赖的package包/类
public CompletionList createCompletionList(final Document document, final XtextResource resource, final TextDocumentPositionParams params, final CancelIndicator cancelIndicator) {
  try {
    final CompletionList result = new CompletionList();
    result.setIsIncomplete(true);
    final IdeContentProposalAcceptor acceptor = this.proposalAcceptorProvider.get();
    final int caretOffset = document.getOffSet(params.getPosition());
    final Position caretPosition = params.getPosition();
    final TextRegion position = new TextRegion(caretOffset, 0);
    try {
      this.createProposals(document.getContents(), position, caretOffset, resource, acceptor);
    } catch (final Throwable _t) {
      if (_t instanceof Throwable) {
        final Throwable t = (Throwable)_t;
        boolean _isOperationCanceledException = this.operationCanceledManager.isOperationCanceledException(t);
        boolean _not = (!_isOperationCanceledException);
        if (_not) {
          throw t;
        }
      } else {
        throw Exceptions.sneakyThrow(_t);
      }
    }
    final Procedure2<ContentAssistEntry, Integer> _function = (ContentAssistEntry it, Integer idx) -> {
      final CompletionItem item = this.toCompletionItem(it, caretOffset, caretPosition, document);
      item.setSortText(Strings.padStart(Integer.toString((idx).intValue()), 5, '0'));
      List<CompletionItem> _items = result.getItems();
      _items.add(item);
    };
    IterableExtensions.<ContentAssistEntry>forEach(acceptor.getEntries(), _function);
    return result;
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:35,代码来源:ContentAssistService.java



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