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

Java TextDocumentPositionParams类代码示例

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

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



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

示例1: testProvideDocumentationOnHover

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

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


示例3: completion

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


示例4: completion

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


示例5: definition

import org.eclipse.lsp4j.TextDocumentPositionParams; //导入依赖的package包/类
@Override
public CompletableFuture<List<? extends Location>> definition(TextDocumentPositionParams position) {
	logInfo(">> document/definition");
	NavigateToDefinitionHandler handler = new NavigateToDefinitionHandler(this.preferenceManager);
	return computeAsync((cc) -> {
		IProgressMonitor monitor = toMonitor(cc);
		try {
			Job.getJobManager().join(DocumentLifeCycleHandler.DOCUMENT_LIFE_CYCLE_JOBS, monitor);
		} catch (OperationCanceledException ignorable) {
			// No need to pollute logs when query is cancelled
		} catch (InterruptedException e) {
			JavaLanguageServerPlugin.logException(e.getMessage(), e);
		}
		return handler.definition(position, toMonitor(cc));
	});
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:17,代码来源:JDTLanguageServer.java


示例6: testHover

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


示例7: testHoverStandalone

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


示例8: testHoverPackage

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


示例9: testEmptyHover

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


示例10: testHoverVariable

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


示例11: testHoverOnPackageWithJavadoc

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


示例12: testHoverThrowable

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


示例13: completion

import org.eclipse.lsp4j.TextDocumentPositionParams; //导入依赖的package包/类
protected Either<List<CompletionItem>, CompletionList> completion(final CancelIndicator origialCancelIndicator, final TextDocumentPositionParams params) {
  final LanguageServerImpl.BufferedCancelIndicator cancelIndicator = new LanguageServerImpl.BufferedCancelIndicator(origialCancelIndicator);
  final URI uri = this._uriExtensions.toUri(params.getTextDocument().getUri());
  final IResourceServiceProvider resourceServiceProvider = this.languagesRegistry.getResourceServiceProvider(uri);
  ContentAssistService _get = null;
  if (resourceServiceProvider!=null) {
    _get=resourceServiceProvider.<ContentAssistService>get(ContentAssistService.class);
  }
  final ContentAssistService contentAssistService = _get;
  if ((contentAssistService == null)) {
    CompletionList _completionList = new CompletionList();
    return Either.<List<CompletionItem>, CompletionList>forRight(_completionList);
  }
  final Function2<Document, XtextResource, CompletionList> _function = (Document document, XtextResource resource) -> {
    return contentAssistService.createCompletionList(document, resource, params, cancelIndicator);
  };
  final CompletionList completionList = this.workspaceManager.<CompletionList>doRead(uri, _function);
  return Either.<List<CompletionItem>, CompletionList>forRight(completionList);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:20,代码来源:LanguageServerImpl.java


示例14: definition

import org.eclipse.lsp4j.TextDocumentPositionParams; //导入依赖的package包/类
protected List<? extends Location> definition(final CancelIndicator cancelIndicator, final TextDocumentPositionParams params) {
  final URI uri = this._uriExtensions.toUri(params.getTextDocument().getUri());
  final IResourceServiceProvider resourceServiceProvider = this.languagesRegistry.getResourceServiceProvider(uri);
  DocumentSymbolService _get = null;
  if (resourceServiceProvider!=null) {
    _get=resourceServiceProvider.<DocumentSymbolService>get(DocumentSymbolService.class);
  }
  final DocumentSymbolService documentSymbolService = _get;
  if ((documentSymbolService == null)) {
    return CollectionLiterals.<Location>emptyList();
  }
  final Function2<Document, XtextResource, List<? extends Location>> _function = (Document document, XtextResource resource) -> {
    return documentSymbolService.getDefinitions(document, resource, params, this.resourceAccess, cancelIndicator);
  };
  return this.workspaceManager.<List<? extends Location>>doRead(uri, _function);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:17,代码来源:LanguageServerImpl.java


示例15: hover

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


示例16: signatureHelp

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


示例17: documentHighlight

import org.eclipse.lsp4j.TextDocumentPositionParams; //导入依赖的package包/类
@Override
public CompletableFuture<List<? extends DocumentHighlight>> documentHighlight(final TextDocumentPositionParams params) {
  final Function1<CancelIndicator, List<? extends DocumentHighlight>> _function = (CancelIndicator cancelIndicator) -> {
    final URI uri = this._uriExtensions.toUri(params.getTextDocument().getUri());
    final IResourceServiceProvider serviceProvider = this.languagesRegistry.getResourceServiceProvider(uri);
    IDocumentHighlightService _get = null;
    if (serviceProvider!=null) {
      _get=serviceProvider.<IDocumentHighlightService>get(IDocumentHighlightService.class);
    }
    final IDocumentHighlightService service = _get;
    if ((service == null)) {
      return CollectionLiterals.<DocumentHighlight>emptyList();
    }
    final Function2<Document, XtextResource, List<? extends DocumentHighlight>> _function_1 = (Document doc, XtextResource resource) -> {
      return service.getDocumentHighlights(doc, resource, params, cancelIndicator);
    };
    return this.workspaceManager.<List<? extends DocumentHighlight>>doRead(uri, _function_1);
  };
  return this.requestManager.<List<? extends DocumentHighlight>>runRead(_function);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:21,代码来源:LanguageServerImpl.java


示例18: testRequest

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


示例19: actionPerformed

import org.eclipse.lsp4j.TextDocumentPositionParams; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
  EditorPartPresenter activeEditor = editorAgent.getActiveEditor();

  TextEditor textEditor = ((TextEditor) activeEditor);
  TextDocumentPositionParams paramsDTO =
      dtoBuildHelper.createTDPP(textEditor.getDocument(), textEditor.getCursorPosition());

  final Promise<List<Location>> promise = client.definition(paramsDTO);
  promise
      .then(
          arg -> {
            if (arg.size() == 1) {
              presenter.onLocationSelected(arg.get(0));
            } else {
              presenter.openLocation(promise);
            }
          })
      .catchError(
          arg -> {
            presenter.showError(arg);
          });
}
 
开发者ID:eclipse,项目名称:che,代码行数:24,代码来源:FindDefinitionAction.java


示例20: testDontProvideDocumentationOnHoverForBadPlaces

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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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