use of com.microsoft.azure.toolkit.intellij.connector.Connection in project azure-tools-for-java by Microsoft.
the class SpringPropertiesLineMarkerProvider method getLineMarkerInfo.
@Override
@Nullable
public LineMarkerInfo<PsiElement> getLineMarkerInfo(@Nonnull PsiElement element) {
if (!(element instanceof PropertyImpl)) {
return null;
}
final String propKey = ((PropertyImpl) element).getKey();
final String propVal = ((PropertyImpl) element).getValue();
final Module module = ModuleUtil.findModuleForFile(element.getContainingFile().getVirtualFile(), element.getProject());
if (Objects.isNull(module)) {
return null;
}
final ImmutablePair<String, String> keyProp = new ImmutablePair<>(propKey, propVal);
final List<Connection<?, ?>> connections = element.getProject().getService(ConnectionManager.class).getConnectionsByConsumerId(module.getName());
for (final Connection<?, ?> connection : connections) {
final List<Pair<String, String>> properties = SpringSupported.getProperties(connection);
if (!properties.isEmpty() && properties.get(0).equals(keyProp)) {
final Resource<?> r = connection.getResource();
return new LineMarkerInfo<>(element, element.getTextRange(), AzureIcons.getIcon("/icons/connector/connect.svg"), element2 -> String.format("%s (%s)", r.getName(), r.getDefinition().getTitle()), new SpringDatasourceNavigationHandler(r), GutterIconRenderer.Alignment.LEFT, () -> "");
}
}
return null;
}
Aggregations