use of org.talend.sdk.component.intellij.completion.properties.Suggestion in project component-runtime by Talend.
the class SuggestionServiceImpl method fromComponent.
private Stream<Suggestion> fromComponent(final PsiClass clazz, final String defaultFamily) {
final PsiAnnotation componentAnnotation = AnnotationUtil.findAnnotation(clazz, PARTITION_MAPPER, PROCESSOR, EMITTER);
final PsiAnnotationMemberValue name = componentAnnotation.findAttributeValue("name");
if (name == null || "\"\"".equals(name.getText())) {
return Stream.empty();
}
final PsiAnnotationMemberValue familyValue = componentAnnotation.findAttributeValue("family");
final String componentFamily = (familyValue == null || removeQuotes(familyValue.getText()).isEmpty()) ? null : removeQuotes(familyValue.getText());
final String family = ofNullable(componentFamily).orElseGet(() -> ofNullable(defaultFamily).orElse(null));
if (family == null) {
return Stream.empty();
}
return Stream.of(new Suggestion(family + "." + DISPLAY_NAME, Suggestion.Type.Family), new Suggestion(family + "." + removeQuotes(name.getText()) + "." + DISPLAY_NAME, Suggestion.Type.Component));
}
Aggregations