Ejemplo n.º 1
0
  String getSourceLocation(IBinding methodBinding, ITypeBinding declaringClass) {
    if (methodBinding == null) {
      throw new IllegalStateException("Cannot find methodbinding, running without workspace?");
    }

    IJavaElement javaElement = methodBinding.getJavaElement();
    if (javaElement == null) {
      return null;
    }
    IPath path = javaElement.getPath();
    if ("jar".equals(path.getFileExtension())) {
      return path.lastSegment();
    } else if (declaringClass != null) {
      return declaringClass
          .getJavaElement()
          .getResource()
          .getProjectRelativePath()
          .toPortableString();
    } else {
      return javaElement.getPath().toPortableString();
    }
  }
Ejemplo n.º 2
0
 @Override
 public boolean visit(MethodDeclaration node) {
   IBinding binding = node.resolveBinding();
   if (binding.getJavaElement().equals(method)) this.declaration = node;
   return super.visit(node);
 }