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

Java CompletionItemKind类代码示例

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

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



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

示例1: completeConstructor

import org.eclipse.lsp4j.CompletionItemKind; //导入依赖的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: getCompletions

import org.eclipse.lsp4j.CompletionItemKind; //导入依赖的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


示例3: testCompletion_import_package

import org.eclipse.lsp4j.CompletionItemKind; //导入依赖的package包/类
@Test
public void testCompletion_import_package() throws JavaModelException{
	ICompilationUnit unit = getWorkingCopy(
			"src/java/Foo.java",
			"import java.sq \n" +
					"public class Foo {\n"+
					"	void foo() {\n"+
					"	}\n"+
			"}\n");

	int[] loc = findCompletionLocation(unit, "java.sq");

	CompletionList list = server.completion(JsonMessageHelper.getParams(createCompletionRequest(unit, loc[0], loc[1]))).join().getRight();

	assertNotNull(list);
	assertEquals(1, list.getItems().size());
	CompletionItem item = list.getItems().get(0);
	// Check completion item
	assertNull(item.getInsertText());
	assertEquals("java.sql",item.getLabel());
	assertEquals(CompletionItemKind.Module, item.getKind() );
	assertEquals("999999215", item.getSortText());
	assertNull(item.getTextEdit());


	CompletionItem resolvedItem = server.resolveCompletionItem(item).join();
	assertNotNull(resolvedItem);
	TextEdit te = item.getTextEdit();
	assertNotNull(te);
	assertEquals("java.sql.*;",te.getNewText());
	assertNotNull(te.getRange());
	Range range = te.getRange();
	assertEquals(0, range.getStart().getLine());
	assertEquals(7, range.getStart().getCharacter());
	assertEquals(0, range.getEnd().getLine());
	//Not checking the range end character
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:38,代码来源:CompletionHandlerTest.java


示例4: testRequest

import org.eclipse.lsp4j.CompletionItemKind; //导入依赖的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


示例5: CompletionImageProvider

import org.eclipse.lsp4j.CompletionItemKind; //导入依赖的package包/类
@Inject
public CompletionImageProvider(LanguageServerResources resources) {
  this.resources = resources;
  // TODO add missed icons
  // no icon for keyword kind
  imageMap.put(CompletionItemKind.Text, resources.textItem());
  imageMap.put(CompletionItemKind.Method, resources.methodItem());
  //        imageMap.put(CompletionItemKind.KIND_FUNCTION, );
  //        imageMap.put(CompletionItemKind.KIND_CONSTRUCTOR, );
  imageMap.put(CompletionItemKind.Field, resources.fieldItem());
  imageMap.put(CompletionItemKind.Variable, resources.variableItem());
  imageMap.put(CompletionItemKind.Class, resources.classItem());
  imageMap.put(CompletionItemKind.Interface, resources.interfaceItem());
  imageMap.put(CompletionItemKind.Module, resources.moduleItem());
  imageMap.put(CompletionItemKind.Property, resources.propertyItem());
  //        imageMap.put(CompletionItemKind.KIND_UNIT, );
  imageMap.put(CompletionItemKind.Value, resources.valueItem());
  imageMap.put(CompletionItemKind.Enum, resources.enumItem());
  imageMap.put(CompletionItemKind.Snippet, resources.snippetItem());
  //        imageMap.put(CompletionItemKind.KIND_COLOR, );
  imageMap.put(CompletionItemKind.File, resources.fileItem());
  //        imageMap.put(CompletionItemKind.KIND_REFERENCE, );
}
 
开发者ID:eclipse,项目名称:che,代码行数:24,代码来源:CompletionImageProvider.java


示例6: getIcon

import org.eclipse.lsp4j.CompletionItemKind; //导入依赖的package包/类
public Icon getIcon(CompletionItemKind completionKind) {
  return new Icon("", imageMap.get(completionKind));
}
 
开发者ID:eclipse,项目名称:che,代码行数:4,代码来源:CompletionImageProvider.java


示例7: classKind

import org.eclipse.lsp4j.CompletionItemKind; //导入依赖的package包/类
private CompletionItemKind classKind(ElementKind kind) {
    switch (kind) {
        case CLASS:
            return CompletionItemKind.Class;
        case ANNOTATION_TYPE:
        case INTERFACE:
            return CompletionItemKind.Interface;
        case ENUM:
            return CompletionItemKind.Enum;
        default:
            throw new RuntimeException("Expected CLASS, INTERFACE or ENUM but found " + kind);
    }
}
 
开发者ID:georgewfraser,项目名称:vscode-javac,代码行数:14,代码来源:Completions.java


示例8: matchAndAdd

import org.eclipse.lsp4j.CompletionItemKind; //导入依赖的package包/类
private void matchAndAdd(final SSymbol query, final SSymbol symbol,
    final Set<CompletionItem> results, final CompletionItemKind kind) {
  if (fuzzyMatches(symbol, query)) {
    CompletionItem item = new CompletionItem();
    item.setKind(kind);
    item.setLabel(symbol.getString());
    results.add(item);
  }
}
 
开发者ID:smarr,项目名称:SOMns-vscode,代码行数:10,代码来源:SomStructures.java


示例9: testCompletion_method_withLSPV2

import org.eclipse.lsp4j.CompletionItemKind; //导入依赖的package包/类
@Test
public void testCompletion_method_withLSPV2() throws JavaModelException{
	mockLSP2Client();

	ICompilationUnit unit = getWorkingCopy(
			"src/java/Foo.java",
			"public class Foo {\n"+
					"	void foo() {\n"+
					"System.out.print(\"Hello\");\n" +
					"System.out.println(\" World!\");\n"+
					"HashMap<String, String> map = new HashMap<>();\n"+
					"map.pu\n" +
					"	}\n"+
			"}\n");

	int[] loc = findCompletionLocation(unit, "map.pu");

	CompletionList list = server.completion(JsonMessageHelper.getParams(createCompletionRequest(unit, loc[0], loc[1]))).join().getRight();
	assertNotNull(list);
	CompletionItem ci = list.getItems().stream()
			.filter( item->  item.getLabel().matches("put\\(String \\w+, String \\w+\\) : String"))
			.findFirst().orElse(null);
	assertNotNull(ci);

	assertEquals("put", ci.getInsertText());
	assertEquals(CompletionItemKind.Function, ci.getKind());
	assertEquals("999999019", ci.getSortText());
	assertNull(ci.getTextEdit());

	CompletionItem resolvedItem = server.resolveCompletionItem(ci).join();
	assertNotNull(resolvedItem.getTextEdit());
	assertTextEdit(5, 4, 6, "put", resolvedItem.getTextEdit());
	assertNotNull(resolvedItem.getAdditionalTextEdits());
	List<TextEdit> edits = resolvedItem.getAdditionalTextEdits();
	assertEquals(3, edits.size());
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:37,代码来源:CompletionHandlerTest.java


示例10: testCompletion_method_withLSPV3

import org.eclipse.lsp4j.CompletionItemKind; //导入依赖的package包/类
@Test
public void testCompletion_method_withLSPV3() throws JavaModelException{
	ICompilationUnit unit = getWorkingCopy(
			"src/java/Foo.java",
			"public class Foo {\n"+
					"	void foo() {\n"+
					"System.out.print(\"Hello\");\n" +
					"System.out.println(\" World!\");\n"+
					"HashMap<String, String> map = new HashMap<>();\n"+
					"map.pu\n" +
					"	}\n"+
			"}\n");

	int[] loc = findCompletionLocation(unit, "map.pu");

	CompletionList list = server.completion(JsonMessageHelper.getParams(createCompletionRequest(unit, loc[0], loc[1]))).join().getRight();
	assertNotNull(list);
	CompletionItem ci = list.getItems().stream()
			.filter( item->  item.getLabel().matches("put\\(String \\w+, String \\w+\\) : String"))
			.findFirst().orElse(null);
	assertNotNull(ci);

	assertEquals("put", ci.getInsertText());
	assertEquals(CompletionItemKind.Function, ci.getKind());
	assertEquals("999999019", ci.getSortText());
	assertNull(ci.getTextEdit());

	CompletionItem resolvedItem = server.resolveCompletionItem(ci).join();
	assertNotNull(resolvedItem.getTextEdit());
	try {
		assertTextEdit(5, 4, 6, "put(${1:key}, ${2:value})", resolvedItem.getTextEdit());
	} catch (ComparisonFailure e) {
		//In case the JDK has no sources
		assertTextEdit(5, 4, 6, "put(${1:arg0}, ${2:arg1})", resolvedItem.getTextEdit());
	}
	assertNotNull(resolvedItem.getAdditionalTextEdits());
	List<TextEdit> edits = resolvedItem.getAdditionalTextEdits();
	assertEquals(3, edits.size());
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:40,代码来源:CompletionHandlerTest.java


示例11: testCompletion_field

import org.eclipse.lsp4j.CompletionItemKind; //导入依赖的package包/类
@Test
public void testCompletion_field() throws JavaModelException{
	ICompilationUnit unit = getWorkingCopy(
			"src/java/Foo.java",
			"import java.sq \n" +
					"public class Foo {\n"+
					"private String myTestString;\n"+
					"	void foo() {\n"+
					"   this.myTestS\n"+
					"	}\n"+
			"}\n");

	int[] loc = findCompletionLocation(unit, "this.myTestS");

	CompletionList list = server.completion(JsonMessageHelper.getParams(createCompletionRequest(unit, loc[0], loc[1]))).join().getRight();

	assertNotNull(list);
	assertEquals(1, list.getItems().size());
	CompletionItem item = list.getItems().get(0);
	assertEquals(CompletionItemKind.Field, item.getKind());
	assertEquals("myTestString", item.getInsertText());
	assertNull(item.getAdditionalTextEdits());
	assertNull(item.getTextEdit());

	CompletionItem resolvedItem = server.resolveCompletionItem(item).join();
	assertNotNull(resolvedItem.getTextEdit());
	assertTextEdit(4,8,15,"myTestString",resolvedItem.getTextEdit());
	//Not checking the range end character
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:30,代码来源:CompletionHandlerTest.java


示例12: testCompletion_import_type

import org.eclipse.lsp4j.CompletionItemKind; //导入依赖的package包/类
@Test
public void testCompletion_import_type() throws JavaModelException{
	ICompilationUnit unit = getWorkingCopy(
			"src/java/Foo.java",
			"import java.sq \n" +
					"public class Foo {\n"+
					"	void foo() {\n"+
					"   java.util.Ma\n"+
					"	}\n"+
			"}\n");

	int[] loc = findCompletionLocation(unit, "java.util.Ma");

	CompletionList list = server.completion(JsonMessageHelper.getParams(createCompletionRequest(unit, loc[0], loc[1]))).join().getRight();

	assertNotNull(list);
	assertEquals(1, list.getItems().size());
	CompletionItem item = list.getItems().get(0);
	assertEquals(CompletionItemKind.Class, item.getKind());
	assertEquals("Map", item.getInsertText());
	assertNull(item.getAdditionalTextEdits());
	assertNull(item.getTextEdit());

	CompletionItem resolvedItem = server.resolveCompletionItem(item).join();
	assertNotNull(resolvedItem.getTextEdit());
	assertTextEdit(3,3,15,"java.util.Map",resolvedItem.getTextEdit());
	//Not checking the range end character
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:29,代码来源:CompletionHandlerTest.java


示例13: testCompletion_getter

import org.eclipse.lsp4j.CompletionItemKind; //导入依赖的package包/类
@Test
public void testCompletion_getter() throws Exception {

	ICompilationUnit unit = getWorkingCopy(
			"src/java/Foo.java",
			"public class Foo {\n"+
					"    private String strField;\n" +
					"    get" +
			"}\n");

	int[] loc = findCompletionLocation(unit, "get");


	CompletionList list = server.completion(JsonMessageHelper.getParams(createCompletionRequest(unit, loc[0], loc[1]))).join().getRight();
	assertNotNull(list);
	CompletionItem ci = list.getItems().stream()
			.filter(item -> item.getLabel().startsWith("getStrField() : String"))
			.findFirst().orElse(null);
	assertNotNull(ci);

	assertEquals("getStrField", ci.getInsertText());
	assertEquals(CompletionItemKind.Function, ci.getKind());
	assertEquals("999999979", ci.getSortText());
	assertNull(ci.getTextEdit());

	CompletionItem resolvedItem = server.resolveCompletionItem(ci).join();
	assertNotNull(resolvedItem.getTextEdit());
	assertTextEdit(2, 4, 7, "/**\n" +
			 " * @return the strField\n" +
			 " */\n" +
			"public String getStrField() {\n" +
			"	return strField;\n" +
			"}", resolvedItem.getTextEdit());
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:35,代码来源:CompletionHandlerTest.java


示例14: testCompletion_booleangetter

import org.eclipse.lsp4j.CompletionItemKind; //导入依赖的package包/类
@Test
public void testCompletion_booleangetter() throws Exception {

	ICompilationUnit unit = getWorkingCopy(
			"src/java/Foo.java",
			"public class Foo {\n"+
					"    private boolean boolField;\n" +
					"    is\n" +
			"}\n");

	int[] loc = findCompletionLocation(unit, "is");


	CompletionList list = server.completion(JsonMessageHelper.getParams(createCompletionRequest(unit, loc[0], loc[1]))).join().getRight();
	assertNotNull(list);
	CompletionItem ci = list.getItems().stream()
			.filter(item -> item.getLabel().startsWith("isBoolField() : boolean"))
			.findFirst().orElse(null);
	assertNotNull(ci);

	assertEquals("isBoolField", ci.getInsertText());
	assertEquals(CompletionItemKind.Function, ci.getKind());
	assertEquals("999999979", ci.getSortText());
	assertNull(ci.getTextEdit());

	CompletionItem resolvedItem = server.resolveCompletionItem(ci).join();
	assertNotNull(resolvedItem.getTextEdit());
	assertTextEdit(2, 4, 6, "/**\n" +
			 " * @return the boolField\n" +
			 " */\n" +
			"public boolean isBoolField() {\n" +
			"	return boolField;\n" +
			"}", resolvedItem.getTextEdit());
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:35,代码来源:CompletionHandlerTest.java


示例15: testCompletion_setter

import org.eclipse.lsp4j.CompletionItemKind; //导入依赖的package包/类
@Test
public void testCompletion_setter() throws Exception {
	ICompilationUnit unit = getWorkingCopy(
			"src/java/Foo.java",
			"public class Foo {\n"+
					"    private String strField;\n" +
					"    set" +
			"}\n");

	int[] loc = findCompletionLocation(unit, "set");


	CompletionList list = server.completion(JsonMessageHelper.getParams(createCompletionRequest(unit, loc[0], loc[1]))).join().getRight();
	assertNotNull(list);
	CompletionItem ci = list.getItems().stream()
			.filter(item -> item.getLabel().startsWith("setStrField(String strField) : void"))
			.findFirst().orElse(null);
	assertNotNull(ci);

	assertEquals("setStrField", ci.getInsertText());
	assertEquals(CompletionItemKind.Function, ci.getKind());
	assertEquals("999999979", ci.getSortText());
	assertNull(ci.getTextEdit());

	CompletionItem resolvedItem = server.resolveCompletionItem(ci).join();
	assertNotNull(resolvedItem.getTextEdit());
	assertTextEdit(2, 4, 7, "/**\n" +
			" * @param strField the strField to set\n" +
			 " */\n" +
			"public void setStrField(String strField) {\n" +
			"	this.strField = strField;\n" +
			"}", resolvedItem.getTextEdit());
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:34,代码来源:CompletionHandlerTest.java


示例16: testCompletion_AnonymousType

import org.eclipse.lsp4j.CompletionItemKind; //导入依赖的package包/类
@Test
public void testCompletion_AnonymousType() throws Exception {
	ICompilationUnit unit = getWorkingCopy(
			"src/java/Foo.java",
			"public class Foo {\n"+
					"    public static void main(String[] args) {\n" +
					"        IFoo foo = new \n" +
					"    } \n" +
					"    interface IFoo {\n"+
					"        String getName();\n"+
					"    }\n"+
			"}\n");
	waitForBackgroundJobs();
	int[] loc = findCompletionLocation(unit, "new ");
	CompletionList list = server.completion(JsonMessageHelper.getParams(createCompletionRequest(unit, loc[0], loc[1]))).join().getRight();
	assertNotNull(list);
	CompletionItem ci = list.getItems().stream()
			.filter(item -> item.getLabel().startsWith("Foo.IFoo()  Anonymous Inner Type"))
			.findFirst().orElse(null);
	assertNotNull(ci);

	assertEquals("Foo.IFoo", ci.getInsertText());
	assertEquals(CompletionItemKind.Constructor, ci.getKind());
	assertEquals("999998684", ci.getSortText());
	assertNull(ci.getTextEdit());

	CompletionItem resolvedItem = server.resolveCompletionItem(ci).join();
	assertNotNull(resolvedItem.getTextEdit());
	assertTextEdit(2, 23, 23, "IFoo(){\n" +
			"\n" +
			"		@Override\n" +
			"		public String getName() {\n" +
			"			${0:return null;}\n" +
			"		}\n" +
			"};", resolvedItem.getTextEdit());
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:37,代码来源:CompletionHandlerTest.java


示例17: testCompletion_AnonymousTypeMoreMethods

import org.eclipse.lsp4j.CompletionItemKind; //导入依赖的package包/类
@Test
public void testCompletion_AnonymousTypeMoreMethods() throws Exception {
	ICompilationUnit unit = getWorkingCopy(
			"src/java/Foo.java",
			"public class Foo {\n"+
					"    public static void main(String[] args) {\n" +
					"        IFoo foo = new \n" +
					"    } \n" +
					"    interface IFoo {\n"+
					"        String getName();\n"+
					"        void setName(String name);\n"+
					"    }\n"+
			"}\n");
	waitForBackgroundJobs();
	int[] loc = findCompletionLocation(unit, "new ");
	CompletionList list = server.completion(JsonMessageHelper.getParams(createCompletionRequest(unit, loc[0], loc[1]))).join().getRight();
	assertNotNull(list);
	CompletionItem ci = list.getItems().stream()
			.filter(item -> item.getLabel().startsWith("Foo.IFoo()  Anonymous Inner Type"))
			.findFirst().orElse(null);
	assertNotNull(ci);

	assertEquals("Foo.IFoo", ci.getInsertText());
	assertEquals(CompletionItemKind.Constructor, ci.getKind());
	assertEquals("999998684", ci.getSortText());
	assertNull(ci.getTextEdit());

	CompletionItem resolvedItem = server.resolveCompletionItem(ci).join();
	assertNotNull(resolvedItem.getTextEdit());
	assertTextEdit(2, 23, 23, "IFoo(){\n" +
			"\n		@Override\n" +
			"		public void setName(String name) {\n" +
			"			${0}\n" +
			"		}\n" +
			"\n		@Override\n" +
			"		public String getName() {\n" +
			"			return null;\n" +
			"		}\n" +
			"};", resolvedItem.getTextEdit());
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:41,代码来源:CompletionHandlerTest.java


示例18: testCompletion_AnonymousDeclarationType

import org.eclipse.lsp4j.CompletionItemKind; //导入依赖的package包/类
@Test
public void testCompletion_AnonymousDeclarationType() throws Exception {
	ICompilationUnit unit = getWorkingCopy(
			"src/java/Foo.java",
			"public class Foo {\n"+
					"    public static void main(String[] args) {\n" +
					"        new Runnable()\n" +
					"    }\n" +
			"}\n");
	waitForBackgroundJobs();
	int[] loc = findCompletionLocation(unit, "Runnable(");
	CompletionList list = server.completion(JsonMessageHelper.getParams(createCompletionRequest(unit, loc[0], loc[1]))).join().getRight();
	assertNotNull(list);
	CompletionItem ci = list.getItems().stream()
			.filter(item -> item.getLabel().startsWith("Runnable()  Anonymous Inner Type"))
			.findFirst().orElse(null);
	assertNotNull(ci);

	assertEquals("Runnable", ci.getInsertText());
	assertEquals(CompletionItemKind.Class, ci.getKind());
	assertEquals("999999372", ci.getSortText());
	assertNull(ci.getTextEdit());

	CompletionItem resolvedItem = server.resolveCompletionItem(ci).join();
	assertNotNull(resolvedItem.getTextEdit());
	assertTextEdit(2, 20, 22, "(){\n" +
			"\n" +
			"	@Override\n" +
			"	public void run() {\n" +
			"		${0}\n" +
			"	}\n" +
			"}", resolvedItem.getTextEdit());
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:34,代码来源:CompletionHandlerTest.java


示例19: testCompletion_AnonymousDeclarationType2

import org.eclipse.lsp4j.CompletionItemKind; //导入依赖的package包/类
@Test
public void testCompletion_AnonymousDeclarationType2() throws Exception {
	ICompilationUnit unit = getWorkingCopy(
			"src/java/Foo.java",
			"public class Foo {\n"+
					"    public static void main(String[] args) {\n" +
					"        new Runnable(  )\n" +
					"    }\n" +
			"}\n");
	waitForBackgroundJobs();
	int[] loc = findCompletionLocation(unit, "Runnable( ");
	CompletionList list = server.completion(JsonMessageHelper.getParams(createCompletionRequest(unit, loc[0], loc[1]))).join().getRight();
	assertNotNull(list);
	CompletionItem ci = list.getItems().stream()
			.filter(item -> item.getLabel().startsWith("Runnable()  Anonymous Inner Type"))
			.findFirst().orElse(null);
	assertNotNull(ci);

	assertEquals("Runnable", ci.getInsertText());
	assertEquals(CompletionItemKind.Class, ci.getKind());
	assertEquals("999999372", ci.getSortText());
	assertNull(ci.getTextEdit());

	CompletionItem resolvedItem = server.resolveCompletionItem(ci).join();
	assertNotNull(resolvedItem.getTextEdit());
	assertTextEdit(2, 20, 24, "(){\n" +
			"\n" +
			"	@Override\n" +
			"	public void run() {\n" +
			"		${0}\n" +
			"	}\n" +
			"}", resolvedItem.getTextEdit());
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:34,代码来源:CompletionHandlerTest.java


示例20: testCompletion_AnonymousDeclarationType3

import org.eclipse.lsp4j.CompletionItemKind; //导入依赖的package包/类
@Test
public void testCompletion_AnonymousDeclarationType3() throws Exception {
	ICompilationUnit unit = getWorkingCopy(
			"src/java/Foo.java",
			"public class Foo {\n"+
					"    public static void main(String[] args) {\n" +
					"        run(\"name\", new Runnable(, 1);\n" +
					"    }\n" +
					"    void run(String name, Runnable runnable, int i) {\n" +
					"    }\n" +
			"}\n");
	waitForBackgroundJobs();
	int[] loc = findCompletionLocation(unit, "Runnable(");
	CompletionList list = server.completion(JsonMessageHelper.getParams(createCompletionRequest(unit, loc[0], loc[1]))).join().getRight();
	assertNotNull(list);
	CompletionItem ci = list.getItems().stream()
			.filter(item -> item.getLabel().startsWith("Runnable()  Anonymous Inner Type"))
			.findFirst().orElse(null);
	assertNotNull(ci);

	assertEquals("Runnable", ci.getInsertText());
	assertEquals(CompletionItemKind.Class, ci.getKind());
	assertEquals("999999372", ci.getSortText());
	assertNull(ci.getTextEdit());

	CompletionItem resolvedItem = server.resolveCompletionItem(ci).join();
	assertNotNull(resolvedItem.getTextEdit());
	assertTextEdit(2, 32, 33, "(){\n" +
			"\n" +
			"	@Override\n" +
			"	public void run() {\n" +
			"		${0}\n" +
			"	}\n" +
			"}", resolvedItem.getTextEdit());
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:36,代码来源:CompletionHandlerTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java ItemBasedRecommender类代码示例发布时间:2022-05-23
下一篇:
Java Ends类代码示例发布时间: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