Java Code Examples for org.eclipse.jdt.core.dom.Modifier#ABSTRACT
The following examples show how to use
org.eclipse.jdt.core.dom.Modifier#ABSTRACT .
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: SemanticHighlightings.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
@Override public boolean consumes(SemanticToken token) { SimpleName node = token.getNode(); if (node.isDeclaration()) { return false; } IBinding binding = token.getBinding(); boolean isAbstractMethod = binding != null && binding.getKind() == IBinding.METHOD && (binding.getModifiers() & Modifier.ABSTRACT) == Modifier.ABSTRACT; if (!isAbstractMethod) { return false; } // filter out annotation value references if (binding != null) { ITypeBinding declaringType = ((IMethodBinding) binding).getDeclaringClass(); if (declaringType.isAnnotation()) { return false; } } return true; }
Example 3
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 4
Source File: SemanticHighlightings.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public boolean consumes(SemanticToken token) { SimpleName node= token.getNode(); if (node.isDeclaration()) return false; IBinding binding= token.getBinding(); boolean isAbstractMethod= binding != null && binding.getKind() == IBinding.METHOD && (binding.getModifiers() & Modifier.ABSTRACT) == Modifier.ABSTRACT; if (!isAbstractMethod) return false; // filter out annotation value references if (binding != null) { ITypeBinding declaringType= ((IMethodBinding)binding).getDeclaringClass(); if (declaringType.isAnnotation()) return false; } return true; }
Example 5
Source File: SemanticHighlightings.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public boolean consumes(SemanticToken token) { // 1: match types SimpleName name= token.getNode(); ASTNode node= name.getParent(); int nodeType= node.getNodeType(); if (nodeType != ASTNode.SIMPLE_TYPE && nodeType != ASTNode.THIS_EXPRESSION && nodeType != ASTNode.QUALIFIED_TYPE && nodeType != ASTNode.QUALIFIED_NAME && nodeType != ASTNode.TYPE_DECLARATION && nodeType != ASTNode.METHOD_INVOCATION) return false; while (nodeType == ASTNode.QUALIFIED_NAME) { node= node.getParent(); nodeType= node.getNodeType(); if (nodeType == ASTNode.IMPORT_DECLARATION) return false; } // 2: match classes IBinding binding= token.getBinding(); if (binding instanceof ITypeBinding) { ITypeBinding typeBinding= (ITypeBinding) binding; // see also ClassHighlighting return typeBinding.isClass() && (typeBinding.getModifiers() & Modifier.ABSTRACT) != 0; } return false; }
Example 6
Source File: TokenModifiers.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Override public boolean applies(IBinding binding) { int flags = binding.getModifiers(); if ((flags & Modifier.ABSTRACT) != 0) { return true; } return false; }
Example 7
Source File: SemanticHighlightings.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Override public boolean consumes(SemanticToken token) { // 1: match types SimpleName name = token.getNode(); ASTNode node = name.getParent(); int nodeType = node.getNodeType(); if (nodeType != ASTNode.SIMPLE_TYPE && nodeType != ASTNode.THIS_EXPRESSION && nodeType != ASTNode.QUALIFIED_TYPE && nodeType != ASTNode.QUALIFIED_NAME && nodeType != ASTNode.TYPE_DECLARATION && nodeType != ASTNode.METHOD_INVOCATION) { return false; } while (nodeType == ASTNode.QUALIFIED_NAME) { node = node.getParent(); nodeType = node.getNodeType(); if (nodeType == ASTNode.IMPORT_DECLARATION) { return false; } } // 2: match classes IBinding binding = token.getBinding(); if (binding instanceof ITypeBinding) { ITypeBinding typeBinding = (ITypeBinding) binding; // see also ClassHighlighting return typeBinding.isClass() && (typeBinding.getModifiers() & Modifier.ABSTRACT) != 0; } return false; }
Example 8
Source File: PushDownRefactoringProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
int getNewModifiersForOriginal(int oldModifiers) throws JavaModelException { if (isFieldInfo()) return oldModifiers; if (isToBeDeletedFromDeclaringClass()) return oldModifiers; int modifiers= oldModifiers; if (isNewMethodToBeDeclaredAbstract()) { modifiers= JdtFlags.clearFlag(Modifier.FINAL | Modifier.NATIVE, oldModifiers); modifiers|= Modifier.ABSTRACT; if (!JdtFlags.isPublic(fMember)) modifiers= Modifier.PROTECTED | JdtFlags.clearAccessModifiers(modifiers); } return modifiers; }
Example 9
Source File: NewDefiningMethodProposal.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private int evaluateModifiers() { if (getSenderBinding().isInterface()) { return 0; } else { int modifiers= fMethod.getModifiers(); if (Modifier.isPrivate(modifiers)) { modifiers |= Modifier.PROTECTED; } return modifiers & (Modifier.PUBLIC | Modifier.PROTECTED | Modifier.ABSTRACT | Modifier.STRICTFP); } }
Example 10
Source File: ElementTypeTeller.java From txtUML with Eclipse Public License 1.0 | 4 votes |
public static boolean isAbstract(ITypeBinding type) { return (type.getModifiers() & Modifier.ABSTRACT) != 0; }
Example 11
Source File: ASTReader.java From JDeodorant with MIT License | 4 votes |
private ClassObject processEnumDeclaration(IFile iFile, IDocument document, EnumDeclaration enumDeclaration, List<Comment> comments) { final ClassObject classObject = new ClassObject(); classObject.setEnum(true); classObject.setIFile(iFile); classObject.addComments(processComments(iFile, document, enumDeclaration, comments)); classObject.setName(enumDeclaration.resolveBinding().getQualifiedName()); classObject.setAbstractTypeDeclaration(enumDeclaration); int modifiers = enumDeclaration.getModifiers(); if((modifiers & Modifier.ABSTRACT) != 0) classObject.setAbstract(true); if((modifiers & Modifier.PUBLIC) != 0) classObject.setAccess(Access.PUBLIC); else if((modifiers & Modifier.PROTECTED) != 0) classObject.setAccess(Access.PROTECTED); else if((modifiers & Modifier.PRIVATE) != 0) classObject.setAccess(Access.PRIVATE); else classObject.setAccess(Access.NONE); if((modifiers & Modifier.STATIC) != 0) classObject.setStatic(true); List<Type> superInterfaceTypes = enumDeclaration.superInterfaceTypes(); for(Type interfaceType : superInterfaceTypes) { ITypeBinding binding = interfaceType.resolveBinding(); String qualifiedName = binding.getQualifiedName(); TypeObject typeObject = TypeObject.extractTypeObject(qualifiedName); classObject.addInterface(typeObject); } List<EnumConstantDeclaration> enumConstantDeclarations = enumDeclaration.enumConstants(); for(EnumConstantDeclaration enumConstantDeclaration : enumConstantDeclarations) { EnumConstantDeclarationObject enumConstantDeclarationObject = new EnumConstantDeclarationObject(enumConstantDeclaration.getName().getIdentifier()); enumConstantDeclarationObject.setEnumName(classObject.getName()); enumConstantDeclarationObject.setEnumConstantDeclaration(enumConstantDeclaration); List<Expression> arguments = enumConstantDeclaration.arguments(); for(Expression argument : arguments) { AbstractExpression abstractExpression = new AbstractExpression(argument); enumConstantDeclarationObject.addArgument(abstractExpression); } classObject.addEnumConstantDeclaration(enumConstantDeclarationObject); } List<BodyDeclaration> bodyDeclarations = enumDeclaration.bodyDeclarations(); for(BodyDeclaration bodyDeclaration : bodyDeclarations) { if(bodyDeclaration instanceof MethodDeclaration) { processMethodDeclaration(classObject, (MethodDeclaration)bodyDeclaration); } else if(bodyDeclaration instanceof FieldDeclaration) { processFieldDeclaration(classObject, (FieldDeclaration)bodyDeclaration); } } return classObject; }