Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecated constructor SymbolInformation changed to WorkspaceSymbol #1227

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2020, 2024 Red Hat, Inc.
* Copyright (c) 2020, 2025 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution,
Expand Down Expand Up @@ -399,8 +399,8 @@ public CodeAction resolveCodeAction(CodeAction unresolved, IPsiUtils utils) {
* @param monitor the progress monitor
* @return the workspace symbols for the given java project
*/
public List<SymbolInformation> workspaceSymbols(String projectUri, IPsiUtils utils, ProgressIndicator monitor) {
List<SymbolInformation> symbols = new ArrayList<>();
public List<WorkspaceSymbol> workspaceSymbols(String projectUri, IPsiUtils utils, ProgressIndicator monitor) {
List<WorkspaceSymbol> symbols = new ArrayList<>();
Module module = getModule(projectUri, utils);
if (module != null) {
collectWorkspaceSymbols(module, utils, symbols, monitor);
Expand All @@ -418,7 +418,7 @@ public List<SymbolInformation> workspaceSymbols(String projectUri, IPsiUtils uti
return null;
}

private void collectWorkspaceSymbols(Module project, IPsiUtils utils, List<SymbolInformation> symbols,
private void collectWorkspaceSymbols(Module project, IPsiUtils utils, List<WorkspaceSymbol> symbols,
ProgressIndicator monitor) {
if (monitor.isCanceled()) {
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2024 Red Hat Inc. and others.
* Copyright (c) 2024, 2025 Red Hat Inc. and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand All @@ -17,7 +17,7 @@
import com.intellij.openapi.module.Module;
import com.intellij.openapi.progress.ProgressIndicator;
import io.openliberty.tools.intellij.lsp4mp4ij.psi.core.utils.IPsiUtils;
import org.eclipse.lsp4j.SymbolInformation;
import org.eclipse.lsp4j.WorkspaceSymbol;

import java.util.List;

Expand All @@ -37,7 +37,7 @@ public interface IJavaWorkspaceSymbolsParticipant {
* @param symbols the list of symbols to add to
* @param monitor the progress monitor
*/
void collectSymbols(Module project, IPsiUtils utils, List<SymbolInformation> symbols,
void collectSymbols(Module project, IPsiUtils utils, List<WorkspaceSymbol> symbols,
ProgressIndicator monitor);

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2024 Red Hat Inc. and others.
* Copyright (c) 2024, 2025 Red Hat Inc. and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand All @@ -24,8 +24,10 @@
import io.openliberty.tools.intellij.lsp4mp4ij.psi.core.utils.IPsiUtils;
import org.eclipse.lsp4j.Location;
import org.eclipse.lsp4j.Range;
import org.eclipse.lsp4j.SymbolInformation;
import org.eclipse.lsp4j.SymbolKind;
import org.eclipse.lsp4j.WorkspaceSymbol;
import org.eclipse.lsp4j.WorkspaceSymbolLocation;
import org.eclipse.lsp4j.jsonrpc.messages.Either;

import java.net.MalformedURLException;
import java.net.URL;
Expand All @@ -44,7 +46,7 @@ public class JaxRsWorkspaceSymbolParticipant implements IJavaWorkspaceSymbolsPar
private static final Logger LOGGER = Logger.getLogger(JaxRsWorkspaceSymbolParticipant.class.getName());

@Override
public void collectSymbols(Module project, IPsiUtils utils, List<SymbolInformation> symbols, ProgressIndicator monitor) {
public void collectSymbols(Module project, IPsiUtils utils, List<WorkspaceSymbol> symbols, ProgressIndicator monitor) {
if (monitor.isCanceled()) {
return;
}
Expand Down Expand Up @@ -106,10 +108,11 @@ private static Set<PsiClass> getAllJaxRsTypes(Module javaProject, IPsiUtils util
return jaxrsTypes;
}

private static SymbolInformation createSymbol(JaxRsMethodInfo methodInfo, IPsiUtils utils) throws MalformedURLException {
private static WorkspaceSymbol createSymbol(JaxRsMethodInfo methodInfo, IPsiUtils utils) throws MalformedURLException {
TextRange sourceRange = methodInfo.getJavaMethod().getNameIdentifier().getTextRange();
Range r = utils.toRange(methodInfo.getJavaMethod(), sourceRange.getStartOffset(), sourceRange.getLength());
Location location = new Location(methodInfo.getDocumentUri(), r);
Either<Location, WorkspaceSymbolLocation> eitherLocation = Either.forLeft(location);

StringBuilder nameBuilder = new StringBuilder("@");
URL url = new URL(methodInfo.getUrl());
Expand All @@ -118,10 +121,10 @@ private static SymbolInformation createSymbol(JaxRsMethodInfo methodInfo, IPsiUt
nameBuilder.append(": ");
nameBuilder.append(methodInfo.getHttpMethod());

SymbolInformation symbol = new SymbolInformation();
WorkspaceSymbol symbol = new WorkspaceSymbol();
symbol.setName(nameBuilder.toString());
symbol.setKind(SymbolKind.Method);
symbol.setLocation(location);
symbol.setLocation(eitherLocation);
return symbol;
}

Expand Down
Loading