本文整理匯總了Java中org.eclipse.jdt.core.dom.Modifier.PUBLIC屬性的典型用法代碼示例。如果您正苦於以下問題:Java Modifier.PUBLIC屬性的具體用法?Java Modifier.PUBLIC怎麽用?Java Modifier.PUBLIC使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.eclipse.jdt.core.dom.Modifier
的用法示例。
在下文中一共展示了Modifier.PUBLIC屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: installLinkedVisibilityProposals
public static void installLinkedVisibilityProposals(LinkedProposalModel linkedProposalModel, ASTRewrite rewrite, List<IExtendedModifier> modifiers, boolean inInterface, String groupId) {
ASTNode modifier = findVisibilityModifier(modifiers);
if (modifier != null) {
int selected = ((Modifier) modifier).getKeyword().toFlagValue();
LinkedProposalPositionGroup positionGroup = linkedProposalModel.getPositionGroup(groupId, true);
positionGroup.addPosition(rewrite.track(modifier), false);
positionGroup.addProposal(new ModifierLinkedModeProposal(selected, 10));
// add all others
int[] flagValues = inInterface ? new int[] { Modifier.PUBLIC, 0 } : new int[] { Modifier.PUBLIC, 0, Modifier.PROTECTED, Modifier.PRIVATE };
for (int i = 0; i < flagValues.length; i++) {
if (flagValues[i] != selected) {
positionGroup.addProposal(new ModifierLinkedModeProposal(flagValues[i], 9 - i));
}
}
}
}
示例2: getInterfaceMethodModifiers
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;
}
示例3: getLocalRefType
public static ITypeBinding getLocalRefType() {
synchronized (instance) {
if (instance.localRefType == null) {
ITypeBinding objectType = instance.ast.resolveWellKnownType("java.lang.Object");
GeneratedTypeBinding refType =
GeneratedTypeBinding.newTypeBinding("com.google.j2objc.util.ScopedLocalRef",
objectType, false);
GeneratedVariableBinding varBinding = new GeneratedVariableBinding("var", Modifier.PUBLIC,
objectType, true, false, refType, null);
refType.addField(varBinding);
GeneratedMethodBinding constructor =
GeneratedMethodBinding.newConstructor(refType, Modifier.PUBLIC);
constructor.addParameter(objectType);
refType.addMethod(constructor);
instance.localRefType = refType;
}
return instance.localRefType;
}
}
示例4: getNeededVisibility
private static int getNeededVisibility(
ASTNode currNode, ITypeBinding targetType, IBinding binding) {
ITypeBinding currNodeBinding = Bindings.getBindingOfParentType(currNode);
if (currNodeBinding == null) { // import
return Modifier.PUBLIC;
}
if (Bindings.isSuperType(targetType, currNodeBinding)) {
if (binding != null
&& (JdtFlags.isProtected(binding) || binding.getKind() == IBinding.TYPE)) {
return Modifier.PUBLIC;
}
return Modifier.PROTECTED;
}
if (currNodeBinding.getPackage().getKey().equals(targetType.getPackage().getKey())) {
return 0;
}
return Modifier.PUBLIC;
}
示例5: isHigherVisibility
/**
* Compares two visibilities.
*
* @param newVisibility the 'new' visibility
* @param oldVisibility the 'old' visibility
* @return <code>true</code> iff the 'new' visibility is strictly higher than the old visibility
* @see Modifier#PUBLIC
* @see Modifier#PROTECTED
* @see Modifier#NONE
* @see Modifier#PRIVATE
*/
public static boolean isHigherVisibility(int newVisibility, int oldVisibility) {
assertVisibility(oldVisibility);
assertVisibility(newVisibility);
switch (oldVisibility) {
case Modifier.PRIVATE:
return newVisibility == Modifier.NONE
|| newVisibility == Modifier.PUBLIC
|| newVisibility == Modifier.PROTECTED;
case Modifier.NONE:
return newVisibility == Modifier.PUBLIC || newVisibility == Modifier.PROTECTED;
case Modifier.PROTECTED:
return newVisibility == Modifier.PUBLIC;
case Modifier.PUBLIC:
return false;
default:
Assert.isTrue(false);
return false;
}
}
示例6: isHigherVisibility
/**
* Compares two visibilities.
*
* @param newVisibility the 'new' visibility
* @param oldVisibility the 'old' visibility
* @return <code>true</code> iff the 'new' visibility is strictly higher than the old visibility
* @see org.eclipse.jdt.core.dom.Modifier#PUBLIC
* @see org.eclipse.jdt.core.dom.Modifier#PROTECTED
* @see org.eclipse.jdt.core.dom.Modifier#NONE
* @see org.eclipse.jdt.core.dom.Modifier#PRIVATE
*/
public static boolean isHigherVisibility(int newVisibility, int oldVisibility) {
assertVisibility(oldVisibility);
assertVisibility(newVisibility);
switch (oldVisibility) {
case Modifier.PRIVATE:
return newVisibility == Modifier.NONE
|| newVisibility == Modifier.PUBLIC
|| newVisibility == Modifier.PROTECTED;
case Modifier.NONE:
return newVisibility == Modifier.PUBLIC || newVisibility == Modifier.PROTECTED;
case Modifier.PROTECTED:
return newVisibility == Modifier.PUBLIC;
case Modifier.PUBLIC:
return false;
default:
Assert.isTrue(false);
return false;
}
}
示例7: getVisibility
private Visibility getVisibility(int methodModifiers) {
Visibility visibility;
if ((methodModifiers & Modifier.PUBLIC) != 0)
visibility = Visibility.PUBLIC;
else if ((methodModifiers & Modifier.PROTECTED) != 0)
visibility = Visibility.PROTECTED;
else if ((methodModifiers & Modifier.PRIVATE) != 0)
visibility = Visibility.PRIVATE;
else
visibility = Visibility.PACKAGE;
return visibility;
}
示例8: getModifier
private static String getModifier(IBinding ib) {
if ((ib.getModifiers() & Modifier.PUBLIC) > 0)
return Fact.PUBLIC;
else if ((ib.getModifiers() & Modifier.PROTECTED) > 0)
return Fact.PROTECTED;
else if ((ib.getModifiers() & Modifier.PRIVATE) > 0)
return Fact.PRIVATE;
else
return Fact.PACKAGE;
}
示例9: evaluateFieldModifiers
private int evaluateFieldModifiers(ASTNode newTypeDecl) {
if (fSenderBinding.isAnnotation()) {
return 0;
}
if (fSenderBinding.isInterface()) {
// for interface members copy the modifiers from an existing field
FieldDeclaration[] fieldDecls= ((TypeDeclaration) newTypeDecl).getFields();
if (fieldDecls.length > 0) {
return fieldDecls[0].getModifiers();
}
return 0;
}
int modifiers= 0;
if (fVariableKind == CONST_FIELD) {
modifiers |= Modifier.FINAL | Modifier.STATIC;
} else {
ASTNode parent= fOriginalNode.getParent();
if (parent instanceof QualifiedName) {
IBinding qualifierBinding= ((QualifiedName)parent).getQualifier().resolveBinding();
if (qualifierBinding instanceof ITypeBinding) {
modifiers |= Modifier.STATIC;
}
} else if (ASTResolving.isInStaticContext(fOriginalNode)) {
modifiers |= Modifier.STATIC;
}
}
ASTNode node= ASTResolving.findParentType(fOriginalNode, true);
if (newTypeDecl.equals(node)) {
modifiers |= Modifier.PRIVATE;
} else if (node instanceof AnonymousClassDeclaration) {
modifiers |= Modifier.PROTECTED;
} else {
modifiers |= Modifier.PUBLIC;
}
return modifiers;
}
示例10: endVisit
@Override
public void endVisit(TypeDeclaration node) {
ITypeBinding type = node.getTypeBinding();
List<IVariableBinding> fields = getWeakFields(node);
if (fields.isEmpty()) {
return;
}
ITypeBinding voidType = Types.resolveJavaType("void");
int modifiers = Modifier.PUBLIC | BindingUtil.ACC_SYNTHETIC;
IOSMethodBinding methodBinding = IOSMethodBinding.newMethod(
JAVA_CLONE_METHOD, modifiers, voidType, type);
MethodDeclaration declaration = new MethodDeclaration(methodBinding);
node.getBodyDeclarations().add(declaration);
Block body = new Block();
declaration.setBody(body);
List<Statement> statements = body.getStatements();
SuperMethodInvocation superCall = new SuperMethodInvocation(nsObjectJavaClone);
statements.add(new ExpressionStatement(superCall));
for (IVariableBinding field : fields) {
if (Options.useARC()) {
FunctionInvocation invocation = new FunctionInvocation(
"JreRelease", voidType, voidType, voidType);
invocation.getArguments().add(new SimpleName(field));
statements.add(new ExpressionStatement(invocation));
} else {
statements.add(new ExpressionStatement(
new MethodInvocation(releaseBinding, new SimpleName(field))));
}
}
}
示例11: addDefaultConstructor
void addDefaultConstructor(
ITypeBinding type, List<BodyDeclaration> members, List<Statement> initStatements) {
int constructorModifier =
type.getModifiers() & (Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE);
GeneratedMethodBinding binding = GeneratedMethodBinding.newConstructor(
type.getSuperclass(), constructorModifier);
initStatements.add(0, new SuperConstructorInvocation(binding));
members.add(createMethod(GeneratedMethodBinding.newConstructor(type, constructorModifier),
initStatements));
}
示例12: buildFinalizeMethod
private MethodDeclaration buildFinalizeMethod(
ITypeBinding declaringClass, List<IVariableBinding> fields) {
ITypeBinding voidType = Types.mapTypeName("void");
int modifiers = Modifier.PUBLIC | BindingUtil.ACC_SYNTHETIC;
GeneratedMethodBinding binding = GeneratedMethodBinding.newMethod(
NameTable.DEALLOC_METHOD, modifiers, voidType, declaringClass);
MethodDeclaration method = new MethodDeclaration(binding);
method.setBody(new Block());
addReleaseStatements(method, fields);
return method;
}
示例13: maybeRewriteArrayLength
private void maybeRewriteArrayLength(Expression node, SimpleName name, Expression expr) {
ITypeBinding exprType = expr.getTypeBinding();
if (name.getIdentifier().equals("length") && exprType.isArray()) {
GeneratedVariableBinding sizeField = new GeneratedVariableBinding(
"size", Modifier.PUBLIC, Types.resolveJavaType("int"), true, false,
Types.mapType(exprType), null);
node.replaceWith(new FieldAccess(sizeField, TreeUtil.remove(expr)));
}
}
示例14: getVisibilityCode
public static int getVisibilityCode(IMember member) throws JavaModelException {
if (isPublic(member)) return Modifier.PUBLIC;
else if (isProtected(member)) return Modifier.PROTECTED;
else if (isPackageVisible(member)) return Modifier.NONE;
else if (isPrivate(member)) return Modifier.PRIVATE;
Assert.isTrue(false);
return VISIBILITY_CODE_INVALID;
}
示例15: evaluateFieldModifiers
private int evaluateFieldModifiers(ASTNode newTypeDecl) {
if (fSenderBinding.isAnnotation()) {
return 0;
}
if (fSenderBinding.isInterface()) {
// for interface members copy the modifiers from an existing field
FieldDeclaration[] fieldDecls = ((TypeDeclaration) newTypeDecl).getFields();
if (fieldDecls.length > 0) {
return fieldDecls[0].getModifiers();
}
return 0;
}
int modifiers = 0;
if (fVariableKind == CONST_FIELD) {
modifiers |= Modifier.FINAL | Modifier.STATIC;
} else {
ASTNode parent = fOriginalNode.getParent();
if (parent instanceof QualifiedName) {
IBinding qualifierBinding = ((QualifiedName) parent).getQualifier().resolveBinding();
if (qualifierBinding instanceof ITypeBinding) {
modifiers |= Modifier.STATIC;
}
} else if (ASTResolving.isInStaticContext(fOriginalNode)) {
modifiers |= Modifier.STATIC;
}
}
ASTNode node = ASTResolving.findParentType(fOriginalNode, true);
if (newTypeDecl.equals(node)) {
modifiers |= Modifier.PRIVATE;
} else if (node instanceof AnonymousClassDeclaration) {
modifiers |= Modifier.PROTECTED;
} else {
modifiers |= Modifier.PUBLIC;
}
return modifiers;
}