Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions org.eclipse.lsp4e.jdt/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: JDT Integration for LSP4E
Bundle-SymbolicName: org.eclipse.lsp4e.jdt;singleton:=true
Bundle-Version: 0.14.2.qualifier
Export-Package: org.eclipse.lsp4e.jdt
Bundle-Version: 0.14.3.qualifier
Export-Package: org.eclipse.lsp4e.jdt,
org.eclipse.lsp4e.jdt.internal;x-friends:=org.eclipse.lsp4e.test
Automatic-Module-Name: org.eclipse.lsp4e.jdt
Bundle-Activator: org.eclipse.lsp4e.jdt.LanguageServerJdtPlugin
Bundle-ActivationPolicy: lazy
Expand Down
1 change: 1 addition & 0 deletions org.eclipse.lsp4e.jdt/plugin.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@
###############################################################################

lsCompletionComputer_name=Language Server Proposals
lsTextBlockCompletionComputer_name=Language Server Proposals in Java Text Blocks
languageservers.jdt.preferences.page=Java
13 changes: 13 additions & 0 deletions org.eclipse.lsp4e.jdt/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension-point id="org.eclipse.lsp4e.jdt.LSJavaTextBlockLanguageDetector" name="LSJavaTextBlockLanguageDetector" schema="schema/org.eclipse.lsp4e.jdt.LSJavaTextBlockLanguageDetector.exsd"/>

<extension
id="ls-based-java-completion-computer"
Expand All @@ -14,6 +15,18 @@
requiresUIThread="false">
</javaCompletionProposalComputer>
</extension>
<extension
id="ls-based-java-text-block-completion-computer"
name="%lsTextBlockCompletionComputer_name"
point="org.eclipse.jdt.ui.javaCompletionProposalComputer">
<javaCompletionProposalComputer
activate="true"
categoryId="org.eclipse.lsp4e.jdt.ls-based-java-text-block-completion-computer"
class="org.eclipse.lsp4e.jdt.internal.JavaTextBlockProposalComputer"
needsSortingAfterFiltering="false"
requiresUIThread="false">
</javaCompletionProposalComputer>
</extension>

<extension
id="ls-based-java-hover-provider"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="org.eclipse.lsp4e.jdt" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appinfo>
<meta.schema plugin="org.eclipse.lsp4e.jdt" id="org.eclipse.lsp4e.jdt.LSJavaTextBlockLanguageDetector" name="LSJavaTextBlockLanguageDetector"/>
</appinfo>
<documentation>
This extension point allows customizing which language servers should be used for language server functionality within Java text blocks.
</documentation>
</annotation>

<element name="extension">
<annotation>
<appinfo>
<meta.element />
</appinfo>
</annotation>
<complexType>
<choice minOccurs="1" maxOccurs="unbounded">
<element ref="detector"/>
</choice>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>

</documentation>
</annotation>
</attribute>
<attribute name="id" type="string">
<annotation>
<documentation>

</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>

</documentation>
<appinfo>
<meta.attribute translatable="true"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>

<element name="detector">
<complexType>
<attribute name="class" type="string" use="required">
<annotation>
<documentation>
The class deciding on the language server that should be used for language server functionality in Java text blocks.
</documentation>
<appinfo>
<meta.attribute kind="java" basedOn=":org.eclipse.lsp4e.jdt.LSJavaTextBlockLanguageDetector"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>

<annotation>
<appinfo>
<meta.section type="since"/>
</appinfo>
<documentation>
0.14.3
</documentation>
</annotation>

<annotation>
<appinfo>
<meta.section type="examples"/>
</appinfo>
<documentation>
The following extension point can be used with a language server that expects SQL files:

&lt;pre&gt;
&lt;extension
point=&quot;org.eclipse.lsp4e.jdt.LSJavaTextBlockLanguageDetector&quot;
class=&quot;com.example.AlwaysSQLLanguageDetector&quot;&gt;
&lt;/extension&gt;
&lt;/pre&gt;

The &lt;code&gt;AlwaysSQLLanguageDetector&lt;/code&gt; class could be written as follows:

&lt;pre&gt;
public class AlwaysSQLLanguageDetector implements LSJavaTextBlockLanguageDetector {
@Override
public URI createURIForTextBlock(ICompilationUnit compilationUnit, ITextViewer textViewer, IRegion textBlockRegion) {
return URI.create(&quot;javatextblock:///test.sql&quot;);
}
}
&lt;/pre&gt;

This will make sure that language servers expecting that URI are taken into account for that text block.
</documentation>
</annotation>

<annotation>
<appinfo>
<meta.section type="apiinfo"/>
</appinfo>
<documentation>
[Enter API information here.]
</documentation>
</annotation>

<annotation>
<appinfo>
<meta.section type="implementation"/>
</appinfo>
<documentation>
[Enter information about supplied implementation of this extension point.]
</documentation>
</annotation>


</schema>
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.lsp4e.LanguageServerPlugin;
import org.eclipse.lsp4e.jdt.internal.LSJavaProposal;
import org.eclipse.lsp4e.operations.completion.LSCompletionProposal;
import org.eclipse.lsp4e.operations.completion.LSContentAssistProcessor;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*******************************************************************************
* Copyright (c) 2026 Daniel Schmid and others.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* - Daniel Schmid - Initial API and implementation
*******************************************************************************/
package org.eclipse.lsp4e.jdt;

import java.net.URI;

import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextViewer;

/**
* Allows plugins providing custom logic for which language servers should be
* used within Java text blocks.
*/
public interface LSJavaTextBlockLanguageDetector {
/**
* Creates a {@link URI} indicating the language server that should be used for
* a Java text block.
*
* @param compilationUnit
* The compilation unit corresponding to the Java
* file.
* @param textViewer
* The text viewer the Java file is opened in.
* @param textBlockRegion
* The source code region of the text block within
* the Java file.
* @return A {@link URI} where documents corresponding to that {@link URI} are
* recognized by that language server. This {@link URI} does not need to
* be resolvable.
*/
@Nullable
URI createURIForTextBlock(ICompilationUnit compilationUnit, ITextViewer textViewer, IRegion textBlockRegion);
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.eclipse.jface.text.quickassist.IQuickAssistInvocationContext;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.TextInvocationContext;
import org.eclipse.lsp4e.jdt.internal.LSJavaProposal;
import org.eclipse.lsp4e.operations.codeactions.LSPCodeActionQuickAssistProcessor;
import org.eclipse.lsp4e.operations.completion.LSCompletionProposal;

Expand Down
Loading
Loading