Beispiel #1
0
  /**
   * writeElement
   *
   * @param index
   * @param element
   */
  public void writeElement(Index index, ElementElement element, URI location) {
    String[] columns =
        new String[] { //
          element.getName(), //
          element.getDisplayName(), //
          StringUtil.join(XMLIndexConstants.SUB_DELIMITER, element.getAttributes()), //
          element.getDescription() //
        };
    String key = StringUtil.join(XMLIndexConstants.DELIMITER, columns);

    index.addEntry(this._keyProvider.getElementKey(), key, location);
  }
  /**
   * toSource
   *
   * @param printer
   */
  public void toSource(SourcePrinter printer) {
    printer.printIndent();

    // print any annotations
    if (!this.isInstanceProperty()) {
      printer.print("static "); // $NON-NLS-1$
    }
    if (this.isInternal()) {
      printer.print("internal "); // $NON-NLS-1$
    }
    if (this.isConstructor()) {
      printer.print("constructor "); // $NON-NLS-1$
    }
    if (this.isMethod()) {
      printer.print("method "); // $NON-NLS-1$
    }

    // print name
    printer.print(this.getName());

    // print parameter types
    printer
        .print('(')
        .print(StringUtil.join(JSTypeConstants.PARAMETER_DELIMITER, this.getParameterTypes()))
        .print(')');

    // print return types
    List<String> returnTypes = this.getReturnTypeNames();

    printer.print(JSTypeConstants.FUNCTION_SIGNATURE_DELIMITER);

    if (!CollectionsUtil.isEmpty(returnTypes)) {
      printer.print(StringUtil.join(JSTypeConstants.RETURN_TYPE_DELIMITER, returnTypes));
    } else {
      printer.print(JSTypeConstants.UNDEFINED_TYPE);
    }

    // print exceptions
    if (this.hasExceptions()) {
      printer
          .print(" throws ")
          .print(StringUtil.join(", ", this.getExceptionTypes())); // $NON-NLS-1$ //$NON-NLS-2$
    }
  }
Beispiel #3
0
  /**
   * writeAttribute
   *
   * @param index
   * @param attribute
   */
  public void writeAttribute(Index index, AttributeElement attribute, URI location) {
    String[] columns =
        new String[] { //
          attribute.getName(), //
          attribute.getElement(), //
          attribute.getDescription(), //
          "" // values //$NON-NLS-1$
        };
    String key = StringUtil.join(XMLIndexConstants.DELIMITER, columns);

    index.addEntry(this._keyProvider.getAttributeKey(), key, location);
  }
  /**
   * SuperTypeName(Simple)/SuperTypeNamespace/SimpleName/EnclosingTypeName/SuperIsClassOrModule(M|C)
   * isClassorModule(M|C)
   *
   * @param typeName
   * @param enclosingTypeNames
   * @param classOrModule
   * @param superTypeName
   * @param superClassOrModule
   * @return
   */
  private String createSuperTypeReferenceKey(
      String typeName,
      String[] enclosingTypeNames,
      char classOrModule,
      String superTypeName,
      char superClassOrModule) {
    if (superTypeName == null) {
      superTypeName = IRubyIndexConstants.OBJECT;
    }
    String superSimpleName = lastSegment(superTypeName, NAMESPACE_DELIMETER);
    char[] superQualification = null;
    if (!superTypeName.equals(superSimpleName)) {
      int length = superTypeName.length() - superSimpleName.length() - 1;
      superQualification = new char[length - 1];
      System.arraycopy(superTypeName.toCharArray(), 0, superQualification, 0, length - 1);
    }

    // if the supertype name contains a $, then split it into: source name and append the $
    // prefix to the qualification
    // e.g. p.A$B ---> p.A$ + B
    String superTypeSourceName = lastSegment(superSimpleName, NAMESPACE_DELIMETER);
    if (superSimpleName != null && !superSimpleName.equals(superTypeSourceName)) {
      int start = superQualification == null ? 0 : superQualification.length + 1;
      int prefixLength = superSimpleName.length() - superTypeSourceName.length();
      char[] mangledQualification = new char[start + prefixLength];
      if (superQualification != null) {
        System.arraycopy(superQualification, 0, mangledQualification, 0, start - 1);
        mangledQualification[start - 1] = '.';
      }
      System.arraycopy(superSimpleName.toCharArray(), 0, mangledQualification, start, prefixLength);
      superQualification = mangledQualification;
      superSimpleName = superTypeSourceName;
    }

    String simpleName = lastSegment(typeName, NAMESPACE_DELIMETER);
    String enclosingTypeName = StringUtil.join(NAMESPACE_DELIMETER, enclosingTypeNames);

    StringBuilder builder = new StringBuilder();
    builder.append(superSimpleName);
    builder.append(IRubyIndexConstants.SEPARATOR);
    if (superQualification != null) {
      builder.append(superQualification);
    }
    builder.append(IRubyIndexConstants.SEPARATOR);
    builder.append(simpleName);
    builder.append(IRubyIndexConstants.SEPARATOR);
    builder.append(enclosingTypeName);
    builder.append(IRubyIndexConstants.SEPARATOR);
    builder.append(superClassOrModule);
    builder.append(classOrModule);

    return builder.toString();
  }