Examples of IBinaryMethod


Examples of org.eclipse.jdt.internal.compiler.env.IBinaryMethod

  char[][] typeParams = Signature.getTypeParameters(dotBasedSignature);
  return CharOperation.toStrings(typeParams);
}

public String[] getRawParameterNames() throws JavaModelException {
  IBinaryMethod info = (IBinaryMethod) getElementInfo();
  int paramCount = Signature.getParameterCount(new String(info.getMethodDescriptor()));
  return getRawParameterNames(paramCount);
}
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.env.IBinaryMethod

/*
* @see IMethod
*/
public String getReturnType() throws JavaModelException {
  if (this.returnType == null) {
    IBinaryMethod info = (IBinaryMethod) getElementInfo();
    this.returnType = getReturnType(info);
  }
  return this.returnType;
}
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.env.IBinaryMethod

}
/*
* @see IMethod
*/
public String getSignature() throws JavaModelException {
  IBinaryMethod info = (IBinaryMethod) getElementInfo();
  return new String(info.getMethodDescriptor());
}
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.env.IBinaryMethod

public boolean isConstructor() throws JavaModelException {
  if (!getElementName().equals(this.parent.getElementName())) {
    // faster than reaching the info
    return false;
  }
  IBinaryMethod info = (IBinaryMethod) getElementInfo();
  return info.isConstructor();
}
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.env.IBinaryMethod

    toStringName(buffer);
    buffer.append(" (not open)"); //$NON-NLS-1$
  } else if (info == NO_INFO) {
    toStringName(buffer);
  } else {
    IBinaryMethod methodInfo = (IBinaryMethod) info;
    int flags = methodInfo.getModifiers();
    if (Flags.isStatic(flags)) {
      buffer.append("static "); //$NON-NLS-1$
    }
    if (!methodInfo.isConstructor()) {
      buffer.append(Signature.toString(getReturnType(methodInfo)));
      buffer.append(' ');
    }
    toStringName(buffer, flags);
  }
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.env.IBinaryMethod

  IBinaryMethod[] methods = typeInfo.getMethods();
  if (methods == null) {
    return;
  }
  for (int i = 0, methodCount = methods.length; i < methodCount; i++) {
    IBinaryMethod methodInfo = methods[i];
    // TODO (jerome) filter out synthetic members
    //                        indexer should not index them as well
    // if ((methodInfo.getModifiers() & IConstants.AccSynthetic) != 0) continue; // skip synthetic
    boolean useGenericSignature = true;
    char[] signature = methodInfo.getGenericSignature();
    if (signature == null) {
      useGenericSignature = false;
      signature = methodInfo.getMethodDescriptor();
    }
    String selector = new String(methodInfo.getSelector());
    final boolean isConstructor = methodInfo.isConstructor();
    if (isConstructor) {
      selector = type.getElementName();
    }
    String[] pNames = null;
    try {
      pNames = Signature.getParameterTypes(new String(signature));
      if (isConstructor
          && useGenericSignature
          && type.isMember()
          && !Flags.isStatic(type.getFlags())) {
        int length = pNames.length;
        System.arraycopy(pNames, 0, (pNames = new String[length + 1]), 1, length);
        char[] descriptor = methodInfo.getMethodDescriptor();
        final String[] parameterTypes = Signature.getParameterTypes(new String(descriptor));
        pNames[0] = parameterTypes[0];
      }
    } catch (IllegalArgumentException e) {
      // protect against malformed .class file (e.g. com/sun/crypto/provider/SunJCE_b.class has a 'a' generic signature)
      signature = methodInfo.getMethodDescriptor();
      pNames = Signature.getParameterTypes(new String(signature));
    } catch (JavaModelException e) {
      // protect against malformed .class file (e.g. com/sun/crypto/provider/SunJCE_b.class has a 'a' generic signature)
      signature = methodInfo.getMethodDescriptor();
      pNames = Signature.getParameterTypes(new String(signature));
    }
    char[][] paramNames= new char[pNames.length][];
    for (int j= 0; j < pNames.length; j++) {
      paramNames[j]= pNames[j].toCharArray();
    }
    char[][] parameterTypes = ClassFile.translatedNames(paramNames);
    JavaModelManager manager = JavaModelManager.getJavaModelManager();
    selector =  manager.intern(selector);
    for (int j= 0; j < pNames.length; j++) {
      pNames[j]= manager.intern(new String(parameterTypes[j]));
    }
    BinaryMethod method = new BinaryMethod((JavaElement)type, selector, pNames);
    childrenHandles.add(method);

    // ensure that 2 binary methods with the same signature but with different return types have different occurrence counts.
    // (case of bridge methods in 1.5)
    while (newElements.containsKey(method))
      method.occurrenceCount++;

    newElements.put(method, methodInfo);

    int max = pNames.length;
    char[][] argumentNames = methodInfo.getArgumentNames();
    if (argumentNames == null || argumentNames.length < max) {
      argumentNames = new char[max][];
      for (int j = 0; j < max; j++) {
        argumentNames[j] = ("arg" + j).toCharArray(); //$NON-NLS-1$
      }
    }
    for (int j = 0; j < max; j++) {
      IBinaryAnnotation[] parameterAnnotations = methodInfo.getParameterAnnotations(j);
      if (parameterAnnotations != null) {
        LocalVariable localVariable = new LocalVariable(
            method,
            new String(argumentNames[j]),
            0,
            -1,
            0,
            -1,
            method.parameterTypes[j],
            null,
            -1,
            true);
        generateAnnotationsInfos(localVariable, argumentNames[j], parameterAnnotations, methodInfo.getTagBits(), newElements);
      }
    }
    generateTypeParameterInfos(method, signature, newElements, typeParameterHandles);
    generateAnnotationsInfos(method, methodInfo.getAnnotations(), methodInfo.getTagBits(), newElements);
    Object defaultValue = methodInfo.getDefaultValue();
    if (defaultValue instanceof IBinaryAnnotation) {
      generateAnnotationInfo(method, newElements, (IBinaryAnnotation) defaultValue, new String(methodInfo.getSelector()));
    }
  }
}
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.env.IBinaryMethod

                parameters = paramNames;
              }
            }
          }
        } else {
          IBinaryMethod info = (IBinaryMethod) ((JavaElement)method).getElementInfo();
          char[][] argumentNames = info.getArgumentNames();
          if (argumentNames != null && argumentNames.length == length) {
            parameters = argumentNames;
            return parameters;
          }
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.env.IBinaryMethod

   
    String methodName = method.getElementName();
    if (method.isConstructor()) {
      methodName = typeQualifiedName;
    }
    IBinaryMethod info = (IBinaryMethod) method.getElementInfo();

    char[] genericSignature = info.getGenericSignature();
    String anchor = null;
    if (genericSignature != null) {
      genericSignature = CharOperation.replaceOnCopy(genericSignature, '/', '.');
      anchor = Util.toAnchor(0, genericSignature, methodName, Flags.isVarargs(method.getFlags()));
      if (anchor == null) throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.UNKNOWN_JAVADOC_FORMAT, method));
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.env.IBinaryMethod

public boolean equals(Object o) {
  if (!(o instanceof BinaryMethod)) return false;
  return super.equals(o) && Util.equalArraysOrNull(getErasedParameterTypes(), ((BinaryMethod)o).getErasedParameterTypes());
}
public IAnnotation[] getAnnotations() throws JavaModelException {
  IBinaryMethod info = (IBinaryMethod) getElementInfo();
  IBinaryAnnotation[] binaryAnnotations = info.getAnnotations();
  return getAnnotations(binaryAnnotations, info.getTagBits());
}
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.env.IBinaryMethod

  IBinaryMethod info = (IBinaryMethod) getElementInfo();
  IBinaryAnnotation[] binaryAnnotations = info.getAnnotations();
  return getAnnotations(binaryAnnotations, info.getTagBits());
}
public ILocalVariable[] getParameters() throws JavaModelException {
  IBinaryMethod info = (IBinaryMethod) getElementInfo();
  int length = this.parameterTypes.length;
  if (length == 0) {
    return LocalVariable.NO_LOCAL_VARIABLES;
  }
  ILocalVariable[] localVariables = new ILocalVariable[length];
  char[][] argumentNames = info.getArgumentNames();
  if (argumentNames == null || argumentNames.length < length) {
    argumentNames = new char[length][];
    for (int j = 0; j < length; j++) {
      argumentNames[j] = ("arg" + j).toCharArray(); //$NON-NLS-1$
    }
  }
  int startIndex = 0;
  try {
    if (isConstructor()) {
      IType declaringType = this.getDeclaringType();
      if (declaringType.isEnum()) {
        startIndex = 2;
      } else if (declaringType.isMember()
          && !Flags.isStatic(declaringType.getFlags())) {
        startIndex = 1;
      }
    }
  } catch(JavaModelException e) {
    // ignore
  }
  for (int i= 0; i < length; i++) {
    if (i < startIndex) {
      LocalVariable localVariable = new LocalVariable(
          this,
          new String(argumentNames[i]),
          0,
          -1,
          0,
          -1,
          this.parameterTypes[i],
          null,
          -1,
          true);
      localVariables[i] = localVariable;
      localVariable.annotations = Annotation.NO_ANNOTATIONS;
    } else {
      LocalVariable localVariable = new LocalVariable(
          this,
          new String(argumentNames[i]),
          0,
          -1,
          0,
          -1,
          this.parameterTypes[i],
          null,
          -1,
          true);
      localVariables[i] = localVariable;
      IAnnotation[] annotations = getAnnotations(localVariable, info.getParameterAnnotations(i - startIndex));
      localVariable.annotations = annotations;
    }
  }
  return localVariables;
}
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.