org.eclipse.lsp4j.HoverCapabilities Java Examples

The following examples show how to use org.eclipse.lsp4j.HoverCapabilities. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XMLCapabilitiesTest.java    From lemminx with Eclipse Public License 2.0 6 votes vote down vote up
private void setAllCapabilities(boolean areAllDynamic) {
	textDocument.setRangeFormatting(new RangeFormattingCapabilities(areAllDynamic));
	textDocument.setFormatting(new FormattingCapabilities(areAllDynamic));
	CompletionCapabilities completion = new CompletionCapabilities();
	completion.setDynamicRegistration(areAllDynamic);
	textDocument.setCompletion(completion);
	textDocument.setDocumentSymbol(new DocumentSymbolCapabilities(areAllDynamic));
	textDocument.setHover(new HoverCapabilities(areAllDynamic));
	textDocument.setDocumentHighlight(new DocumentHighlightCapabilities(areAllDynamic));
	textDocument.setRename(new RenameCapabilities(areAllDynamic));
	FoldingRangeCapabilities folding = new FoldingRangeCapabilities();
	folding.setDynamicRegistration(areAllDynamic);
	textDocument.setFoldingRange(folding);
	textDocument.setDocumentLink(new DocumentLinkCapabilities(areAllDynamic));
	textDocument.setCodeAction(new CodeActionCapabilities(areAllDynamic));
	workspace.setDidChangeWatchedFiles(new DidChangeWatchedFilesCapabilities(areAllDynamic));
}
 
Example #2
Source File: LanguageServerWrapper.java    From lsp4intellij with Apache License 2.0 5 votes vote down vote up
private InitializeParams getInitParams() {
    InitializeParams initParams = new InitializeParams();
    initParams.setRootUri(FileUtils.pathToUri(projectRootPath));
    //TODO update capabilities when implemented
    WorkspaceClientCapabilities workspaceClientCapabilities = new WorkspaceClientCapabilities();
    workspaceClientCapabilities.setApplyEdit(true);
    workspaceClientCapabilities.setDidChangeWatchedFiles(new DidChangeWatchedFilesCapabilities());
    workspaceClientCapabilities.setExecuteCommand(new ExecuteCommandCapabilities());
    workspaceClientCapabilities.setWorkspaceEdit(new WorkspaceEditCapabilities());
    workspaceClientCapabilities.setSymbol(new SymbolCapabilities());
    workspaceClientCapabilities.setWorkspaceFolders(false);
    workspaceClientCapabilities.setConfiguration(false);

    TextDocumentClientCapabilities textDocumentClientCapabilities = new TextDocumentClientCapabilities();
    textDocumentClientCapabilities.setCodeAction(new CodeActionCapabilities());
    textDocumentClientCapabilities.setCompletion(new CompletionCapabilities(new CompletionItemCapabilities(true)));
    textDocumentClientCapabilities.setDefinition(new DefinitionCapabilities());
    textDocumentClientCapabilities.setDocumentHighlight(new DocumentHighlightCapabilities());
    textDocumentClientCapabilities.setFormatting(new FormattingCapabilities());
    textDocumentClientCapabilities.setHover(new HoverCapabilities());
    textDocumentClientCapabilities.setOnTypeFormatting(new OnTypeFormattingCapabilities());
    textDocumentClientCapabilities.setRangeFormatting(new RangeFormattingCapabilities());
    textDocumentClientCapabilities.setReferences(new ReferencesCapabilities());
    textDocumentClientCapabilities.setRename(new RenameCapabilities());
    textDocumentClientCapabilities.setSemanticHighlightingCapabilities(new SemanticHighlightingCapabilities(false));
    textDocumentClientCapabilities.setSignatureHelp(new SignatureHelpCapabilities());
    textDocumentClientCapabilities.setSynchronization(new SynchronizationCapabilities(true, true, true));
    initParams.setCapabilities(
            new ClientCapabilities(workspaceClientCapabilities, textDocumentClientCapabilities, null));
    initParams.setInitializationOptions(
            serverDefinition.getInitializationOptions(URI.create(initParams.getRootUri())));

    return initParams;
}
 
Example #3
Source File: XMLAssert.java    From lemminx with Eclipse Public License 2.0 5 votes vote down vote up
public static void assertHover(XMLLanguageService xmlLanguageService, String value, String catalogPath,
		String fileURI, String expectedHoverLabel, Range expectedHoverRange, ContentModelSettings settings)
		throws BadLocationException {
	SharedSettings sharedSettings = new SharedSettings();
	HoverCapabilities capabilities = new HoverCapabilities(Arrays.asList(MarkupKind.MARKDOWN), false);
	sharedSettings.getHoverSettings().setCapabilities(capabilities);
	assertHover(xmlLanguageService, value, catalogPath, fileURI, expectedHoverLabel, expectedHoverRange, settings,
			sharedSettings);
}
 
Example #4
Source File: XMLSchemaHoverDocumentationTypeTest.java    From lemminx with Eclipse Public License 2.0 5 votes vote down vote up
private SharedSettings createSharedSettings(SchemaDocumentationType docSource, boolean markdownSupported) {
	SharedSettings settings = new SharedSettings();
	if (markdownSupported) {
		HoverCapabilities capabilities = new HoverCapabilities(Arrays.asList(MarkupKind.MARKDOWN), false);
		settings.getHoverSettings().setCapabilities(capabilities);
	}
	settings.getPreferences()
			.setShowSchemaDocumentationType(docSource);
	return settings;
}
 
Example #5
Source File: XMLHoverSettings.java    From lemminx with Eclipse Public License 2.0 4 votes vote down vote up
public void setCapabilities(HoverCapabilities capabilities) {
	this.capabilities = capabilities;
}
 
Example #6
Source File: XMLHoverSettings.java    From lemminx with Eclipse Public License 2.0 4 votes vote down vote up
public HoverCapabilities getCapabilities() {
	return capabilities;
}
 
Example #7
Source File: XMLCapabilitiesTest.java    From lemminx with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void testBothCapabilityTypes() {
	// Dynamic capabilities
	textDocument.setRangeFormatting(new RangeFormattingCapabilities(true));
	textDocument.setFormatting(new FormattingCapabilities(true));
	CompletionCapabilities completion = new CompletionCapabilities();
	completion.setDynamicRegistration(true);
	textDocument.setCompletion(completion);
	textDocument.setDocumentSymbol(new DocumentSymbolCapabilities(true));
	workspace.setDidChangeWatchedFiles(new DidChangeWatchedFilesCapabilities(true));

	// Non dynamic capabilities
	textDocument.setHover(new HoverCapabilities(false));
	textDocument.setDocumentHighlight(new DocumentHighlightCapabilities(false));
	textDocument.setRename(new RenameCapabilities(false));
	FoldingRangeCapabilities folding = new FoldingRangeCapabilities();
	folding.setDynamicRegistration(false);
	textDocument.setFoldingRange(folding);
	textDocument.setDocumentLink(new DocumentLinkCapabilities(false));
	textDocument.setCodeAction(new CodeActionCapabilities(false));

	setAndInitializeCapabilities();

	assertEquals(5, capabilityIDs.size());
	assertEquals(true, capabilityIDs.contains(FORMATTING_ID));
	assertEquals(true, capabilityIDs.contains(FORMATTING_RANGE_ID));
	assertEquals(true, capabilityIDs.contains(COMPLETION_ID));
	assertEquals(true, capabilityIDs.contains(DOCUMENT_SYMBOL_ID));

	ServerCapabilities serverCapabilities = ServerCapabilitiesInitializer
			.getNonDynamicServerCapabilities(manager.getClientCapabilities(), false);
	assertEquals(false, serverCapabilities.getDocumentRangeFormattingProvider());
	assertEquals(false, serverCapabilities.getDocumentFormattingProvider());
	assertEquals(false, serverCapabilities.getDocumentSymbolProvider());
	assertEquals(true, serverCapabilities.getHoverProvider());
	assertEquals(true, serverCapabilities.getDocumentHighlightProvider());
	assertEquals(true, serverCapabilities.getRenameProvider().getLeft());
	assertEquals(true, serverCapabilities.getFoldingRangeProvider().getLeft());
	assertEquals(true, serverCapabilities.getCodeActionProvider().getLeft());
	assertEquals(null, serverCapabilities.getCompletionProvider());
	assertEquals(DEFAULT_LINK_OPTIONS, serverCapabilities.getDocumentLinkProvider());
}
 
Example #8
Source File: TextDocumentClientCapabilities.java    From lsp4j with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Capabilities specific to the `textDocument/hover`
 */
@Pure
public HoverCapabilities getHover() {
  return this.hover;
}
 
Example #9
Source File: TextDocumentClientCapabilities.java    From lsp4j with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Capabilities specific to the `textDocument/hover`
 */
public void setHover(final HoverCapabilities hover) {
  this.hover = hover;
}