avoid AST traversal if no boot app is running
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2016, 2017 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
|
||||
@@ -147,7 +147,7 @@ public class BootJavaLanguageServer extends SimpleLanguageServer {
|
||||
getClient().highlight(new HighlightParams(params.getDocument().getId(), testHightlighter.apply(doc)));
|
||||
} else {
|
||||
liveHoverWatchdog.watchDocument(doc.getUri());
|
||||
liveHoverWatchdog.update(doc.getUri());
|
||||
liveHoverWatchdog.update(doc.getUri(), null);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -137,15 +137,25 @@ public class SpringLiveHoverWatchdog {
|
||||
refreshEnablement();
|
||||
}
|
||||
|
||||
public void update(String docURI) {
|
||||
public void update(String docURI, SpringBootApp[] runningBootApps) {
|
||||
if (highlightsEnabled) {
|
||||
|
||||
try {
|
||||
SpringBootApp[] runningBootApps = runningAppProvider.getAllRunningSpringApps().toArray(new SpringBootApp[0]);
|
||||
TextDocument doc = this.server.getTextDocumentService().get(docURI);
|
||||
if (doc != null) {
|
||||
Range[] ranges = this.hoverProvider.getLiveHoverHints(doc, runningBootApps);
|
||||
publishLiveHints(docURI, ranges);
|
||||
if (runningBootApps == null) {
|
||||
runningBootApps = runningAppProvider.getAllRunningSpringApps().toArray(new SpringBootApp[0]);
|
||||
}
|
||||
|
||||
if (runningBootApps != null && runningBootApps.length > 0) {
|
||||
TextDocument doc = this.server.getTextDocumentService().get(docURI);
|
||||
if (doc != null) {
|
||||
Range[] ranges = this.hoverProvider.getLiveHoverHints(doc, runningBootApps);
|
||||
publishLiveHints(docURI, ranges);
|
||||
}
|
||||
}
|
||||
else {
|
||||
cleanupLiveHints(docURI);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -154,8 +164,13 @@ public class SpringLiveHoverWatchdog {
|
||||
|
||||
protected void update() {
|
||||
if (this.watchedDocs.size() > 0) {
|
||||
for (String docURI : watchedDocs) {
|
||||
update(docURI);
|
||||
try {
|
||||
SpringBootApp[] runningBootApps = runningAppProvider.getAllRunningSpringApps().toArray(new SpringBootApp[0]);
|
||||
for (String docURI : watchedDocs) {
|
||||
update(docURI, runningBootApps);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user