forked from redhat-developer/quarkus-ls
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes redhat-developer#595 Signed-off-by: azerr <azerr@redhat.com>
- Loading branch information
1 parent
b16a72c
commit 58bba8a
Showing
20 changed files
with
994 additions
and
42 deletions.
There are no files selected for viewing
82 changes: 82 additions & 0 deletions
82
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,82 @@ | ||
/******************************************************************************* | ||
* 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.messages.Either; | ||
import org.eclipse.lsp4j.jsonrpc.validation.NonNull; | ||
import org.eclipse.lsp4j.util.Preconditions; | ||
|
||
/** | ||
* 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; | ||
|
||
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; | ||
} | ||
} |
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]; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
qute.ls/com.redhat.qute.ls/src/main/java/com/redhat/lsp4j/proposed/InlayHintLabelPart.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,18 @@ | ||
/******************************************************************************* | ||
* 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 class InlayHintLabelPart { | ||
|
||
|
||
|
||
} |
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"); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
....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,26 @@ | ||
/******************************************************************************* | ||
* 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 { | ||
|
||
@JsonRequest("textDocument/inlayHint") | ||
default CompletableFuture<List<InlayHint>> inlayHint(InlayHintParams params) { | ||
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
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
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.