请选择 进入手机版 | 继续访问电脑版
  • 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MethodDeclaration类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: generateSymbolAddresses

import com.sun.mirror.declaration.MethodDeclaration; //导入依赖的package包/类
static void generateSymbolAddresses(final PrintWriter writer, final InterfaceDeclaration d) {
	final Alias alias_annotation = d.getAnnotation(Alias.class);
	final boolean aliased = alias_annotation != null && alias_annotation.postfix().length() > 0;

	boolean foundNative = false;
	for ( final MethodDeclaration method : d.getMethods() ) {
		if ( method.getAnnotation(Alternate.class) != null || method.getAnnotation(Reuse.class) != null )
			continue;

		if ( !foundNative ) {
			//writer.println("\t// " + d.getSimpleName());
			writer.println("\tstatic final boolean " + CLGeneratorProcessorFactory.getExtensionName(d.getSimpleName()) + ";");
			foundNative = true;
		}
		writer.print("\tstatic final long " + Utils.getFunctionAddressName(d, method) + " = CL.getFunctionAddress(");

		if ( aliased )
			writer.println("new String [] {\"" + Utils.getFunctionAddressName(d, method) + "\",\"" + method.getSimpleName() + alias_annotation.postfix() + "\"});");
		else
			writer.println("\"" + Utils.getFunctionAddressName(d, method) + "\");");
	}

	if ( foundNative )
		writer.println();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:26,代码来源:CLCapabilitiesGenerator.java


示例2: printErrorCheckMethod

import com.sun.mirror.declaration.MethodDeclaration; //导入依赖的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


示例3: parseLex

import com.sun.mirror.declaration.MethodDeclaration; //导入依赖的package包/类
private void parseLex (Lex lex, MethodDeclaration method, int lineNumber)
{
	if (lex == null)
		return;

	RuleDoc rule = new RuleDoc (getLexer ());

	rule.setAction (getLexAction (method, lex.token ()));

	PatternDoc pattern = new PatternDoc (false);
	pattern.setPattern (lex.pattern ());
	if (lineNumber < 0)
		pattern.setLineNumber (getAnnotationLineNumber (method, Lex.class.getName ()));
	else
		pattern.setLineNumber (lineNumber);

	rule.addPattern (pattern);
	rule.addStates (lex.state ());
}
 
开发者ID:coconut2015,项目名称:cookcc,代码行数:20,代码来源:ClassVisitor.java


示例4: parseRule

import com.sun.mirror.declaration.MethodDeclaration; //导入依赖的package包/类
private void parseRule (Rule rule, MethodDeclaration method, int lineNumber)
{
	if (rule == null)
		return;

	GrammarDoc grammar = getParser ().getGrammar (rule.lhs ());
	RhsDoc rhs = new RhsDoc ();
	rhs.setTerms (rule.rhs ());
	if (lineNumber < 0)
		rhs.setLineNumber (getAnnotationLineNumber (method, Rule.class.getName ()));
	else
		rhs.setLineNumber (lineNumber);
	String precedence = rule.precedence ().trim ();
	if (precedence.length () > 0)
		rhs.setPrecedence (precedence);
	String action = getParseAction (method, rule.args ());
	rhs.setAction (action);
	grammar.addRhs (rhs);
}
 
开发者ID:coconut2015,项目名称:cookcc,代码行数:20,代码来源:ClassVisitor.java


示例5: ProcessedHttpUrlAnnotation

import com.sun.mirror.declaration.MethodDeclaration; //导入依赖的package包/类
public ProcessedHttpUrlAnnotation(String typeName, Declaration declaration, String value, int weight) {
    MethodDeclaration methodDeclaration = (MethodDeclaration) declaration;
    String className = methodDeclaration.getDeclaringType().getQualifiedName();
    this.methodName = declaration.getSimpleName();
    this.docComment = declaration.getDocComment();
    this.className = className;
    this.value = value;
    this.weight = weight;
    this.setParams(methodDeclaration.getParameters());
    String typeNameShort = typeName.substring(typeName.lastIndexOf("."));
    SourcePosition positionInCode = declaration.getPosition();
    sourceRef = positionInCode.file().getName() + ":" + positionInCode.line();
    if (!(declaration instanceof MethodDeclaration)) {
        messager.printWarning(positionInCode, "@" + typeNameShort + " declared on a non-method " + positionInCode);
    }
    if (showPositionsOfAnnotations) {
        messager.printNotice(positionInCode, "@" + typeNameShort + " value " + value + " weight " + weight);
    }
}
 
开发者ID:paultuckey,项目名称:urlrewritefilter,代码行数:20,代码来源:HttpUrlAnnotationProcessor.java


示例6: generateExceptionBeans

import com.sun.mirror.declaration.MethodDeclaration; //导入依赖的package包/类
private boolean generateExceptionBeans(MethodDeclaration method) {
    String beanPackage = packageName + PD_JAXWS_PACKAGE_PD;
    if (packageName.length() == 0)
        beanPackage = JAXWS_PACKAGE_PD;
    boolean beanGenerated = false;
    for (ReferenceType thrownType : method.getThrownTypes()) {
        ClassDeclaration typeDecl = ((ClassType)thrownType).getDeclaration();
        if (typeDecl == null){
            builder.onError(WebserviceapMessages.WEBSERVICEAP_COULD_NOT_FIND_TYPEDECL(thrownType.toString(), context.getRound()));
            return false;
        }
        boolean tmp = generateExceptionBean(typeDecl, beanPackage);
        beanGenerated = beanGenerated || tmp;
    }
    return beanGenerated;
}
 
开发者ID:alexkasko,项目名称:openjdk-icedtea7,代码行数:17,代码来源:WebServiceWrapperGenerator.java


示例7: getSchemaGenerator

import com.sun.mirror.declaration.MethodDeclaration; //导入依赖的package包/类
private synchronized XmlSchemaGenerator<TypeMirror, TypeDeclaration, FieldDeclaration, MethodDeclaration> getSchemaGenerator() {
    if(xsdgen==null) {
        xsdgen = new XmlSchemaGenerator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>( types.getNavigator(), types );

        for (Map.Entry<QName, Reference> e : additionalElementDecls.entrySet()) {
            Reference value = e.getValue();
            if(value!=null) {
                NonElement<TypeMirror, TypeDeclaration> typeInfo = refMap.get(value);
                if(typeInfo==null)
                    throw new IllegalArgumentException(e.getValue()+" was not specified to JavaCompiler.bind");
                xsdgen.add(e.getKey(),!(value.type instanceof PrimitiveType),typeInfo);
            } else {
                xsdgen.add(e.getKey(),false,null);
            }
        }
    }
    return xsdgen;
}
 
开发者ID:alexkasko,项目名称:openjdk-icedtea7,代码行数:19,代码来源:JAXBModelImpl.java


示例8: isOverriding

import com.sun.mirror.declaration.MethodDeclaration; //导入依赖的package包/类
public boolean isOverriding(MethodDeclaration method, TypeDeclaration base) {
    ClassDeclaration sc = (ClassDeclaration) base;

    Declarations declUtil = env.getDeclarationUtils();

    while(true) {
        for (MethodDeclaration m : sc.getMethods()) {
            if(declUtil.overrides(method,m))
                return true;
        }

        if(sc.getSuperclass()==null)
            return false;
        sc = sc.getSuperclass().getDeclaration();
    }
}
 
开发者ID:alexkasko,项目名称:openjdk-icedtea7,代码行数:17,代码来源:APTNavigator.java


示例9: visitMethodDeclaration

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

    ERROR_PREFIX = methodDeclaration.getSimpleName() + ERROR_PREFIX_STATIC;

    // return type must be void
    if (!(methodDeclaration.getReturnType() instanceof VoidType))
        reportError(methodDeclaration,
                "the method shouldn't have any return value, but instead returns " +
                    methodDeclaration.getReturnType().toString());

    // method must not have arguments
    if (!methodDeclaration.getParameters().isEmpty())
        reportError(methodDeclaration, "the method accepts parameters");

}
 
开发者ID:mnip91,项目名称:proactive-component-monitoring,代码行数:17,代码来源:OnDepartureVisitorAPT.java


示例10: visitMethodDeclaration

import com.sun.mirror.declaration.MethodDeclaration; //导入依赖的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


示例11: visitMethodDeclaration

import com.sun.mirror.declaration.MethodDeclaration; //导入依赖的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


示例12: checkGettersSetters

import com.sun.mirror.declaration.MethodDeclaration; //导入依赖的package包/类
private boolean checkGettersSetters(String fieldName) {

        final String getField = GenerateGettersSetters.getterPattern(fieldName);
        boolean foundGet = false;
        final String setField = GenerateGettersSetters.setterPattern(fieldName);
        boolean foundSet = false;

        Collection<MethodDeclaration> methods = _containingClassMethods;
        for (MethodDeclaration methodDeclaration : methods) {
            if (!foundGet && methodDeclaration.getSimpleName().matches(getField)) {
                foundGet = true;
            }
            if (!foundSet && methodDeclaration.getSimpleName().matches(setField)) {
                foundSet = true;
            }
            if (foundGet && foundSet)
                return true;
        }

        return false;

    }
 
开发者ID:mnip91,项目名称:proactive-component-monitoring,代码行数:23,代码来源:ActiveObjectVisitorAPT.java


示例13: generateSymbolAddresses

import com.sun.mirror.declaration.MethodDeclaration; //导入依赖的package包/类
public static void generateSymbolAddresses(PrintWriter writer, InterfaceDeclaration d) {
	boolean first = true;
	for ( final MethodDeclaration method : d.getMethods() ) {
		if ( method.getAnnotation(Alternate.class) != null || method.getAnnotation(Reuse.class) != null )
			continue;

		if ( first ) {
			writer.println("\t// " + d.getSimpleName());
			first = false;
		}
		writer.println("\tlong " + Utils.getFunctionAddressName(d, method) + ";");
	}
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:14,代码来源:GLCapabilitiesGenerator.java


示例14: generateClearsFromParameters

import com.sun.mirror.declaration.MethodDeclaration; //导入依赖的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


示例15: generateCopiesFromParameters

import com.sun.mirror.declaration.MethodDeclaration; //导入依赖的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


示例16: generateClearsFromMethods

import com.sun.mirror.declaration.MethodDeclaration; //导入依赖的package包/类
private static void generateClearsFromMethods(PrintWriter writer, InterfaceDeclaration interface_decl) {
	for (MethodDeclaration method : interface_decl.getMethods()) {
		if ( method.getAnnotation(Alternate.class) != null )
			continue;

		generateClearsFromParameters(writer, interface_decl, method);
	}
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:9,代码来源:GLReferencesGeneratorProcessorFactory.java


示例17: generateCopiesFromMethods

import com.sun.mirror.declaration.MethodDeclaration; //导入依赖的package包/类
private static void generateCopiesFromMethods(PrintWriter writer, InterfaceDeclaration interface_decl) {
	for (MethodDeclaration method : interface_decl.getMethods()) {
		if ( method.getAnnotation(Alternate.class) != null )
			continue;

		generateCopiesFromParameters(writer, interface_decl, method);
	}
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:9,代码来源:GLReferencesGeneratorProcessorFactory.java


示例18: generateReferencesFromParameters

import com.sun.mirror.declaration.MethodDeclaration; //导入依赖的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


示例19: generateReferencesFromMethods

import com.sun.mirror.declaration.MethodDeclaration; //导入依赖的package包/类
private static void generateReferencesFromMethods(PrintWriter writer, InterfaceDeclaration interface_decl) {
	for (MethodDeclaration method : interface_decl.getMethods()) {
		if ( method.getAnnotation(Alternate.class) != null )
			continue;

		generateReferencesFromParameters(writer, interface_decl, method);
	}
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:9,代码来源:GLReferencesGeneratorProcessorFactory.java


示例20: generateExtensionChecks

import com.sun.mirror.declaration.MethodDeclaration; //导入依赖的package包/类
static void generateExtensionChecks(final PrintWriter writer, final InterfaceDeclaration d) {
	Iterator<? extends MethodDeclaration> methods = d.getMethods().iterator();
	if ( !methods.hasNext() )
		return;

	writer.println("\tprivate static boolean " + getExtensionSupportedName(d.getSimpleName()) + "() {");
	writer.println("\t\treturn ");

	boolean first = true;
	while ( methods.hasNext() ) {
		MethodDeclaration method = methods.next();
		if ( method.getAnnotation(Alternate.class) != null )
			continue;

		if ( !first )
			writer.println(" &");
		else
			first = false;

		final boolean optional = method.getAnnotation(Optional.class) != null;

		writer.print("\t\t\t");
		if ( optional )
			writer.print('(');
		writer.print(Utils.getFunctionAddressName(d, method) + " != 0");
		if ( optional )
			writer.print(" || true)");
	}
	writer.println(";");
	writer.println("\t}");
	writer.println();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:33,代码来源:CLCapabilitiesGenerator.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TypeBoundKind类代码示例发布时间:2022-05-21
下一篇:
Java EDataTypeUniqueEList类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap