Java Code Examples for org.eclipse.jdt.core.dom.Modifier#isProtected()
The following examples show how to use
org.eclipse.jdt.core.dom.Modifier#isProtected() .
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: Utils.java From txtUML with Eclipse Public License 1.0 | 6 votes |
public static void checkModifiers(ProblemCollector collector, BodyDeclaration elem, Predicate<Modifier> allowSpecific) { for (Object obj : elem.modifiers()) { if (!(obj instanceof Modifier)) { continue; } Modifier modifier = (Modifier) obj; boolean valid; if (allowSpecific.test(modifier)) { valid = true; } else { valid = modifier.isPrivate() || modifier.isPublic() || modifier.isProtected() || modifier.isFinal(); } if (!valid) { collector.report(INVALID_MODIFIER.create(collector.getSourceInfo(), modifier)); } } }
Example 2
Source File: JavaASTVisitor.java From SnowGraph with Apache License 2.0 | 5 votes |
private static String getVisibility(TypeDeclaration 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 3
Source File: ModifierCorrectionSubProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static String getVisibilityString(int code) { if (Modifier.isPublic(code)) { return "public"; //$NON-NLS-1$ } else if (Modifier.isProtected(code)) { return "protected"; //$NON-NLS-1$ } else if (Modifier.isPrivate(code)) { return "private"; //$NON-NLS-1$ } return CorrectionMessages.ModifierCorrectionSubProcessor_default; }
Example 4
Source File: BindingLabelProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static ImageDescriptor getInnerClassImageDescriptor(int modifiers) { if (Modifier.isPublic(modifiers)) return JavaPluginImages.DESC_OBJS_INNER_CLASS_PUBLIC; else if (Modifier.isPrivate(modifiers)) return JavaPluginImages.DESC_OBJS_INNER_CLASS_PRIVATE; else if (Modifier.isProtected(modifiers)) return JavaPluginImages.DESC_OBJS_INNER_CLASS_PROTECTED; else return JavaPluginImages.DESC_OBJS_INNER_CLASS_DEFAULT; }
Example 5
Source File: BindingLabelProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static ImageDescriptor getMethodImageDescriptor(int modifiers) { if (Modifier.isPublic(modifiers)) return JavaPluginImages.DESC_MISC_PUBLIC; if (Modifier.isProtected(modifiers)) return JavaPluginImages.DESC_MISC_PROTECTED; if (Modifier.isPrivate(modifiers)) return JavaPluginImages.DESC_MISC_PRIVATE; return JavaPluginImages.DESC_MISC_DEFAULT; }
Example 6
Source File: JdtFlags.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static String getVisibilityString(int visibilityCode){ if (Modifier.isPublic(visibilityCode)) return VISIBILITY_STRING_PUBLIC; if (Modifier.isProtected(visibilityCode)) return VISIBILITY_STRING_PROTECTED; if (Modifier.isPrivate(visibilityCode)) return VISIBILITY_STRING_PRIVATE; return VISIBILITY_STRING_PACKAGE; }
Example 7
Source File: InJavaImporter.java From jdt2famix with Eclipse Public License 1.0 | 5 votes |
private void extractBasicModifiersFromBinding(int modifiers, NamedEntity entity) { Boolean publicModifier = Modifier.isPublic(modifiers); Boolean protectedModifier = Modifier.isProtected(modifiers); Boolean privateModifier = Modifier.isPrivate(modifiers); if (publicModifier) entity.addModifiers("public"); if (protectedModifier) entity.addModifiers("protected"); if (privateModifier) entity.addModifiers("private"); if (!(publicModifier || protectedModifier || privateModifier)) entity.addModifiers("package"); if (Modifier.isFinal(modifiers)) entity.addModifiers("final"); if (Modifier.isAbstract(modifiers)) entity.addModifiers("abstract"); if (Modifier.isNative(modifiers)) entity.addModifiers("native"); if (Modifier.isSynchronized(modifiers)) entity.addModifiers("synchronized"); if (Modifier.isTransient(modifiers)) entity.addModifiers("transient"); if (Modifier.isVolatile(modifiers)) entity.addModifiers("volatile"); /* * We do not extract the static modifier here because we want to set the * hasClassScope property and we do that specifically only for attributes and * methods */ }
Example 8
Source File: NumberOfMethods.java From ck with Apache License 2.0 | 5 votes |
@Override public void visit(MethodDeclaration node) { methods++; // visibility boolean isPublic = Modifier.isPublic(node.getModifiers()); boolean isPrivate = Modifier.isPrivate(node.getModifiers()); boolean isProtected = Modifier.isProtected(node.getModifiers()); if(isPublic) publicMethods++; else if(isPrivate) privateMethods++; else if(isProtected) protectedMethods++; else defaultMethods++; // other characteristics boolean isFinal = Modifier.isFinal(node.getModifiers()); boolean isSynchronized = Modifier.isSynchronized(node.getModifiers()); boolean isAbstract = Modifier.isAbstract(node.getModifiers()); boolean isStatic = Modifier.isStatic(node.getModifiers()); if(isStatic) staticMethods++; if(isAbstract) abstractMethods++; if(isFinal) finalMethods++; if(isSynchronized) synchronizedMethods++; }
Example 9
Source File: BindingLabelProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static ImageDescriptor getInnerInterfaceImageDescriptor(int modifiers) { if (Modifier.isPublic(modifiers)) return JavaPluginImages.DESC_OBJS_INNER_INTERFACE_PUBLIC; else if (Modifier.isPrivate(modifiers)) return JavaPluginImages.DESC_OBJS_INNER_INTERFACE_PRIVATE; else if (Modifier.isProtected(modifiers)) return JavaPluginImages.DESC_OBJS_INNER_INTERFACE_PROTECTED; else return JavaPluginImages.DESC_OBJS_INTERFACE_DEFAULT; }
Example 10
Source File: JdtFlags.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
public static String getVisibilityString(int visibilityCode){ if (Modifier.isPublic(visibilityCode)) { return VISIBILITY_STRING_PUBLIC; } if (Modifier.isProtected(visibilityCode)) { return VISIBILITY_STRING_PROTECTED; } if (Modifier.isPrivate(visibilityCode)) { return VISIBILITY_STRING_PRIVATE; } return VISIBILITY_STRING_PACKAGE; }
Example 11
Source File: ModifierCorrectionSubProcessor.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private static String getVisibilityString(int code) { if (Modifier.isPublic(code)) { return "public"; //$NON-NLS-1$ } else if (Modifier.isProtected(code)) { return "protected"; //$NON-NLS-1$ } else if (Modifier.isPrivate(code)) { return "private"; //$NON-NLS-1$ } return CorrectionMessages.ModifierCorrectionSubProcessor_default; }
Example 12
Source File: JdtBasedTypeFactory.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected void setVisibility(JvmMember result, int modifiers) { if (Modifier.isPrivate(modifiers)) result.setVisibility(JvmVisibility.PRIVATE); else if (Modifier.isProtected(modifiers)) result.setVisibility(JvmVisibility.PROTECTED); else if (Modifier.isPublic(modifiers)) result.setVisibility(JvmVisibility.PUBLIC); else result.setVisibility(JvmVisibility.DEFAULT); }
Example 13
Source File: JavaASTVisitor.java From SnowGraph with Apache License 2.0 | 5 votes |
private static String getVisibility(FieldDeclaration 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 14
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 15
Source File: JdtUtils.java From j2cl with Apache License 2.0 | 5 votes |
private static Visibility getVisibility(int modifiers) { if (Modifier.isPublic(modifiers)) { return Visibility.PUBLIC; } else if (Modifier.isProtected(modifiers)) { return Visibility.PROTECTED; } else if (Modifier.isPrivate(modifiers)) { return Visibility.PRIVATE; } else { return Visibility.PACKAGE_PRIVATE; } }
Example 16
Source File: JdtFlags.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 4 votes |
public static boolean isProtected(IBinding binding) { return Modifier.isProtected(binding.getModifiers()); }
Example 17
Source File: JdtFlags.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 4 votes |
public static boolean isProtected(BodyDeclaration bodyDeclaration) { return Modifier.isProtected(bodyDeclaration.getModifiers()); }
Example 18
Source File: ExtractClassRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private FieldDeclaration createParameterObjectField(ParameterObjectFactory pof, TypeDeclaration typeNode, int modifier) { AST ast= fBaseCURewrite.getAST(); ClassInstanceCreation creation= ast.newClassInstanceCreation(); creation.setType(pof.createType(fDescriptor.isCreateTopLevel(), fBaseCURewrite, typeNode.getStartPosition())); ListRewrite listRewrite= fBaseCURewrite.getASTRewrite().getListRewrite(creation, ClassInstanceCreation.ARGUMENTS_PROPERTY); for (Iterator<FieldInfo> iter= fVariables.values().iterator(); iter.hasNext();) { FieldInfo fi= iter.next(); if (isCreateField(fi)) { Expression expression= fi.initializer; if (expression != null && !fi.hasFieldReference()) { importNodeTypes(expression, fBaseCURewrite); ASTNode createMoveTarget= fBaseCURewrite.getASTRewrite().createMoveTarget(expression); if (expression instanceof ArrayInitializer) { ArrayInitializer ai= (ArrayInitializer) expression; ITypeBinding type= ai.resolveTypeBinding(); Type addImport= fBaseCURewrite.getImportRewrite().addImport(type, ast); fBaseCURewrite.getImportRemover().registerAddedImports(addImport); ArrayCreation arrayCreation= ast.newArrayCreation(); arrayCreation.setType((ArrayType) addImport); arrayCreation.setInitializer((ArrayInitializer) createMoveTarget); listRewrite.insertLast(arrayCreation, null); } else { listRewrite.insertLast(createMoveTarget, null); } } } } VariableDeclarationFragment fragment= ast.newVariableDeclarationFragment(); fragment.setName(ast.newSimpleName(fDescriptor.getFieldName())); fragment.setInitializer(creation); ModifierKeyword acc= null; if (Modifier.isPublic(modifier)) { acc= ModifierKeyword.PUBLIC_KEYWORD; } else if (Modifier.isProtected(modifier)) { acc= ModifierKeyword.PROTECTED_KEYWORD; } else if (Modifier.isPrivate(modifier)) { acc= ModifierKeyword.PRIVATE_KEYWORD; } FieldDeclaration fieldDeclaration= ast.newFieldDeclaration(fragment); fieldDeclaration.setType(pof.createType(fDescriptor.isCreateTopLevel(), fBaseCURewrite, typeNode.getStartPosition())); if (acc != null) fieldDeclaration.modifiers().add(ast.newModifier(acc)); return fieldDeclaration; }
Example 19
Source File: JdtFlags.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public static boolean isProtected(BodyDeclaration bodyDeclaration) { return Modifier.isProtected(bodyDeclaration.getModifiers()); }
Example 20
Source File: JdtFlags.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public static boolean isProtected(IBinding binding) { return Modifier.isProtected(binding.getModifiers()); }