use of com.perl5.lang.perl.idea.presentations.PerlItemPresentationBase in project Perl5-IDEA by Camelcade.
the class PerlLightTestCase method serializeTree.
private void serializeTree(@NotNull StructureViewTreeElement currentElement, @NotNull StructureViewModel structureViewModel, @NotNull StringBuilder sb, @Nullable Collection<Pair<Grouper, Group>> groups, @NotNull String prefix, @NotNull Set<Object> recursionSet) {
Object value = currentElement.getValue();
ItemPresentation presentation = currentElement.getPresentation();
assertNotNull(presentation);
String locationString = presentation.getLocationString();
sb.append(prefix).append(presentation.getPresentableText()).append(" in ").append(locationString == null ? null : locationString.replaceAll("\\\\", "/")).append("; ").append(getIconText(presentation.getIcon(true)));
if (presentation instanceof PerlItemPresentationBase) {
sb.append("; ").append(((PerlItemPresentationBase) presentation).getTextAttributesKey());
}
if (value instanceof PsiElement) {
sb.append(" -> ").append(serializePsiElement((PsiElement) value));
}
sb.append("\n");
// filters
if (structureViewModel.getFilters().length > 0) {
List<String> passedFilters = new ArrayList<>();
for (Filter filter : structureViewModel.getFilters()) {
if (filter.isVisible(currentElement)) {
passedFilters.add(filter.getName());
}
}
if (!passedFilters.isEmpty()) {
sb.append(prefix).append("Passed by filters: ").append(StringUtil.join(passedFilters, ", ")).append("\n");
}
}
// groups
if (groups != null) {
for (Pair<Grouper, Group> groupPair : groups) {
Grouper grouper = groupPair.first;
Group group = groupPair.second;
ItemPresentation groupPresentation = group.getPresentation();
sb.append(prefix).append("Grouped by: '").append(grouper.getPresentation().getText()).append("' (").append(grouper.getName()).append(") to ").append(groupPresentation.getPresentableText()).append(" in ").append(groupPresentation.getLocationString()).append("\n");
}
}
if (recursionSet.add(value)) {
sb.append("\n");
TreeElement[] children = currentElement.getChildren();
MultiMap<TreeElement, Pair<Grouper, Group>> groupingResults = new MultiMap<>();
for (Grouper grouper : structureViewModel.getGroupers()) {
for (Group group : grouper.group(new TreeElementWrapper(getProject(), currentElement, structureViewModel), Arrays.asList(children))) {
for (TreeElement element : group.getChildren()) {
groupingResults.putValue(element, Pair.create(grouper, group));
}
}
}
for (TreeElement childElement : children) {
assertInstanceOf(childElement, StructureViewTreeElement.class);
serializeTree((StructureViewTreeElement) childElement, structureViewModel, sb, groupingResults.get(childElement), prefix + " ", new THashSet<>(recursionSet));
}
} else {
sb.append("(recursion)").append("\n\n");
}
}
use of com.perl5.lang.perl.idea.presentations.PerlItemPresentationBase in project Perl5-IDEA by Camelcade.
the class PerlStructureViewElement method getPresentation.
@NotNull
@Override
public ItemPresentation getPresentation() {
ItemPresentation itemPresentation = createPresentation();
if ((isInherited() || isImported()) && itemPresentation instanceof PerlItemPresentationBase) {
if (getValue() instanceof PerlDeprecatable && ((PerlDeprecatable) getValue()).isDeprecated()) {
((PerlItemPresentationBase) itemPresentation).setAttributesKey(PerlSyntaxHighlighter.UNUSED_DEPRECATED);
} else {
((PerlItemPresentationBase) itemPresentation).setAttributesKey(CodeInsightColors.NOT_USED_ELEMENT_ATTRIBUTES);
}
}
if (isImported() && itemPresentation instanceof PerlItemPresentationSimple) {
PerlExportDescriptor exportDescriptor = getExportDescriptor();
assert exportDescriptor != null;
((PerlItemPresentationSimple) itemPresentation).setPresentableText(exportDescriptor.getImportedName());
}
return itemPresentation;
}
Aggregations