本文整理汇总了Java中org.eclipse.jdt.internal.compiler.lookup.FieldBinding.isStatic方法的典型用法代码示例。如果您正苦于以下问题:Java FieldBinding.isStatic方法的具体用法?Java FieldBinding.isStatic怎么用?Java FieldBinding.isStatic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.internal.compiler.lookup.FieldBinding
的用法示例。
在下文中一共展示了FieldBinding.isStatic方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: matchLevelAndReportImportRef
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; //导入方法依赖的package包/类
protected void matchLevelAndReportImportRef(ImportReference importRef, Binding binding, MatchLocator locator) throws CoreException {
// for static import, binding can be a field binding or a member type binding
// verify that in this case binding is static and use declaring class for fields
Binding refBinding = binding;
if (importRef.isStatic()) {
if (binding instanceof FieldBinding) {
FieldBinding fieldBinding = (FieldBinding) binding;
if (!fieldBinding.isStatic()) return;
refBinding = fieldBinding.declaringClass;
} else if (binding instanceof MethodBinding) {
MethodBinding methodBinding = (MethodBinding) binding;
if (!methodBinding.isStatic()) return;
refBinding = methodBinding.declaringClass;
} else if (binding instanceof MemberTypeBinding) {
MemberTypeBinding memberBinding = (MemberTypeBinding) binding;
if (!memberBinding.isStatic()) return;
}
}
// Look for closest pattern
PatternLocator closestPattern = null;
int level = IMPOSSIBLE_MATCH;
for (int i = 0, length = this.patternLocators.length; i < length; i++) {
PatternLocator patternLocator = this.patternLocators[i];
int newLevel = patternLocator.referenceType() == 0 ? IMPOSSIBLE_MATCH : patternLocator.resolveLevel(refBinding);
if (newLevel > level) {
closestPattern = patternLocator;
if (newLevel == ACCURATE_MATCH) break;
level = newLevel;
}
}
if (closestPattern != null) {
closestPattern.matchLevelAndReportImportRef(importRef, binding, locator);
}
}
示例2: analyseCode
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; //导入方法依赖的package包/类
public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo, boolean valueRequired) {
switch (this.bits & ASTNode.RestrictiveFlagMASK) {
case Binding.FIELD : // reading a field
if (valueRequired || currentScope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_4) {
manageSyntheticAccessIfNecessary(currentScope, flowInfo, true /*read-access*/);
}
// check if reading a final blank field
FieldBinding fieldBinding = (FieldBinding) this.binding;
if (fieldBinding.isBlankFinal() && currentScope.needBlankFinalFieldInitializationCheck(fieldBinding)) {
FlowInfo fieldInits = flowContext.getInitsForFinalBlankInitializationCheck(fieldBinding.declaringClass.original(), flowInfo);
if (!fieldInits.isDefinitelyAssigned(fieldBinding)) {
currentScope.problemReporter().uninitializedBlankFinalField(fieldBinding, this);
}
}
if (!fieldBinding.isStatic()) {
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=318682
currentScope.resetDeclaringClassMethodStaticFlag(fieldBinding.declaringClass);
}
break;
case Binding.LOCAL : // reading a local variable
LocalVariableBinding localBinding;
if (!flowInfo.isDefinitelyAssigned(localBinding = (LocalVariableBinding) this.binding)) {
currentScope.problemReporter().uninitializedLocalVariable(localBinding, this);
}
if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) == 0) {
localBinding.useFlag = LocalVariableBinding.USED;
} else if (localBinding.useFlag == LocalVariableBinding.UNUSED) {
localBinding.useFlag = LocalVariableBinding.FAKE_USED;
}
}
if (valueRequired) {
manageEnclosingInstanceAccessIfNecessary(currentScope, flowInfo);
}
return flowInfo;
}
示例3: 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) {
if (this.delegateThis == null) {
return super.checkFieldAccess(scope);
}
FieldBinding fieldBinding = (FieldBinding) this.binding;
this.bits &= ~RestrictiveFlagMASK; // clear bits
this.bits |= Binding.FIELD;
if (!fieldBinding.isStatic()) {
// must check for the static status....
if (this.evaluationContext.isStatic) {
scope.problemReporter().staticFieldAccessToNonStaticVariable(
this,
fieldBinding);
this.constant = Constant.NotAConstant;
return null;
}
}
this.constant = fieldBinding.constant();
if (isFieldUseDeprecated(fieldBinding, scope, this.bits)) {
scope.problemReporter().deprecatedField(fieldBinding, this);
}
return fieldBinding.type;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:30,代码来源:CodeSnippetSingleNameReference.java
示例4: generateAssignment
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; //导入方法依赖的package包/类
public void generateAssignment(BlockScope currentScope, CodeStream codeStream, Assignment assignment, boolean valueRequired) {
FieldBinding codegenBinding = this.binding.original();
if (codegenBinding.canBeSeenBy(this.actualReceiverType, this, currentScope)) {
this.receiver.generateCode(currentScope, codeStream, !codegenBinding.isStatic());
assignment.expression.generateCode(currentScope, codeStream, true);
fieldStore(currentScope, codeStream, codegenBinding, null, this.actualReceiverType, this.receiver.isImplicitThis(), valueRequired);
} else {
codeStream.generateEmulationForField(codegenBinding);
this.receiver.generateCode(currentScope, codeStream, !codegenBinding.isStatic());
if (codegenBinding.isStatic()) { // need a receiver?
codeStream.aconst_null();
}
assignment.expression.generateCode(currentScope, codeStream, true);
if (valueRequired) {
switch (codegenBinding.type.id) {
case TypeIds.T_long :
case TypeIds.T_double :
codeStream.dup2_x2();
break;
default :
codeStream.dup_x2();
break;
}
}
codeStream.generateEmulatedWriteAccessForField(codegenBinding);
}
if (valueRequired){
codeStream.generateImplicitConversion(assignment.implicitConversion);
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:31,代码来源:CodeSnippetFieldReference.java
示例5: searchVisibleFields
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; //导入方法依赖的package包/类
private void searchVisibleFields(
FieldBinding[] fields,
ReferenceBinding receiverType,
Scope scope,
InvocationSite invocationSite,
Scope invocationScope,
boolean onlyStaticFields,
ObjectVector localsFound,
ObjectVector fieldsFound) {
ObjectVector newFieldsFound = new ObjectVector();
// Inherited fields which are hidden by subclasses are filtered out
// No visibility checks can be performed without the scope & invocationSite
next : for (int f = fields.length; --f >= 0;) {
FieldBinding field = fields[f];
if (field.isSynthetic()) continue next;
if (onlyStaticFields && !field.isStatic()) continue next;
if (!field.canBeSeenBy(receiverType, invocationSite, scope)) continue next;
for (int i = fieldsFound.size; --i >= 0;) {
FieldBinding otherField = (FieldBinding) fieldsFound.elementAt(i);
if (CharOperation.equals(field.name, otherField.name, true)) {
continue next;
}
}
for (int l = localsFound.size; --l >= 0;) {
LocalVariableBinding local = (LocalVariableBinding) localsFound.elementAt(l);
if (CharOperation.equals(field.name, local.name, true)) {
continue next;
}
}
newFieldsFound.add(field);
}
fieldsFound.addAll(newFieldsFound);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:43,代码来源:InternalExtendedCompletionContext.java
示例6: generateCode
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; //导入方法依赖的package包/类
public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
int pc = codeStream.position;
if (this.constant != Constant.NotAConstant) {
if (valueRequired) {
codeStream.generateConstant(this.constant, this.implicitConversion);
}
} else {
switch (this.bits & RestrictiveFlagMASK) {
case Binding.FIELD : // reading a field
if (!valueRequired)
break;
FieldBinding codegenField = ((FieldBinding) this.binding).original();
Constant fieldConstant = codegenField.constant();
if (fieldConstant == Constant.NotAConstant) { // directly use inlined value for constant fields
if (codegenField.canBeSeenBy(getReceiverType(currentScope), this, currentScope)) {
TypeBinding someReceiverType = this.delegateThis != null ? this.delegateThis.type : this.actualReceiverType;
TypeBinding constantPoolDeclaringClass = CodeStream.getConstantPoolDeclaringClass(currentScope, codegenField, someReceiverType, true /* implicit this */);
if (codegenField.isStatic()) {
codeStream.fieldAccess(Opcodes.OPC_getstatic, codegenField, constantPoolDeclaringClass);
} else {
if ((this.bits & DepthMASK) != 0) {
ReferenceBinding targetType = currentScope.enclosingSourceType().enclosingTypeAt((this.bits & DepthMASK) >> DepthSHIFT);
Object[] emulationPath = currentScope.getEmulationPath(targetType, true /*only exact match*/, false/*consider enclosing arg*/);
codeStream.generateOuterAccess(emulationPath, this, targetType, currentScope);
} else {
generateReceiver(codeStream);
}
codeStream.fieldAccess(Opcodes.OPC_getfield, codegenField, constantPoolDeclaringClass);
}
} else {
// managing private access
if (!codegenField.isStatic()) {
if ((this.bits & DepthMASK) != 0) {
// internal error, per construction we should have found it
// not yet supported
currentScope.problemReporter().needImplementation(this);
} else {
generateReceiver(codeStream);
}
} else {
codeStream.aconst_null();
}
codeStream.generateEmulatedReadAccessForField(codegenField);
}
if (this.genericCast != null) codeStream.checkcast(this.genericCast);
codeStream.generateImplicitConversion(this.implicitConversion);
} else { // directly use the inlined value
codeStream.generateConstant(fieldConstant, this.implicitConversion);
}
break;
case Binding.LOCAL : // reading a local
LocalVariableBinding localBinding = (LocalVariableBinding) this.binding;
if (localBinding.resolvedPosition == -1) {
if (valueRequired) {
// restart code gen
localBinding.useFlag = LocalVariableBinding.USED;
throw new AbortMethod(CodeStream.RESTART_CODE_GEN_FOR_UNUSED_LOCALS_MODE, null);
}
codeStream.recordPositionsFrom(pc, this.sourceStart);
return;
}
if (!valueRequired)
break;
// outer local?
if ((this.bits & DepthMASK) != 0) {
// outer local can be reached either through a synthetic arg or a synthetic field
VariableBinding[] path = currentScope.getEmulationPath(localBinding);
codeStream.generateOuterAccess(path, this, localBinding, currentScope);
} else {
// regular local variable read
codeStream.load(localBinding);
}
codeStream.generateImplicitConversion(this.implicitConversion);
break;
}
}
codeStream.recordPositionsFrom(pc, this.sourceStart);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:79,代码来源:CodeSnippetSingleNameReference.java
示例7: generateCode
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; //导入方法依赖的package包/类
public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
int pc = codeStream.position;
if (this.constant != Constant.NotAConstant) {
if (valueRequired) {
codeStream.generateConstant(this.constant, this.implicitConversion);
}
} else {
switch (this.bits & RestrictiveFlagMASK) {
case Binding.FIELD : // reading a field
if (!valueRequired)
break;
FieldBinding codegenField = ((FieldBinding) this.binding).original();
Constant fieldConstant = codegenField.constant();
if (fieldConstant == Constant.NotAConstant) { // directly use inlined value for constant fields
if (codegenField.canBeSeenBy(getReceiverType(currentScope), this, currentScope)) {
TypeBinding someReceiverType = this.delegateThis != null ? this.delegateThis.type : this.actualReceiverType;
TypeBinding constantPoolDeclaringClass = CodeStream.getConstantPoolDeclaringClass(currentScope, codegenField, someReceiverType, true /* implicit this */);
if (codegenField.isStatic()) {
codeStream.fieldAccess(Opcodes.OPC_getstatic, codegenField, constantPoolDeclaringClass);
} else {
if ((this.bits & DepthMASK) != 0) {
ReferenceBinding targetType = currentScope.enclosingSourceType().enclosingTypeAt((this.bits & DepthMASK) >> DepthSHIFT);
Object[] emulationPath = currentScope.getEmulationPath(targetType, true /*only exact match*/, false/*consider enclosing arg*/);
codeStream.generateOuterAccess(emulationPath, this, targetType, currentScope);
} else {
generateReceiver(codeStream);
}
codeStream.fieldAccess(Opcodes.OPC_getfield, codegenField, constantPoolDeclaringClass);
}
} else {
// managing private access
if (!codegenField.isStatic()) {
if ((this.bits & DepthMASK) != 0) {
// internal error, per construction we should have found it
// not yet supported
currentScope.problemReporter().needImplementation(this);
} else {
generateReceiver(codeStream);
}
} else {
codeStream.aconst_null();
}
codeStream.generateEmulatedReadAccessForField(codegenField);
}
if (this.genericCast != null) codeStream.checkcast(this.genericCast);
codeStream.generateImplicitConversion(this.implicitConversion);
} else { // directly use the inlined value
codeStream.generateConstant(fieldConstant, this.implicitConversion);
}
break;
case Binding.LOCAL : // reading a local
LocalVariableBinding localBinding = (LocalVariableBinding) this.binding;
if (localBinding.resolvedPosition == -1) {
if (valueRequired) {
// restart code gen
localBinding.useFlag = LocalVariableBinding.USED;
throw new AbortMethod(CodeStream.RESTART_CODE_GEN_FOR_UNUSED_LOCALS_MODE, null);
}
codeStream.recordPositionsFrom(pc, this.sourceStart);
return;
}
if (!valueRequired)
break;
// outer local?
if ((this.bits & IsCapturedOuterLocal) != 0) {
checkEffectiveFinality(localBinding, currentScope);
// outer local can be reached either through a synthetic arg or a synthetic field
VariableBinding[] path = currentScope.getEmulationPath(localBinding);
codeStream.generateOuterAccess(path, this, localBinding, currentScope);
} else {
// regular local variable read
codeStream.load(localBinding);
}
codeStream.generateImplicitConversion(this.implicitConversion);
break;
}
}
codeStream.recordPositionsFrom(pc, this.sourceStart);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:80,代码来源:CodeSnippetSingleNameReference.java
示例8: 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) {
FieldBinding lastFieldBinding = this.otherBindings == null ? (FieldBinding) this.binding : this.otherBindings[this.otherBindings.length-1];
if (lastFieldBinding.canBeSeenBy(getFinalReceiverType(), this, currentScope)) {
super.generateCompoundAssignment(currentScope, codeStream, expression, operator, assignmentImplicitConversion, valueRequired);
return;
}
lastFieldBinding = generateReadSequence(currentScope, codeStream);
if (lastFieldBinding.isStatic()){
codeStream.generateEmulationForField(lastFieldBinding);
codeStream.swap();
codeStream.aconst_null();
codeStream.swap();
codeStream.generateEmulatedReadAccessForField(lastFieldBinding);
} else {
codeStream.generateEmulationForField(lastFieldBinding);
codeStream.swap();
codeStream.dup();
codeStream.generateEmulatedReadAccessForField(lastFieldBinding);
}
// the last field access is a write access
// perform the actual compound operation
int operationTypeID;
if ((operationTypeID = (this.implicitConversion & IMPLICIT_CONVERSION_MASK) >> 4) == T_JavaLangString) {
codeStream.generateStringConcatenationAppend(currentScope, null, expression);
} else {
// promote the array reference to the suitable operation type
codeStream.generateImplicitConversion(this.implicitConversion);
// generate the increment value (will by itself be promoted to the operation value)
if (expression == IntLiteral.One){ // prefix operation
codeStream.generateConstant(expression.constant, this.implicitConversion);
} else {
expression.generateCode(currentScope, codeStream, true);
}
// perform the operation
codeStream.sendOperator(operator, operationTypeID);
// cast the value back to the array reference type
codeStream.generateImplicitConversion(assignmentImplicitConversion);
}
// actual assignment
// current stack is:
// field receiver value
if (valueRequired) {
switch (lastFieldBinding.type.id) {
case TypeIds.T_long :
case TypeIds.T_double :
codeStream.dup2_x2();
break;
default :
codeStream.dup_x2();
break;
}
}
// current stack is:
// value field receiver value
codeStream.generateEmulatedWriteAccessForField(lastFieldBinding);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:59,代码来源:CodeSnippetQualifiedNameReference.java
示例9: generatePostIncrement
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; //导入方法依赖的package包/类
public void generatePostIncrement(BlockScope currentScope, CodeStream codeStream, CompoundAssignment postIncrement, boolean valueRequired) {
FieldBinding lastFieldBinding = generateReadSequence(currentScope, codeStream);
// check if this post increment is the only usage of a private field
reportOnlyUselesslyReadPrivateField(currentScope, lastFieldBinding, valueRequired);
boolean isFirst = lastFieldBinding == this.binding
&& (this.indexOfFirstFieldBinding == 1 || lastFieldBinding.declaringClass == currentScope.enclosingReceiverType())
&& this.otherBindings == null; // could be dup: next.next.next
TypeBinding constantPoolDeclaringClass = CodeStream.getConstantPoolDeclaringClass(currentScope, lastFieldBinding, getFinalReceiverType(), isFirst);
SyntheticMethodBinding accessor = this.syntheticReadAccessors == null
? null
: this.syntheticReadAccessors[this.syntheticReadAccessors.length - 1];
if (lastFieldBinding.isStatic()) {
if (accessor == null) {
codeStream.fieldAccess(Opcodes.OPC_getstatic, lastFieldBinding, constantPoolDeclaringClass);
} else {
codeStream.invoke(Opcodes.OPC_invokestatic, accessor, constantPoolDeclaringClass);
}
} else {
codeStream.dup();
if (accessor == null) {
codeStream.fieldAccess(Opcodes.OPC_getfield, lastFieldBinding, null /* default declaringClass */);
} else {
codeStream.invoke(Opcodes.OPC_invokestatic, accessor, null /* default declaringClass */);
}
}
TypeBinding requiredGenericCast = getGenericCast(this.otherBindings == null ? 0 : this.otherBindings.length);
TypeBinding operandType;
if (requiredGenericCast != null) {
codeStream.checkcast(requiredGenericCast);
operandType = requiredGenericCast;
} else {
operandType = lastFieldBinding.type;
}
// duplicate the old field value
if (valueRequired) {
if (lastFieldBinding.isStatic()) {
switch (operandType.id) {
case TypeIds.T_long :
case TypeIds.T_double :
codeStream.dup2();
break;
default:
codeStream.dup();
break;
}
} else { // Stack: [owner][old field value] ---> [old field value][owner][old field value]
switch (operandType.id) {
case TypeIds.T_long :
case TypeIds.T_double :
codeStream.dup2_x1();
break;
default:
codeStream.dup_x1();
break;
}
}
}
codeStream.generateImplicitConversion(this.implicitConversion);
codeStream.generateConstant(
postIncrement.expression.constant,
this.implicitConversion);
codeStream.sendOperator(postIncrement.operator, this.implicitConversion & TypeIds.COMPILE_TYPE_MASK);
codeStream.generateImplicitConversion(
postIncrement.preAssignImplicitConversion);
fieldStore(currentScope, codeStream, lastFieldBinding, this.syntheticWriteAccessor, getFinalReceiverType(), false /*implicit this*/, false);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:67,代码来源: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) {
FieldBinding lastFieldBinding = generateReadSequence(currentScope, codeStream);
// check if compound assignment is the only usage of a private field
reportOnlyUselesslyReadPrivateField(currentScope, lastFieldBinding, valueRequired);
boolean isFirst = lastFieldBinding == this.binding
&& (this.indexOfFirstFieldBinding == 1 || lastFieldBinding.declaringClass == currentScope.enclosingReceiverType())
&& this.otherBindings == null; // could be dup: next.next.next
TypeBinding constantPoolDeclaringClass = CodeStream.getConstantPoolDeclaringClass(currentScope, lastFieldBinding, getFinalReceiverType(), isFirst);
SyntheticMethodBinding accessor = this.syntheticReadAccessors == null ? null : this.syntheticReadAccessors[this.syntheticReadAccessors.length - 1];
if (lastFieldBinding.isStatic()) {
if (accessor == null) {
codeStream.fieldAccess(Opcodes.OPC_getstatic, lastFieldBinding, constantPoolDeclaringClass);
} else {
codeStream.invoke(Opcodes.OPC_invokestatic, accessor, null /* default declaringClass */);
}
} else {
codeStream.dup();
if (accessor == null) {
codeStream.fieldAccess(Opcodes.OPC_getfield, lastFieldBinding, constantPoolDeclaringClass);
} else {
codeStream.invoke(Opcodes.OPC_invokestatic, accessor, null /* default declaringClass */);
}
}
// the last field access is a write access
// perform the actual compound operation
int operationTypeID;
switch(operationTypeID = (this.implicitConversion & TypeIds.IMPLICIT_CONVERSION_MASK) >> 4) {
case T_JavaLangString :
case T_JavaLangObject :
case T_undefined :
codeStream.generateStringConcatenationAppend(currentScope, null, expression);
break;
default :
TypeBinding requiredGenericCast = getGenericCast(this.otherBindings == null ? 0 : this.otherBindings.length);
if (requiredGenericCast != null) codeStream.checkcast(requiredGenericCast);
// promote the array reference to the suitable operation type
codeStream.generateImplicitConversion(this.implicitConversion);
// generate the increment value (will by itself be promoted to the operation value)
if (expression == IntLiteral.One) { // prefix operation
codeStream.generateConstant(expression.constant, this.implicitConversion);
} else {
expression.generateCode(currentScope, codeStream, true);
}
// perform the operation
codeStream.sendOperator(operator, operationTypeID);
// cast the value back to the array reference type
codeStream.generateImplicitConversion(assignmentImplicitConversion);
}
// actual assignment
fieldStore(currentScope, codeStream, lastFieldBinding, this.syntheticWriteAccessor, getFinalReceiverType(), false /*implicit this*/, valueRequired);
// equivalent to valuesRequired[maxOtherBindings]
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:53,代码来源:QualifiedNameReference.java
示例11: generatePostIncrement
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; //导入方法依赖的package包/类
public void generatePostIncrement(BlockScope currentScope, CodeStream codeStream, CompoundAssignment postIncrement, boolean valueRequired) {
switch (this.bits & RestrictiveFlagMASK) {
case Binding.FIELD : // assigning to a field
FieldBinding codegenField = ((FieldBinding) this.binding).original();
if (codegenField.canBeSeenBy(getReceiverType(currentScope), this, currentScope)) {
super.generatePostIncrement(currentScope, codeStream, postIncrement, valueRequired);
} else {
if (codegenField.isStatic()) {
codeStream.aconst_null();
} else {
if ((this.bits & DepthMASK) != 0) {
// internal error, per construction we should have found it
// not yet supported
currentScope.problemReporter().needImplementation(this);
} else {
generateReceiver(codeStream);
}
}
codeStream.generateEmulatedReadAccessForField(codegenField);
if (valueRequired) {
switch (codegenField.type.id) {
case TypeIds.T_long :
case TypeIds.T_double :
codeStream.dup2();
break;
default:
codeStream.dup();
break;
}
}
codeStream.generateEmulationForField(codegenField);
switch (codegenField.type.id) {
case TypeIds.T_long :
case TypeIds.T_double :
codeStream.dup_x2();
codeStream.pop();
if (codegenField.isStatic()) {
codeStream.aconst_null();
} else {
generateReceiver(codeStream);
}
codeStream.dup_x2();
codeStream.pop();
break;
default:
codeStream.dup_x1();
codeStream.pop();
if (codegenField.isStatic()) {
codeStream.aconst_null();
} else {
generateReceiver(codeStream);
}
codeStream.dup_x1();
codeStream.pop();
break;
}
codeStream.generateConstant(postIncrement.expression.constant, this.implicitConversion);
codeStream.sendOperator(postIncrement.operator, codegenField.type.id);
codeStream.generateImplicitConversion(postIncrement.preAssignImplicitConversion);
codeStream.generateEmulatedWriteAccessForField(codegenField);
}
return;
case Binding.LOCAL : // assigning to a local variable
super.generatePostIncrement(currentScope, codeStream, postIncrement, valueRequired);
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:67,代码来源:CodeSnippetSingleNameReference.java
示例12: generatePostIncrement
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; //导入方法依赖的package包/类
public void generatePostIncrement(BlockScope currentScope, CodeStream codeStream, CompoundAssignment postIncrement, boolean valueRequired) {
FieldBinding lastFieldBinding = this.otherBindings == null ? (FieldBinding) this.binding : this.otherBindings[this.otherBindings.length-1];
if (lastFieldBinding.canBeSeenBy(getFinalReceiverType(), this, currentScope)) {
super.generatePostIncrement(currentScope, codeStream, postIncrement, valueRequired);
return;
}
lastFieldBinding = generateReadSequence(currentScope, codeStream);
codeStream.generateEmulatedReadAccessForField(lastFieldBinding);
if (valueRequired) {
switch (lastFieldBinding.type.id) {
case TypeIds.T_long :
case TypeIds.T_double :
codeStream.dup2();
break;
default :
codeStream.dup();
break;
}
}
codeStream.generateEmulationForField(lastFieldBinding);
if ((TypeBinding.equalsEquals(lastFieldBinding.type, TypeBinding.LONG)) || (TypeBinding.equalsEquals(lastFieldBinding.type, TypeBinding.DOUBLE))) {
codeStream.dup_x2();
codeStream.pop();
if (lastFieldBinding.isStatic()) {
codeStream.aconst_null();
} else {
generateReadSequence(currentScope, codeStream);
}
codeStream.dup_x2();
codeStream.pop();
} else {
codeStream.dup_x1();
codeStream.pop();
if (lastFieldBinding.isStatic()) {
codeStream.aconst_null();
} else {
generateReadSequence(currentScope, codeStream);
}
codeStream.dup_x1();
codeStream.pop();
}
codeStream.generateConstant(postIncrement.expression.constant, this.implicitConversion);
codeStream.sendOperator(postIncrement.operator, lastFieldBinding.type.id);
codeStream.generateImplicitConversion(postIncrement.preAssignImplicitConversion);
codeStream.generateEmulatedWriteAccessForField(lastFieldBinding);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:47,代码来源:CodeSnippetQualifiedNameReference.java
示例13: canBeSeenByForCodeSnippet
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; //导入方法依赖的package包/类
public final boolean canBeSeenByForCodeSnippet(FieldBinding fieldBinding, TypeBinding receiverType, InvocationSite invocationSite, Scope scope) {
if (fieldBinding.isPublic()) return true;
ReferenceBinding invocationType = (ReferenceBinding) receiverType;
if (TypeBinding.equalsEquals(invocationType, fieldBinding.declaringClass)) return true;
if (fieldBinding.isProtected()) {
// answer true if the invocationType is the declaringClass or they are in the same package
// OR the invocationType is a subclass of the declaringClass
// AND the receiverType is the invocationType or its subclass
// OR the field is a static field accessed directly through a type
if (TypeBinding.equalsEquals(invocationType, fieldBinding.declaringClass)) return true;
if (invocationType.fPackage == fieldBinding.declaringClass.fPackage) return true;
if (fieldBinding.declaringClass.isSuperclassOf(invocationType)) {
if (invocationSite.isSuperAccess()) return true;
// receiverType can be an array binding in one case... see if you can change it
if (receiverType instanceof ArrayBinding)
return false;
if (invocationType.isSuperclassOf((ReferenceBinding) receiverType))
return true;
if (fieldBinding.isStatic())
return true; // see 1FMEPDL - return invocationSite.isTypeAccess();
}
return false;
}
if (fieldBinding.isPrivate()) {
// answer true if the receiverType is the declaringClass
// AND the invocationType and the declaringClass have a common enclosingType
if (TypeBinding.notEquals(receiverType, fieldBinding.declaringClass)) return false;
if (TypeBinding.notEquals(invocationType, fieldBinding.declaringClass)) {
ReferenceBinding outerInvocationType = invocationType;
ReferenceBinding temp = outerInvocationType.enclosingType();
while (temp != null) {
outerInvocationType = temp;
temp = temp.enclosingType();
}
ReferenceBinding outerDeclaringClass = fieldBinding.declaringClass;
temp = outerDeclaringClass.enclosingType();
while (temp != null) {
outerDeclaringClass = temp;
temp = temp.enclosingType();
}
if (TypeBinding.notEquals(outerInvocationType, outerDeclaringClass)) return false;
}
return true;
}
// isDefault()
if (invocationType.fPackage != fieldBinding.declaringClass.fPackage) return false;
// receiverType can be an array binding in one case... see if you can change it
if (receiverType instanceof ArrayBinding)
return false;
ReferenceBinding type = (ReferenceBinding) receiverType;
PackageBinding declaringPackage = fieldBinding.declaringClass.fPackage;
TypeBinding originalDeclaringClass = fieldBinding.declaringClass .original();
do {
if (type.isCapture()) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=285002
if (TypeBinding.equalsEquals(originalDeclaringClass, type.erasure().original())) return true;
} else {
if (TypeBinding.equalsEquals(originalDeclaringClass, type.original())) return true;
}
if (declaringPackage != type.fPackage) return false;
} while ((type = type.superclass()) != null);
return false;
}
示例14: checkFieldAccess
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; //导入方法依赖的package包/类
public TypeBinding checkFieldAccess(BlockScope scope) {
FieldBinding fieldBinding = (FieldBinding) this.binding;
this.constant = fieldBinding.constant();
this.bits &= ~ASTNode.RestrictiveFlagMASK; // clear bits
this.bits |= Binding.FIELD;
MethodScope methodScope = scope.methodScope();
if (fieldBinding.isStatic()) {
// check if accessing enum static field in initializer
ReferenceBinding declaringClass = fieldBinding.declaringClass;
if (declaringClass.isEnum()) {
SourceTypeBinding sourceType = scope.enclosingSourceType();
if (this.constant == Constant.NotAConstant
&& !methodScope.isStatic
&& (TypeBinding.equalsEquals(sourceType, declaringClass) || TypeBinding.equalsEquals(sourceType.superclass, declaringClass)) // enum constant body
&& methodScope.isInsideInitializerOrConstructor()) {
scope.problemReporter().enumStaticFieldUsedDuringInitialization(fieldBinding, this);
}
}
} else {
if (scope.compilerOptions().getSeverity(CompilerOptions.UnqualifiedFieldAccess) != ProblemSeverities.Ignore) {
scope.problemReporter().unqualifiedFieldAccess(this, fieldBinding);
}
// must check for the static status....
if (methodScope.isStatic) {
scope.problemReporter().staticFieldAccessToNonStaticVariable(this, fieldBinding);
return fieldBinding.type;
} else {
scope.tagAsAccessingEnclosingInstanceStateOf(fieldBinding.declaringClass, false /* type variable access */);
}
}
if (isFieldUseDeprecated(fieldBinding, scope, this.bits))
scope.problemReporter().deprecatedField(fieldBinding, this);
if ((this.bits & ASTNode.IsStrictlyAssigned) == 0
&& TypeBinding.equalsEquals(methodScope.enclosingSourceType(), fieldBinding.original().declaringClass)
&& methodScope.lastVisibleFieldID >= 0
&& fieldBinding.id >= methodScope.lastVisibleFieldID
&& (!fieldBinding.isStatic() || methodScope.isStatic)) {
scope.problemReporter().forwardReference(this, 0, fieldBinding);
this.bits |= ASTNode.IgnoreNoEffectAssignCheck;
}
return fieldBinding.type;
}
示例15: analyseCode
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; //导入方法依赖的package包/类
public void analyseCode(
ClassScope classScope,
InitializationFlowContext staticInitializerFlowContext,
FlowInfo flowInfo) {
if (this.ignoreFurtherInvestigation)
return;
try {
ExceptionHandlingFlowContext clinitContext =
new ExceptionHandlingFlowContext(
staticInitializerFlowContext.parent,
this,
Binding.NO_EXCEPTIONS,
staticInitializerFlowContext,
this.scope,
FlowInfo.DEAD_END);
// check for missing returning path
if ((flowInfo.tagBits & FlowInfo.UNREACHABLE_OR_DEAD) == 0) {
this.bits |= ASTNode.NeedFreeReturn;
}
// check missing blank final field initializations
flowInfo = flowInfo.mergedWith(staticInitializerFlowContext.initsOnReturn);
FieldBinding[] fields = this.scope.enclosingSourceType().fields();
for (int i = 0, count = fields.length; i < count; i++) {
FieldBinding field = fields[i];
if (field.isStatic()) {
if (!flowInfo.isDefinitelyAssigned(field)) {
if (field.isFinal()) {
this.scope.problemReporter().uninitializedBlankFinalField(
field,
this.scope.referenceType().declarationOf(field.original()));
// can complain against the field decl, since only one <clinit>
} else if (field.isNonNull()) {
this.scope.problemReporter().uninitializedNonNullField(
field,
this.scope.referenceType().declarationOf(field.original()));
}
}
}
}
// check static initializers thrown exceptions
staticInitializerFlowContext.checkInitializerExceptions(
this.scope,
clinitContext,
flowInfo);
} catch (AbortMethod e) {
this.ignoreFurtherInvestigation = true;
}
}