private static Pair<String, String> getTypeAndDescription(
      @Nullable final String docString, @NotNull final PyNamedParameter followed) {
    StructuredDocString structuredDocString = DocStringUtil.parse(docString);
    String type = null;
    String desc = null;
    if (structuredDocString != null) {
      final String name = followed.getName();
      type = structuredDocString.getParamType(name);

      desc = structuredDocString.getParamDescription(name);
    }

    return Pair.create(type, desc);
  }
Ejemplo n.º 2
0
 @Nullable
 private String extractReturnType() {
   final String ARROW = "->";
   final StructuredDocString structuredDocString = getStructuredDocString();
   if (structuredDocString != null) {
     return structuredDocString.getReturnType();
   }
   final String docString = getDocStringValue();
   if (docString != null && docString.contains(ARROW)) {
     final List<String> lines = StringUtil.split(docString, "\n");
     while (lines.size() > 0 && lines.get(0).trim().length() == 0) {
       lines.remove(0);
     }
     if (lines.size() > 1 && lines.get(1).trim().length() == 0) {
       String firstLine = lines.get(0);
       int pos = firstLine.lastIndexOf(ARROW);
       if (pos >= 0) {
         return firstLine.substring(pos + 2).trim();
       }
     }
   }
   return null;
 }