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

Java Hover类代码示例

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

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



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

示例1: testProvideDocumentationOnHover

import org.eclipse.lsp4j.Hover; //导入依赖的package包/类
@Test
public void testProvideDocumentationOnHover() throws Exception {
	CamelLanguageServer camelLanguageServer = initializeLanguageServer("<from uri=\"ahc:httpUri\" xmlns=\"http://camel.apache.org/schema/spring\"></from>\n");
	
	TextDocumentPositionParams position = new TextDocumentPositionParams(new TextDocumentIdentifier(DUMMY_URI), new Position(0, 13));
	CompletableFuture<Hover> hover = camelLanguageServer.getTextDocumentService().hover(position);
	
	assertThat(hover.get().getContents().get(0).getLeft()).isEqualTo(AHC_DOCUMENTATION);
}
 
开发者ID:lhein,项目名称:camel-language-server,代码行数:10,代码来源:CamelLanguageServerHoverTest.java


示例2: testHover

import org.eclipse.lsp4j.Hover; //导入依赖的package包/类
@Test
public void testHover() throws Exception {
	//given
	//Hovers on the System.out
	String payload = createHoverRequest("src/java/Foo.java", 5, 15);
	TextDocumentPositionParams position = getParams(payload);

	//when
	Hover hover = handler.hover(position, monitor);

	//then
	assertNotNull(hover);
	assertNotNull(hover.getContents());
	MarkedString signature = hover.getContents().get(0).getRight();
	assertEquals("Unexpected hover " + signature, "java", signature.getLanguage());
	assertEquals("Unexpected hover " + signature, "java.Foo", signature.getValue());
	String doc = hover.getContents().get(1).getLeft();
	assertEquals("Unexpected hover " + doc, "This is foo", doc);
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:20,代码来源:HoverHandlerTest.java


示例3: testHoverStandalone

import org.eclipse.lsp4j.Hover; //导入依赖的package包/类
@Test
public void testHoverStandalone() throws Exception {
	//given
	//Hovers on the System.out
	URI standalone = Paths.get("projects","maven","salut","src","main","java","java","Foo.java").toUri();
	String payload = createHoverRequest(standalone, 10, 71);
	TextDocumentPositionParams position = getParams(payload);

	//when
	Hover hover = handler.hover(position, monitor);

	//then
	assertNotNull(hover);
	assertNotNull(hover.getContents());
	MarkedString signature = hover.getContents().get(0).getRight();
	assertEquals("Unexpected hover " + signature, "java", signature.getLanguage());
	assertEquals("Unexpected hover " + signature, "java.Foo", signature.getValue());
	String doc = hover.getContents().get(1).getLeft();
	assertEquals("Unexpected hover "+doc, "This is foo", doc);
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:21,代码来源:HoverHandlerTest.java


示例4: testHoverPackage

import org.eclipse.lsp4j.Hover; //导入依赖的package包/类
@Test
public void testHoverPackage() throws Exception {
	// given
	// Hovers on the java.internal package
	String payload = createHoverRequest("src/java/Baz.java", 2, 16);
	TextDocumentPositionParams position = getParams(payload);

	// when
	Hover hover = handler.hover(position, monitor);

	// then
	assertNotNull(hover);
	String signature = hover.getContents().get(0).getRight().getValue();//
	assertEquals("Unexpected signature ", "java.internal", signature);
	String result = hover.getContents().get(1).getLeft();//
	assertEquals("Unexpected hover ", "this is a **bold** package!", result);
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:18,代码来源:HoverHandlerTest.java


示例5: testEmptyHover

import org.eclipse.lsp4j.Hover; //导入依赖的package包/类
@Test
public void testEmptyHover() throws Exception {
	//given
	//Hovers on the System.out
	URI standalone = Paths.get("projects","maven","salut","src","main","java","java","Foo.java").toUri();
	String payload = createHoverRequest(standalone, 1, 2);
	TextDocumentPositionParams position = getParams(payload);

	//when
	Hover hover = handler.hover(position, monitor);

	//then
	assertNotNull(hover);
	assertNotNull(hover.getContents());
	assertEquals(1, hover.getContents().size());
	assertEquals("Should find empty hover for " + payload, "", hover.getContents().get(0).getLeft());
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:18,代码来源:HoverHandlerTest.java


示例6: testHoverVariable

import org.eclipse.lsp4j.Hover; //导入依赖的package包/类
@Test
public void testHoverVariable() throws Exception {
	//given
	//Hover on args parameter
	String argParam = createHoverRequest("src/java/Foo.java", 7, 37);
	TextDocumentPositionParams position = getParams(argParam);

	//when
	Hover hover = handler.hover(position, monitor);

	//then
	assertNotNull(hover);
	assertNotNull(hover.getContents());
	MarkedString signature = hover.getContents().get(0).getRight();
	assertEquals("Unexpected hover " + signature, "java", signature.getLanguage());
	assertEquals("Unexpected hover " + signature, "String[] args - java.Foo.main(String[])", signature.getValue());
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:18,代码来源:HoverHandlerTest.java


示例7: testHoverOnPackageWithJavadoc

import org.eclipse.lsp4j.Hover; //导入依赖的package包/类
@Test
public void testHoverOnPackageWithJavadoc() throws Exception {
	importProjects("maven/salut2");
	project = WorkspaceHelper.getProject("salut2");
	handler = new HoverHandler(preferenceManager);
	//given
	//Hovers on the org.apache.commons import
	String payload = createHoverRequest("src/main/java/foo/Bar.java", 2, 22);
	TextDocumentPositionParams position = getParams(payload);

	//when
	Hover hover = handler.hover(position, monitor);
	assertNotNull(hover);
	String result = hover.getContents().get(0).getRight().getValue();//
	assertEquals("Unexpected hover ", "org.apache.commons", result);

	assertEquals(logListener.getErrors().toString(), 0, logListener.getErrors().size());
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:19,代码来源:HoverHandlerTest.java


示例8: testHoverThrowable

import org.eclipse.lsp4j.Hover; //导入依赖的package包/类
@Test
public void testHoverThrowable() throws Exception {
	String uriString = ClassFileUtil.getURI(project, "java.lang.Exception");
	IClassFile classFile = JDTUtils.resolveClassFile(uriString);
	String contents = JavaLanguageServerPlugin.getContentProviderManager().getSource(classFile, monitor);
	IDocument document = new Document(contents);
	IRegion region = new FindReplaceDocumentAdapter(document).find(0, "Throwable", true, false, false, false);
	int offset = region.getOffset();
	int line = document.getLineOfOffset(offset);
	int character = offset - document.getLineOffset(line);
	TextDocumentIdentifier textDocument = new TextDocumentIdentifier(uriString);
	Position position = new Position(line, character);
	TextDocumentPositionParams params = new TextDocumentPositionParams(textDocument, position);
	Hover hover = handler.hover(params, monitor);
	assertNotNull(hover);
	assertTrue("Unexpected hover ", !hover.getContents().isEmpty());
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:18,代码来源:HoverHandlerTest.java


示例9: hover

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

import org.eclipse.lsp4j.Hover; //导入依赖的package包/类
public CompletableFuture<Hover> getHover(Position position) {
	try {
		ParserFileHelper parserFileHelper = new ParserFileHelper();
		if(parserFileHelper.getCorrespondingCamelNodeForCompletion(textDocumentItem, position.getLine()) != null){
			String camelComponentUri = parserFileHelper.getCamelComponentUri(textDocumentItem, position);
			String componentName = StringUtils.asComponentName(camelComponentUri);
			if (componentName != null) {
				return camelCatalog.thenApply(new HoverFuture(componentName));
			}
		}
	} catch (Exception e) {
		LOGGER.error("Error searching hover", e);
	}
	return CompletableFuture.completedFuture(null);
}
 
开发者ID:lhein,项目名称:camel-language-server,代码行数:16,代码来源:HoverProcessor.java


示例11: apply

import org.eclipse.lsp4j.Hover; //导入依赖的package包/类
@Override
public Hover apply(CamelCatalog camelCatalog) {
	Hover hover = new Hover();
	ComponentModel componentModel = ModelHelper.generateComponentModel(camelCatalog.componentJSonSchema(componentName), true);
	hover.setContents(Collections.singletonList((Either.forLeft(componentModel.getDescription()))));
	return hover;
}
 
开发者ID:lhein,项目名称:camel-language-server,代码行数:8,代码来源:HoverFuture.java


示例12: testDontProvideDocumentationOnHoverForBadPlaces

import org.eclipse.lsp4j.Hover; //导入依赖的package包/类
@Test
public void testDontProvideDocumentationOnHoverForBadPlaces() throws Exception {
	CamelLanguageServer camelLanguageServer = initializeLanguageServer("<from uri=\"ahc:httpUri\" xmlns=\"http://camel.apache.org/schema/spring\"></from>\n");
	
	TextDocumentPositionParams position = new TextDocumentPositionParams(new TextDocumentIdentifier(DUMMY_URI), new Position(0, 4));
	CompletableFuture<Hover> hover = camelLanguageServer.getTextDocumentService().hover(position);
	
	assertThat(hover.get()).isNull();
}
 
开发者ID:lhein,项目名称:camel-language-server,代码行数:10,代码来源:CamelLanguageServerHoverTest.java


示例13: hoverText

import org.eclipse.lsp4j.Hover; //导入依赖的package包/类
public static Hover hoverText(Element el, Javadocs docs) {
    Optional<String> doc = docs.doc(el).map(Hovers::commentText).map(Javadocs::htmlToMarkdown);
    String sig = signature(el);
    String result =
            doc.map(text -> String.format("```java\n%s\n```\n%s", sig, text)).orElse(sig);

    return new Hover(Collections.singletonList(Either.forLeft(result)), null);
}
 
开发者ID:georgewfraser,项目名称:vscode-javac,代码行数:9,代码来源:Hovers.java


示例14: hover

import org.eclipse.lsp4j.Hover; //导入依赖的package包/类
public Hover hover(TextDocumentPositionParams position, IProgressMonitor monitor) {
	ITypeRoot unit = JDTUtils.resolveTypeRoot(position.getTextDocument().getUri());

	List<Either<String, MarkedString>> content = null;
	if (unit != null && !monitor.isCanceled()) {
		content = computeHover(unit, position.getPosition().getLine(), position.getPosition().getCharacter(), monitor);
	}
	Hover $ = new Hover();
	$.setContents(content);
	return $;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:12,代码来源:HoverHandler.java


示例15: testHoverInheritedJavadoc

import org.eclipse.lsp4j.Hover; //导入依赖的package包/类
@Test
public void testHoverInheritedJavadoc() throws Exception {
	// given
	// Hovers on the overriding foo()
	String payload = createHoverRequest("src/java/Bar.java", 22, 19);
	TextDocumentPositionParams position = getParams(payload);

	// when
	Hover hover = handler.hover(position, monitor);

	// then
	assertNotNull(hover);
	String result = hover.getContents().get(1).getLeft();//
	assertEquals("Unexpected hover ", "This method comes from Foo", result);
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:16,代码来源:HoverHandlerTest.java


示例16: testHoverOverNullElement

import org.eclipse.lsp4j.Hover; //导入依赖的package包/类
@Test
public void testHoverOverNullElement() throws Exception {
	IPackageFragment pack1 = sourceFolder.createPackageFragment("test1", false, null);
	StringBuilder buf = new StringBuilder();
	buf.append("package test1;\n");
	buf.append("import javax.xml.bind.Binder;\n");
	buf.append("public class E {}\n");
	ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null);
	Hover hover = getHover(cu, 1, 8);
	assertNotNull(hover);
	assertEquals(1, hover.getContents().size());
	assertEquals("Unexpected hover ", "javax", hover.getContents().get(0).getRight().getValue());
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:14,代码来源:HoverHandlerTest.java


示例17: testHoverUnresolvedType

import org.eclipse.lsp4j.Hover; //导入依赖的package包/类
@Test
public void testHoverUnresolvedType() throws Exception {
	importProjects("eclipse/unresolvedtype");
	project = WorkspaceHelper.getProject("unresolvedtype");
	handler = new HoverHandler(preferenceManager);
	//given
	//Hovers on the IFoo
	String payload = createHoverRequest("src/pckg/Foo.java", 2, 31);
	TextDocumentPositionParams position = getParams(payload);

	// when
	Hover hover = handler.hover(position, monitor);
	assertNotNull(hover);
	assertTrue("Unexpected hover ", hover.getContents().isEmpty());
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:16,代码来源:HoverHandlerTest.java


示例18: getTitleHover

import org.eclipse.lsp4j.Hover; //导入依赖的package包/类
/**
 * @param cu
 * @return
 */
private String getTitleHover(ICompilationUnit cu, int line, int character) {
	// when
	Hover hover = getHover(cu, line, character);

	// then
	assertNotNull(hover);
	MarkedString result = hover.getContents().get(0).getRight();
	return result.getValue();
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:14,代码来源:HoverHandlerTest.java


示例19: _toExpectation

import org.eclipse.lsp4j.Hover; //导入依赖的package包/类
protected String _toExpectation(final Hover it) {
  StringConcatenation _builder = new StringConcatenation();
  String _expectation = this.toExpectation(it.getRange());
  _builder.append(_expectation);
  _builder.newLineIfNotEmpty();
  String _expectation_1 = this.toExpectation(it.getContents());
  _builder.append(_expectation_1);
  _builder.newLineIfNotEmpty();
  return _builder.toString();
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:11,代码来源:AbstractLanguageServerTest.java


示例20: hover

import org.eclipse.lsp4j.Hover; //导入依赖的package包/类
protected Hover hover(final HoverContext context) {
  if ((context == null)) {
    return IHoverService.EMPTY_HOVER;
  }
  final List<Either<String, MarkedString>> contents = this.getContents(context);
  if ((contents == null)) {
    return IHoverService.EMPTY_HOVER;
  }
  final Range range = this.getRange(context);
  if ((range == null)) {
    return IHoverService.EMPTY_HOVER;
  }
  return new Hover(contents, range);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:15,代码来源:HoverService.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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