More output to debug test fails in CI builds

This commit is contained in:
Kris De Volder
2019-05-10 10:21:57 -07:00
parent 738d7ffceb
commit 17e5cf91a3
6 changed files with 98 additions and 49 deletions

View File

@@ -21,6 +21,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.ide.vscode.commons.languageserver.util.HoverHandler;
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.Log;
import org.springframework.ide.vscode.commons.util.Renderable;
import org.springframework.ide.vscode.commons.util.StringUtil;
import org.springframework.ide.vscode.commons.util.text.IRegion;
@@ -40,7 +41,7 @@ public class VscodeHoverEngineAdapter implements HoverHandler {
private HoverInfoProvider hoverInfoProvider;
private SimpleLanguageServer server;
private HoverType type;
final static Logger logger = LoggerFactory.getLogger(VscodeHoverEngineAdapter.class);
final static Logger log = LoggerFactory.getLogger(VscodeHoverEngineAdapter.class);
public VscodeHoverEngineAdapter(SimpleLanguageServer server, HoverInfoProvider hoverInfoProvider) {
@@ -76,11 +77,17 @@ public class VscodeHoverEngineAdapter implements HoverHandler {
if (StringUtil.hasText(rendered)) {
Hover hover = new Hover(ImmutableList.of(Either.forLeft(rendered)), range);
return hover;
} else {
log.debug("No hover because rendered hover has no text");
}
} else {
log.debug("No hover because hoverInfoProvider returned no hover");
}
} else {
log.debug("No hover because doc is null");
}
} catch (Exception e) {
logger.error("error computing hover", e);
log.error("error computing hover", e);
}
return SimpleTextDocumentService.NO_HOVER;
}

View File

@@ -322,13 +322,20 @@ public class SimpleTextDocumentService implements TextDocumentService, DocumentE
@Override
public CompletableFuture<Hover> hover(TextDocumentPositionParams position) {
return async.invoke(() -> {
HoverHandler h = hoverHandler;
if (h!=null) {
return hoverHandler.handle(position);
}
return null;
});
log.debug("hover requested for {}", position);
return async.invoke(() -> {
try {
log.debug("hover handler starting");
HoverHandler h = hoverHandler;
if (h!=null) {
return hoverHandler.handle(position);
}
log.debug("no hover because there is no handler");
return null;
} finally {
log.debug("hover handler finished");
}
});
}
@Override

View File

@@ -1 +1 @@
spring.main.banner-mode=off
spring.main.banner-mode=off

View File

@@ -12,6 +12,8 @@ package org.springframework.ide.vscode.commons.yaml.hover;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ide.vscode.commons.languageserver.hover.HoverInfoProvider;
import org.springframework.ide.vscode.commons.util.Assert;
import org.springframework.ide.vscode.commons.util.Renderable;
@@ -44,6 +46,8 @@ import reactor.util.function.Tuples;
*/
public class YamlHoverInfoProvider implements HoverInfoProvider {
private static final Logger log = LoggerFactory.getLogger(YamlHoverInfoProvider.class);
private YamlASTProvider astProvider;
private YamlAssistContextProvider assistContextProvider;
private YamlStructureProvider structureProvider;
@@ -60,42 +64,59 @@ public class YamlHoverInfoProvider implements HoverInfoProvider {
@Override
public Tuple2<Renderable, IRegion> getHoverInfo(IDocument doc, int offset) throws Exception {
YamlFileAST ast = getAst(doc);
if (ast != null) {
IRegion region = getHoverRegion(ast, offset);
if (region!=null) {
YamlDocument ymlDoc = new YamlDocument(doc, structureProvider);
YamlAssistContext assistContext = assistContextProvider.getGlobalAssistContext(ymlDoc);
if (assistContext != null) {
List<NodeRef<?>> astPath = ast.findPath(offset);
final YamlPath path = YamlPath.fromASTPath(astPath);
if (path != null) {
YamlPath assistPath = path;
if (assistPath.pointsAtKey()) {
// When a path points at a key we must tramsform it to a
// 'value-terminating path'
// to be able to reuse the 'getHoverInfo' method on
// YamlAssistContext (as navigation
// into 'key' is not defined for YamlAssistContext.
String key = path.getLastSegment().toPropString();
assistPath = path.dropLast().append(YamlPathSegment.valueAt(key));
}
assistContext = assistPath.traverse(assistContext);
if (assistContext != null) {
Renderable info = path.pointsAtValue()
? assistContext.getValueHoverInfo(ymlDoc, new DocumentRegion(doc, region))
: assistContext.getHoverInfo();
// Fix for: PT 134914895. If assist context cannot provide an info, then don't return a Tuple.
if (info != null) {
return Tuples.of(info, region);
log.debug("YamlHoverInfoProvider starting");
try {
YamlFileAST ast = getAst(doc);
if (ast == null) {
log.debug("No hover because ast is null");
} else {
IRegion region = getHoverRegion(ast, offset);
if (region==null) {
log.debug("No hover because region is null");
} else {
YamlDocument ymlDoc = new YamlDocument(doc, structureProvider);
YamlAssistContext assistContext = assistContextProvider.getGlobalAssistContext(ymlDoc);
if (assistContext == null) {
log.debug("No hover because GLOBAL assistContext is null");
} else {
List<NodeRef<?>> astPath = ast.findPath(offset);
final YamlPath path = YamlPath.fromASTPath(astPath);
if (path == null) {
log.debug("No hover because path is null");
} else {
YamlPath assistPath = path;
if (assistPath.pointsAtKey()) {
// When a path points at a key we must tramsform it to a
// 'value-terminating path'
// to be able to reuse the 'getHoverInfo' method on
// YamlAssistContext (as navigation
// into 'key' is not defined for YamlAssistContext.
String key = path.getLastSegment().toPropString();
assistPath = path.dropLast().append(YamlPathSegment.valueAt(key));
}
assistContext = assistPath.traverse(assistContext);
if (assistContext == null) {
log.debug("No hover because assistContext for path {} is null", assistPath);
} else {
Renderable info = path.pointsAtValue()
? assistContext.getValueHoverInfo(ymlDoc, new DocumentRegion(doc, region))
: assistContext.getHoverInfo();
// Fix for: PT 134914895. If assist context cannot provide an info, then don't return a Tuple.
if (info == null) {
log.debug("No hover because assistContext returned no hover", assistPath);
} else {
return Tuples.of(info, region);
}
}
}
}
}
}
return null;
} finally {
log.debug("YamlHoverInfoProvider finished");
}
return null;
}
private IRegion getHoverRegion(YamlFileAST ast, int offset) {

View File

@@ -15,6 +15,8 @@ import java.util.List;
import javax.annotation.PostConstruct;
import org.eclipse.lsp4j.CompletionList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
@@ -52,10 +54,11 @@ import reactor.core.publisher.Mono;
@Component
public class ConcourseLanguageServerInitializer {
private static final Logger log = LoggerFactory.getLogger(ConcourseLanguageServerInitializer.class);
private final YamlCompletionEngineOptions COMPLETION_OPTIONS = YamlCompletionEngineOptions.DEFAULT;
private final YamlStructureProvider structureProvider = YamlStructureProvider.DEFAULT;
private SchemaSpecificPieces forPipelines;
private SchemaSpecificPieces forTasks;
private YamlQuickfixes yamlQuickfixes;
@@ -154,15 +157,25 @@ public class ConcourseLanguageServerInitializer {
return item;
});
documents.onHover(params -> {
TextDocument doc = documents.get(params);
if (doc!=null) {
if (LanguageId.CONCOURSE_PIPELINE.equals(doc.getLanguageId())) {
return forPipelines.hoverEngine.handle(params);
} else if (LanguageId.CONCOURSE_TASK.equals(doc.getLanguageId())) {
return forTasks.hoverEngine.handle(params);
log.debug("Concourse hover handler starting");
try {
TextDocument doc = documents.get(params);
if (doc!=null) {
LanguageId languageId = doc.getLanguageId();
if (LanguageId.CONCOURSE_PIPELINE.equals(doc.getLanguageId())) {
return forPipelines.hoverEngine.handle(params);
} else if (LanguageId.CONCOURSE_TASK.equals(doc.getLanguageId())) {
return forTasks.hoverEngine.handle(params);
} else {
log.debug("No hovers because language-id = {}", languageId);
}
} else {
log.debug("No hovers because doc is null");
}
return SimpleTextDocumentService.NO_HOVER;
} finally {
log.debug("Concourse hover handler finished");
}
return SimpleTextDocumentService.NO_HOVER;
});
documents.onDefinition(definitionFinder);
// documents.onDocumentSymbol((params) -> {

View File

@@ -1 +1,2 @@
spring.main.banner-mode=off
spring.main.banner-mode=off
logging.level.org.springframework.ide.vscode=debug