當前位置: 首頁>>代碼示例>>Java>>正文


Java MethodDeclaration.getType方法代碼示例

本文整理匯總了Java中com.github.javaparser.ast.body.MethodDeclaration.getType方法的典型用法代碼示例。如果您正苦於以下問題:Java MethodDeclaration.getType方法的具體用法?Java MethodDeclaration.getType怎麽用?Java MethodDeclaration.getType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.github.javaparser.ast.body.MethodDeclaration的用法示例。


在下文中一共展示了MethodDeclaration.getType方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: MethodNode

import com.github.javaparser.ast.body.MethodDeclaration; //導入方法依賴的package包/類
MethodNode( MethodDeclaration metDec)
{
    super();
    this.metDec = metDec;
    type = metDec.getType();
    if(metDec.isPrivate())
        modifier = "- ";
    else if(metDec.isPublic())
        modifier = "+ ";
    else if(metDec.isProtected())
        modifier = "# ";
    else
        modifier = "~ ";
    nodeName =  modifier + metDec.getName() + "(";
    if (metDec.getParameters() != null)
    {
        parameters = new ArrayList<Parameter>(metDec.getParameters());
        for (Parameter p : parameters)
            nodeName = nodeName + " " + p + ", ";
        if (nodeName.lastIndexOf(',') > 0 )
            nodeName = nodeName.substring(0, nodeName.lastIndexOf(','));
    }
    nodeName = nodeName + ") : " + type.toString();
}
 
開發者ID:bufferhe4d,項目名稱:call-IDE,代碼行數:25,代碼來源:MethodNode.java

示例2: callDelegateCode

import com.github.javaparser.ast.body.MethodDeclaration; //導入方法依賴的package包/類
private String callDelegateCode(MethodDeclaration methodDeclaration, String parameters) {
    if (methodDeclaration.getType() instanceof VoidType) {
        return delegateFieldName + "." + methodDeclaration.getName() + "(" + parameters + ");\n";
    } else {
        return "return " + delegateFieldName + "." + methodDeclaration.getName() + "(" + parameters + ");\n";
    }
}
 
開發者ID:theangrydev,項目名稱:fluent-bdd,代碼行數:8,代碼來源:ThenMethodCodeEmitter.java

示例3: parseMethodInfo

import com.github.javaparser.ast.body.MethodDeclaration; //導入方法依賴的package包/類
public static MethodInfo parseMethodInfo(ClassInfo containedClass, SourceInfo sourceInfo, MethodDeclaration methodDecl) {
//        Log.d(TAG, "method name: %s, returnType: %s", methodDecl.name, methodDecl.getReturnType());
        if (containedClass != null && methodDecl.getType() != null) {
            MethodInfo methodInfo = new MethodInfo();
            
            String methodName = methodDecl.getName();
            methodName = containedClass.getQualifiedName() + "." + methodName;
            Type returnType = TypeParser.parseType(sourceInfo, methodDecl.getType(), methodDecl.getType().toString());
            methodInfo.setMethodName(methodName);
            methodInfo.setReturnType(returnType);
            
            if (methodDecl.getModifiers() != 0) {
                methodInfo.addAllModifiers(Modifier.parseModifiersFromFlags(methodDecl.getModifiers()));
            }
            
            Log.d(TAG, "parseMethodInfo, methodName: %s, returnType: %s", methodName, returnType);
            
            // parse parameters
            if (methodDecl.getParameters() != null && methodDecl.getParameters().size() > 0) {
                for (Parameter parameter : methodDecl.getParameters()) {
                    Type paramType = TypeParser.parseType(sourceInfo, parameter.getType(), parameter.getType().toString());
                    methodInfo.addParamType(paramType);
                    Log.d(TAG, "parseMethodInfo, parameter type: %s", paramType);
                }
            }
            
            // parse annotaion
            if (methodDecl.getAnnotations() != null && methodDecl.getAnnotations().size() > 0) {
                for (AnnotationExpr annotation : methodDecl.getAnnotations()) {
                    AnnotationModifier annotationModifier = AnnotationModifierParser.parseAnnotation(sourceInfo, annotation);
                    methodInfo.putAnnotation(annotationModifier);
                }
            }
            
            return methodInfo;
        }
        
        return null;
    }
 
開發者ID:ragnraok,項目名稱:JParserUtil,代碼行數:40,代碼來源:MethodParser.java

示例4: handleMethodDeclaration

import com.github.javaparser.ast.body.MethodDeclaration; //導入方法依賴的package包/類
private void handleMethodDeclaration(MethodDeclaration md) {
	String name = md.getName().asString();

	//-- We're only interested in getter/setters of a property.
	Type type;
	String propertyName;
	boolean isSetter = false;
	if(name.startsWith("get") || name.startsWith("is")) {
		if(md.getParameters().size() != 0)
			return;
		type = md.getType();
		if(type.equals(new VoidType()))
			return;
		int len = name.startsWith("is") ? 2 : 3;
		propertyName = name.substring(len);
	} else if(name.startsWith("set")) {
		if(md.getParameters().size() != 1)
			return;
		type = md.getParameter(0).getType();
		isSetter = true;
		propertyName = name.substring(3);
	} else
		return;

	if("opentopublic".equalsIgnoreCase(propertyName)) {
		System.out.println("GOTCHA");
	}

	//-- Decode a property name
	ColumnWrapper cw = findColumnByPropertyName(propertyName);
	if(null == cw) {
		cw = new ColumnWrapper(this);
		m_allColumnWrappers.add(cw);
		cw.setPropertyName(Introspector.decapitalize(propertyName));
	}
	cw.setPropertyType(type);
	if(isSetter)
		cw.setSetter(md);
	else
		cw.setGetter(md);

	for(AnnotationExpr annotationExpr : md.getAnnotations()) {
		handleDatabaseAnnotation(cw, annotationExpr);
	}
}
 
開發者ID:fjalvingh,項目名稱:domui,代碼行數:46,代碼來源:ClassWrapper.java


注:本文中的com.github.javaparser.ast.body.MethodDeclaration.getType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。