use of com.jetbrains.lang.dart.resolve.ComponentNameScopeProcessor in project intellij-plugins by JetBrains.
the class DartRefactoringUtil method collectUsedComponents.
public static Set<DartComponentName> collectUsedComponents(PsiElement context) {
final Set<DartComponentName> usedComponentNames = new THashSet<>();
PsiTreeUtil.treeWalkUp(new ComponentNameScopeProcessor(usedComponentNames), context, null, ResolveState.initial());
return usedComponentNames;
}
use of com.jetbrains.lang.dart.resolve.ComponentNameScopeProcessor in project intellij-plugins by JetBrains.
the class DartStructureViewElement method getChildrenBase.
@NotNull
@Override
public Collection<StructureViewTreeElement> getChildrenBase() {
final NavigatablePsiElement element = getElement();
final List<StructureViewTreeElement> result = new ArrayList<>();
if (element instanceof DartFile || element instanceof DartEmbeddedContent) {
THashSet<DartComponentName> componentNames = new THashSet<>();
DartPsiCompositeElementImpl.processDeclarationsImpl(element, new ComponentNameScopeProcessor(componentNames), ResolveState.initial(), null);
for (DartComponentName componentName : componentNames) {
PsiElement parent = componentName.getParent();
if (parent instanceof DartComponent) {
result.add(new DartStructureViewElement((DartComponent) parent));
}
}
} else if (element instanceof DartClass) {
for (DartComponent subNamedComponent : DartResolveUtil.getNamedSubComponents((DartClass) element)) {
result.add(new DartStructureViewElement(subNamedComponent));
}
}
Collections.sort(result, (o1, o2) -> {
PsiElement element1, element2;
if (o1 instanceof DartStructureViewElement && o2 instanceof DartStructureViewElement && (element1 = ((DartStructureViewElement) o1).getElement()) != null && (element2 = ((DartStructureViewElement) o2).getElement()) != null) {
return element1.getTextRange().getStartOffset() - element2.getTextRange().getStartOffset();
}
return 0;
});
return result;
}
Aggregations