Skip to content

Commit

Permalink
Extract method for running the content generators from extensions ecl…
Browse files Browse the repository at this point in the history
  • Loading branch information
travkin79 committed Aug 16, 2024
1 parent 0338539 commit 348eeb2
Showing 1 changed file with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,24 +106,24 @@ public boolean allTypesSelected(Collection<MarkerType> selectedTypes) {
public MarkerField[] getAllFields() {
List<MarkerField> allFieldsList = new ArrayList<>(Arrays.asList(allFieldsWithoutExtensions));

Iterator<IConfigurationElement> extensions = generatorExtensions.iterator();
while (extensions.hasNext()) {
addMarkerFieldsFrom(extensions.next(), allFieldsList);
}
getExtensionsDescriptorsStream().flatMap(descriptor -> Arrays.stream(descriptor.getAllFields()))
.forEach(field -> allFieldsList.add(field));

return allFieldsList.toArray(new MarkerField[allFieldsList.size()]);
}

private void addMarkerFieldsFrom(IConfigurationElement extensionElement, List<MarkerField> markerFields) {
String extendingMarkerContentGeneratorId = extensionElement
.getAttribute(MarkerSupportInternalUtilities.ATTRIBUTE_ID);
if (extendingMarkerContentGeneratorId != null && !extendingMarkerContentGeneratorId.isBlank()) {
ContentGeneratorDescriptor descriptor = MarkerSupportRegistry.getInstance()
.getContentGenDescriptor(extendingMarkerContentGeneratorId);
if (descriptor != null) {
Arrays.stream(descriptor.getAllFields()).forEach(field -> markerFields.add(field));
}
private Stream<ContentGeneratorDescriptor> getExtensionsDescriptorsStream() {
if (generatorExtensions != null) {
final MarkerSupportRegistry registry = MarkerSupportRegistry.getInstance();

return generatorExtensions.stream()
.map(extensionConfigElem -> extensionConfigElem
.getAttribute(MarkerSupportInternalUtilities.ATTRIBUTE_ID))
.filter(id -> id != null && !id.isBlank())
.map(contentGeneratorId -> registry.getContentGenDescriptor(contentGeneratorId))
.filter(generator -> generator != null);
}
return Stream.empty();
}

/**
Expand Down

0 comments on commit 348eeb2

Please sign in to comment.