当前位置: 首页>>代码示例>>Java>>正文


Java ParameterDeclaration类代码示例

本文整理汇总了Java中com.sun.mirror.declaration.ParameterDeclaration的典型用法代码示例。如果您正苦于以下问题:Java ParameterDeclaration类的具体用法?Java ParameterDeclaration怎么用?Java ParameterDeclaration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ParameterDeclaration类属于com.sun.mirror.declaration包,在下文中一共展示了ParameterDeclaration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: printErrorCheckMethod

import com.sun.mirror.declaration.ParameterDeclaration; //导入依赖的package包/类
public void printErrorCheckMethod(final PrintWriter writer, final MethodDeclaration method, final String tabs) {
	final Check check = method.getAnnotation(Check.class);
	if ( check != null ) // Get the error code from an IntBuffer output parameter
		writer.println(tabs + "Util.checkCLError(" + check.value() + ".get(" + check.value() + ".position()));");
	else {
		final Class return_type = Utils.getJavaType(method.getReturnType());
		if ( return_type == int.class )
			writer.println(tabs + "Util.checkCLError(__result);");
		else {
			boolean hasErrCodeParam = false;
			for ( final ParameterDeclaration param : method.getParameters() ) {
				if ( "errcode_ret".equals(param.getSimpleName()) && Utils.getJavaType(param.getType()) == IntBuffer.class ) {
					hasErrCodeParam = true;
					break;
				}
			}
			if ( hasErrCodeParam )
				throw new RuntimeException("A method is missing the @Check annotation: " + method.toString());
		}
	}
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:22,代码来源:CLTypeMap.java

示例2: setParams

import com.sun.mirror.declaration.ParameterDeclaration; //导入依赖的package包/类
void setParams(Collection<ParameterDeclaration> params) {
    paramsFormatted = "(";
    chainUsed = false;
    if (params.size() > 0) {
        int i = 1;
        for (ParameterDeclaration paramDeclaration : params) {
            String paramType = paramDeclaration.getType().toString();
            if (FILTER_CHAIN_CLASS_NAME.equals(paramType)) {
                chainUsed = true;
            }
            paramsFormatted += (i == 1 ? "" : ", ") + paramType;

            HttpParam httpParam = paramDeclaration.getAnnotation(HttpParam.class);
            if (httpParam != null) {
                paramsFormatted += " ";
                if (!"[ unassigned ]".equals(httpParam.value())) {
                    paramsFormatted += httpParam.value();
                } else {
                    paramsFormatted += paramDeclaration.getSimpleName();
                }
            }
            i++;
        }
    }
    paramsFormatted += ")";
}
 
开发者ID:paultuckey,项目名称:urlrewritefilter,代码行数:27,代码来源:HttpUrlAnnotationProcessor.java

示例3: visitMethodDeclaration

import com.sun.mirror.declaration.ParameterDeclaration; //导入依赖的package包/类
@Override
public void visitMethodDeclaration(MethodDeclaration methodDeclaration) {
    boolean correctSignature = false;
    Collection<ParameterDeclaration> methodParams = methodDeclaration.getParameters();
    // return type must be void
    if (methodDeclaration.getReturnType() instanceof VoidType && methodParams.size() == 2) {
        Iterator<ParameterDeclaration> it = methodParams.iterator();
        ParameterDeclaration param = it.next();
        ParameterDeclaration param2 = it.next();

        if (param.getType().toString().equals(Node.class.getName()) &&
            param2.getType().toString().equals(String.class.getName())) {
            correctSignature = true;
        }
    }

    if (!correctSignature) {
        reportError(methodDeclaration,
                ErrorMessages.INCORRECT_METHOD_SIGNATURE_FOR_NODE_ATTACHEMENT_CALLBACK);
    }
}
 
开发者ID:mnip91,项目名称:proactive-component-monitoring,代码行数:22,代码来源:NodeAttachmentCallbackVisitorAPT.java

示例4: visitMethodDeclaration

import com.sun.mirror.declaration.ParameterDeclaration; //导入依赖的package包/类
@Override
public void visitMethodDeclaration(MethodDeclaration methodDeclaration) {

    boolean correctSignature = false;
    Collection<ParameterDeclaration> methodParams = methodDeclaration.getParameters();
    // return type must be void
    if (methodDeclaration.getReturnType() instanceof VoidType && methodParams.size() == 1) {
        Iterator<ParameterDeclaration> it = methodParams.iterator();
        ParameterDeclaration param = it.next();

        if (param.getType().toString().equals(String.class.getName())) {
            correctSignature = true;
        }
    }

    if (!correctSignature) {
        reportError(methodDeclaration, ErrorMessages.INCORRECT_METHOD_SIGNATURE_FOR_ISREADY_CALLBACK);
    }
}
 
开发者ID:mnip91,项目名称:proactive-component-monitoring,代码行数:20,代码来源:VirtualNodeIsReadyCallbackVisitorAPT.java

示例5: generateClearsFromParameters

import com.sun.mirror.declaration.ParameterDeclaration; //导入依赖的package包/类
private static void generateClearsFromParameters(PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method) {
	for (ParameterDeclaration param : method.getParameters()) {
		CachedReference cached_reference_annotation = param.getAnnotation(CachedReference.class);
		if (cached_reference_annotation != null && cached_reference_annotation.name().length() == 0) {
			Class nio_type = Utils.getNIOBufferType(param.getType());
			String reference_name = Utils.getReferenceName(interface_decl, method, param);
			writer.println("\t\tthis." + reference_name + " = null;");
		}
	}
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:11,代码来源:GLReferencesGeneratorProcessorFactory.java

示例6: generateCopiesFromParameters

import com.sun.mirror.declaration.ParameterDeclaration; //导入依赖的package包/类
private static void generateCopiesFromParameters(PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method) {
	for (ParameterDeclaration param : method.getParameters()) {
		CachedReference cached_reference_annotation = param.getAnnotation(CachedReference.class);
		if (cached_reference_annotation != null && cached_reference_annotation.name().length() == 0) {
			Class nio_type = Utils.getNIOBufferType(param.getType());
			String reference_name = Utils.getReferenceName(interface_decl, method, param);
			writer.print("\t\t\tthis." + reference_name + " = ");
			writer.println(REFERENCES_PARAMETER_NAME + "." + reference_name + ";");
		}
	}
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:12,代码来源:GLReferencesGeneratorProcessorFactory.java

示例7: generateReferencesFromParameters

import com.sun.mirror.declaration.ParameterDeclaration; //导入依赖的package包/类
private static void generateReferencesFromParameters(PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method) {
	for (ParameterDeclaration param : method.getParameters()) {
		CachedReference cached_reference_annotation = param.getAnnotation(CachedReference.class);
		if (cached_reference_annotation != null && cached_reference_annotation.name().length() == 0) {
			Class nio_type = Utils.getNIOBufferType(param.getType());
			if (nio_type == null)
				throw new RuntimeException(param + " in method " + method + " in " + interface_decl + " is annotated with "
						+ cached_reference_annotation.annotationType().getSimpleName() + " but the parameter is not a NIO buffer");
			writer.print("\t" + nio_type.getName() + " " + Utils.getReferenceName(interface_decl, method, param));
			writer.println(";");
		}
	}
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:14,代码来源:GLReferencesGeneratorProcessorFactory.java

示例8: visitConstructorDeclaration

import com.sun.mirror.declaration.ParameterDeclaration; //导入依赖的package包/类
/**
 * Stores information about constructors annotated with {@link Constructor},
 * particularly with the {@link ConstructorParameter} annotated parameters
 * and their required imports. The {@link SPAnnotationProcessor} takes this
 * information and generates
 * {@link SPPersisterHelper#commitObject(ca.sqlpower.dao.PersistedSPObject, Multimap, List, ca.sqlpower.dao.helper.SPPersisterHelperFactory)}
 * and
 * {@link SPPersisterHelper#persistObject(SPObject, int, SPPersister, ca.sqlpower.dao.session.SessionPersisterSuperConverter)}
 * methods.
 * 
 * @param d
 *            The {@link ConstructorDeclaration} of the constructor to
 *            visit.
 */
public void visitConstructorDeclaration(ConstructorDeclaration d) {
	
	if (!constructorFound && d.getAnnotation(Constructor.class) != null 
			&& d.getSimpleName().equals(typeDecl.getSimpleName())) {
		
		for (ParameterDeclaration pd : d.getParameters()) {
			ConstructorParameter cp = pd.getAnnotation(ConstructorParameter.class);
			if (cp != null) {
				try {
					TypeMirror type = pd.getType();
					Class<?> c = SPAnnotationProcessorUtils.convertTypeMirrorToClass(type);
					
					ParameterType property = cp.parameterType();
					String name;
					
					if (property.equals(ParameterType.PROPERTY)) {
						name = cp.propertyName();
					} else {
						name = pd.getSimpleName();
					}

					if (type instanceof PrimitiveType) {
						constructorParameters.add(
								new ConstructorParameterObject(property, c, name));

					} else if (type instanceof ClassType || type instanceof InterfaceType) {
						constructorParameters.add(
								new ConstructorParameterObject(property, c, name));
						constructorImports.add(c.getName());
					}
				} catch (ClassNotFoundException e) {
					valid = false;
					e.printStackTrace();
				}
			}
		}
		constructorFound = true;
	}
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:54,代码来源:SPClassVisitor.java

示例9: getMethodParameters

import com.sun.mirror.declaration.ParameterDeclaration; //导入依赖的package包/类
public TypeMirror[] getMethodParameters(MethodDeclaration m) {
    Collection<ParameterDeclaration> ps = m.getParameters();
    TypeMirror[] r = new TypeMirror[ps.size()];
    int i=0;
    for( ParameterDeclaration p : ps )
        r[i++] = p.getType();
    return r;
}
 
开发者ID:alexkasko,项目名称:openjdk-icedtea7,代码行数:9,代码来源:APTNavigator.java

示例10: visitMethodDeclaration

import com.sun.mirror.declaration.ParameterDeclaration; //导入依赖的package包/类
/**
 * Stores information about getter and setter methods annotated with
 * {@link Accessor} and {@link Mutator}. This includes thrown exceptions,
 * setter parameters annotated with {@link MutatorParameter}, and required
 * imports. The {@link SPAnnotationProcessor} takes this information and
 * generates
 * {@link SPPersisterHelper#commitProperty(SPObject, String, Object, ca.sqlpower.dao.session.SessionPersisterSuperConverter)}
 * and
 * {@link SPPersisterHelper#findProperty(SPObject, String, ca.sqlpower.dao.session.SessionPersisterSuperConverter)}
 * methods.
 * 
 * @param d
 *            The {@link MethodDeclaration} of the method to visit.
 */
public void visitMethodDeclaration(MethodDeclaration d) {
	Accessor accessorAnnotation = d.getAnnotation(Accessor.class);
	Mutator mutatorAnnotation = d.getAnnotation(Mutator.class);
	Transient transientAnnotation = d.getAnnotation(Transient.class);
	TypeMirror type = null;
	
	if (!d.getDeclaringType().equals(typeDecl)) return;

	if (accessorAnnotation != null && transientAnnotation == null) {
		type = d.getReturnType();
	} else if (mutatorAnnotation != null && transientAnnotation == null) {
		type = d.getParameters().iterator().next().getType();
	} else {
		return;
	}
	
	String methodName = d.getSimpleName();
	Class<?> c = null;
	
	try {
		
		c = SPAnnotationProcessorUtils.convertTypeMirrorToClass(type);

		if (!propertiesToAccess.containsKey(methodName) && accessorAnnotation != null) {
			propertiesToAccess.put(methodName, c);
			
			if (accessorAnnotation.persistOnlyIfNonNull()) {
				propertiesToPersistOnlyIfNonNull.add(
						SPAnnotationProcessorUtils.convertMethodToProperty(methodName));
			}
			accessorAdditionalInfo.putAll(
					methodName, Arrays.asList(accessorAnnotation.additionalInfo()));
			
		} else if (!propertiesToMutate.containsKey(methodName) && mutatorAnnotation != null) {
			for (ReferenceType refType : d.getThrownTypes()) {
				Class<? extends Exception> thrownType = 
					(Class<? extends Exception>) Class.forName(refType.toString());
				mutatorThrownTypes.put(methodName, thrownType);
				mutatorImports.put(methodName, thrownType.getName());
			}

			propertiesToMutate.put(methodName, c);
			mutatorImports.put(methodName, c.getName());
			
			for (ParameterDeclaration pd : d.getParameters()) {
				MutatorParameter mutatorParameterAnnotation = 
					pd.getAnnotation(MutatorParameter.class);
				
				if (mutatorParameterAnnotation != null) {
					Class<?> extraParamType = 
						SPAnnotationProcessorUtils.convertTypeMirrorToClass(pd.getType());
					mutatorExtraParameters.put(methodName, 
							new MutatorParameterObject(
									extraParamType,
									pd.getSimpleName(), 
									mutatorParameterAnnotation.value()));
					mutatorImports.put(methodName, extraParamType.getName());
				}
			}
		}
		
	} catch (ClassNotFoundException e) {
		valid = false;
		e.printStackTrace();
	}
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:81,代码来源:SPClassVisitor.java

示例11: visitParameterDeclaration

import com.sun.mirror.declaration.ParameterDeclaration; //导入依赖的package包/类
public void visitParameterDeclaration(ParameterDeclaration d) {
	// no-op		
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:4,代码来源:SPClassVisitor.java

示例12: getParseAction

import com.sun.mirror.declaration.ParameterDeclaration; //导入依赖的package包/类
private String getParseAction (MethodDeclaration method, String args)
{
	if (args == null)
		args = "";
	StringBuffer buffer = new StringBuffer ();

	String returnType = method.getReturnType ().toString ();
	if ("int".equals (returnType))
		buffer.append ("return ");
	else if (!"void".equals (returnType))
	buffer.append ("_yyValue = ");

	buffer.append (THIS_STR).append (method.getSimpleName ()).append (" (");

	ParameterDeclaration[] params = method.getParameters ().toArray (new ParameterDeclaration[method.getParameters ().size ()]);

	int[] argv = getArgs (args);

	if (argv.length != params.length)
		throw new IllegalArgumentException ("Method " + method + " does not have the same number of arguments as specified.");

	for (int i = 0; i < argv.length; ++i)
	{
		if (i > 0)
			buffer.append (", ");
		int v = argv[i];
		String cl = params[i].getType ().toString ();
		if (!"java.lang.Object".equals (cl))
		{
			buffer.append ("(").append (cl).append (")");
			if (cl.indexOf ('<') > 0)
			{
				getParser ().setProperty (PROP_SUPPRESSING_UNCHECK_WARNING, Boolean.TRUE);
			}
		}
		buffer.append ("yyGetValue (").append (v).append (")");
	}
	buffer.append (")");

	buffer.append (";");
	return buffer.toString ();
}
 
开发者ID:coconut2015,项目名称:cookcc,代码行数:43,代码来源:ClassVisitor.java

示例13: visitParameterDeclaration

import com.sun.mirror.declaration.ParameterDeclaration; //导入依赖的package包/类
public void visitParameterDeclaration (ParameterDeclaration parameterDeclaration)
{
}
 
开发者ID:coconut2015,项目名称:cookcc,代码行数:4,代码来源:ClassVisitor.java

示例14: methodToString

import com.sun.mirror.declaration.ParameterDeclaration; //导入依赖的package包/类
public String methodToString(MethodDeclaration method) {
    StringBuffer buf = new StringBuffer(method.getSimpleName());
    for (ParameterDeclaration param : method.getParameters())
        buf.append(";"+param.getType().toString());
    return buf.toString();
}
 
开发者ID:alexkasko,项目名称:openjdk-icedtea7,代码行数:7,代码来源:AnnotationProcessorContext.java

示例15: getMethodParameterAnnotation

import com.sun.mirror.declaration.ParameterDeclaration; //导入依赖的package包/类
public <A extends Annotation> A getMethodParameterAnnotation(Class<A> a, MethodDeclaration m, int paramIndex, Locatable srcPos) {
    ParameterDeclaration[] params = m.getParameters().toArray(new ParameterDeclaration[0]);
    return LocatableAnnotation.create(
        params[paramIndex].getAnnotation(a), srcPos );
}
 
开发者ID:alexkasko,项目名称:openjdk-icedtea7,代码行数:6,代码来源:InlineAnnotationReaderImpl.java


注:本文中的com.sun.mirror.declaration.ParameterDeclaration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。