Example #1
0
 public static JavaSourceMethod create(IJavaASTNode methodNode, JavaSourceType containingClass) {
   IJavaASTNode nameNode = methodNode.getChildOfType(JavaParser.IDENTIFIER);
   if (nameNode == null) {
     return null;
   }
   String methodName = nameNode.getText();
   if (methodName.equals(containingClass.getSimpleName())) {
     return new JavaSourceConstructor(methodNode, containingClass);
   } else if (containingClass.isAnnotation()) {
     return new JavaSourceAnnotationMethod(methodNode, containingClass);
   } else {
     return new JavaSourceMethod(methodNode, containingClass);
   }
 }
Example #2
0
 public IJavaClassType getGenericReturnType() {
   if (_genericReturnType == null) {
     int indexOfName = _methodNode.getChildOfTypeIndex(JavaParser.IDENTIFIER);
     _genericReturnType = JavaSourceType.createType(this, _methodNode.getChild(indexOfName - 1));
     if (_genericReturnType == null) {
       throw new RuntimeException("Cannot compute return type.");
     }
   }
   return _genericReturnType;
 }
Example #3
0
  @Override
  public IJavaClassType resolveType(String relativeName, int ignoreFlags) {
    IJavaClassTypeVariable[] typeParameters = getTypeParameters();
    for (IJavaClassTypeVariable typeParameter : typeParameters) {
      if (relativeName.equals(typeParameter.getName())) {
        return typeParameter;
      }
    }

    return _containingClass.resolveType(relativeName, ignoreFlags);
  }
 public IJavaClassType[] getBounds() {
   if (_bounds == null) {
     final List<? extends Tree> boundsList = _typeParameter.getBounds();
     if (!boundsList.isEmpty()) {
       _bounds = new IJavaClassType[boundsList.size()];
       for (int i = 0; i < _bounds.length; i++) {
         _bounds[i] = JavaSourceType.createType(_owner, boundsList.get(i));
       }
     } else {
       _bounds = new IJavaClassType[] {JavaTypes.OBJECT().getBackingClassInfo()};
     }
   }
   return _bounds;
 }
Example #5
0
 @Override
 public IJavaClassInfo getReturnClassInfo() {
   if (_returnType == null) {
     int indexOfName = _methodNode.getChildOfTypeIndex(JavaParser.IDENTIFIER);
     IJavaASTNode typeNode = _methodNode.getChild(indexOfName - 1);
     String typeName;
     if (typeNode instanceof TypeASTNode) {
       typeName = ((TypeASTNode) typeNode).getTypeName();
     } else {
       typeName = typeNode.getText();
     }
     _returnType =
         (IJavaClassInfo)
             JavaSourceType.createType(this, typeName, JavaSourceType.IGNORE_NONE)
                 .getConcreteType();
     if (_returnType == null) {
       throw new RuntimeException("Cannot compute return type.");
     }
   }
   return _returnType;
 }
Example #6
0
 @Override
 public IModule getModule() {
   return _containingClass.getModule();
 }