コード例 #1
0
  private static void appendClassSignature(final StringBuilder builder, final DartClass dartClass) {
    if (dartClass.isEnum()) {
      builder.append("enum <b>").append(dartClass.getName()).append("</b>");
      return;
    }

    if (dartClass.isAbstract()) {
      builder.append("abstract ");
    }

    builder.append("class <b>").append(dartClass.getName()).append("</b>");
    appendTypeParams(builder, dartClass.getTypeParameters());

    final List<DartType> mixins = dartClass.getMixinsList();
    final DartType superClass = dartClass.getSuperClass();
    if (superClass != null) {
      builder.append(" extends ").append(StringUtil.escapeXml(superClass.getText()));
    }

    if (!mixins.isEmpty()) {
      builder.append(" with ");
      appendDartTypeList(builder, mixins);
    }

    final List<DartType> implementsList = dartClass.getImplementsList();
    if (!implementsList.isEmpty()) {
      builder.append(" implements ");
      appendDartTypeList(builder, implementsList);
    }
  }
コード例 #2
0
 private static void appendVariableSignature(
     final StringBuilder builder, final DartComponent component, final DartType type) {
   if (type == null) {
     builder.append("var ");
   } else {
     builder.append(type.getReferenceExpression().getText());
     appendTypeArguments(builder, type);
     builder.append(" ");
   }
   builder.append("<b>").append(component.getName()).append("</b>");
 }
コード例 #3
0
 private static void appendTypeArguments(
     final @NotNull StringBuilder builder, final @NotNull DartType type) {
   final DartTypeArguments typeArguments = type.getTypeArguments();
   if (typeArguments != null) {
     final DartTypeList typeList = typeArguments.getTypeList();
     final List<DartType> children = typeList.getTypeList();
     if (!children.isEmpty()) {
       builder.append("&lt;");
       for (Iterator<DartType> iter = children.iterator(); iter.hasNext(); ) {
         DartType child = iter.next();
         builder.append(child.getFirstChild().getText());
         appendTypeArguments(builder, child);
         if (iter.hasNext()) {
           builder.append(", ");
         }
       }
       builder.append("&gt;");
     }
   }
 }
コード例 #4
0
  @Override
  public void showParameterInfo(@NotNull PsiElement element, CreateParameterInfoContext context) {
    DartFunctionDescription functionDescription = null;
    if (element instanceof DartCallExpression) {
      functionDescription = DartFunctionDescription.tryGetDescription((DartCallExpression) element);
    } else if (element instanceof DartNewExpression) {
      final DartNewExpression newExpression = (DartNewExpression) element;
      final DartType type = newExpression.getType();
      final DartClassResolveResult classResolveResult = DartResolveUtil.resolveClassByType(type);
      PsiElement psiElement = ((DartNewExpression) element).getReferenceExpression();
      psiElement = psiElement == null && type != null ? type.getReferenceExpression() : psiElement;
      final PsiElement target = psiElement != null ? ((DartReference) psiElement).resolve() : null;
      if (target instanceof DartComponentName) {
        functionDescription =
            DartFunctionDescription.createDescription(
                (DartComponent) target.getParent(), classResolveResult);
      }
    }

    if (functionDescription != null && functionDescription.getParameters().length > 0) {
      context.setItemsToShow(new Object[] {functionDescription});
      context.showHint(element, element.getTextRange().getStartOffset(), this);
    }
  }