Exemplo n.º 1
0
  @SuppressWarnings({"HardCodedStringLiteral"})
  private static JVMName getJVMSignature(
      @Nullable PsiMethod method, boolean constructor, @Nullable PsiClass declaringClass) {
    JVMNameBuffer signature = new JVMNameBuffer();
    signature.append("(");

    if (constructor) {
      if (declaringClass != null) {
        final PsiClass outerClass = declaringClass.getContainingClass();
        if (outerClass != null) {
          // declaring class is an inner class
          if (!declaringClass.hasModifierProperty(PsiModifier.STATIC)) {
            appendJvmClassQualifiedName(signature, getJVMQualifiedName(outerClass));
          }
        }
      }
    }
    if (method != null) {
      for (PsiParameter psiParameter : method.getParameterList().getParameters()) {
        appendJVMSignature(signature, psiParameter.getType());
      }
    }
    signature.append(")");
    if (!constructor && method != null) {
      appendJVMSignature(signature, method.getReturnType());
    } else {
      signature.append(new JVMRawText("V"));
    }
    return signature.toName();
  }
Exemplo n.º 2
0
  public static JVMName getJVMQualifiedName(PsiType psiType) {
    if (psiType instanceof PsiArrayType) {
      final PsiArrayType arrayType = (PsiArrayType) psiType;
      JVMName jvmName = getJVMQualifiedName(arrayType.getComponentType());
      JVMNameBuffer buffer = new JVMNameBuffer();
      buffer.append(jvmName);
      buffer.append("[]");
      return buffer.toName();
    }

    PsiClass psiClass = PsiUtil.resolveClassInType(psiType);
    if (psiClass == null) {
      return getJVMRawText(psiType.getCanonicalText());
    } else {
      return getJVMQualifiedName(psiClass);
    }
  }
Exemplo n.º 3
0
  private static void appendJvmClassQualifiedName(JVMNameBuffer buffer, final JVMName jvmName) {
    buffer.append("L");
    if (jvmName instanceof JVMRawText) {
      buffer.append(((JVMRawText) jvmName).getName().replace('.', '/'));
    } else {
      buffer.append(
          new JVMName() {
            public String getName(DebugProcessImpl process) throws EvaluateException {
              return jvmName.getName(process).replace('.', '/');
            }

            public String getDisplayName(DebugProcessImpl debugProcess) {
              return jvmName.getDisplayName(debugProcess);
            }
          });
    }
    buffer.append(";");
  }
Exemplo n.º 4
0
 @SuppressWarnings({"HardCodedStringLiteral"})
 private static void appendJVMSignature(JVMNameBuffer buffer, PsiType type) {
   if (type == null) {
     return;
   }
   final PsiType psiType = TypeConversionUtil.erasure(type);
   if (psiType instanceof PsiArrayType) {
     buffer.append(new JVMRawText("["));
     appendJVMSignature(buffer, ((PsiArrayType) psiType).getComponentType());
   } else if (psiType instanceof PsiClassType) {
     final JVMName jvmName = getJVMQualifiedName(psiType);
     appendJvmClassQualifiedName(buffer, jvmName);
   } else if (psiType instanceof PsiPrimitiveType) {
     buffer.append(getPrimitiveSignature(psiType.getCanonicalText()));
   } else {
     LOG.error("unknown type " + type.getCanonicalText());
   }
 }