List of usage examples for org.eclipse.jdt.internal.compiler.lookup FieldBinding isPublic
public final boolean isPublic()
From source file:com.google.gwt.dev.javac.Shared.java
License:Open Source License
public static int bindingToModifierBits(FieldBinding binding) { int bits = 0; bits |= (binding.isPublic() ? MOD_PUBLIC : 0); bits |= (binding.isPrivate() ? MOD_PRIVATE : 0); bits |= (binding.isProtected() ? MOD_PROTECTED : 0); bits |= (binding.isStatic() ? MOD_STATIC : 0); bits |= (binding.isTransient() ? MOD_TRANSIENT : 0); bits |= (binding.isFinal() ? MOD_FINAL : 0); bits |= (binding.isVolatile() ? MOD_VOLATILE : 0); return bits;//from w ww.ja v a2s . c om }
From source file:com.google.gwt.dev.jjs.ast.AccessModifier.java
License:Apache License
public static AccessModifier fromFieldBinding(FieldBinding fieldBinding) { if (fieldBinding.isPublic()) { return PUBLIC; } else if (fieldBinding.isProtected()) { return PROTECTED; } else if (fieldBinding.isPrivate()) { return PRIVATE; }//w w w . ja va 2 s. c o m assert fieldBinding.isDefault(); return DEFAULT; }
From source file:com.google.gwt.dev.jjs.impl.BuildTypeMap.java
License:Apache License
private void resolve(JDeclaredType type, ReferenceBinding binding) { process(binding);// w w w. j a v a2 s . c om for (FieldBinding fieldBinding : binding.fields()) { if (fieldBinding.isPrivate() || (type.getName().startsWith("java.") && !fieldBinding.isPublic() && !fieldBinding.isProtected())) { continue; } createField(type.getSourceInfo(), fieldBinding, type); } for (MethodBinding methodBinding : binding.methods()) { processExternalMethod(methodBinding, type); } if (binding instanceof BinaryTypeBinding) { // Unlike SourceTypeBindings, we have to explicitly ask for bridge methods // for BinaryTypeBindings. try { // TODO(tobyr) Fix so we don't have to use reflection. Method m = BinaryTypeBinding.class.getDeclaredMethod("bridgeMethods"); MethodBinding[] bridgeMethods = (MethodBinding[]) m.invoke(binding); for (MethodBinding methodBinding : bridgeMethods) { processExternalMethod(methodBinding, type); } } catch (Exception e) { throw new InternalCompilerException("Unexpected failure", e); } } }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.ast.FieldAccessSpec.java
License:Open Source License
@Override // if an access method is needed, return that accessor, else null public MethodBinding resolveFeature(final ReferenceBinding baseType, final BlockScope scope, boolean callinExpected, boolean isBaseSide, boolean allowEnclosing) { // find field in type or superclass: this.resolvedField = TypeAnalyzer.findField(baseType, this.selector, /*don't check static*/false, /*outer*/false); if (this.resolvedField == null) this.resolvedField = new ProblemFieldBinding(baseType, this.selector, ProblemReasons.NotFound); // Note: if more resilience is desired, try to set resolvedField.resolvedType and proceed if (!this.resolvedField.isValidBinding()) return null; this.fieldType = resolvedType(); // may be improved below final TypeBinding fieldLeafType = this.fieldType.leafComponentType(); if (fieldLeafType instanceof ReferenceBinding) { final int outerDimensions = this.fieldType.dimensions(); TypeArgumentUpdater updater = new TypeArgumentUpdater() { @Override/* ww w. ja va2s . com*/ public TypeBinding updateArg(ReferenceBinding type) { boolean atTopLevel = type == fieldLeafType; //$IDENTITY-COMPARISON$ if (type.isRole()) { // find team anchor for role type of base field: ITeamAnchor newAnchor = null; if (baseType instanceof RoleTypeBinding) { // base class is already a role: construct the full team anchor: RoleTypeBinding baseRole = (RoleTypeBinding) baseType; if (type instanceof RoleTypeBinding) { RoleTypeBinding fieldRole = (RoleTypeBinding) type; if (fieldRole.hasExplicitAnchor()) newAnchor = fieldRole._teamAnchor.setPathPrefix(baseRole._teamAnchor); else newAnchor = baseRole._teamAnchor; } else { newAnchor = baseRole._teamAnchor; } } else if (baseType.isTeam()) { // base class is a team, construct simple anchor ReferenceBinding enclRole = scope.enclosingSourceType(); newAnchor = TypeAnalyzer.findField(enclRole, IOTConstants._OT_BASE, /*don't check static*/false, /*outer*/false); } // else fieldLeafType might already be a anchored type, // independent of _OT$base, leave it as it is if (newAnchor != null && newAnchor.isValidBinding()) return newAnchor.getRoleTypeBinding(type, atTopLevel ? outerDimensions : 0); } return atTopLevel ? FieldAccessSpec.this.fieldType : type; } }; this.fieldType = updater.updateArg((ReferenceBinding) fieldLeafType).maybeWrapRoleType(this, updater); } if (!baseType.isRole() && this.resolvedField.canBeSeenBy(scope.enclosingReceiverType().baseclass(), this, scope)) { // no accessor method needed this.implementationStrategy = ImplementationStrategy.DIRECT; if (!this.isSetter()) this.parameters = Binding.NO_PARAMETERS; else this.parameters = new TypeBinding[] { this.fieldType }; return null; } this.implementationStrategy = scope.compilerOptions().weavingScheme == WeavingScheme.OTDRE ? ImplementationStrategy.DYN_ACCESS : ImplementationStrategy.DECAPS_WRAPPER; // find accessor method which might have been generated already. char[] accessorSelector = getSelector(); MethodBinding result = null; if (!this.resolvedField.isPrivate()) // don't reuse accessor to private field from super-base (see Trac #232) result = baseType.getMethod(scope, accessorSelector); // NOTE: could be optimized if type has no such method but exact type already has. // but the the OTRE would need to be informed.. if (result == null || !isMethodCompatible(result)) { // record this field access for Attribute generation: RoleModel roleModel = scope.enclosingSourceType().roleModel; // find appropriate target class FieldBinding field = this.resolvedField; ReferenceBinding targetClass = field.declaringClass; // default: the class declaring the field (could be super of bound base) if (!field.isStatic() && (field.isProtected() || field.isPublic())) targetClass = roleModel.getBaseTypeBinding(); // use the specific declared bound class (avoids weaving into possibly inaccessible super base) // create accessor method: result = createMethod(scope, targetClass, accessorSelector); } this.selector = accessorSelector; this.resolvedMethod = result; this.parameters = this.resolvedMethod.getSourceParameters(); return this.resolvedMethod; }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.model.RoleModel.java
License:Open Source License
/** * Record that a given field is accessed using callout. * @param field//from w w w.j a v a2 s .c o m * @param calloutModifier either TokenNameget or TokenNameset (from TerminalTokens). * @return the accessId (per team) for this field */ public int addAccessedBaseField(FieldBinding field, int calloutModifier) { // find appropriate target class ReferenceBinding targetClass = field.declaringClass; // default: the class declaring the field (could be super of bound base) if (!field.isStatic() && (field.isProtected() || field.isPublic())) targetClass = getBaseTypeBinding(); // use the specific declared bound class (avoids weaving into possibly inaccessible super base) // push out to the team to ensure early evaluation by the OTRE: OTSpecialAccessAttribute specialAccess = getTeamModel().getSpecialAccessAttribute(); int accessId = specialAccess.addCalloutFieldAccess(field, targetClass, calloutModifier); specialAccess.addAdaptedBaseClass(field.declaringClass); return accessId; }