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


Java MethodDeclaration.getThrows方法代碼示例

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


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

示例1: visit

import com.github.javaparser.ast.body.MethodDeclaration; //導入方法依賴的package包/類
@Override public void visit(final MethodDeclaration n, final A arg) {
	visitComment(n.getComment(), arg);
	visitAnnotations(n, arg);
	if (n.getTypeParameters() != null) {
		for (final TypeParameter t : n.getTypeParameters()) {
			t.accept(this, arg);
		}
	}
	n.getElementType().accept(this, arg);
	n.getNameExpr().accept(this, arg);
	if (n.getParameters() != null) {
		for (final Parameter p : n.getParameters()) {
			p.accept(this, arg);
		}
	}
	if (n.getThrows() != null) {
		for (final ReferenceType name : n.getThrows()) {
			name.accept(this, arg);
		}
	}
	if (n.getBody() != null) {
		n.getBody().accept(this, arg);
	}
}
 
開發者ID:javaparser,項目名稱:javasymbolsolver,代碼行數:25,代碼來源:VoidVisitorAdapter.java

示例2: visit

import com.github.javaparser.ast.body.MethodDeclaration; //導入方法依賴的package包/類
@Override public void visit(final MethodDeclaration n, final A arg) {
	visitComment(n.getComment(), arg);
	if (n.getJavaDoc() != null) {
		n.getJavaDoc().accept(this, arg);
	}
	if (n.getAnnotations() != null) {
		for (final AnnotationExpr a : n.getAnnotations()) {
			a.accept(this, arg);
		}
	}
	if (n.getTypeParameters() != null) {
		for (final TypeParameter t : n.getTypeParameters()) {
			t.accept(this, arg);
		}
	}
	n.getType().accept(this, arg);
	if (n.getParameters() != null) {
		for (final Parameter p : n.getParameters()) {
			p.accept(this, arg);
		}
	}
	if (n.getThrows() != null) {
		for (final ReferenceType name : n.getThrows()) {
			name.accept(this, arg);
		}
	}
	if (n.getBody() != null) {
		n.getBody().accept(this, arg);
	}
}
 
開發者ID:plum-umd,項目名稱:java-sketch,代碼行數:31,代碼來源:VoidVisitorAdapter.java

示例3: visit

import com.github.javaparser.ast.body.MethodDeclaration; //導入方法依賴的package包/類
@Override public void visit(final MethodDeclaration n, final A arg) {
    jw.write(n); 
    visitComment(n.getComment(), arg);
    if (n.getJavaDoc() != null) {
        n.getJavaDoc().accept(this, arg);
    }
    if (n.getAnnotations() != null) {
        for (final AnnotationExpr a : n.getAnnotations()) {
            a.accept(this, arg);
        }
    }
    if (n.getTypeParameters() != null) {
        for (final TypeParameter t : n.getTypeParameters()) {
            t.accept(this, arg);
        }
    }
    n.getType().accept(this, arg);
    if (n.getParameters() != null) {
        for (final Parameter p : n.getParameters()) {
            p.accept(this, arg);
        }
    }
    if (n.getThrows() != null) {
        for (final ReferenceType name : n.getThrows()) {
            name.accept(this, arg);
        }
    }
    if (n.getBody() != null) {
        n.getBody().accept(this, arg);
    }
}
 
開發者ID:plum-umd,項目名稱:java-sketch,代碼行數:32,代碼來源:JsonVisitorAdapter.java

示例4: visit

import com.github.javaparser.ast.body.MethodDeclaration; //導入方法依賴的package包/類
@Override public Node visit(final MethodDeclaration n, final A arg) {
	if (n.getJavaDoc() != null) {
		n.setJavaDoc((JavadocComment) n.getJavaDoc().accept(this, arg));
	}
	final List<AnnotationExpr> annotations = n.getAnnotations();
	if (annotations != null) {
		for (int i = 0; i < annotations.size(); i++) {
			annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg));
		}
		removeNulls(annotations);
	}
	final List<TypeParameter> typeParameters = n.getTypeParameters();
	if (typeParameters != null) {
		for (int i = 0; i < typeParameters.size(); i++) {
			typeParameters.set(i, (TypeParameter) typeParameters.get(i).accept(this, arg));
		}
		removeNulls(typeParameters);
	}
	n.setType((Type) n.getType().accept(this, arg));
	final List<Parameter> parameters = n.getParameters();
	if (parameters != null) {
		for (int i = 0; i < parameters.size(); i++) {
			parameters.set(i, (Parameter) parameters.get(i).accept(this, arg));
		}
		removeNulls(parameters);
	}
	final List<ReferenceType> throwz = n.getThrows();
	if (throwz != null) {
		for (int i = 0; i < throwz.size(); i++) {
			throwz.set(i, (ReferenceType) throwz.get(i).accept(this, arg));
		}
		removeNulls(throwz);
	}
	if (n.getBody() != null) {
		n.setBody((BlockStmt) n.getBody().accept(this, arg));
	}
	return n;
}
 
開發者ID:plum-umd,項目名稱:java-sketch,代碼行數:39,代碼來源:ModifierVisitorAdapter.java

示例5: visit

import com.github.javaparser.ast.body.MethodDeclaration; //導入方法依賴的package包/類
@Override public Node visit(final MethodDeclaration n, final A arg) {
	visitComment(n, arg);
	final List<AnnotationExpr> annotations = n.getAnnotations();
	if (annotations != null) {
		for (int i = 0; i < annotations.size(); i++) {
			annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg));
		}
		removeNulls(annotations);
	}
	final List<TypeParameter> typeParameters = n.getTypeParameters();
	if (typeParameters != null) {
		for (int i = 0; i < typeParameters.size(); i++) {
			typeParameters.set(i, (TypeParameter) typeParameters.get(i).accept(this, arg));
		}
		removeNulls(typeParameters);
	}
	n.setElementType((Type) n.getElementType().accept(this, arg));
	final List<Parameter> parameters = n.getParameters();
	if (parameters != null) {
		for (int i = 0; i < parameters.size(); i++) {
			parameters.set(i, (Parameter) parameters.get(i).accept(this, arg));
		}
		removeNulls(parameters);
	}
	final List<ReferenceType> throwz = n.getThrows();
	if (throwz != null) {
		for (int i = 0; i < throwz.size(); i++) {
			throwz.set(i, (ReferenceType) throwz.get(i).accept(this, arg));
		}
		removeNulls(throwz);
	}
	if (n.getBody() != null) {
		n.setBody((BlockStmt) n.getBody().accept(this, arg));
	}
	return n;
}
 
開發者ID:javaparser,項目名稱:javasymbolsolver,代碼行數:37,代碼來源:ModifierVisitorAdapter.java

示例6: visit

import com.github.javaparser.ast.body.MethodDeclaration; //導入方法依賴的package包/類
@Override public void visit(final MethodDeclaration n, final A arg) {
	visitComment(n.getComment(), arg);
	if (n.getJavaDoc() != null) {
		n.getJavaDoc().accept(this, arg);
	}
	if (n.getAnnotations() != null) {
		for (final AnnotationExpr a : n.getAnnotations()) {
			a.accept(this, arg);
		}
	}
	if (n.getTypeParameters() != null) {
		for (final TypeParameter t : n.getTypeParameters()) {
			t.accept(this, arg);
		}
	}
	n.getType().accept(this, arg);
	if (n.getParameters() != null) {
		for (final Parameter p : n.getParameters()) {
			p.accept(this, arg);
		}
	}
	if (n.getThrows() != null) {
		for (final NameExpr name : n.getThrows()) {
			name.accept(this, arg);
		}
	}
	if (n.getBody() != null) {
		n.getBody().accept(this, arg);
	}
}
 
開發者ID:javaparser,項目名稱:javasymbolsolver,代碼行數:31,代碼來源:VoidVisitorAdapter.java

示例7: visit

import com.github.javaparser.ast.body.MethodDeclaration; //導入方法依賴的package包/類
@Override public Node visit(final MethodDeclaration n, final A arg) {
	if (n.getJavaDoc() != null) {
		n.setJavaDoc((JavadocComment) n.getJavaDoc().accept(this, arg));
	}
	final List<AnnotationExpr> annotations = n.getAnnotations();
	if (annotations != null) {
		for (int i = 0; i < annotations.size(); i++) {
			annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg));
		}
		removeNulls(annotations);
	}
	final List<TypeParameter> typeParameters = n.getTypeParameters();
	if (typeParameters != null) {
		for (int i = 0; i < typeParameters.size(); i++) {
			typeParameters.set(i, (TypeParameter) typeParameters.get(i).accept(this, arg));
		}
		removeNulls(typeParameters);
	}
	n.setType((Type) n.getType().accept(this, arg));
	final List<Parameter> parameters = n.getParameters();
	if (parameters != null) {
		for (int i = 0; i < parameters.size(); i++) {
			parameters.set(i, (Parameter) parameters.get(i).accept(this, arg));
		}
		removeNulls(parameters);
	}
	final List<NameExpr> throwz = n.getThrows();
	if (throwz != null) {
		for (int i = 0; i < throwz.size(); i++) {
			throwz.set(i, (NameExpr) throwz.get(i).accept(this, arg));
		}
		removeNulls(throwz);
	}
	if (n.getBody() != null) {
		n.setBody((BlockStmt) n.getBody().accept(this, arg));
	}
	return n;
}
 
開發者ID:javaparser,項目名稱:javasymbolsolver,代碼行數:39,代碼來源:ModifierVisitorAdapter.java

示例8: buildMethodAST

import com.github.javaparser.ast.body.MethodDeclaration; //導入方法依賴的package包/類
/**
 * The standard factory method to get an enhanced AST from a method
 * @param methodDec Method declaration object as per javaparser
 * @return An enhanced AST, which can be converted to a JSON
 */
public void buildMethodAST(MethodDeclaration methodDec){
	try{
                                
        this.text = printAndExtractText(methodDec);
        
        // Get all thrown Exceptions
        for(ReferenceType type: methodDec.getThrows()){
        	this.exceptions.add(type.toString());
        }
        
        this.name = methodDec.getName();
        Node parent = methodDec.getParentNode();
        if (parent instanceof ClassOrInterfaceDeclaration){
            this.className = ((ClassOrInterfaceDeclaration) parent).getName();
        }
        this.modifier = methodDec.getModifiers();
        this.returnType = methodDec.getType().toString();

        this.paramTypes = getParamTypes(methodDec);
        
        // Get Annotations
        for(AnnotationExpr annotExpr: methodDec.getAnnotations()){
        	this.annotations.add(annotExpr.getName().toString());
        }
        
        // If JavaDocs present, extract them
        if (methodDec.getJavaDoc() != null){
            this.javaDoc = cleanDocumentation(methodDec.getJavaDoc().getContent());
        }
        
        this.comments = extractContainedComments(methodDec);
        
        // These are in-line comments just before the method definitition
        if (methodDec.getComment() != null){
        	if (this.comments == null){
        		this.comments = "";
        	}
        	this.comments += methodDec.getComment().getContent(); 
        }
        
        // Recursively loop through child nodes and make a dictionary
        this.parseBody(methodDec.getBody());
        
        this.extractHighLevelConcepts();            

    } catch (Exception ex){
        ex.printStackTrace();
    }

}
 
開發者ID:shashanksingh28,項目名稱:code-similarity,代碼行數:56,代碼來源:ASTEnhanced.java


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