Skip to content

Commit

Permalink
feat: Provide InlayHint for property expression in
Browse files Browse the repository at this point in the history
microprofile-config.properties (#971)

Fixes #971

Signed-off-by: azerr <[email protected]>
  • Loading branch information
angelozerr committed Jun 23, 2023
1 parent 3e86087 commit 2d5f552
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
import com.intellij.codeInsight.hints.presentation.MouseButton;
import com.intellij.codeInsight.hints.presentation.PresentationFactory;
import com.intellij.codeInsight.hints.presentation.SequencePresentation;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.ScrollingModel;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Pair;
Expand Down Expand Up @@ -69,7 +72,7 @@ public boolean collect(@NotNull PsiElement psiElement, @NotNull Editor editor, @
try {
URI docURI = LSPIJUtils.toUri(editor.getDocument());
if (docURI != null) {
Range viewPortRange = new Range(new Position(0, 0), new Position(0,0));
Range viewPortRange = getViewPortRange(editor);
InlayHintParams param = new InlayHintParams(new TextDocumentIdentifier(docURI.toString()), viewPortRange);
BlockingDeque<Pair<InlayHint, LanguageServer>> pairs = new LinkedBlockingDeque<>();
List<Pair<Integer,Pair<InlayHint, LanguageServer>>> inlayhints = new ArrayList<>();
Expand Down Expand Up @@ -106,6 +109,14 @@ public boolean collect(@NotNull PsiElement psiElement, @NotNull Editor editor, @
};
}

@NotNull
private static Range getViewPortRange(Editor editor) {
Position start = new Position(0, 0);
Document document = editor.getDocument();
Position end = LSPIJUtils.toPosition(document.getTextLength(), document);
return new Range(start, end);
}

private InlayPresentation toPresentation(Editor editor, int offset,
List<Pair<Integer, Pair<InlayHint, LanguageServer>>> elements,
PresentationFactory factory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,23 @@ public QuarkusServer() {

@Override
public Object getInitializationOptions(URI rootUri) {

Map<String, Object> root = new HashMap<>();
Map<String, Object> settings = new HashMap<>();
Map<String, Object> quarkus = new HashMap<>();
Map<String, Object> tools = new HashMap<>();
Map<String, Object> trace = new HashMap<>();
trace.put("server", "verbose");
tools.put("trace", trace);

Map<String, Object> codeLens = new HashMap<>();
codeLens.put("urlCodeLensEnabled", "true");
tools.put("codeLens", codeLens);

Map<String, Object> inlayHint = new HashMap<>();
inlayHint.put("enabled", "true");
tools.put("inlayHint", inlayHint);

quarkus.put("tools", tools);
settings.put("microprofile", quarkus);
root.put("settings", settings);
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/META-INF/lsp4ij-quarkus.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
implementationClass="com.redhat.devtools.intellij.lsp4ij.operations.diagnostics.LSPDiagnosticAnnotator"/>
<externalAnnotator language="JAVA"
implementationClass="com.redhat.devtools.intellij.lsp4ij.operations.documentLink.LSPDocumentLinkAnnotator"/>
<codeInsight.inlayProvider language="Properties"
implementationClass="com.redhat.devtools.intellij.lsp4ij.operations.inlayhint.LSPInlayHintInlayProvider"/>
</extensions>

</idea-plugin>

0 comments on commit 2d5f552

Please sign in to comment.