Visits a pre-destroy method injection point.

@param declaringType The declaring type of the method. Either a Class or a string representing the name of the type
@param returnType    The return type of the method
@param methodName    The method name
480669
public void visitPreDestroyMethod(Object declaringType,
                                      Object returnType,
                                      String methodName) {
        visitPreDestroyMethodDefinition();
        final MethodVisitData methodVisitData = new MethodVisitData(
                declaringType,
                false,
                returnType,
                methodName,
                Collections.emptyMap(),
                Collections.emptyMap(),
                Collections.emptyMap(),
                AnnotationMetadata.EMPTY_METADATA);
        preDestroyMethodVisits.add(methodVisitData);
        visitMethodInjectionPointInternal(methodVisitData,
                constructorVisitor,
                preDestroyMethodVisitor,
                preDestroyInstanceIndex,
                ADD_PRE_DESTROY_METHOD);
    }
112155
public static TypeName injectableType(TypeMirror type) {
    return type.accept(new SimpleTypeVisitor6<TypeName, Void>() {
      @Override public TypeName visitPrimitive(PrimitiveType primitiveType, Void v) {
        return box(primitiveType);
      }

      @Override public TypeName visitError(ErrorType errorType, Void v) {
        // Error type found, a type may not yet have been generated, but we need the type
        // so we can generate the correct code in anticipation of the type being available
        // to the compiler.

        // Paramterized types which don't exist are returned as an error type whose name is "<any>"
        if ("<any>".equals(errorType.toString())) {
          throw new CodeGenerationIncompleteException(
              "Type reported as <any> is likely a not-yet generated parameterized type.");
        }

        return ClassName.bestGuess(errorType.toString());
      }

      @Override protected TypeName defaultAction(TypeMirror typeMirror, Void v) {
        return TypeName.get(typeMirror);
      }
    }, null);
  }
409583
private static Class<?> findTypeFromGeneric(final InvocationOnMock invocation, final TypeVariable returnType) {
        // Class level
        final MockCreationSettings mockSettings = MockUtil.getMockHandler(invocation.getMock()).getMockSettings();
        final GenericMetadataSupport returnTypeSupport = GenericMetadataSupport
            .inferFrom(mockSettings.getTypeToMock())
            .resolveGenericReturnType(invocation.getMethod());
        final Class<?> rawType = returnTypeSupport.rawType();

        // Method level
        if (rawType == Object.class) {
            return findTypeFromGenericInArguments(invocation, returnType);
        }
        return rawType;
    }
416155
public static void injectMethod(JavacNode typeNode, JCMethodDecl method, List<Type> paramTypes, Type returnType) {
		JCClassDecl type = (JCClassDecl) typeNode.get();
		
		if (method.getName().contentEquals("<init>")) {
			//Scan for default constructor, and remove it.
			int idx = 0;
			for (JCTree def : type.defs) {
				if (def instanceof JCMethodDecl) {
					if ((((JCMethodDecl) def).mods.flags & Flags.GENERATEDCONSTR) != 0) {
						JavacNode tossMe = typeNode.getNodeFor(def);
						if (tossMe != null) tossMe.up().removeChild(tossMe);
						type.defs = addAllButOne(type.defs, idx);
						ClassSymbolMembersField.remove(type.sym, ((JCMethodDecl) def).sym);
						break;
					}
				}
				idx++;
			}
		}
		
		addSuppressWarningsAll(method.mods, typeNode, method.pos, getGeneratedBy(method), typeNode.getContext());
		addGenerated(method.mods, typeNode, method.pos, getGeneratedBy(method), typeNode.getContext());
		type.defs = type.defs.append(method);
		
		fixMethodMirror(typeNode.getContext(), typeNode.getElement(), method.getModifiers().flags, method.getName(), paramTypes, returnType);
		
		typeNode.add(method, Kind.METHOD);
	}
874206
public static Method getMethod(Class<?> declaringType, String methodName, Class<?>... parameterTypes) {
    return findMethod(declaringType, methodName, parameterTypes);
  }
1212450
public static <T> MethodLiteral<T, Constructor<?>> get(Constructor<?> constructor,
      TypeLiteral<T> declaringType) {
    Preconditions.checkArgument(
        constructor.getDeclaringClass().equals(declaringType.getRawType()),
        "declaringType (%s) must be the type literal where constructor was declared (%s)!",
        declaringType, constructor.getDeclaringClass());
    return new ConstructorLiteral<T>(constructor, declaringType);
  }
505429
public final Method getTargetMethod() {
        Method method = initialize();
        if (method == null) {
            if (LOG.isWarnEnabled()) {
                if (LOG.isWarnEnabled()) {
                    LOG.warn("Type [{}] previously declared a method [{}] which has been removed or changed. It is recommended you re-compile the class or library against the latest version to remove this warning.", declaringType, methodName);
                }
            }
            throw ReflectionUtils.newNoSuchMethodError(declaringType, methodName, argTypes);
        }
        return method;
    }
188011
protected void registerStaticMethod(final String name, final Closure callable, final Class[] paramTypes) {
        performOperationOnMetaClass(new Callable() {
            public void call() {
                String methodName;
                if (name.equals(METHOD_MISSING))
                    methodName = STATIC_METHOD_MISSING;
                else if (name.equals(PROPERTY_MISSING))
                    methodName = STATIC_PROPERTY_MISSING;
                else
                    methodName = name;

                ClosureStaticMetaMethod metaMethod = null;

                if (paramTypes != null) {
                    metaMethod = new ClosureStaticMetaMethod(methodName, theClass, callable, paramTypes);
                } else {
                    metaMethod = new ClosureStaticMetaMethod(methodName, theClass, callable);
                }

                if (methodName.equals(INVOKE_METHOD_METHOD) && callable.getParameterTypes().length == 2) {
                    invokeStaticMethodMethod = metaMethod;
                } else {
                    if (methodName.equals(METHOD_MISSING)) {
                        methodName = STATIC_METHOD_MISSING;
                    }
                    MethodKey key = new DefaultCachedMethodKey(theClass, methodName, metaMethod.getParameterTypes(), false);

                    addMetaMethod(metaMethod);
                    dropStaticMethodCache(methodName);
//                    cacheStaticMethod(key,metaMethod);

                    if (isGetter(methodName, metaMethod.getParameterTypes())) {
                        String propertyName = getPropertyForGetter(methodName);
                        registerBeanPropertyForMethod(metaMethod, propertyName, true, true);

                    } else if (isSetter(methodName, metaMethod.getParameterTypes())) {
                        String propertyName = getPropertyForSetter(methodName);
                        registerBeanPropertyForMethod(metaMethod, propertyName, false, true);
                    }
                    performRegistryCallbacks();
                    expandoMethods.put(key, metaMethod);
                }
            }

        });
    }
330927
public static <T> MethodLiteral<T, Method> get(Method method, TypeLiteral<T> declaringType) {
    Preconditions.checkArgument(method.getDeclaringClass().equals(declaringType.getRawType()),
        "declaringType (%s) must be the type literal where method was declared (%s)!",
        declaringType, method.getDeclaringClass());
    return new ConcreteMethodLiteral<T>(method, declaringType);
  }
1103010
private static boolean methodReturnsValue(CtBehavior method) throws NotFoundException {

        if (method instanceof CtMethod == false) {
            return false;
        }

        CtClass returnType = ((CtMethod) method).getReturnType();
        String returnTypeName = returnType.getName();

        boolean isVoidMethod = "void".equals(returnTypeName);

        boolean methodReturnsValue = isVoidMethod == false;
        return methodReturnsValue;
    }
632340
protected <T> T invokeJavascriptReturnValue(String function, Class<T> returnType, Object... args) {
        Object returnObject = invokeJavascript(function, args);
        if (returnObject != null) {
            return (T) returnObject;
        } else {
            return null;
        }
    }
1267013
public static void generateJavaDocReturnType(MethodSpec.Builder methodBuilder, TypeName returnType) {
		if (returnType == TypeName.VOID) {

		} else if (TypeUtility.isTypeIncludedIn(returnType, Boolean.TYPE, Boolean.class)) {
			methodBuilder.addJavadoc("\n");
			methodBuilder.addJavadoc("@return <code>true</code> if record is inserted, <code>false</code> otherwise");
		} else if (TypeUtility.isTypeIncludedIn(returnType, Long.TYPE, Long.class)) {
			methodBuilder.addJavadoc("\n");
			methodBuilder.addJavadoc("@return <strong>id</strong> of inserted record");
		} else if (TypeUtility.isTypeIncludedIn(returnType, Integer.TYPE, Integer.class)) {
			methodBuilder.addJavadoc("\n");
			methodBuilder.addJavadoc("@return <strong>id</strong> of inserted record");
		}
		methodBuilder.addJavadoc("\n");
	}
550562
void outputStaticInjectionMethods(Class<?> type, FragmentMap fragments,
      NameGenerator nameGenerator, SourceWriteUtil sourceWriteUtil) {
    String methodName = nameGenerator.convertToValidMemberName("injectStatic_" + type.getName());
    SourceSnippetBuilder body = new SourceSnippetBuilder();
    for (InjectionPoint injectionPoint : InjectionPoint.forStaticMethodsAndFields(type)) {
      Member member = injectionPoint.getMember();
      try {
        List<InjectorMethod> staticInjectionHelpers = new ArrayList<InjectorMethod>();

        if (member instanceof Method) {
          MethodLiteral<?, Method> method =
              MethodLiteral.get((Method) member, TypeLiteral.get(member.getDeclaringClass()));
          body.append(methodCallUtil.createMethodCallWithInjection(method, null, nameGenerator,
              staticInjectionHelpers));
        } else if (member instanceof Field) {
          FieldLiteral<?> field =
              FieldLiteral.get((Field) member, TypeLiteral.get(member.getDeclaringClass()));
          body.append(sourceWriteUtil.createFieldInjection(field, null, nameGenerator,
              staticInjectionHelpers));
        }

        outputMethods(staticInjectionHelpers, fragments);
      } catch (NoSourceNameException e) {
        errorManager.logError(e.getMessage(), e);
      }
    }

    // Note that the top-level method that performs static injection will only
    // invoke a bunch of other injector methods.  Therefore, it doesn't matter
    // which package it goes in, and we don't need to invoke getUserPackageName
    // (which is good, because in practice users statically inject types that
    // have no user package name because they're private inner classes!)
    String packageName = type.getPackage().getName();
    InjectorMethod method = SourceSnippets.asMethod(false, "private void " + methodName + "()",
        packageName, body.build());
    GinjectorFragmentOutputter fragment =
        fragments.get(fragmentPackageNameFactory.create(packageName));
    fragment.outputMethod(method);
    fragment.invokeInInitializeStaticInjections(methodName);
  }
1117147
public static void validateReturnType(Method method, Class<? extends Annotation> annotationType,
                                          Class<?> expectedReturnType) {
        if (!method.getReturnType().equals(expectedReturnType)) {
            throw new BeanCreationException("Method " + method.getName() + " annotated with @"
                  + annotationType.getName() + " must have a return type of "
                  + expectedReturnType.getName());
        }
    }
1199319
@SuppressWarnings("UnusedDeclaration")
    public static Object methodCall(Class<?> type, String methodName, Object[] args, Class<?>[] sig,
                                    String returnTypeAsString) throws Throwable {
        return doMethodCall(type, methodName, args, sig, returnTypeAsString);
    }
96483
public String generateJavaDoc(MethodSpec.Builder methodBuilder, final SQLiteModelMethod method, TypeName returnType) {
		final SQLiteEntity entity = method.getEntity();
		final One<Boolean> inColumnValues = new One<Boolean>(false);
		final List<Pair<String, TypeName>> methodParamsUsedAsColumnValue = new ArrayList<>();
		final List<Pair<String, TypeName>> methodParamsUsedAsParameter = new ArrayList<>();

		// transform JQL to SQL
		String sqlInsert = JQLChecker.getInstance().replace(method, method.jql, new JQLReplacerListenerImpl(method) {

			@Override
			public void onColumnValueSetBegin(Column_value_setContext ctx) {
				inColumnValues.value0 = true;
			}

			@Override
			public void onColumnValueSetEnd(Column_value_setContext ctx) {
				inColumnValues.value0 = false;
			}

			@Override
			public String onColumnName(String columnName) {
				Set<SQLProperty> property = currentSchema.getPropertyBySimpleName(columnName);
				AssertKripton.assertTrueOrUnknownPropertyInJQLException(property != null, method, columnName);

				SQLProperty tempProperty = property.iterator().next();
				AssertKripton.assertTrueOrUnknownPropertyInJQLException(tempProperty != null, method, columnName);

				return tempProperty.columnName;
			}

			@Override
			public String onBindParameter(String bindParameterName, boolean inStatement) {
				String resolvedParamName = method.findParameterNameByAlias(bindParameterName);

				if (inColumnValues.value0) {
					methodParamsUsedAsColumnValue.add(new Pair<>(resolvedParamName, method.findParameterType(resolvedParamName)));
				} else {
					methodParamsUsedAsParameter.add(new Pair<>(resolvedParamName, method.findParameterType(resolvedParamName)));
				}

				return SqlAnalyzer.PARAM_PREFIX + resolvedParamName + SqlAnalyzer.PARAM_SUFFIX;
			}					

		});

		methodBuilder.addJavadoc("<h2>SQL insert</h2>\n");
		methodBuilder.addJavadoc("<pre>$L</pre>\n", sqlInsert);
		methodBuilder.addJavadoc("\n");

		if (methodParamsUsedAsColumnValue.size() > 0) {
			// list of inserted fields
			methodBuilder.addJavadoc("<h2>Inserted columns:</strong></h2>\n");
			methodBuilder.addJavadoc("<dl>\n");
			for (Pair<String, TypeName> property : methodParamsUsedAsColumnValue) {
				//String resolvedName = method.findParameterAliasByName(property.value0);				
				String resolvedName=method.findParameterNameByAlias(property.value0);
				/*SQLProperty prop = entity.get(resolvedName);
								
				if (prop == null)
					throw (new PropertyNotFoundException(method, property.value0, property.value1));*/
				
				methodBuilder.addJavadoc("\t<dt>$L</dt>", property.value0);
				methodBuilder.addJavadoc("<dd>is binded to query's parameter <strong>$L</strong> and method's parameter <strong>$L</strong></dd>\n", SqlAnalyzer.PARAM_PREFIX + property.value0 + SqlAnalyzer.PARAM_SUFFIX, resolvedName);
			}
			methodBuilder.addJavadoc("</dl>\n\n");
		}

		// list of parameters
		if (methodParamsUsedAsParameter.size() > 0) {
			methodBuilder.addJavadoc("<h2>Method parameters used as sql parameters</h2>\n");
			methodBuilder.addJavadoc("<dl>\n");
			for (Pair<String, TypeName> property : methodParamsUsedAsParameter) {
				String resolvedName = method.findParameterNameByAlias(property.value0);
				methodBuilder.addJavadoc("\t<dt>$L</dt>", resolvedName);
				methodBuilder.addJavadoc("<dd>is binded to query's parameter <strong>"+SqlAnalyzer.PARAM_PREFIX+"$L"+SqlAnalyzer.PARAM_SUFFIX+"</strong></dd>\n", property.value0);
			}
			methodBuilder.addJavadoc("</dl>\n\n");
		}

		for (Pair<String, TypeName> param : method.getParameters()) {
			if (methodParamsUsedAsColumnValue.contains(param)) {
				methodBuilder.addJavadoc("@param $L\n", param.value0);
				
				if (entity.get(method.findParameterAliasByName(param.value0))!=null) {												
					methodBuilder.addJavadoc("\tis binded to column value <strong>$L</strong>\n", entity.get(method.findParameterAliasByName(param.value0)).columnName);
				} else {
					// in case of JQL explicit, you can declare name of parameter
					methodBuilder.addJavadoc("\tis binded to query parameter <strong>$L</strong>\n", param.value0);				}
			}

			if (methodParamsUsedAsParameter.contains(param)) {
				methodBuilder.addJavadoc("@param $L\n", param.value0);
				methodBuilder.addJavadoc("\tis used as parameter\n");
			}
		}

		generateJavaDocReturnType(methodBuilder, returnType);
		return sqlInsert;
	}
494744
protected void processReturnTypeOfMethodDeclaration( MethodDeclaration methodDeclaration,
                                                         MethodMetadata methodMetadata ) {
        Type type = methodDeclaration.getReturnType2();
        if (type.isPrimitiveType()) {
            methodMetadata.setReturnType(FieldMetadata.primitiveType(((PrimitiveType)type).getPrimitiveTypeCode().toString()));
        }
        if (type.isSimpleType()) {
            methodMetadata.setReturnType(FieldMetadata.simpleType(JavaMetadataUtil.getName(((SimpleType)type).getName())));
        }
    }