Skip to content

Commit

Permalink
Don't annotate SymbolInformation as Deprecated (#698)
Browse files Browse the repository at this point in the history
While SymbolInformation class is deprecated in the
LSP specification. It is not annotated with Deprecated
annotation because the TextDocumentService.documentSymbol
method requires it and causes deprecated warning in
the code of all users of that API.

Instead we mark all the methods/constructors as
@deprecated so that consumers that are actually using
instances of SymbolInformation get deprecated warnings,
while avoiding deprecated warnings for just referring
to the type.

Fixes #697
  • Loading branch information
jonahgraham committed Feb 17, 2023
1 parent fcd6b76 commit 044e46c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
15 changes: 13 additions & 2 deletions org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/Protocol.xtend
Original file line number Diff line number Diff line change
Expand Up @@ -6679,29 +6679,35 @@ class DocumentSymbol {
/**
* Represents information about programming constructs like variables, classes, interfaces etc.
*
* @deprecated Use {@link DocumentSymbol} or {@link WorkspaceSymbol} instead if supported.
* Deprecated Use {@link DocumentSymbol} or {@link WorkspaceSymbol} instead if supported.
*
* This class is deprecated in the LSP specification. It is not annotated with Deprecated
* annotation because the {@link org.eclipse.lsp4j.services.TextDocumentService.documentSymbol(DocumentSymbolParams)}
* method requires it and causes deprecated warning in the code of all users of that API.
*/
@Deprecated
@JsonRpcData
@JsonAdapter(SymbolInformationTypeAdapter.Factory)
class SymbolInformation {
/**
* The name of this symbol.
*/
@NonNull
@Deprecated
String name

/**
* The kind of this symbol.
*/
@NonNull
@Deprecated
SymbolKind kind

/**
* Tags for this symbol.
* <p>
* Since 3.16.0
*/
@Deprecated
List<SymbolTag> tags

/**
Expand All @@ -6726,6 +6732,7 @@ class SymbolInformation {
* the symbols.
*/
@NonNull
@Deprecated
Location location

/**
Expand All @@ -6734,17 +6741,21 @@ class SymbolInformation {
* if necessary). It can't be used to re-infer a hierarchy for the document
* symbols.
*/
@Deprecated
String containerName

@Deprecated
new() {
}

@Deprecated
new(@NonNull String name, @NonNull SymbolKind kind, @NonNull Location location) {
this.name = Preconditions.checkNotNull(name, 'name')
this.kind = Preconditions.checkNotNull(kind, 'kind')
this.location = Preconditions.checkNotNull(location, 'location')
}

@Deprecated
new(@NonNull String name, @NonNull SymbolKind kind, @NonNull Location location, String containerName) {
this(name, kind, location)
this.containerName = containerName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import com.google.gson.TypeAdapterFactory;
import com.google.gson.reflect.TypeToken;

@SuppressWarnings("deprecation")
public class DocumentSymbolResponseAdapter implements TypeAdapterFactory {

private static final TypeToken<Either<SymbolInformation, DocumentSymbol>> ELEMENT_TYPE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import com.google.gson.TypeAdapterFactory;
import com.google.gson.reflect.TypeToken;

@SuppressWarnings("deprecation")
public class WorkspaceSymbolResponseAdapter implements TypeAdapterFactory {

private static final TypeToken<Either<List<? extends SymbolInformation>, List<? extends WorkspaceSymbol>>> EITHER_TYPE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@
import org.eclipse.lsp4j.jsonrpc.services.JsonRequest;
import org.eclipse.lsp4j.jsonrpc.services.JsonSegment;

@SuppressWarnings("deprecation")
@JsonSegment("textDocument")
public interface TextDocumentService {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.eclipse.lsp4j.jsonrpc.services.JsonRequest;
import org.eclipse.lsp4j.jsonrpc.services.JsonSegment;

@SuppressWarnings("deprecation")
@JsonSegment("workspace")
public interface WorkspaceService {
/**
Expand Down

0 comments on commit 044e46c

Please sign in to comment.