use of org.springframework.ide.vscode.commons.boot.app.cli.SpringBootApp in project sts4 by spring-projects.
the class LiveAppURLSymbolProvider method getSymbols.
public List<? extends SymbolInformation> getSymbols(String query) {
System.out.println(query);
List<SymbolInformation> result = new ArrayList<>();
try {
SpringBootApp[] runningApps = runningAppProvider.getAllRunningSpringApps().toArray(new SpringBootApp[0]);
for (SpringBootApp app : runningApps) {
try {
String host = app.getHost();
String port = app.getPort();
Stream<String> urls = app.getRequestMappings().stream().flatMap(rm -> Arrays.stream(rm.getSplitPath())).map(path -> UrlUtil.createUrl(host, port, path));
urls.forEach(url -> result.add(new SymbolInformation(url, SymbolKind.Method, new Location(url, new Range(new Position(0, 0), new Position(0, 1))))));
} catch (Exception e) {
Log.log(e);
}
}
} catch (Exception e) {
Log.log(e);
}
return result;
}
use of org.springframework.ide.vscode.commons.boot.app.cli.SpringBootApp in project sts4 by spring-projects.
the class RequestMappingHoverProvider method addHoverContent.
private void addHoverContent(List<Tuple2<RequestMapping, SpringBootApp>> mappingMethods, List<Either<String, MarkedString>> hoverContent) throws Exception {
for (int i = 0; i < mappingMethods.size(); i++) {
Tuple2<RequestMapping, SpringBootApp> mappingMethod = mappingMethods.get(i);
SpringBootApp app = mappingMethod.getT2();
String port = mappingMethod.getT2().getPort();
String host = mappingMethod.getT2().getHost();
List<Renderable> renderableUrls = Arrays.stream(mappingMethod.getT1().getSplitPath()).flatMap(path -> {
String url = UrlUtil.createUrl(host, port, path);
StringBuilder builder = new StringBuilder();
builder.append("[");
builder.append(url);
builder.append("]");
builder.append("(");
builder.append(url);
builder.append(")");
return Stream.of(Renderables.text(builder.toString()), Renderables.lineBreak());
}).collect(Collectors.toList());
// Remove the last line break
renderableUrls.remove(renderableUrls.size() - 1);
hoverContent.add(Either.forLeft(Renderables.concat(renderableUrls).toMarkdown()));
hoverContent.add(Either.forLeft(LiveHoverUtils.niceAppName(app)));
if (i < mappingMethods.size() - 1) {
// Three dashes == line separator in Markdown
hoverContent.add(Either.forLeft("---"));
}
}
}
use of org.springframework.ide.vscode.commons.boot.app.cli.SpringBootApp in project sts4 by spring-projects.
the class ActiveProfilesProvider method provideHover.
@Override
public Hover provideHover(ASTNode node, Annotation annotation, ITypeBinding type, int offset, TextDocument doc, IJavaProject project, SpringBootApp[] runningApps) {
if (runningApps.length > 0) {
StringBuilder markdown = new StringBuilder();
markdown.append("**Active Profiles**\n\n");
boolean hasInterestingApp = false;
for (SpringBootApp app : runningApps) {
List<String> profiles = app.getActiveProfiles();
if (profiles == null) {
markdown.append(niceAppName(app) + " : _Unknown_\n\n");
} else {
hasInterestingApp = true;
if (profiles.isEmpty()) {
markdown.append(niceAppName(app) + " : _None_\n\n");
} else {
markdown.append(niceAppName(app) + " :\n");
for (String profile : profiles) {
markdown.append("- " + profile + "\n");
}
markdown.append("\n");
}
}
}
if (hasInterestingApp) {
return new Hover(ImmutableList.of(Either.forLeft(markdown.toString())));
}
}
return null;
}
use of org.springframework.ide.vscode.commons.boot.app.cli.SpringBootApp in project sts4 by spring-projects.
the class LiveHoverUtils method findRelevantBeans.
public static Stream<LiveBean> findRelevantBeans(SpringBootApp app, LiveBean definedBean) {
LiveBeansModel beansModel = app.getBeans();
if (beansModel != null) {
Stream<LiveBean> relevantBeans = beansModel.getBeansOfName(definedBean.getId()).stream();
String type = definedBean.getType();
if (type != null) {
relevantBeans = relevantBeans.filter(bean -> type.equals(bean.getType(true)));
}
return relevantBeans;
}
return Stream.empty();
}
Aggregations