Search in sources :

Example 1 with Suggestion

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));
}
Also used : Suggestion(org.talend.sdk.component.intellij.completion.properties.Suggestion) PsiAnnotation(com.intellij.psi.PsiAnnotation) PsiAnnotationMemberValue(com.intellij.psi.PsiAnnotationMemberValue)

Aggregations

PsiAnnotation (com.intellij.psi.PsiAnnotation)1 PsiAnnotationMemberValue (com.intellij.psi.PsiAnnotationMemberValue)1 Suggestion (org.talend.sdk.component.intellij.completion.properties.Suggestion)1