use of com.jetbrains.lang.dart.psi.DartComponent in project intellij-plugins by JetBrains.
the class CreateToStringFix method buildFunctionsText.
protected Template buildFunctionsText(TemplateManager templateManager, Set<DartComponent> elementsToProcess) {
final Template template = templateManager.createTemplate(getClass().getName(), DART_TEMPLATE_GROUP);
template.setToReformat(true);
if (CodeStyleSettingsManager.getSettings(myDartClass.getProject()).INSERT_OVERRIDE_ANNOTATION) {
template.addTextSegment("@override\n");
}
template.addTextSegment("String toString() {");
template.addTextSegment(DartTokenTypes.RETURN.toString());
template.addTextSegment(" ");
template.addTextSegment("'");
//noinspection ConstantConditions
template.addTextSegment(myDartClass.getName());
template.addTextSegment("{");
for (Iterator<DartComponent> iterator = elementsToProcess.iterator(); iterator.hasNext(); ) {
DartComponent component = iterator.next();
//noinspection ConstantConditions
template.addTextSegment(component.getName());
template.addTextSegment(": $");
//noinspection ConstantConditions
template.addTextSegment(component.getName());
if (iterator.hasNext()) {
template.addTextSegment(", ");
}
}
template.addTextSegment("}';\n");
template.addTextSegment("}");
template.addEndVariable();
// trailing space is removed when auto-reformatting, but it helps to enter line break if needed
template.addTextSegment(" ");
return template;
}
use of com.jetbrains.lang.dart.psi.DartComponent in project intellij-plugins by JetBrains.
the class DartImplementMethodHandler method collectCandidates.
@Override
protected void collectCandidates(@NotNull final DartClass dartClass, @NotNull final List<DartComponent> candidates) {
Map<Pair<String, Boolean>, DartComponent> result = new THashMap<>(computeSuperInterfacesMembersMap(dartClass));
Map<Pair<String, Boolean>, DartComponent> superClassesMemberMap = new THashMap<>(computeSuperClassesMemberMap(dartClass));
result.keySet().removeAll(superClassesMemberMap.keySet());
for (Map.Entry<Pair<String, Boolean>, DartComponent> entry : superClassesMemberMap.entrySet()) {
final DartComponent component = entry.getValue();
if (component.isAbstract() && !result.containsKey(entry.getKey())) {
result.put(entry.getKey(), entry.getValue());
}
}
result.keySet().removeAll(computeClassMembersMap(dartClass, false).keySet());
candidates.addAll(ContainerUtil.findAll(result.values(), component -> component.isPublic() || DartResolveUtil.sameLibrary(dartClass, component)));
}
use of com.jetbrains.lang.dart.psi.DartComponent in project intellij-plugins by JetBrains.
the class BaseDartGenerateHandler method computeSuperClassesMemberMap.
@NotNull
protected final Map<Pair<String, Boolean>, DartComponent> computeSuperClassesMemberMap(@NotNull final DartClass dartClass) {
final List<DartClass> superClasses = new ArrayList<>();
final List<DartClass> superInterfaces = new ArrayList<>();
DartResolveUtil.collectSupers(superClasses, superInterfaces, dartClass);
List<DartComponent> superClassesMembers = new ArrayList<>();
for (DartClass superClass : superClasses) {
superClassesMembers.addAll(DartResolveUtil.getNamedSubComponents(superClass));
}
superClassesMembers = ContainerUtil.filter(superClassesMembers, NOT_CONSTRUCTOR_CONDITION);
superClassesMembers = ContainerUtil.filter(superClassesMembers, NOT_STATIC_CONDITION);
return DartResolveUtil.namedComponentToMap(superClassesMembers);
}
use of com.jetbrains.lang.dart.psi.DartComponent in project intellij-plugins by JetBrains.
the class BaseDartGenerateHandler method computeSuperInterfacesMembersMap.
@NotNull
protected final Map<Pair<String, Boolean>, DartComponent> computeSuperInterfacesMembersMap(@NotNull final DartClass dartClass) {
final List<DartClass> superClasses = new ArrayList<>();
final List<DartClass> superInterfaces = new ArrayList<>();
DartResolveUtil.collectSupers(superClasses, superInterfaces, dartClass);
List<DartComponent> superInterfacesMembers = new ArrayList<>();
for (DartClass superInterface : superInterfaces) {
superInterfacesMembers.addAll(DartResolveUtil.getNamedSubComponents(superInterface));
}
superInterfacesMembers = ContainerUtil.filter(superInterfacesMembers, NOT_CONSTRUCTOR_CONDITION);
superInterfacesMembers = ContainerUtil.filter(superInterfacesMembers, NOT_STATIC_CONDITION);
return DartResolveUtil.namedComponentToMap(superInterfacesMembers);
}
Aggregations