Java Code Examples for org.eclipse.jdt.core.dom.AbstractTypeDeclaration#getModifiers()
The following examples show how to use
org.eclipse.jdt.core.dom.AbstractTypeDeclaration#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: JavaSourceFileParser.java From BUILD_file_generator with Apache License 2.0 | 6 votes |
private static String decideRuleKind(ReferencedClassesParser parser, Set<String> dependencies) { CompilationUnit cu = parser.compilationUnit; if (cu.types().isEmpty()) { return "java_library"; } AbstractTypeDeclaration topLevelClass = (AbstractTypeDeclaration) cu.types().get(0); if ((topLevelClass.getModifiers() & Modifier.ABSTRACT) != 0) { // Class is abstract, can't be a test. return "java_library"; } // JUnit 4 tests if (parser.className.endsWith("Test") && dependencies.contains("org.junit.Test")) { return "java_test"; } if (any( topLevelClass.bodyDeclarations(), d -> d instanceof MethodDeclaration && isMainMethod((MethodDeclaration) d))) { return "java_binary"; } return "java_library"; }
Example 2
Source File: UMLModelASTReader.java From RefactoringMiner with MIT License | 6 votes |
private void processModifiers(CompilationUnit cu, String sourceFile, AbstractTypeDeclaration typeDeclaration, UMLClass umlClass) { int modifiers = typeDeclaration.getModifiers(); if((modifiers & Modifier.ABSTRACT) != 0) umlClass.setAbstract(true); if((modifiers & Modifier.PUBLIC) != 0) umlClass.setVisibility("public"); else if((modifiers & Modifier.PROTECTED) != 0) umlClass.setVisibility("protected"); else if((modifiers & Modifier.PRIVATE) != 0) umlClass.setVisibility("private"); else umlClass.setVisibility("package"); List<IExtendedModifier> extendedModifiers = typeDeclaration.modifiers(); for(IExtendedModifier extendedModifier : extendedModifiers) { if(extendedModifier.isAnnotation()) { Annotation annotation = (Annotation)extendedModifier; umlClass.addAnnotation(new UMLAnnotation(cu, sourceFile, annotation)); } } }
Example 3
Source File: ChangeSignatureProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static int getAccessModifier(AbstractTypeDeclaration subclass) { int modifiers= subclass.getModifiers(); if (Modifier.isPublic(modifiers)) return Modifier.PUBLIC; else if (Modifier.isProtected(modifiers)) return Modifier.PROTECTED; else if (Modifier.isPrivate(modifiers)) return Modifier.PRIVATE; else return Modifier.NONE; }