-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #595 Signed-off-by: azerr <azerr@redhat.com>
- Loading branch information
1 parent
3a9f9c2
commit cec54cf
Showing
26 changed files
with
1,267 additions
and
128 deletions.
There are no files selected for viewing
110 changes: 110 additions & 0 deletions
110
qute.ls/com.redhat.qute.ls/src/main/java/com/redhat/lsp4j/proposed/InlayHint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 Red Hat Inc. and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat Inc. - initial API and implementation | ||
*******************************************************************************/ | ||
package com.redhat.lsp4j.proposed; | ||
|
||
import java.util.List; | ||
|
||
import org.eclipse.lsp4j.Position; | ||
import org.eclipse.lsp4j.jsonrpc.json.adapters.JsonElementTypeAdapter; | ||
import org.eclipse.lsp4j.jsonrpc.messages.Either; | ||
import org.eclipse.lsp4j.jsonrpc.validation.NonNull; | ||
import org.eclipse.lsp4j.util.Preconditions; | ||
import org.eclipse.xtext.xbase.lib.Pure; | ||
|
||
import com.google.gson.annotations.JsonAdapter; | ||
|
||
/** | ||
* Inlay hint information. | ||
* | ||
* @since 3.17.0 - proposed state | ||
*/ | ||
public class InlayHint { | ||
|
||
/** | ||
* The position of this hint. | ||
*/ | ||
@NonNull | ||
private Position position; | ||
|
||
/** | ||
* The label of this hint. A human readable string or an array of | ||
* InlayHintLabelPart label parts. | ||
* | ||
* *Note* that neither the string nor the label part can be empty. | ||
*/ | ||
@NonNull | ||
private Either<String, List<InlayHintLabelPart>> label; | ||
|
||
/** | ||
* The kind of this hint. Can be omitted in which case the client should fall | ||
* back to a reasonable default. | ||
*/ | ||
private InlayHintKind kind; | ||
|
||
/** | ||
* A data entry field that is preserved on a completion item between a | ||
* completion and a completion resolve request. | ||
*/ | ||
@JsonAdapter(JsonElementTypeAdapter.Factory.class) | ||
private Object data; | ||
|
||
public InlayHint(@NonNull Position position, Either<String, List<InlayHintLabelPart>> label) { | ||
this.position = Preconditions.<Position>checkNotNull(position, "position"); | ||
this.label = label; | ||
|
||
} | ||
|
||
public InlayHint() { | ||
|
||
} | ||
|
||
public Position getPosition() { | ||
return position; | ||
} | ||
|
||
public void setPosition(Position position) { | ||
this.position = position; | ||
} | ||
|
||
public Either<String, List<InlayHintLabelPart>> getLabel() { | ||
return label; | ||
} | ||
|
||
public void setLabel(Either<String, List<InlayHintLabelPart>> label) { | ||
this.label = label; | ||
} | ||
|
||
public InlayHintKind getKind() { | ||
return kind; | ||
} | ||
|
||
public void setKind(InlayHintKind kind) { | ||
this.kind = kind; | ||
} | ||
|
||
/** | ||
* A data entry field that is preserved on a completion item between a | ||
* completion and a completion resolve request. | ||
*/ | ||
@Pure | ||
public Object getData() { | ||
return this.data; | ||
} | ||
|
||
/** | ||
* A data entry field that is preserved on a completion item between a | ||
* completion and a completion resolve request. | ||
*/ | ||
public void setData(final Object data) { | ||
this.data = data; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
qute.ls/com.redhat.qute.ls/src/main/java/com/redhat/lsp4j/proposed/InlayHintKind.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 Red Hat Inc. and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat Inc. - initial API and implementation | ||
*******************************************************************************/ | ||
package com.redhat.lsp4j.proposed; | ||
|
||
public enum InlayHintKind { | ||
|
||
/** | ||
* An inlay hint that for a type annotation. | ||
*/ | ||
Type(1), | ||
|
||
/** | ||
* An inlay hint that is for a parameter. | ||
*/ | ||
Parameter(2); | ||
|
||
private final int value; | ||
|
||
InlayHintKind(int value) { | ||
this.value = value; | ||
} | ||
|
||
public int getValue() { | ||
return value; | ||
} | ||
|
||
public static InlayHintKind forValue(int value) { | ||
InlayHintKind[] allValues = InlayHintKind.values(); | ||
if (value < 1 || value > allValues.length) | ||
throw new IllegalArgumentException("Illegal enum value: " + value); | ||
return allValues[value - 1]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
qute.ls/com.redhat.qute.ls/src/main/java/com/redhat/lsp4j/proposed/InlayHintParams.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 Red Hat Inc. and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat Inc. - initial API and implementation | ||
*******************************************************************************/ | ||
package com.redhat.lsp4j.proposed; | ||
|
||
import org.eclipse.lsp4j.Range; | ||
import org.eclipse.lsp4j.TextDocumentIdentifier; | ||
import org.eclipse.lsp4j.WorkDoneProgressParams; | ||
import org.eclipse.lsp4j.jsonrpc.messages.Either; | ||
import org.eclipse.lsp4j.jsonrpc.validation.NonNull; | ||
import org.eclipse.lsp4j.util.Preconditions; | ||
import org.eclipse.xtext.xbase.lib.Pure; | ||
|
||
public class InlayHintParams implements WorkDoneProgressParams { | ||
|
||
/** | ||
* An optional token that a server can use to report work done progress. | ||
*/ | ||
private Either<String, Integer> workDoneToken; | ||
|
||
/** | ||
* The document to format. | ||
*/ | ||
@NonNull | ||
private TextDocumentIdentifier textDocument; | ||
|
||
/** | ||
* The visible document range for which inlay hints should be computed. | ||
*/ | ||
@NonNull | ||
private Range range; | ||
|
||
/** | ||
* An optional token that a server can use to report work done progress. | ||
*/ | ||
@Pure | ||
@Override | ||
public Either<String, Integer> getWorkDoneToken() { | ||
return this.workDoneToken; | ||
} | ||
|
||
/** | ||
* An optional token that a server can use to report work done progress. | ||
*/ | ||
public void setWorkDoneToken(final Either<String, Integer> workDoneToken) { | ||
this.workDoneToken = workDoneToken; | ||
} | ||
|
||
public void setWorkDoneToken(final String workDoneToken) { | ||
if (workDoneToken == null) { | ||
this.workDoneToken = null; | ||
return; | ||
} | ||
this.workDoneToken = Either.forLeft(workDoneToken); | ||
} | ||
|
||
/** | ||
* The document to format. | ||
*/ | ||
@Pure | ||
@NonNull | ||
public TextDocumentIdentifier getTextDocument() { | ||
return this.textDocument; | ||
} | ||
|
||
/** | ||
* The document to format. | ||
*/ | ||
public void setTextDocument(@NonNull final TextDocumentIdentifier textDocument) { | ||
this.textDocument = Preconditions.checkNotNull(textDocument, "textDocument"); | ||
} | ||
|
||
public void setWorkDoneToken(final Integer workDoneToken) { | ||
if (workDoneToken == null) { | ||
this.workDoneToken = null; | ||
return; | ||
} | ||
this.workDoneToken = Either.forRight(workDoneToken); | ||
} | ||
|
||
/** | ||
* Returns the visible document range for which inlay hints should be computed. | ||
* | ||
* @return the visible document range for which inlay hints should be computed. | ||
*/ | ||
@Pure | ||
@NonNull | ||
public Range getRange() { | ||
return range; | ||
} | ||
|
||
/** | ||
* Set the visible document range for which inlay hints should be computed. | ||
* | ||
* @param range | ||
*/ | ||
public void setRange(@NonNull Range range) { | ||
this.range = Preconditions.checkNotNull(range, "range"); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
....ls/com.redhat.qute.ls/src/main/java/com/redhat/lsp4j/proposed/QuteInlayHintProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 Red Hat Inc. and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat Inc. - initial API and implementation | ||
*******************************************************************************/ | ||
package com.redhat.lsp4j.proposed; | ||
|
||
import java.util.List; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
import org.eclipse.lsp4j.jsonrpc.services.JsonRequest; | ||
|
||
public interface QuteInlayHintProvider { | ||
|
||
/** | ||
* The inlay hints request is sent from the client to the server to compute | ||
* inlay hints for a given [text document, range] tuple that may be rendered in | ||
* the editor in place with other text. | ||
* <p> | ||
* Since 3.17.0 | ||
*/ | ||
@JsonRequest("textDocument/inlayHint") | ||
default CompletableFuture<List<InlayHint>> inlayHint(InlayHintParams params) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
/** | ||
* The request is sent from the client to the server to resolve additional | ||
* information for a given inlay hint. This is usually used to compute the | ||
* {@code tooltip}, {@code location} or {@code command} properties of an inlay | ||
* hint's label part to avoid its unnecessary computation during the | ||
* {@code textDocument/inlayHint} request. | ||
* <p> | ||
* Since 3.17.0 | ||
*/ | ||
@JsonRequest(value = "inlayHint/resolve", useSegment = false) | ||
default CompletableFuture<InlayHint> resolveInlayHint(InlayHint unresolved) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.