PT #158305061: Hanlde only java documents by boot java handlers
This commit is contained in:
@@ -552,6 +552,10 @@ public class LanguageServerHarness<S extends SimpleLanguageServerWrapper> {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #newEditor(LanguageId, String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public Editor newEditor(String contents) throws Exception {
|
||||
return newEditor(getDefaultLanguageId(), contents);
|
||||
}
|
||||
|
||||
@@ -85,11 +85,11 @@ import com.google.common.collect.ImmutableSet;
|
||||
* @author Martin Lippert
|
||||
*/
|
||||
public class BootJavaLanguageServerComponents implements LanguageServerComponents {
|
||||
|
||||
|
||||
private static final Set<LanguageId> LANGUAGES = ImmutableSet.of(LanguageId.JAVA);
|
||||
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(BootJavaLanguageServerComponents.class);
|
||||
|
||||
|
||||
private final SimpleLanguageServer server;
|
||||
private final BootLanguageServerParams serverParams;
|
||||
private final SpringIndexer indexer;
|
||||
@@ -124,9 +124,13 @@ public class BootJavaLanguageServerComponents implements LanguageServerComponent
|
||||
|
||||
indexer = createAnnotationIndexer(server, serverParams);
|
||||
documents.onDidSave(params -> {
|
||||
String docURI = params.getDocument().getId().getUri();
|
||||
String content = params.getDocument().get();
|
||||
indexer.updateDocument(docURI, content);
|
||||
TextDocument document = params.getDocument();
|
||||
// Spring Boot LS get events from boot properties files as well, so filter them out
|
||||
if (getInterestingLanguages().contains(document.getLanguageId())) {
|
||||
String docURI = document.getId().getUri();
|
||||
String content = document.get();
|
||||
indexer.updateDocument(docURI, content);
|
||||
}
|
||||
});
|
||||
|
||||
documents.onDocumentSymbol(new BootJavaDocumentSymbolHandler(indexer));
|
||||
@@ -137,21 +141,24 @@ public class BootJavaLanguageServerComponents implements LanguageServerComponent
|
||||
// documents.onCodeLens(codeLensHandler::createCodeLenses);
|
||||
// documents.onCodeLensResolve(codeLensHandler::resolveCodeLens);
|
||||
|
||||
hoverProvider = createHoverHandler(projectFinder, serverParams.runningAppProvider);
|
||||
hoverProvider = createHoverHandler(projectFinder, serverParams.runningAppProvider);
|
||||
liveHoverWatchdog = new SpringLiveHoverWatchdog(server, hoverProvider, serverParams.runningAppProvider,
|
||||
projectFinder, projectObserver, serverParams.watchDogInterval);
|
||||
documents.onDidChangeContent(params -> {
|
||||
TextDocument doc = params.getDocument();
|
||||
// if (testHightlighter != null) {
|
||||
// getClient().highlight(new HighlightParams(params.getDocument().getId(), testHightlighter.apply(doc)));
|
||||
// } else {
|
||||
try {
|
||||
liveHoverWatchdog.watchDocument(doc.getUri());
|
||||
liveHoverWatchdog.update(doc.getUri(), null);
|
||||
} catch (Throwable t) {
|
||||
log.error("", t);
|
||||
if (getInterestingLanguages().contains(doc.getLanguageId())) {
|
||||
// if (testHightlighter != null) {
|
||||
// getClient()
|
||||
// .highlight(new HighlightParams(params.getDocument().getId(), testHightlighter.apply(doc)));
|
||||
// } else {
|
||||
try {
|
||||
liveHoverWatchdog.watchDocument(doc.getUri());
|
||||
liveHoverWatchdog.update(doc.getUri(), null);
|
||||
} catch (Throwable t) {
|
||||
log.error("", t);
|
||||
}
|
||||
// }
|
||||
}
|
||||
// }
|
||||
});
|
||||
|
||||
documents.onDidClose(doc -> {
|
||||
@@ -161,13 +168,13 @@ public class BootJavaLanguageServerComponents implements LanguageServerComponent
|
||||
liveHoverWatchdog.unwatchDocument(doc.getUri());
|
||||
// }
|
||||
});
|
||||
|
||||
|
||||
codeLensHandler = createCodeLensEngine();
|
||||
documents.onCodeLens(codeLensHandler);
|
||||
|
||||
|
||||
highlightsEngine = createDocumentHighlightEngine();
|
||||
documents.onDocumentHighlight(highlightsEngine);
|
||||
|
||||
|
||||
workspaceService.onDidChangeConfiguraton(settings -> {
|
||||
config.handleConfigurationChange(settings);
|
||||
if (config.isBootHintsEnabled()) {
|
||||
@@ -181,25 +188,25 @@ public class BootJavaLanguageServerComponents implements LanguageServerComponent
|
||||
server.onInitialized(this::initialized);
|
||||
server.onShutdown(this::shutdown);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ICompletionEngine getCompletionEngine() {
|
||||
return createCompletionEngine(projectFinder, propertyIndexProvider);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public HoverHandler getHoverProvider() {
|
||||
return hoverProvider;
|
||||
}
|
||||
|
||||
|
||||
public CodeLensHandler getCodeLensHandler() {
|
||||
return codeLensHandler;
|
||||
}
|
||||
|
||||
|
||||
public DocumentHighlightHandler getDocumentHighlightHandler() {
|
||||
return highlightsEngine;
|
||||
}
|
||||
|
||||
|
||||
private void initialize(InitializeParams params) {
|
||||
// this.indexer.initialize(server.getWorkspaceRoots());
|
||||
}
|
||||
@@ -313,7 +320,7 @@ public class BootJavaLanguageServerComponents implements LanguageServerComponent
|
||||
|
||||
providers.put(Annotations.BEAN, new BeansSymbolProvider());
|
||||
providers.put(Annotations.COMPONENT, new ComponentSymbolProvider());
|
||||
|
||||
|
||||
providers.put(Annotations.REPOSITORY, new DataRepositorySymbolProvider());
|
||||
providers.put("", new WebfluxRouterSymbolProvider());
|
||||
|
||||
@@ -325,7 +332,7 @@ public class BootJavaLanguageServerComponents implements LanguageServerComponent
|
||||
providers.put(org.springframework.ide.vscode.boot.java.value.Constants.SPRING_VALUE,
|
||||
new ValuePropertyReferencesProvider(server));
|
||||
|
||||
return new BootJavaReferencesHandler(server, projectFinder, providers);
|
||||
return new BootJavaReferencesHandler(this, projectFinder, providers);
|
||||
}
|
||||
|
||||
protected BootJavaCodeLensEngine createCodeLensEngine() {
|
||||
@@ -334,11 +341,11 @@ public class BootJavaLanguageServerComponents implements LanguageServerComponent
|
||||
|
||||
return new BootJavaCodeLensEngine(this, codeLensProvider);
|
||||
}
|
||||
|
||||
|
||||
protected BootJavaDocumentHighlightEngine createDocumentHighlightEngine() {
|
||||
Collection<HighlightProvider> highlightProvider = new ArrayList<>();
|
||||
highlightProvider.add(new WebfluxRouteHighlightProdivder(this));
|
||||
|
||||
|
||||
return new BootJavaDocumentHighlightEngine(this, highlightProvider);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,13 +42,16 @@ public class BootJavaCodeLensEngine implements CodeLensHandler {
|
||||
|
||||
if (documents.get(docURI) != null) {
|
||||
TextDocument doc = documents.get(docURI).copy();
|
||||
try {
|
||||
List<? extends CodeLens> codeLensesResult = provideCodeLenses(doc);
|
||||
if (codeLensesResult != null) {
|
||||
return codeLensesResult;
|
||||
// Spring Boot LS get events from boot properties files as well, so filter them out
|
||||
if (server.getInterestingLanguages().contains(doc.getLanguageId())) {
|
||||
try {
|
||||
List<? extends CodeLens> codeLensesResult = provideCodeLenses(doc);
|
||||
if (codeLensesResult != null) {
|
||||
return codeLensesResult;
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,13 +60,13 @@ public class BootJavaCodeLensEngine implements CodeLensHandler {
|
||||
|
||||
private List<? extends CodeLens> provideCodeLenses(TextDocument document) {
|
||||
return server.getCompilationUnitCache().withCompilationUnit(document, cu -> {
|
||||
|
||||
|
||||
if (cu != null) {
|
||||
List<CodeLens> result = new ArrayList<>();
|
||||
for (CodeLensProvider codeLensProvider : codelensProviders) {
|
||||
codeLensProvider.provideCodeLenses(document, cu, result);
|
||||
}
|
||||
|
||||
|
||||
if (result.size() > 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.springframework.ide.vscode.commons.util.text.TextDocument;
|
||||
public class BootJavaDocumentHighlightEngine implements DocumentHighlightHandler {
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(BootJavaDocumentHighlightEngine.class);
|
||||
|
||||
|
||||
private BootJavaLanguageServerComponents server;
|
||||
private Collection<HighlightProvider> highlightProviders;
|
||||
|
||||
@@ -46,11 +46,14 @@ public class BootJavaDocumentHighlightEngine implements DocumentHighlightHandler
|
||||
|
||||
if (documents.get(docURI) != null) {
|
||||
TextDocument doc = documents.get(docURI).copy();
|
||||
try {
|
||||
return provideDocumentHighlights(doc, params.getPosition());
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error("", e);
|
||||
// Spring Boot LS get events from boot properties files as well, so filter them out
|
||||
if (doc != null && server.getInterestingLanguages().contains(doc.getLanguageId())) {
|
||||
try {
|
||||
return provideDocumentHighlights(doc, params.getPosition());
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error("", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -68,14 +68,17 @@ public class BootJavaHoverProvider implements HoverHandler {
|
||||
SimpleTextDocumentService documents = server.getTextDocumentService();
|
||||
if (documents.get(params) != null) {
|
||||
TextDocument doc = documents.get(params).copy();
|
||||
try {
|
||||
int offset = doc.toOffset(params.getPosition());
|
||||
Hover hoverResult = provideHover(doc, offset);
|
||||
if (hoverResult != null) {
|
||||
return hoverResult;
|
||||
// Spring Boot LS get events from boot properties files as well, so filter them out
|
||||
if (server.getInterestingLanguages().contains(doc.getLanguageId())) {
|
||||
try {
|
||||
int offset = doc.toOffset(params.getPosition());
|
||||
Hover hoverResult = provideHover(doc, offset);
|
||||
if (hoverResult != null) {
|
||||
return hoverResult;
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,12 +26,12 @@ import org.eclipse.jdt.core.dom.NodeFinder;
|
||||
import org.eclipse.lsp4j.Location;
|
||||
import org.eclipse.lsp4j.ReferenceParams;
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.springframework.ide.vscode.boot.java.BootJavaLanguageServerComponents;
|
||||
import org.springframework.ide.vscode.commons.java.IClasspath;
|
||||
import org.springframework.ide.vscode.commons.java.IClasspathUtil;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.ReferencesHandler;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleTextDocumentService;
|
||||
import org.springframework.ide.vscode.commons.util.text.IDocument;
|
||||
import org.springframework.ide.vscode.commons.util.text.TextDocument;
|
||||
@@ -42,10 +42,10 @@ import org.springframework.ide.vscode.commons.util.text.TextDocument;
|
||||
public class BootJavaReferencesHandler implements ReferencesHandler {
|
||||
|
||||
private JavaProjectFinder projectFinder;
|
||||
private SimpleLanguageServer server;
|
||||
private BootJavaLanguageServerComponents server;
|
||||
private Map<String, ReferenceProvider> referenceProviders;
|
||||
|
||||
public BootJavaReferencesHandler(SimpleLanguageServer server, JavaProjectFinder projectFinder, Map<String, ReferenceProvider> specificProviders) {
|
||||
public BootJavaReferencesHandler(BootJavaLanguageServerComponents server, JavaProjectFinder projectFinder, Map<String, ReferenceProvider> specificProviders) {
|
||||
this.server = server;
|
||||
this.projectFinder = projectFinder;
|
||||
this.referenceProviders = specificProviders;
|
||||
@@ -56,14 +56,17 @@ public class BootJavaReferencesHandler implements ReferencesHandler {
|
||||
SimpleTextDocumentService documents = server.getTextDocumentService();
|
||||
TextDocument doc = documents.get(params).copy();
|
||||
if (doc != null) {
|
||||
try {
|
||||
int offset = doc.toOffset(params.getPosition());
|
||||
List<? extends Location> referencesResult = provideReferences(doc, offset);
|
||||
if (referencesResult != null) {
|
||||
return referencesResult;
|
||||
// Spring Boot LS get events from boot properties files as well, so filter them out
|
||||
if (server.getInterestingLanguages().contains(doc.getLanguageId())) {
|
||||
try {
|
||||
int offset = doc.toOffset(params.getPosition());
|
||||
List<? extends Location> referencesResult = provideReferences(doc, offset);
|
||||
if (referencesResult != null) {
|
||||
return referencesResult;
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,11 +40,11 @@ import org.springframework.ide.vscode.languageserver.testharness.LanguageServerH
|
||||
import org.springframework.ide.vscode.project.harness.ProjectsHarness;
|
||||
|
||||
public abstract class AbstractPropsEditorTest {
|
||||
|
||||
|
||||
public static final String INTEGER = Integer.class.getName();
|
||||
public static final String BOOLEAN = Boolean.class.getName();
|
||||
public static final String STRING = String.class.getName();
|
||||
|
||||
|
||||
private ProjectsHarness projects = ProjectsHarness.INSTANCE;
|
||||
|
||||
protected PropertyIndexHarness md;
|
||||
@@ -54,10 +54,10 @@ public abstract class AbstractPropsEditorTest {
|
||||
return Optional.ofNullable(getTestProject());
|
||||
}
|
||||
}));
|
||||
|
||||
private LanguageServerHarness harness;
|
||||
|
||||
protected LanguageServerHarness harness;
|
||||
private IJavaProject testProject;
|
||||
private TypeUtil typeUtil;
|
||||
private TypeUtil typeUtil;
|
||||
|
||||
protected TypeUtilProvider typeUtilProvider = (IDocument doc) -> {
|
||||
if (typeUtil==null) {
|
||||
@@ -66,10 +66,8 @@ public abstract class AbstractPropsEditorTest {
|
||||
return typeUtil;
|
||||
};
|
||||
|
||||
public Editor newEditor(String contents) throws Exception {
|
||||
return harness.newEditor(contents);
|
||||
}
|
||||
|
||||
abstract public Editor newEditor(String contents) throws Exception;
|
||||
|
||||
private IJavaProject getTestProject() {
|
||||
return testProject;
|
||||
}
|
||||
@@ -82,13 +80,14 @@ public abstract class AbstractPropsEditorTest {
|
||||
protected LanguageId getDefaultLanguageId() {
|
||||
return AbstractPropsEditorTest.this.getLanguageId();
|
||||
}
|
||||
@Override
|
||||
protected String getFileExtension() {
|
||||
return AbstractPropsEditorTest.this.getFileExtension();
|
||||
}
|
||||
};
|
||||
harness.intialize(null);
|
||||
}
|
||||
|
||||
|
||||
protected abstract LanguageId getLanguageId();
|
||||
|
||||
/**
|
||||
@@ -97,27 +96,27 @@ public abstract class AbstractPropsEditorTest {
|
||||
* extension (e.g. different validation, completions etc. for .yml versus .properties
|
||||
*/
|
||||
protected abstract String getFileExtension();
|
||||
|
||||
|
||||
protected abstract SimpleLanguageServer newLanguageServer();
|
||||
|
||||
|
||||
public ItemConfigurer data(String id, String type, Object deflt, String description, String... sources) {
|
||||
return md.data(id, type, deflt, description, sources);
|
||||
}
|
||||
|
||||
|
||||
public void defaultTestData() {
|
||||
md.defaultTestData();
|
||||
}
|
||||
|
||||
|
||||
public MavenJavaProject createPredefinedMavenProject(String name) throws Exception {
|
||||
return projects.mavenProject(name);
|
||||
}
|
||||
|
||||
|
||||
public void useProject(IJavaProject p) throws Exception {
|
||||
md.useProject(p);
|
||||
this.testProject = p;
|
||||
this.typeUtil = null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Simulates applying the first completion to a text buffer and checks the result.
|
||||
*/
|
||||
@@ -134,7 +133,7 @@ public abstract class AbstractPropsEditorTest {
|
||||
Editor editor = newEditor(editorText);
|
||||
editor.assertCompletionDetails(expectLabel, null, expectInfoSnippet);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks that completions contains a completion with a given display string, detail and documentation text
|
||||
*/
|
||||
@@ -142,7 +141,7 @@ public abstract class AbstractPropsEditorTest {
|
||||
Editor editor = newEditor(editorText);
|
||||
editor.assertCompletionDetails(expectLabel, expectDetail, expectDocumenation);
|
||||
}
|
||||
|
||||
|
||||
public boolean isEmptyMetadata() {
|
||||
return md.isEmpty();
|
||||
}
|
||||
@@ -198,7 +197,7 @@ public abstract class AbstractPropsEditorTest {
|
||||
}
|
||||
assertElements(actualLabels, completionsLabels);
|
||||
}
|
||||
|
||||
|
||||
public void assertCompletionsDisplayStringAndDetail(String editorText, String[]...expectCompletions) throws Exception {
|
||||
String[] completionsLabels = new String[expectCompletions.length];
|
||||
String[] completionDetails = new String[expectCompletions.length];
|
||||
@@ -221,7 +220,7 @@ public abstract class AbstractPropsEditorTest {
|
||||
public SpringPropertyIndexProvider getIndexProvider() {
|
||||
return md.getIndexProvider();
|
||||
}
|
||||
|
||||
|
||||
@SafeVarargs
|
||||
public static <T> void assertElements(T[] actual, T... expect) {
|
||||
assertElements(Arrays.asList(actual), expect);
|
||||
@@ -245,7 +244,7 @@ public abstract class AbstractPropsEditorTest {
|
||||
fail("Missing elements: \n"+missing);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void assertStyledCompletions(String editorText, StyledStringMatcher... expectStyles) throws Exception {
|
||||
Editor editor = newEditor(editorText);
|
||||
List<CompletionItem> completions = editor.getCompletions();
|
||||
@@ -262,7 +261,7 @@ public abstract class AbstractPropsEditorTest {
|
||||
public void deprecate(String key, String replacedBy, String reason) {
|
||||
md.deprecate(key, replacedBy, reason);
|
||||
}
|
||||
|
||||
|
||||
public void keyHints(String id, String... hintValues) {
|
||||
md.keyHints(id, hintValues);
|
||||
}
|
||||
|
||||
@@ -270,7 +270,7 @@ public class AutowiredHoverProviderTest {
|
||||
.build();
|
||||
|
||||
|
||||
Editor editor = harness.newEditor(
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
"import org.springframework.beans.factory.annotation.Autowired;\n" +
|
||||
@@ -332,7 +332,7 @@ public class AutowiredHoverProviderTest {
|
||||
.build();
|
||||
|
||||
|
||||
Editor editor = harness.newEditor(
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
"import org.springframework.beans.factory.annotation.Autowired;\n" +
|
||||
|
||||
@@ -136,7 +136,7 @@ public class BeanInjectedIntoHoverProviderTest {
|
||||
"@Bean({\"beanId\", \"alias\"})",
|
||||
};
|
||||
for (String beanAnnotation : beanAnnotations) {
|
||||
Editor editor = harness.newEditor(
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package hello;\n" +
|
||||
"\n" +
|
||||
"import org.springframework.context.annotation.Bean;\n" +
|
||||
|
||||
@@ -44,13 +44,13 @@ public class WebFluxCodeLensProviderTest {
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
harness = BootJavaLanguageServerHarness.builder().build();
|
||||
|
||||
|
||||
harness.intialize(null);
|
||||
indexer = harness.getServerWrapper().getComponents().getSpringIndexer();
|
||||
|
||||
|
||||
directory = new File(ProjectsHarness.class.getResource("/test-projects/test-webflux-project/").toURI());
|
||||
String projectDir = directory.toURI().toString();
|
||||
|
||||
|
||||
// trigger project creation
|
||||
harness.getServerWrapper().getComponents().getProjectFinder().find(new TextDocumentIdentifier(projectDir)).get();
|
||||
|
||||
@@ -61,13 +61,13 @@ public class WebFluxCodeLensProviderTest {
|
||||
@Test
|
||||
public void testRoutesCodeLensesSimpleCase() throws Exception {
|
||||
String docUri = directory.toPath().resolve("src/main/java/org/test/QuoteHandler.java").toUri().toString();
|
||||
TextDocumentInfo doc = harness.getOrReadFile(new File(new URI(docUri)), LanguageId.JAVA.toString());
|
||||
TextDocumentInfo doc = harness.getOrReadFile(new File(new URI(docUri)), LanguageId.JAVA.getId());
|
||||
TextDocumentInfo openedDoc = harness.openDocument(doc);
|
||||
|
||||
|
||||
List<? extends CodeLens> codeLenses = harness.getCodeLenses(openedDoc);
|
||||
|
||||
assertEquals(4, codeLenses.size());
|
||||
|
||||
|
||||
assertTrue(containsCodeLens(codeLenses, "GET /hello - Accept: text/plain", 25, 29, 25, 34));
|
||||
assertTrue(containsCodeLens(codeLenses, "POST /echo - Accept: text/plain - Content-Type: text/plain", 30, 29, 30, 33));
|
||||
assertTrue(containsCodeLens(codeLenses, "GET /quotes - Accept: application/stream+json", 35, 29, 35, 41));
|
||||
@@ -77,13 +77,13 @@ public class WebFluxCodeLensProviderTest {
|
||||
@Test
|
||||
public void testRoutesCodeLensesNestedRoutes1() throws Exception {
|
||||
String docUri = directory.toPath().resolve("src/main/java/org/test/PersonHandler1.java").toUri().toString();
|
||||
TextDocumentInfo doc = harness.getOrReadFile(new File(new URI(docUri)), LanguageId.JAVA.toString());
|
||||
TextDocumentInfo doc = harness.getOrReadFile(new File(new URI(docUri)), LanguageId.JAVA.getId());
|
||||
TextDocumentInfo openedDoc = harness.openDocument(doc);
|
||||
|
||||
|
||||
List<? extends CodeLens> codeLenses = harness.getCodeLenses(openedDoc);
|
||||
|
||||
assertEquals(3, codeLenses.size());
|
||||
|
||||
|
||||
assertTrue(containsCodeLens(codeLenses, "GET /person/{id} - Accept: application/json", 9, 29, 9, 38));
|
||||
assertTrue(containsCodeLens(codeLenses, "POST /person/ - Content-Type: application/json", 13, 29, 13, 41));
|
||||
assertTrue(containsCodeLens(codeLenses, "GET /person - Accept: application/json", 17, 29, 17, 39));
|
||||
@@ -92,13 +92,13 @@ public class WebFluxCodeLensProviderTest {
|
||||
@Test
|
||||
public void testRoutesCodeLensesNestedRoutes2() throws Exception {
|
||||
String docUri = directory.toPath().resolve("src/main/java/org/test/PersonHandler2.java").toUri().toString();
|
||||
TextDocumentInfo doc = harness.getOrReadFile(new File(new URI(docUri)), LanguageId.JAVA.toString());
|
||||
TextDocumentInfo doc = harness.getOrReadFile(new File(new URI(docUri)), LanguageId.JAVA.getId());
|
||||
TextDocumentInfo openedDoc = harness.openDocument(doc);
|
||||
|
||||
|
||||
List<? extends CodeLens> codeLenses = harness.getCodeLenses(openedDoc);
|
||||
|
||||
assertEquals(3, codeLenses.size());
|
||||
|
||||
|
||||
assertTrue(containsCodeLens(codeLenses, "GET /person/{id} - Accept: application/json", 9, 29, 9, 38));
|
||||
assertTrue(containsCodeLens(codeLenses, "POST / - Accept: application/json - Content-Type: application/json,application/pdf", 13, 29, 13, 41));
|
||||
assertTrue(containsCodeLens(codeLenses, "GET,HEAD /person - Accept: text/plain,application/json", 17, 29, 17, 39));
|
||||
@@ -107,13 +107,13 @@ public class WebFluxCodeLensProviderTest {
|
||||
@Test
|
||||
public void testRoutesCodeLensesNestedRoutes3() throws Exception {
|
||||
String docUri = directory.toPath().resolve("src/main/java/org/test/PersonHandler3.java").toUri().toString();
|
||||
TextDocumentInfo doc = harness.getOrReadFile(new File(new URI(docUri)), LanguageId.JAVA.toString());
|
||||
TextDocumentInfo doc = harness.getOrReadFile(new File(new URI(docUri)), LanguageId.JAVA.getId());
|
||||
TextDocumentInfo openedDoc = harness.openDocument(doc);
|
||||
|
||||
|
||||
List<? extends CodeLens> codeLenses = harness.getCodeLenses(openedDoc);
|
||||
|
||||
assertEquals(6, codeLenses.size());
|
||||
/*
|
||||
/*
|
||||
assertTrue(containsCodeLens(codeLenses, "GET /person/{id} - Accept: application/json", 9, 29, 9, 38));
|
||||
assertTrue(containsCodeLens(codeLenses, "POST / - Accept: application/json - Content-Type: application/json, application/pdf", 13, 29, 13, 41));
|
||||
assertTrue(containsCodeLens(codeLenses, "GET, HEAD /person - Accept: text/plain, application/json", 17, 29, 17, 39));
|
||||
@@ -132,7 +132,7 @@ public class WebFluxCodeLensProviderTest {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2016 Pivotal, Inc.
|
||||
* Copyright (c) 2016, 2018 Pivotal, 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
|
||||
@@ -1604,7 +1604,7 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest {
|
||||
useProject(createPredefinedMavenProject("enums-boot-1.3.2-app"));
|
||||
data("my.color-set", "java.util.Set<demo.Color>", null, "Set of colors that can be used.");
|
||||
|
||||
assertCompletions("my.colos<*>",
|
||||
assertCompletions("my.colos<*>",
|
||||
"my.color-set=<*>"
|
||||
);
|
||||
assertCompletions("my.color-set=<*>",
|
||||
@@ -1621,13 +1621,13 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest {
|
||||
}
|
||||
|
||||
////////////// harness code below /////////////////////////
|
||||
|
||||
|
||||
@Override
|
||||
protected SimpleLanguageServer newLanguageServer() {
|
||||
ComposableLanguageServer<?> server = BootLanguageServer.create(
|
||||
s -> new BootLanguageServerParams(
|
||||
javaProjectFinder,
|
||||
ProjectObserver.NULL,
|
||||
javaProjectFinder,
|
||||
ProjectObserver.NULL,
|
||||
md.getIndexProvider(),
|
||||
typeUtilProvider,
|
||||
RunningAppProvider.NULL,
|
||||
@@ -1675,4 +1675,9 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest {
|
||||
return LanguageId.BOOT_PROPERTIES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Editor newEditor(String contents) throws Exception {
|
||||
return harness.newEditor(LanguageId.BOOT_PROPERTIES, contents);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2016 Pivotal, Inc.
|
||||
* Copyright (c) 2016, 2018 Pivotal, 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
|
||||
@@ -3888,4 +3888,9 @@ public class ApplicationYamlEditorTest extends AbstractPropsEditorTest {
|
||||
return LanguageId.BOOT_PROPERTIES_YAML;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Editor newEditor(String contents) throws Exception {
|
||||
return harness.newEditor(LanguageId.BOOT_PROPERTIES_YAML, contents);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user