Java Code Examples for org.eclipse.jdt.core.dom.MethodDeclaration#getModifiers()
The following examples show how to use
org.eclipse.jdt.core.dom.MethodDeclaration#getModifiers() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NewMethodCorrectionProposal.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
private int getInterfaceMethodModifiers(ASTNode targetTypeDecl, boolean createAbstractMethod) { // for interface and annotation members copy the modifiers from an existing member if (targetTypeDecl instanceof TypeDeclaration) { TypeDeclaration type= (TypeDeclaration) targetTypeDecl; MethodDeclaration[] methodDecls= type.getMethods(); if (methodDecls.length > 0) { if (createAbstractMethod) { for (MethodDeclaration methodDeclaration : methodDecls) { IMethodBinding methodBinding= methodDeclaration.resolveBinding(); if (methodBinding != null && JdtFlags.isAbstract(methodBinding)) { return methodDeclaration.getModifiers(); } } } return methodDecls[0].getModifiers() & Modifier.PUBLIC; } List<BodyDeclaration> bodyDecls= type.bodyDeclarations(); if (bodyDecls.size() > 0) { return bodyDecls.get(0).getModifiers() & Modifier.PUBLIC; } } return 0; }
Example 2
Source File: JavaSourceFileParser.java From BUILD_file_generator with Apache License 2.0 | 5 votes |
/** * Returns true iff 'methodDeclaration' represents a void static method named 'main' that takes a * single String[] parameter. */ private static boolean isMainMethod(MethodDeclaration methodDeclaration) { // Is it static? if ((methodDeclaration.getModifiers() & Modifier.STATIC) == 0) { return false; } // Does it return void? Type returnType = methodDeclaration.getReturnType2(); if (!returnType.isPrimitiveType()) { return false; } if (((PrimitiveType) returnType).getPrimitiveTypeCode() != PrimitiveType.VOID) { return false; } // Is it called 'main'? if (!"main".equals(methodDeclaration.getName().getIdentifier())) { return false; } // Does it have a single parameter? if (methodDeclaration.parameters().size() != 1) { return false; } // Is the parameter's type String[]? SingleVariableDeclaration pt = getOnlyElement((List<SingleVariableDeclaration>) methodDeclaration.parameters()); IVariableBinding vb = pt.resolveBinding(); if (vb == null) { return false; } ITypeBinding tb = vb.getType(); return tb != null && "java.lang.String[]".equals(tb.getQualifiedName()); }
Example 3
Source File: SM_Method.java From DesigniteJava with Apache License 2.0 | 5 votes |
public void setMethodInfo(MethodDeclaration method) { int modifiers = method.getModifiers(); if (Modifier.isAbstract(modifiers)) abstractMethod = true; if (Modifier.isFinal(modifiers)) finalMethod = true; if (Modifier.isStatic(modifiers)) staticMethod = true; if (method.isConstructor()) isConstructor = true; }
Example 4
Source File: JavaASTVisitor.java From SnowGraph with Apache License 2.0 | 5 votes |
private static String getVisibility(MethodDeclaration decl) { int modifiers = decl.getModifiers(); if (Modifier.isPrivate(modifiers)) return "private"; if (Modifier.isProtected(modifiers)) return "protected"; if (Modifier.isPublic(modifiers)) return "public"; return "package"; }
Example 5
Source File: UiBinderUtilities.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
public static boolean isUiHandler(MethodDeclaration method) { if ((method.getModifiers() & Modifier.STATIC) != 0) { return false; } if (method.isConstructor()) { return false; } return (JavaASTUtils.findAnnotation(method, UiBinderConstants.UI_HANDLER_TYPE_NAME) != null); }
Example 6
Source File: Testq12.java From compiler with Apache License 2.0 | 5 votes |
@Override public boolean visit(MethodDeclaration node) { if ((node.getModifiers() & Modifier.STATIC) > 0 && !node.getName().toString().equals("main")) { methods++; methods2++; } return true; }
Example 7
Source File: JavaASTVisitor.java From SnowGraph with Apache License 2.0 | 4 votes |
private static boolean isAbstract(MethodDeclaration decl) { int modifiers = decl.getModifiers(); return (Modifier.isAbstract(modifiers)); }
Example 8
Source File: JavaASTVisitor.java From SnowGraph with Apache License 2.0 | 4 votes |
private static boolean isFinal(MethodDeclaration decl) { int modifiers = decl.getModifiers(); return (Modifier.isFinal(modifiers)); }
Example 9
Source File: JavaASTVisitor.java From SnowGraph with Apache License 2.0 | 4 votes |
private static boolean isStatic(MethodDeclaration decl) { int modifiers = decl.getModifiers(); return (Modifier.isStatic(modifiers)); }
Example 10
Source File: JavaASTVisitor.java From SnowGraph with Apache License 2.0 | 4 votes |
private static boolean isSynchronized(MethodDeclaration decl) { int modifiers = decl.getModifiers(); return (Modifier.isSynchronized(modifiers)); }
Example 11
Source File: PreconditionExaminer.java From JDeodorant with MIT License | 4 votes |
private boolean extractToUtilityClass(ITypeBinding commonSuperTypeOfSourceTypeDeclarations, MethodDeclaration methodDeclaration1, MethodDeclaration methodDeclaration2) { return cloneFragmentsDoNotAccessFieldsOrMethods() && (ASTNodeMatcher.isTaggingInterface(commonSuperTypeOfSourceTypeDeclarations) || commonSuperTypeOfSourceTypeDeclarations.isInterface() || (methodDeclaration1.getModifiers() & Modifier.STATIC) != 0 || (methodDeclaration2.getModifiers() & Modifier.STATIC) != 0); }