本文整理汇总了Java中org.eclipse.jdt.internal.compiler.lookup.FieldBinding类的典型用法代码示例。如果您正苦于以下问题:Java FieldBinding类的具体用法?Java FieldBinding怎么用?Java FieldBinding使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FieldBinding类属于org.eclipse.jdt.internal.compiler.lookup包,在下文中一共展示了FieldBinding类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: failIfContainsAnnotation
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; //导入依赖的package包/类
private static void failIfContainsAnnotation(TypeBinding parent, Binding[] bindings) throws DelegateRecursion {
if (bindings == null) return;
for (Binding b : bindings) {
AnnotationBinding[] anns = null;
if (b instanceof MethodBinding) anns = ((MethodBinding) b).getAnnotations();
if (b instanceof FieldBinding) anns = ((FieldBinding) b).getAnnotations();
// anns = b.getAnnotations() would make a heck of a lot more sense, but that is a late addition to ecj, so would cause NoSuchMethodErrors! Don't use that!
if (anns == null) continue;
for (AnnotationBinding ann : anns) {
char[][] name = null;
try {
name = ann.getAnnotationType().compoundName;
} catch (Exception ignore) {}
if (name == null || name.length < 2 || name.length > 3) continue;
if (!Arrays.equals(STRING_LOMBOK, name[0])) continue;
if (!Arrays.equals(STRING_DELEGATE, name[name.length - 1])) continue;
if (name.length == 3 && !Arrays.equals(STRING_EXPERIMENTAL, name[1])) continue;
throw new DelegateRecursion(parent.readableName(), b.readableName());
}
}
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:25,代码来源:PatchDelegate.java
示例2: getField
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; //导入依赖的package包/类
@Override
@Nullable
public ResolvedField getField(@NonNull String name, boolean includeInherited) {
if (mBinding instanceof ReferenceBinding) {
ReferenceBinding cls = (ReferenceBinding) mBinding;
while (cls != null) {
FieldBinding[] fields = cls.fields();
if (fields != null) {
for (FieldBinding field : fields) {
if (sameChars(name, field.name)) {
return new EcjResolvedField(field);
}
}
}
if (includeInherited) {
cls = cls.superclass();
} else {
break;
}
}
}
return null;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:EcjParser.java
示例3: hides
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; //导入依赖的package包/类
@Override
public boolean hides(Element hiddenElement)
{
if (_binding instanceof FieldBinding) {
if (!(((ElementImpl)hiddenElement)._binding instanceof FieldBinding)) {
return false;
}
FieldBinding hidden = (FieldBinding)((ElementImpl)hiddenElement)._binding;
if (hidden.isPrivate()) {
return false;
}
FieldBinding hider = (FieldBinding)_binding;
if (hidden == hider) {
return false;
}
if (!CharOperation.equals(hider.name, hidden.name)) {
return false;
}
return null != hider.declaringClass.findSuperTypeOriginatingFrom(hidden.declaringClass);
}
// TODO: should we implement hides() for method parameters?
return false;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:24,代码来源:VariableElementImpl.java
示例4: getEnclosedElements
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; //导入依赖的package包/类
@Override
public List<? extends Element> getEnclosedElements() {
ReferenceBinding binding = (ReferenceBinding)_binding;
List<Element> enclosed = new ArrayList<Element>(binding.fieldCount() + binding.methods().length);
for (MethodBinding method : binding.methods()) {
ExecutableElement executable = new ExecutableElementImpl(_env, method);
enclosed.add(executable);
}
for (FieldBinding field : binding.fields()) {
// TODO no field should be excluded according to the JLS
if (!field.isSynthetic()) {
VariableElement variable = new VariableElementImpl(_env, field);
enclosed.add(variable);
}
}
for (ReferenceBinding memberType : binding.memberTypes()) {
TypeElement type = new TypeElementImpl(_env, memberType, null);
enclosed.add(type);
}
return Collections.unmodifiableList(enclosed);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:22,代码来源:TypeElementImpl.java
示例5: resolveType
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; //导入依赖的package包/类
public TypeBinding resolveType(BlockScope scope) {
// it can be a package, type, member type, local variable or field
this.binding = scope.getBinding(this.tokens, this);
if (!this.binding.isValidBinding()) {
if (this.binding instanceof ProblemFieldBinding) {
// tolerate some error cases
if (this.binding.problemId() == ProblemReasons.NotVisible
|| this.binding.problemId() == ProblemReasons.InheritedNameHidesEnclosingName
|| this.binding.problemId() == ProblemReasons.NonStaticReferenceInConstructorInvocation
|| this.binding.problemId() == ProblemReasons.NonStaticReferenceInStaticContext) {
throw new SelectionNodeFound(this.binding);
}
scope.problemReporter().invalidField(this, (FieldBinding) this.binding);
} else if (this.binding instanceof ProblemReferenceBinding || this.binding instanceof MissingTypeBinding) {
// tolerate some error cases
if (this.binding.problemId() == ProblemReasons.NotVisible){
throw new SelectionNodeFound(this.binding);
}
scope.problemReporter().invalidType(this, (TypeBinding) this.binding);
} else {
scope.problemReporter().unresolvableReference(this, this.binding);
}
throw new SelectionNodeFound();
}
throw new SelectionNodeFound(this.binding);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:27,代码来源:SelectionOnQualifiedNameReference.java
示例6: checkFieldAccess
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; //导入依赖的package包/类
/**
* Check and/or redirect the field access to the delegate receiver if any
*/
public TypeBinding checkFieldAccess(BlockScope scope) {
FieldBinding fieldBinding = (FieldBinding) this.binding;
MethodScope methodScope = scope.methodScope();
TypeBinding declaringClass = fieldBinding.original().declaringClass;
// check for forward references
if ((this.indexOfFirstFieldBinding == 1 || declaringClass.isEnum())
&& methodScope.enclosingSourceType() == declaringClass
&& methodScope.lastVisibleFieldID >= 0
&& fieldBinding.id >= methodScope.lastVisibleFieldID
&& (!fieldBinding.isStatic() || methodScope.isStatic)) {
scope.problemReporter().forwardReference(this, this.indexOfFirstFieldBinding-1, fieldBinding);
}
this.bits &= ~ASTNode.RestrictiveFlagMASK; // clear bits
this.bits |= Binding.FIELD;
return getOtherFieldBindings(scope);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:20,代码来源:CodeSnippetQualifiedNameReference.java
示例7: unqualifiedFieldAccess
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; //导入依赖的package包/类
public void unqualifiedFieldAccess(NameReference reference, FieldBinding field) {
int sourceStart = reference.sourceStart;
int sourceEnd = reference.sourceEnd;
if (reference instanceof SingleNameReference) {
int numberOfParens = (reference.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
if (numberOfParens != 0) {
sourceStart = retrieveStartingPositionAfterOpeningParenthesis(sourceStart, sourceEnd, numberOfParens);
sourceEnd = retrieveEndingPositionAfterOpeningParenthesis(sourceStart, sourceEnd, numberOfParens);
} else {
sourceStart = nodeSourceStart(field, reference);
sourceEnd = nodeSourceEnd(field, reference);
}
} else {
sourceStart = nodeSourceStart(field, reference);
sourceEnd = nodeSourceEnd(field, reference);
}
this.handle(
IProblem.UnqualifiedFieldAccess,
new String[] {new String(field.declaringClass.readableName()), new String(field.name)},
new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name)},
sourceStart,
sourceEnd);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:24,代码来源:ProblemReporter.java
示例8: manageSyntheticAccessIfNecessary
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; //导入依赖的package包/类
public void manageSyntheticAccessIfNecessary(BlockScope currentScope, FlowInfo flowInfo, boolean isReadAccess) {
if (this.delegateThis == null) {
super.manageSyntheticAccessIfNecessary(currentScope, flowInfo, isReadAccess);
return;
}
if ((flowInfo.tagBits & FlowInfo.UNREACHABLE_OR_DEAD) != 0) return;
//If inlinable field, forget the access emulation, the code gen will directly target it
if (this.constant != Constant.NotAConstant)
return;
// if field from parameterized type got found, use the original field at codegen time
if (this.binding instanceof ParameterizedFieldBinding) {
ParameterizedFieldBinding parameterizedField = (ParameterizedFieldBinding) this.binding;
FieldBinding codegenField = parameterizedField.originalField;
// extra cast needed if field type was type variable
if ((codegenField.type.tagBits & TagBits.HasTypeVariable) != 0) {
this.genericCast = codegenField.type.genericCast(currentScope.boxing(parameterizedField.type)); // runtimeType could be base type in boxing case
}
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:22,代码来源:CodeSnippetSingleNameReference.java
示例9: optimizedBooleanConstant
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; //导入依赖的package包/类
public Constant optimizedBooleanConstant() {
switch (this.resolvedType.id) {
case T_boolean :
case T_JavaLangBoolean :
if (this.constant != Constant.NotAConstant) return this.constant;
switch (this.bits & ASTNode.RestrictiveFlagMASK) {
case Binding.FIELD : // reading a field
if (this.otherBindings == null)
return ((FieldBinding)this.binding).constant();
//$FALL-THROUGH$
case Binding.LOCAL : // reading a local variable
return this.otherBindings[this.otherBindings.length-1].constant();
}
}
return Constant.NotAConstant;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:17,代码来源:QualifiedNameReference.java
示例10: generateCompoundAssignment
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; //导入依赖的package包/类
public void generateCompoundAssignment(BlockScope currentScope, CodeStream codeStream, Expression expression, int operator, int assignmentImplicitConversion, boolean valueRequired) {
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=185682
switch (this.bits & ASTNode.RestrictiveFlagMASK) {
case Binding.LOCAL:
LocalVariableBinding localBinding = (LocalVariableBinding) this.binding;
// check if compound assignment is the only usage of this local
Reference.reportOnlyUselesslyReadLocal(currentScope, localBinding, valueRequired);
break;
case Binding.FIELD:
// check if compound assignment is the only usage of a private field
reportOnlyUselesslyReadPrivateField(currentScope, (FieldBinding)this.binding, valueRequired);
}
this.generateCompoundAssignment(
currentScope,
codeStream,
this.syntheticAccessors == null ? null : this.syntheticAccessors[SingleNameReference.WRITE],
expression,
operator,
assignmentImplicitConversion,
valueRequired);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:22,代码来源:SingleNameReference.java
示例11: reportOnlyUselesslyReadPrivateField
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; //导入依赖的package包/类
void reportOnlyUselesslyReadPrivateField(BlockScope currentScope, FieldBinding fieldBinding, boolean valueRequired) {
if (valueRequired) {
// access is relevant, turn compound use into real use:
fieldBinding.compoundUseFlag = 0;
fieldBinding.modifiers |= ExtraCompilerModifiers.AccLocallyUsed;
} else {
if (fieldBinding.isUsedOnlyInCompound()) {
fieldBinding.compoundUseFlag--; // consume one
if (fieldBinding.compoundUseFlag == 0 // report only the last usage
&& fieldBinding.isOrEnclosedByPrivateType()
&& (this.implicitConversion & TypeIds.UNBOXING) == 0) // don't report if unboxing is involved (might cause NPE)
{
// compoundAssignment/postIncrement is the only usage of this field
currentScope.problemReporter().unusedPrivateField(fieldBinding.sourceField());
fieldBinding.modifiers |= ExtraCompilerModifiers.AccLocallyUsed; // don't report again
}
}
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:Reference.java
示例12: resolve
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; //导入依赖的package包/类
private ResolvedNode resolve(@Nullable Binding binding) {
if (binding == null || binding instanceof ProblemBinding) {
return null;
}
if (binding instanceof TypeBinding) {
TypeBinding tb = (TypeBinding) binding;
return new EcjResolvedClass(tb);
} else if (binding instanceof MethodBinding) {
MethodBinding mb = (MethodBinding) binding;
if (mb instanceof ProblemMethodBinding) {
return null;
}
//noinspection VariableNotUsedInsideIf
if (mb.declaringClass != null) {
return new EcjResolvedMethod(mb);
}
} else if (binding instanceof LocalVariableBinding) {
LocalVariableBinding lvb = (LocalVariableBinding) binding;
//noinspection VariableNotUsedInsideIf
if (lvb.type != null) {
return new EcjResolvedVariable(lvb);
}
} else if (binding instanceof FieldBinding) {
FieldBinding fb = (FieldBinding) binding;
if (fb instanceof ProblemFieldBinding) {
return null;
}
if (fb.type != null && fb.declaringClass != null) {
return new EcjResolvedField(fb);
}
}
return null;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:EcjParser.java
示例13: getUnresolvedJavaElement
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; //导入依赖的package包/类
/** Return the java element corresponding to the given compiler binding. */
public static JavaElement getUnresolvedJavaElement(
FieldBinding binding, WorkingCopyOwner workingCopyOwner, BindingsToNodesMap bindingsToNodes) {
if (binding.declaringClass == null) return null; // array length
JavaElement unresolvedJavaElement =
getUnresolvedJavaElement(binding.declaringClass, workingCopyOwner, bindingsToNodes);
if (unresolvedJavaElement == null
|| unresolvedJavaElement.getElementType() != IJavaElement.TYPE) {
return null;
}
return (JavaElement) ((IType) unresolvedJavaElement).getField(String.valueOf(binding.name));
}
开发者ID:eclipse,项目名称:che,代码行数:13,代码来源:Util.java
示例14: needToEmulateFieldAccess
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; //导入依赖的package包/类
public void needToEmulateFieldAccess(FieldBinding field, ASTNode location, boolean isReadAccess) {
int id = isReadAccess
? IProblem.NeedToEmulateFieldReadAccess
: IProblem.NeedToEmulateFieldWriteAccess;
int severity = computeSeverity(id);
if (severity == ProblemSeverities.Ignore) return;
this.handle(
id,
new String[] {new String(field.declaringClass.readableName()), new String(field.name)},
new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name)},
severity,
nodeSourceStart(field, location),
nodeSourceEnd(field, location));
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:15,代码来源:ProblemReporter.java
示例15: nonStaticAccessToStaticField
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; //导入依赖的package包/类
public void nonStaticAccessToStaticField(ASTNode location, FieldBinding field, int index) {
int severity = computeSeverity(IProblem.NonStaticAccessToStaticField);
if (severity == ProblemSeverities.Ignore) return;
this.handle(
IProblem.NonStaticAccessToStaticField,
new String[] {new String(field.declaringClass.readableName()), new String(field.name)},
new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name)},
severity,
nodeSourceStart(field, location, index),
nodeSourceEnd(field, location, index));
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:12,代码来源:ProblemReporter.java
示例16: getKind
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; //导入依赖的package包/类
@Override
public ElementKind getKind() {
if (_binding instanceof FieldBinding) {
if (((FieldBinding)_binding).declaringClass.isEnum()) {
return ElementKind.ENUM_CONSTANT;
}
else {
return ElementKind.FIELD;
}
}
else {
return ElementKind.PARAMETER;
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:15,代码来源:VariableElementImpl.java
示例17: getPackage
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; //导入依赖的package包/类
@Override
PackageElement getPackage()
{
if (_binding instanceof FieldBinding) {
PackageBinding pkgBinding = ((FieldBinding)_binding).declaringClass.fPackage;
return _env.getFactory().newPackageElement(pkgBinding);
}
else {
// TODO: what is the package of a method parameter?
throw new UnsupportedOperationException("NYI: VariableElmentImpl.getPackage() for method parameter"); //$NON-NLS-1$
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:13,代码来源:VariableElementImpl.java
示例18: unsafeRawFieldAssignment
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; //导入依赖的package包/类
public void unsafeRawFieldAssignment(FieldBinding field, TypeBinding expressionType, ASTNode location) {
if (this.options.sourceLevel < ClassFileConstants.JDK1_5) return; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=305259
int severity = computeSeverity(IProblem.UnsafeRawFieldAssignment);
if (severity == ProblemSeverities.Ignore) return;
this.handle(
IProblem.UnsafeRawFieldAssignment,
new String[] {
new String(expressionType.readableName()), new String(field.name), new String(field.declaringClass.readableName()), new String(field.declaringClass.erasure().readableName()) },
new String[] {
new String(expressionType.shortReadableName()), new String(field.name), new String(field.declaringClass.shortReadableName()), new String(field.declaringClass.erasure().shortReadableName()) },
severity,
nodeSourceStart(field,location),
nodeSourceEnd(field, location));
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:15,代码来源:ProblemReporter.java
示例19: getPackageOf
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; //导入依赖的package包/类
@Override
public PackageElement getPackageOf(Element type) {
switch(type.getKind()) {
case ANNOTATION_TYPE :
case CLASS :
case ENUM :
case INTERFACE :
TypeElementImpl typeElementImpl = (TypeElementImpl) type;
ReferenceBinding referenceBinding = (ReferenceBinding)typeElementImpl._binding;
return (PackageElement) _env.getFactory().newElement(referenceBinding.fPackage);
case PACKAGE :
return (PackageElement) type;
case CONSTRUCTOR :
case METHOD :
ExecutableElementImpl executableElementImpl = (ExecutableElementImpl) type;
MethodBinding methodBinding = (MethodBinding) executableElementImpl._binding;
return (PackageElement) _env.getFactory().newElement(methodBinding.declaringClass.fPackage);
case ENUM_CONSTANT :
case FIELD :
VariableElementImpl variableElementImpl = (VariableElementImpl) type;
FieldBinding fieldBinding = (FieldBinding) variableElementImpl._binding;
return (PackageElement) _env.getFactory().newElement(fieldBinding.declaringClass.fPackage);
case PARAMETER :
variableElementImpl = (VariableElementImpl) type;
LocalVariableBinding localVariableBinding = (LocalVariableBinding) variableElementImpl._binding;
return (PackageElement) _env.getFactory().newElement(localVariableBinding.declaringScope.classScope().referenceContext.binding.fPackage);
case EXCEPTION_PARAMETER :
case INSTANCE_INIT :
case OTHER :
case STATIC_INIT :
case TYPE_PARAMETER :
case LOCAL_VARIABLE :
return null;
}
// unreachable
return null;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:38,代码来源:ElementsImpl.java
示例20: visit
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; //导入依赖的package包/类
@Override
public boolean visit(FieldDeclaration fieldDeclaration, MethodScope scope) {
Annotation[] annotations = fieldDeclaration.annotations;
if (annotations != null) {
FieldBinding fieldBinding = fieldDeclaration.binding;
if (fieldBinding == null) {
return false;
}
((SourceTypeBinding) fieldBinding.declaringClass).resolveTypeFor(fieldBinding);
this.resolveAnnotations(scope, annotations, fieldBinding);
}
return false;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:14,代码来源:AnnotationDiscoveryVisitor.java
注:本文中的org.eclipse.jdt.internal.compiler.lookup.FieldBinding类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论