Skip to content
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
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.springframework.tooling.ls.eclipse.gotosymbol.test</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Goto Symbol Tests
Bundle-SymbolicName: org.springframework.tooling.ls.eclipse.gotosymbol.test
Bundle-Version: 5.4.0.qualifier
Fragment-Host: org.springframework.tooling.ls.eclipse.gotosymbol
Bundle-RequiredExecutionEnvironment: JavaSE-21
Require-Bundle: org.junit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="https://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot.ide</groupId>
<artifactId>org.springframework.boot.ide.servers</artifactId>
<version>5.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>org.springframework.tooling.ls.eclipse.gotosymbol.test</artifactId>
<packaging>eclipse-test-plugin</packaging>

<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<includes>**/*Test.java</includes>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*******************************************************************************
* Copyright (c) 2026 Broadcom, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Broadcom, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.tooling.ls.eclipse.gotosymbol.dialogs;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;

import java.util.Collections;
import java.util.List;

import org.junit.Test;

/**
* Tests the scope selection of the go-to-symbol dialog model.
*
* @author Broadcom, Inc.
*/
public class GotoSymbolDialogModelTest {

@Test
public void startsWithRememberedSymbolsProvider() {
SymbolsProvider workspace = provider("Workspace");
SymbolsProvider project = provider("Project");
SymbolsProvider file = provider("File");

GotoSymbolDialogModel model = new GotoSymbolDialogModel(null, 1, workspace, project, file);

assertSame(project, model.currentSymbolsProvider.getValue());
assertEquals(1, model.getCurrentSymbolsProviderIndex());
}

@Test
public void togglesFromRememberedSymbolsProvider() {
SymbolsProvider workspace = provider("Workspace");
SymbolsProvider project = provider("Project");
SymbolsProvider file = provider("File");
GotoSymbolDialogModel model = new GotoSymbolDialogModel(null, 1, workspace, project, file);

model.toggleSymbolsProvider();

assertSame(file, model.currentSymbolsProvider.getValue());
assertEquals(2, model.getCurrentSymbolsProviderIndex());
}

private SymbolsProvider provider(String name) {
return new SymbolsProvider() {

@Override
public String getName() {
return name;
}

@Override
public List<SymbolContainer> fetchFor(String query) {
return Collections.emptyList();
}

@Override
public boolean fromFile(SymbolContainer symbol) {
return false;
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,16 @@ private List<Match<SymbolContainer>> computeMatches(Collection<SymbolContainer>
private FavouritesPreference favourites = null;

public GotoSymbolDialogModel(String keyBindings, SymbolsProvider... symbolsProviders) {
this(keyBindings, 0, symbolsProviders);
}

public GotoSymbolDialogModel(String keyBindings, int initialSymbolsProviderIndex, SymbolsProvider... symbolsProviders) {
this.keyBindings = keyBindings;
Assert.isLegal(symbolsProviders.length>0);
Assert.isLegal(symbolsProviders.length>0);
Assert.isLegal(initialSymbolsProviderIndex >= 0 && initialSymbolsProviderIndex < symbolsProviders.length);
this.symbolsProviders = symbolsProviders;
this.currentSymbolsProviderIndex = 0;
this.currentSymbolsProvider.setValue(symbolsProviders[0]);
this.currentSymbolsProviderIndex = initialSymbolsProviderIndex;
this.currentSymbolsProvider.setValue(symbolsProviders[initialSymbolsProviderIndex]);
}

public GotoSymbolDialogModel setFavourites(FavouritesPreference favourites) {
Expand Down Expand Up @@ -279,6 +284,10 @@ public SymbolsProvider[] getSymbolsProviders() {
return symbolsProviders;
}

public int getCurrentSymbolsProviderIndex() {
return currentSymbolsProviderIndex;
}

/**
* Set an ok handler. The handler is meant to be called by the UI when user request to
* execute the dialogs action on its current selection. For example, by pressing 'ENTER'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ private static void debug(String string) {
}
}
private static GotoSymbolDialogModel currentDialog = null;
private static int lastSymbolsProviderIndex = 0;

public GotoSymbolHandler() {
debug("Creating GotoSymbolHandler");
Expand All @@ -63,16 +64,17 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
final Shell shell = HandlerUtil.getActiveShell(event);
final ITextEditor textEditor = (ITextEditor) part;

GotoSymbolDialogModel model = new GotoSymbolDialogModel(getKeybindings(event), InWorkspaceSymbolsProvider.createFor(event), InProjectSymbolsProvider.createFor(event), InFileSymbolsProvider.createFor(textEditor))
GotoSymbolDialogModel model = new GotoSymbolDialogModel(getKeybindings(event), lastSymbolsProviderIndex, InWorkspaceSymbolsProvider.createFor(event), InProjectSymbolsProvider.createFor(event), InFileSymbolsProvider.createFor(textEditor))
.setOkHandler(GotoSymbolDialogModel.OPEN_IN_EDITOR_OK_HANDLER);
GotoSymbolDialog dialog = new GotoSymbolDialog(shell, textEditor, model, /*alignRight*/ false);
currentDialog = model;
dialog.open();
debug("GotoSymbolDialog opened");
dialog.getShell().addDisposeListener(de -> {
debug("GotoSymbolDialog closed!");
lastSymbolsProviderIndex = model.getCurrentSymbolsProviderIndex();
currentDialog = null;
});
dialog.open();
debug("GotoSymbolDialog opened");
}
debug("<<<GotoSymbolHandler.execute");
}
Expand Down
1 change: 1 addition & 0 deletions eclipse-language-servers/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
<module>org.springframework.tooling.cloudfoundry.manifest.ls.integration.feature</module>

<module>org.springframework.tooling.ls.eclipse.gotosymbol</module>
<module>org.springframework.tooling.ls.eclipse.gotosymbol.test</module>
<module>org.springframework.tooling.boot.ls</module>
<module>org.springframework.tooling.boot.ls.feature</module>

Expand Down