Examples of IBinaryMethod


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

/*
* @see IMethod
*/
public String[] getExceptionTypes() throws JavaModelException {
  if (this.exceptionTypes == null) {
    IBinaryMethod info = (IBinaryMethod) getElementInfo();
    char[] genericSignature = info.getGenericSignature();
    if (genericSignature != null) {
      char[] dotBasedSignature = CharOperation.replaceOnCopy(genericSignature, '/', '.');
      this.exceptionTypes = Signature.getThrownExceptionTypes(new String(dotBasedSignature));
    }
    if (this.exceptionTypes == null || this.exceptionTypes.length == 0) {
      char[][] eTypeNames = info.getExceptionTypeNames();
      if (eTypeNames == null || eTypeNames.length == 0) {
        this.exceptionTypes = CharOperation.NO_STRINGS;
      } else {
        eTypeNames = ClassFile.translatedNames(eTypeNames);
        this.exceptionTypes = new String[eTypeNames.length];
View Full Code Here

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

}
/*
* @see IMember
*/
public int getFlags() throws JavaModelException {
  IBinaryMethod info = (IBinaryMethod) getElementInfo();
  return info.getModifiers();
}
View Full Code Here

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

      return this.parameterNames;
    }
  }
 
  // try to see if we can retrieve the names from the attached javadoc
  IBinaryMethod info = (IBinaryMethod) getElementInfo();
  final int paramCount = Signature.getParameterCount(new String(info.getMethodDescriptor()));
  if (paramCount != 0) {
    // don't try to look for javadoc for synthetic methods
    int modifiers = this.getFlags();
    if ((modifiers & ClassFileConstants.AccSynthetic) != 0) {
      return this.parameterNames = getRawParameterNames(paramCount);
    }
    String javadocContents = null;
    IType declaringType = this.getDeclaringType();
    PerProjectInfo projectInfo = JavaModelManager.getJavaModelManager().getPerProjectInfoCheckExistence(this.getJavaProject().getProject());
    synchronized (projectInfo.javadocCache) {
      javadocContents = (String) projectInfo.javadocCache.get(declaringType);
      if (javadocContents == null) {
        projectInfo.javadocCache.put(declaringType, BinaryType.EMPTY_JAVADOC);
      }
    }
    if (javadocContents == null) {
      long timeOut = 50; // default value
      try {
        String option = this.getJavaProject().getOption(JavaCore.TIMEOUT_FOR_PARAMETER_NAME_FROM_ATTACHED_JAVADOC, true);
        if (option != null) {
          timeOut = Long.parseLong(option);
        }
      } catch(NumberFormatException e) {
        // ignore
      }
      if (timeOut == 0) {
        // don't try to fetch the values
        return this.parameterNames = getRawParameterNames(paramCount);
      }
      final class ParametersNameCollector {
        String javadoc;
        public void setJavadoc(String s) {
          this.javadoc = s;
        }
        public String getJavadoc() {
          return this.javadoc;
        }
      }
      /*
       * The declaring type is not in the cache yet. The thread wil retrieve the javadoc contents
       */
      final ParametersNameCollector nameCollector = new ParametersNameCollector();
      Thread collect = new Thread() {
        public void run() {
          try {
            // this call has a side-effect on the per project info cache
            nameCollector.setJavadoc(BinaryMethod.this.getAttachedJavadoc(null));
          } catch (JavaModelException e) {
            // ignore
          }
          synchronized(nameCollector) {
            nameCollector.notify();
          }
        }
      };
      collect.start();
      synchronized(nameCollector) {
        try {
          nameCollector.wait(timeOut);
        } catch (InterruptedException e) {
          // ignore
        }
      }
      javadocContents = nameCollector.getJavadoc();
    } else if (javadocContents != BinaryType.EMPTY_JAVADOC){
      // need to extract the part relative to the binary method since javadoc contains the javadoc for the declaring type
      try {
        javadocContents = extractJavadoc(declaringType, javadocContents);
      } catch(JavaModelException e) {
        // ignore
      }
    } else {
      // let's see if we can retrieve them from the debug infos
      char[][] argumentNames = info.getArgumentNames();
      if (argumentNames != null && argumentNames.length == paramCount) {
        String[] names = new String[paramCount];
        for (int i = 0; i < paramCount; i++) {
          names[i] = new String(argumentNames[i]);
        }
        return this.parameterNames = names;
      }
      return getRawParameterNames(paramCount);
    }
    if (javadocContents != null && javadocContents != BinaryType.EMPTY_JAVADOC) {
      final int indexOfOpenParen = javadocContents.indexOf('(');
      if (indexOfOpenParen != -1) {
        final int indexOfClosingParen = javadocContents.indexOf(')', indexOfOpenParen);
        if (indexOfClosingParen != -1) {
          final char[] paramsSource =
            CharOperation.replace(
              javadocContents.substring(indexOfOpenParen + 1, indexOfClosingParen).toCharArray(),
              "&nbsp;".toCharArray(), //$NON-NLS-1$
              new char[] {' '});
          final char[][] params = splitParameters(paramsSource, paramCount);
          final int paramsLength = params.length;
          this.parameterNames = new String[paramsLength];
          for (int i = 0; i < paramsLength; i++) {
            final char[] param = params[i];
            int indexOfSpace = CharOperation.lastIndexOf(' ', param);
            if (indexOfSpace != -1) {
              this.parameterNames[i] = String.valueOf(param, indexOfSpace + 1, param.length - indexOfSpace -1);
            } else {
              this.parameterNames[i] = "arg" + i; //$NON-NLS-1$
            }
          }
          return this.parameterNames;
        }
      }
    }
    // let's see if we can retrieve them from the debug infos
    char[][] argumentNames = info.getArgumentNames();
    if (argumentNames != null && argumentNames.length == paramCount) {
      String[] names = new String[paramCount];
      for (int i = 0; i < paramCount; i++) {
        names[i] = new String(argumentNames[i]);
      }
View Full Code Here

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

* @see IMethod#getTypeParameterSignatures()
* @since 3.0
* @deprecated
*/
public String[] getTypeParameterSignatures() throws JavaModelException {
  IBinaryMethod info = (IBinaryMethod) getElementInfo();
  char[] genericSignature = info.getGenericSignature();
  if (genericSignature == null)
    return CharOperation.NO_STRINGS;
  char[] dotBasedSignature = CharOperation.replaceOnCopy(genericSignature, '/', '.');
  char[][] typeParams = Signature.getTypeParameters(dotBasedSignature);
  return CharOperation.toStrings(typeParams);
View Full Code Here

Examples of org.aspectj.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.aspectj.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.aspectj.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.aspectj.org.eclipse.jdt.internal.compiler.env.IBinaryMethod

public boolean isConstructor() throws JavaModelException {
  if (!this.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.aspectj.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.aspectj.org.eclipse.jdt.internal.compiler.env.IBinaryMethod

  }
  String methodName = this.getElementName();
  if (this.isConstructor()) {
    methodName = typeQualifiedName;
  }
  IBinaryMethod info = (IBinaryMethod) getElementInfo();
  char[] genericSignature = info.getGenericSignature();
  String anchor = null;
  if (genericSignature != null) {
    genericSignature = CharOperation.replaceOnCopy(genericSignature, '/', '.');
    anchor = Util.toAnchor(genericSignature, methodName, Flags.isVarargs(this.getFlags()));
    if (anchor == null) throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.UNKNOWN_JAVADOC_FORMAT, this));
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.