Search in sources :

Example 1 with Element

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);
    }
}
Also used : Element(org.dartlang.analysis.server.protocol.Element)

Example 2 with Element

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);
    }
}
Also used : DartComponent(com.jetbrains.lang.dart.psi.DartComponent) PsiElement(com.intellij.psi.PsiElement) Element(org.dartlang.analysis.server.protocol.Element) NavigatablePsiElement(com.intellij.psi.NavigatablePsiElement) Location(org.dartlang.analysis.server.protocol.Location)

Example 3 with Element

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);
    }
}
Also used : DartComponent(com.jetbrains.lang.dart.psi.DartComponent) PsiElement(com.intellij.psi.PsiElement) Element(org.dartlang.analysis.server.protocol.Element) TypeHierarchyItem(org.dartlang.analysis.server.protocol.TypeHierarchyItem) Location(org.dartlang.analysis.server.protocol.Location)

Example 4 with Element

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;
}
Also used : Element(org.dartlang.analysis.server.protocol.Element) Location(org.dartlang.analysis.server.protocol.Location) Nullable(org.jetbrains.annotations.Nullable)

Example 5 with Element

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);
    }
}
Also used : DartComponent(com.jetbrains.lang.dart.psi.DartComponent) PsiElement(com.intellij.psi.PsiElement) Element(org.dartlang.analysis.server.protocol.Element) TypeHierarchyItem(org.dartlang.analysis.server.protocol.TypeHierarchyItem) Location(org.dartlang.analysis.server.protocol.Location)

Aggregations

Element (org.dartlang.analysis.server.protocol.Element)5 Location (org.dartlang.analysis.server.protocol.Location)4 PsiElement (com.intellij.psi.PsiElement)3 DartComponent (com.jetbrains.lang.dart.psi.DartComponent)3 TypeHierarchyItem (org.dartlang.analysis.server.protocol.TypeHierarchyItem)2 NavigatablePsiElement (com.intellij.psi.NavigatablePsiElement)1 Nullable (org.jetbrains.annotations.Nullable)1