use of org.dartlang.analysis.server.protocol.Element in project intellij-plugins by JetBrains.
the class FindElementReferencesProcessor method process.
public void process(JsonObject resultObject, RequestError requestError) {
if (resultObject != null) {
try {
String searchId = resultObject.has("id") ? resultObject.get("id").getAsString() : null;
Element element = resultObject.has("element") ? Element.fromJson(resultObject.get("element").getAsJsonObject()) : null;
consumer.computedElementReferences(searchId, element);
} catch (Exception exception) {
// catch any exceptions in the formatting of this response
requestError = generateRequestError(exception);
}
}
if (requestError != null) {
consumer.onError(requestError);
}
}
use of org.dartlang.analysis.server.protocol.Element in project intellij-plugins by JetBrains.
the class DartServerGotoSuperHandler method addSuperComponent.
private static void addSuperComponent(@NotNull Project project, List<DartComponent> supers, boolean isInClass, TypeHierarchyItem item) {
// prepare Element for the current item
final Element itemElement = isInClass ? item.getClassElement() : item.getMemberElement();
if (itemElement == null) {
return;
}
// ignore Object
if (ElementKind.CLASS.equals(itemElement.getKind()) && "Object".equals(itemElement.getName())) {
return;
}
// find the DartComponent
final Location itemLocation = itemElement.getLocation();
final DartComponent itemComponent = DartHierarchyUtil.findDartComponent(project, itemLocation);
if (itemComponent != null) {
supers.add(itemComponent);
}
}
use of org.dartlang.analysis.server.protocol.Element in project intellij-plugins by JetBrains.
the class DartInheritorsSearcher method addSubClasses.
private static void addSubClasses(@NotNull final Project project, @NotNull final SearchScope scope, @NotNull final Set<TypeHierarchyItem> visited, @NotNull final List<TypeHierarchyItem> hierarchyItems, @NotNull final List<DartComponent> components, @NotNull final TypeHierarchyItem currentItem, final boolean addItem) {
if (!visited.add(currentItem)) {
return;
}
if (addItem) {
final Element element = currentItem.getClassElement();
final Location location = element.getLocation();
final DartComponent component = DartHierarchyUtil.findDartComponent(project, location);
if (component != null && isInScope(scope, component)) {
components.add(component);
}
}
for (int subIndex : currentItem.getSubclasses()) {
final TypeHierarchyItem subItem = hierarchyItems.get(subIndex);
addSubClasses(project, scope, visited, hierarchyItems, components, subItem, true);
}
}
use of org.dartlang.analysis.server.protocol.Element in project intellij-plugins by JetBrains.
the class DartHierarchyUtil method findDartClass.
@Nullable
public static DartClass findDartClass(@NotNull final Project project, @NotNull final TypeHierarchyItem item) {
final Element classElement = item.getClassElement();
final Location location = classElement.getLocation();
final DartComponent component = findDartComponent(project, location);
return component instanceof DartClass ? (DartClass) component : null;
}
use of org.dartlang.analysis.server.protocol.Element in project intellij-plugins by JetBrains.
the class DartInheritorsSearcher method addSubMembers.
private static void addSubMembers(@NotNull final Project project, @NotNull final SearchScope scope, @NotNull final Set<TypeHierarchyItem> visited, @NotNull final List<TypeHierarchyItem> hierarchyItems, @NotNull final List<DartComponent> components, @NotNull final TypeHierarchyItem currentItem, final boolean addItem) {
if (!visited.add(currentItem)) {
return;
}
if (addItem) {
final Element element = currentItem.getMemberElement();
if (element != null) {
final Location location = element.getLocation();
final DartComponent component = DartHierarchyUtil.findDartComponent(project, location);
if (component != null && isInScope(scope, component)) {
components.add(component);
}
}
}
for (int subIndex : currentItem.getSubclasses()) {
final TypeHierarchyItem subItem = hierarchyItems.get(subIndex);
addSubMembers(project, scope, visited, hierarchyItems, components, subItem, true);
}
}
Aggregations