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


Java MethodDeclaration.modifiers方法代碼示例

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


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

示例1: visit

import org.eclipse.jdt.core.dom.MethodDeclaration; //導入方法依賴的package包/類
public boolean visit(MethodDeclaration methodDeclaration) {
    // ASTNode parentNode = methodDeclaration.getParent();
    // if (!(parentNode instanceof TypeDeclaration)) {
    // // ignore methods from anonymous classes
    // return false;
    // }
    String methodSignature = AstUtils.getSignatureFromMethodDeclaration(methodDeclaration);
    // if
    // (methodDeclaration.getName().getIdentifier().equals("execMultiLineCommands"))
    // {
    // System.out.println("x");
    //
    // }

    final RastNode method = model.createMethod(methodSignature, containerStack.peek(), sourceFilePath, methodDeclaration.isConstructor(), methodDeclaration);

    List<?> modifiers = methodDeclaration.modifiers();
    Set<String> annotations = extractAnnotationTypes(modifiers);
    boolean deprecated = annotations.contains("Deprecated") || AstUtils.containsDeprecatedTag(methodDeclaration.getJavadoc());
    if (deprecated) {
    	method.addStereotypes(Stereotype.DEPRECATED);
    }

    int methodModifiers = methodDeclaration.getModifiers();
    Visibility visibility = getVisibility(methodModifiers);
    boolean isStatic = (methodModifiers & Modifier.STATIC) != 0;
		
    if (!isStatic) {
    	method.addStereotypes(Stereotype.TYPE_MEMBER);
    }
    
    //method.setVisibility(visibility);
    extractParametersAndReturnType(model, methodDeclaration, method);

    Block body = methodDeclaration.getBody();
    if (body == null) {
        method.addStereotypes(Stereotype.ABSTRACT);
    } else {
        final List<String> references = new ArrayList<String>();
        body.accept(new DependenciesAstVisitor(true) {
            @Override
            protected void onMethodAccess(ASTNode node, IMethodBinding binding) {
                String methodKey = AstUtils.getKeyFromMethodBinding(binding);
                references.add(methodKey);
            }

        });
        postProcessReferences.put(method, references);
    }

    return true;
}
 
開發者ID:aserg-ufmg,項目名稱:RefDiff,代碼行數:53,代碼來源:BindingsRecoveryAstVisitor.java

示例2: getNonnullReturnValueAnnotationIfPresent

import org.eclipse.jdt.core.dom.MethodDeclaration; //導入方法依賴的package包/類
private static Annotation getNonnullReturnValueAnnotationIfPresent(MethodDeclaration node) {
	@SuppressWarnings("unchecked")
	final List<IExtendedModifier> modifiers = node.modifiers();
	return findNonnullAnnotation(modifiers);
}
 
開發者ID:fabotronix,項目名稱:jsr305CleanUp,代碼行數:6,代碼來源:Jsr305CleanUp.java


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