Package com.jetbrains.lang.dart.psi

Examples of com.jetbrains.lang.dart.psi.DartComponent


                                   Map<Pair<String, Boolean>, DartComponent> superInterfacesMembersMap,
                                   List<DartComponent> candidates) {
    Map<Pair<String, Boolean>, DartComponent> result = new THashMap<Pair<String, Boolean>, DartComponent>(superInterfacesMembersMap);
    result.keySet().removeAll(superClassesMembersMap.keySet());
    for (Map.Entry<Pair<String, Boolean>, DartComponent> entry : superClassesMembersMap.entrySet()) {
      final DartComponent component = entry.getValue();
      if (component.isAbstract() && !result.containsKey(entry.getKey())) {
        result.put(entry.getKey(), entry.getValue());
      }
    }
    result.keySet().removeAll(classMembersMap.keySet());
    candidates.addAll(result.values());
View Full Code Here


    //noinspection ConstantConditions
    template.addTextSegment(myDartClass.getName());
    template.addTextSegment("(");
    for (Iterator<DartComponent> iterator = elementsToProcess.iterator(); iterator.hasNext(); ) {
      DartComponent component = iterator.next();
      template.addTextSegment("this.");
      //noinspection ConstantConditions
      template.addTextSegment(component.getName());
      if (iterator.hasNext()) {
        template.addTextSegment(",");
      }
    }
    template.addTextSegment(")");
View Full Code Here

    @Override
    public boolean execute(@NotNull final PsiElement queryParameters, @NotNull final Processor<PsiElement> consumer) {
      return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
        public Boolean compute() {
          final PsiElement queryParametersParent = queryParameters.getParent();
          DartComponent dartComponent;
          if (queryParameters instanceof DartClass) {
            dartComponent = (DartClass)queryParameters;
          }
          else if (queryParametersParent instanceof DartComponent && queryParameters instanceof DartComponentName) {
            dartComponent = (DartComponent)queryParametersParent;
          }
          else {
            return true;
          }
          if (dartComponent instanceof DartClass) {
            processInheritors((DartClass)dartComponent, queryParameters, consumer);
          }
          else if (DartComponentType.typeOf(dartComponent) == DartComponentType.METHOD) {
            final String nameToFind = dartComponent.getName();
            if (nameToFind == null) return true;

            DartClass dartClass = PsiTreeUtil.getParentOfType(dartComponent, DartClass.class);
            assert dartClass != null;
View Full Code Here

    });
    if (filteredSuperItems.isEmpty()) {
      return null;
    }
    final PsiElement element = methodDeclaration.getComponentName();
    final DartComponent dartComponent = filteredSuperItems.iterator().next();
    final boolean overrides = !dartComponent.isAbstract();
    final Icon icon = overrides ? AllIcons.Gutter.OverridingMethod : AllIcons.Gutter.ImplementingMethod;
    assert element != null;
    return new LineMarkerInfo<PsiElement>(
      element,
      element.getTextRange(),
View Full Code Here

  public PsiElement substituteElementToRename(@NotNull final PsiElement element,
                                              @NotNull Editor editor) {
    final PsiElement parent = element.getParent();
    if (parent instanceof DartComponent && DartComponentType.typeOf(parent) == DartComponentType.METHOD) {
      final DartClass dartClass = PsiTreeUtil.getParentOfType(parent, DartClass.class, true);
      final DartComponent superMethod = ContainerUtil.find(
        DartResolveUtil.findNamedSuperComponents(dartClass),
        new Condition<DartComponent>() {
          @Override
          public boolean value(DartComponent component) {
            return StringUtil.equals(component.getName(), ((DartComponent)parent).getName());
          }
        }
      );
      if (superMethod != null) {
        return superMethod.getComponentName();
      }
    }
    return element;
  }
View Full Code Here

  @Override
  public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
    final PsiElement at = file.findElementAt(editor.getCaretModel().getOffset());

    final DartComponent component = PsiTreeUtil.getParentOfType(at, DartComponent.class);
    final DartClass dartClass = PsiTreeUtil.getParentOfType(at, DartClass.class);
    if (at == null || dartClass == null || component == null) return;

    final List<DartClass> supers = new ArrayList<DartClass>();
    final DartType superClass = dartClass.getSuperClass();
    // looks like there's no sense in jumping to Object class
    if (superClass != null && !DartResolveUtil.OBJECT.equals(superClass.getReferenceExpression().getText())) {
      final DartClassResolveResult dartClassResolveResult = DartResolveUtil.resolveClassByType(superClass);
      if (dartClassResolveResult.getDartClass() != null) {
        supers.add(dartClassResolveResult.getDartClass());
      }
    }

    List<DartClassResolveResult> implementsAndMixinsList =
      DartResolveUtil.resolveClassesByTypes(DartResolveUtil.getImplementsAndMixinsList(dartClass));
    for (DartClassResolveResult resolveResult : implementsAndMixinsList) {
      final DartClass resolveResultDartClass = resolveResult.getDartClass();
      if (resolveResultDartClass != null) {
        supers.add(resolveResultDartClass);
      }
    }
    final List<DartComponent> superItems = DartResolveUtil.findNamedSubComponents(false, supers.toArray(new DartClass[supers.size()]));

    final DartComponentType type = DartComponentType.typeOf(component);
    if (type == DartComponentType.METHOD) {
      tryNavigateToSuperMethod(editor, component, superItems);
    }
    else if (!supers.isEmpty() && component instanceof DartClass) {
      PsiElementListNavigator.openTargets(
        editor,
        DartResolveUtil.getComponentNames(supers).toArray(new NavigatablePsiElement[supers.size()]),
        DaemonBundle.message("navigation.title.subclass", component.getName(), supers.size()),
        "Subclasses of " + component.getName(),
        new DefaultPsiElementCellRenderer()
      );
    }
  }
View Full Code Here

  }

  @Nullable
  @Override
  public MemberChooserObject getParentNodeDelegate() {
    final DartComponent result = PsiTreeUtil.getParentOfType(getPsiElement(), DartComponent.class);
    return result == null ? null : new DartNamedElementNode(result);
  }
View Full Code Here

  @Nullable
  public List<String> getUrlFor(PsiElement element, PsiElement originalElement) {
    if (!(element instanceof DartComponent) && !(element.getParent() instanceof DartComponent)) {
      return null;
    }
    final DartComponent namedComponent = (DartComponent)(element instanceof DartComponent ? element : element.getParent());
    final String componentName = namedComponent.getName();
    if (componentName == null || !namedComponent.isPublic()) {
      return null;
    }

    final String docUrl = constructDocUrl(namedComponent, componentName, DartResolveUtil.getLibraryName(element.getContainingFile()));
    return docUrl == null ? null : Collections.singletonList(docUrl);
View Full Code Here

    return new DartGenericSpecialization(result);
  }

  public static String getGenericKey(@Nullable PsiElement element, @NotNull String genericName) {
    final StringBuilder result = new StringBuilder();
    final DartComponent dartComponent = PsiTreeUtil.getParentOfType(element, DartComponent.class, false);
    if (dartComponent instanceof DartClass) {
      result.append(dartComponent.getName());
    }
    else if (dartComponent != null) {
      DartClass dartClass = PsiTreeUtil.getParentOfType(dartComponent, DartClass.class);
      if (dartClass != null) {
        result.append(dartClass.getName());
      }
      if (PsiTreeUtil.getChildOfType(dartComponent, DartTypeArguments.class) != null) {
        // generic method
        result.append(":");
        result.append(dartComponent.getName());
      }
    }
    if (result.length() > 0) {
      result.append("-");
    }
View Full Code Here

      result.add(new CreateDartClassAction(name));
    }

    // alone. not class.
    if (DartResolveUtil.aloneOrFirstInChain(reference) && !StringUtil.isCapitalized(name)) {
      final DartComponent parentComponent = PsiTreeUtil.getParentOfType(reference, DartComponent.class);
      if (reference.getParent() instanceof DartCallExpression) {
        result.add(new CreateGlobalDartFunctionAction(name));
        if (PsiTreeUtil.getParentOfType(reference, DartClass.class) != null) {
          result.add(new CreateDartMethodAction(name, parentComponent != null && parentComponent.isStatic()));
        }
      }
      else {
        result.add(new CreateDartGetterSetterAction(name, !isLValue, parentComponent != null && parentComponent.isStatic()));
        result.add(new CreateGlobalDartGetterSetterAction(name, !isLValue));
        result.add(new CreateFieldAction(name, parentComponent != null && parentComponent.isStatic()));
        result.add(new CreateGlobalVariableAction(name));
        result.add(new CreateLocalVariableAction(name));
      }
    }
View Full Code Here

TOP

Related Classes of com.jetbrains.lang.dart.psi.DartComponent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.