Examples of LocalVariableBinding


Examples of org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding

      if (typeBinding != null) {
        return typeBinding;
      }
    } if (node instanceof JavadocSingleNameReference) {
      JavadocSingleNameReference singleNameReference = (JavadocSingleNameReference) node;
      LocalVariableBinding localVariable = (LocalVariableBinding)singleNameReference.binding;
      if (localVariable != null) {
        return this.getTypeBinding(localVariable.type);
      }
    } if (node instanceof SingleNameReference) {
      SingleNameReference singleNameReference = (SingleNameReference) node;
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding

    int size = this.visibleLocalVariables.size();
    if (size > 0) {
      next : for (int i = 0; i < size; i++) {
        try {
          LocalVariableBinding binding = (LocalVariableBinding) this.visibleLocalVariables.elementAt(i);
          if (binding.type == null || (assignableTypeBinding != null && !binding.type.isCompatibleWith(assignableTypeBinding))) continue next;
          JavaElement localVariable = getJavaElement(binding);
          if (localVariable != null) result[elementCount++] = localVariable;
        } catch(AbortCompilation e) {
          // log the exception and proceed
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding

          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;
        }
      }
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding

          //$FALL-THROUGH$
        case Scope.BLOCK_SCOPE :
          BlockScope blockScope = (BlockScope) currentScope;

          next : for (int i = 0, length = blockScope.locals.length; i < length; i++) {
            LocalVariableBinding local = blockScope.locals[i];

            if (local == null)
              break next;

            if (local.isSecret())
              continue next;
            // If the local variable declaration's initialization statement itself has the completion,
            // then don't propose the local variable
            if (local.declaration.initialization != null) {
              /*(use this if-else block if it is found that local.declaration.initialization != null is not sufficient to
                guarantee that proposal is being asked inside a local variable declaration's initializer)
               if(local.declaration.initialization.sourceEnd > 0) {
                if (this.assistNode.sourceEnd <= local.declaration.initialization.sourceEnd
                    && this.assistNode.sourceStart >= local.declaration.initialization.sourceStart) {
                  continue next;
                }
              } else {
                CompletionNodeDetector detector = new CompletionNodeDetector(
                    this.assistNode,
                    local.declaration.initialization);
                if (detector.containsCompletionNode()) {
                  continue next;
                }
              }*/
              continue next;
            }
            for (int f = 0; f < localsFound.size; f++) {
              LocalVariableBinding otherLocal =
                (LocalVariableBinding) localsFound.elementAt(f);
              if (CharOperation.equals(otherLocal.name, local.name, true))
                continue next;
            }

View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding

    int numberOfEntries = 0;
    int localVariableNameIndex =
      this.constantPool.literalIndex(AttributeNamesConstants.LocalVariableTableName);
    int maxOfEntries = 8 + 10 * (methodDeclarationIsStatic ? 0 : 1);
    for (int i = 0; i < this.codeStream.allLocalsCounter; i++) {
      LocalVariableBinding localVariableBinding = this.codeStream.locals[i];
      maxOfEntries += 10 * localVariableBinding.initializationCount;
    }
    // reserve enough space
    if (localContentsOffset + maxOfEntries >= this.contents.length) {
      resizeContents(maxOfEntries);
    }
    this.contents[localContentsOffset++] = (byte) (localVariableNameIndex >> 8);
    this.contents[localContentsOffset++] = (byte) localVariableNameIndex;
    int localVariableTableOffset = localContentsOffset;
    // leave space for attribute_length and local_variable_table_length
    localContentsOffset += 6;
    int nameIndex;
    int descriptorIndex;
    SourceTypeBinding declaringClassBinding = null;
    if (!methodDeclarationIsStatic && !isSynthetic) {
      numberOfEntries++;
      this.contents[localContentsOffset++] = 0; // the startPC for this is always 0
      this.contents[localContentsOffset++] = 0;
      this.contents[localContentsOffset++] = (byte) (code_length >> 8);
      this.contents[localContentsOffset++] = (byte) code_length;
      nameIndex = this.constantPool.literalIndex(ConstantPool.This);
      this.contents[localContentsOffset++] = (byte) (nameIndex >> 8);
      this.contents[localContentsOffset++] = (byte) nameIndex;
      declaringClassBinding = (SourceTypeBinding) this.codeStream.methodDeclaration.binding.declaringClass;
      descriptorIndex =
        this.constantPool.literalIndex(
          declaringClassBinding.signature());
      this.contents[localContentsOffset++] = (byte) (descriptorIndex >> 8);
      this.contents[localContentsOffset++] = (byte) descriptorIndex;
      this.contents[localContentsOffset++] = 0;// the resolved position for this is always 0
      this.contents[localContentsOffset++] = 0;
    }
    // used to remember the local variable with a generic type
    int genericLocalVariablesCounter = 0;
    LocalVariableBinding[] genericLocalVariables = null;
    int numberOfGenericEntries = 0;

    for (int i = 0, max = this.codeStream.allLocalsCounter; i < max; i++) {
      LocalVariableBinding localVariable = this.codeStream.locals[i];
      int initializationCount = localVariable.initializationCount;
      if (initializationCount == 0) continue;
      if (localVariable.declaration == null) continue;
      final TypeBinding localVariableTypeBinding = localVariable.type;
      boolean isParameterizedType = localVariableTypeBinding.isParameterizedType() || localVariableTypeBinding.isTypeVariable();
      if (isParameterizedType) {
        if (genericLocalVariables == null) {
          // we cannot have more than max locals
          genericLocalVariables = new LocalVariableBinding[max];
        }
        genericLocalVariables[genericLocalVariablesCounter++] = localVariable;
      }
      for (int j = 0; j < initializationCount; j++) {
        int startPC = localVariable.initializationPCs[j << 1];
        int endPC = localVariable.initializationPCs[(j << 1) + 1];
        if (startPC != endPC) { // only entries for non zero length
          if (endPC == -1) {
            localVariable.declaringScope.problemReporter().abortDueToInternalError(
                Messages.bind(Messages.abort_invalidAttribute, new String(localVariable.name)),
                (ASTNode) localVariable.declaringScope.methodScope().referenceContext);
          }
          if (isParameterizedType) {
            numberOfGenericEntries++;
          }
          // now we can safely add the local entry
          numberOfEntries++;
          this.contents[localContentsOffset++] = (byte) (startPC >> 8);
          this.contents[localContentsOffset++] = (byte) startPC;
          int length = endPC - startPC;
          this.contents[localContentsOffset++] = (byte) (length >> 8);
          this.contents[localContentsOffset++] = (byte) length;
          nameIndex = this.constantPool.literalIndex(localVariable.name);
          this.contents[localContentsOffset++] = (byte) (nameIndex >> 8);
          this.contents[localContentsOffset++] = (byte) nameIndex;
          descriptorIndex = this.constantPool.literalIndex(localVariableTypeBinding.signature());
          this.contents[localContentsOffset++] = (byte) (descriptorIndex >> 8);
          this.contents[localContentsOffset++] = (byte) descriptorIndex;
          int resolvedPosition = localVariable.resolvedPosition;
          this.contents[localContentsOffset++] = (byte) (resolvedPosition >> 8);
          this.contents[localContentsOffset++] = (byte) resolvedPosition;
        }
      }
    }
    int value = numberOfEntries * 10 + 2;
    this.contents[localVariableTableOffset++] = (byte) (value >> 24);
    this.contents[localVariableTableOffset++] = (byte) (value >> 16);
    this.contents[localVariableTableOffset++] = (byte) (value >> 8);
    this.contents[localVariableTableOffset++] = (byte) value;
    this.contents[localVariableTableOffset++] = (byte) (numberOfEntries >> 8);
    this.contents[localVariableTableOffset] = (byte) numberOfEntries;
    attributesNumber++;

    final boolean currentInstanceIsGeneric =
      !methodDeclarationIsStatic
      && declaringClassBinding != null
      && declaringClassBinding.typeVariables != Binding.NO_TYPE_VARIABLES;
    if (genericLocalVariablesCounter != 0 || currentInstanceIsGeneric) {
      // add the local variable type table attribute
      numberOfGenericEntries += (currentInstanceIsGeneric ? 1 : 0);
      maxOfEntries = 8 + numberOfGenericEntries * 10;
      // reserve enough space
      if (localContentsOffset + maxOfEntries >= this.contents.length) {
        resizeContents(maxOfEntries);
      }
      int localVariableTypeNameIndex =
        this.constantPool.literalIndex(AttributeNamesConstants.LocalVariableTypeTableName);
      this.contents[localContentsOffset++] = (byte) (localVariableTypeNameIndex >> 8);
      this.contents[localContentsOffset++] = (byte) localVariableTypeNameIndex;
      value = numberOfGenericEntries * 10 + 2;
      this.contents[localContentsOffset++] = (byte) (value >> 24);
      this.contents[localContentsOffset++] = (byte) (value >> 16);
      this.contents[localContentsOffset++] = (byte) (value >> 8);
      this.contents[localContentsOffset++] = (byte) value;
      this.contents[localContentsOffset++] = (byte) (numberOfGenericEntries >> 8);
      this.contents[localContentsOffset++] = (byte) numberOfGenericEntries;
      if (currentInstanceIsGeneric) {
        this.contents[localContentsOffset++] = 0; // the startPC for this is always 0
        this.contents[localContentsOffset++] = 0;
        this.contents[localContentsOffset++] = (byte) (code_length >> 8);
        this.contents[localContentsOffset++] = (byte) code_length;
        nameIndex = this.constantPool.literalIndex(ConstantPool.This);
        this.contents[localContentsOffset++] = (byte) (nameIndex >> 8);
        this.contents[localContentsOffset++] = (byte) nameIndex;
        descriptorIndex = this.constantPool.literalIndex(declaringClassBinding.genericTypeSignature());
        this.contents[localContentsOffset++] = (byte) (descriptorIndex >> 8);
        this.contents[localContentsOffset++] = (byte) descriptorIndex;
        this.contents[localContentsOffset++] = 0;// the resolved position for this is always 0
        this.contents[localContentsOffset++] = 0;
      }

      for (int i = 0; i < genericLocalVariablesCounter; i++) {
        LocalVariableBinding localVariable = genericLocalVariables[i];
        for (int j = 0; j < localVariable.initializationCount; j++) {
          int startPC = localVariable.initializationPCs[j << 1];
          int endPC = localVariable.initializationPCs[(j << 1) + 1];
          if (startPC != endPC) {
            // only entries for non zero length
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding

    if (maxLocals != 0) {
      int resolvedPosition = 0;
      // take into account enum constructor synthetic name+ordinal
      final boolean isConstructor = methodBinding.isConstructor();
      if (isConstructor || !methodBinding.isStatic()) {
        LocalVariableBinding localVariableBinding = new LocalVariableBinding(ConstantPool.This, methodBinding.declaringClass, 0, false);
        localVariableBinding.resolvedPosition = 0;
        this.codeStream.record(localVariableBinding);
        localVariableBinding.recordInitializationStartPC(0);
        localVariableBinding.recordInitializationEndPC(codeLength);
        frame.putLocal(resolvedPosition, new VerificationTypeInfo(
            isConstructor ? VerificationTypeInfo.ITEM_UNINITIALIZED_THIS : VerificationTypeInfo.ITEM_OBJECT,
            methodBinding.declaringClass));
        resolvedPosition++;
      }

      if (isConstructor) {
        if (methodBinding.declaringClass.isEnum()) {
          LocalVariableBinding localVariableBinding = new LocalVariableBinding(" name".toCharArray(), this.referenceBinding.scope.getJavaLangString(), 0, false); //$NON-NLS-1$
          localVariableBinding.resolvedPosition = resolvedPosition;
          this.codeStream.record(localVariableBinding);
          localVariableBinding.recordInitializationStartPC(0);
          localVariableBinding.recordInitializationEndPC(codeLength);

          frame.putLocal(resolvedPosition, new VerificationTypeInfo(
              TypeIds.T_JavaLangString,
              ConstantPool.JavaLangStringConstantPoolName));
          resolvedPosition++;

          localVariableBinding = new LocalVariableBinding(" ordinal".toCharArray(), TypeBinding.INT, 0, false); //$NON-NLS-1$
          localVariableBinding.resolvedPosition = resolvedPosition;
          this.codeStream.record(localVariableBinding);
          localVariableBinding.recordInitializationStartPC(0);
          localVariableBinding.recordInitializationEndPC(codeLength);
          frame.putLocal(resolvedPosition, new VerificationTypeInfo(
              TypeBinding.INT));
          resolvedPosition++;
        }

        // take into account the synthetic parameters
        if (methodBinding.declaringClass.isNestedType()) {
          ReferenceBinding enclosingInstanceTypes[];
          if ((enclosingInstanceTypes = methodBinding.declaringClass.syntheticEnclosingInstanceTypes()) != null) {
            for (int i = 0, max = enclosingInstanceTypes.length; i < max; i++) {
              // an enclosingInstanceType can only be a reference
              // binding. It cannot be
              // LongBinding or DoubleBinding
              LocalVariableBinding localVariableBinding = new LocalVariableBinding((" enclosingType" + i).toCharArray(), enclosingInstanceTypes[i], 0, false); //$NON-NLS-1$
              localVariableBinding.resolvedPosition = resolvedPosition;
              this.codeStream.record(localVariableBinding);
              localVariableBinding.recordInitializationStartPC(0);
              localVariableBinding.recordInitializationEndPC(codeLength);

              frame.putLocal(resolvedPosition,
                  new VerificationTypeInfo(enclosingInstanceTypes[i]));
              resolvedPosition++;
            }
          }

          TypeBinding[] arguments;
          if ((arguments = methodBinding.parameters) != null) {
            for (int i = 0, max = arguments.length; i < max; i++) {
              final TypeBinding typeBinding = arguments[i];
              frame.putLocal(resolvedPosition,
                  new VerificationTypeInfo(typeBinding));
              switch (typeBinding.id) {
                case TypeIds.T_double:
                case TypeIds.T_long:
                  resolvedPosition += 2;
                  break;
                default:
                  resolvedPosition++;
              }
            }
          }

          SyntheticArgumentBinding syntheticArguments[];
          if ((syntheticArguments = methodBinding.declaringClass.syntheticOuterLocalVariables()) != null) {
            for (int i = 0, max = syntheticArguments.length; i < max; i++) {
              final TypeBinding typeBinding = syntheticArguments[i].type;
              LocalVariableBinding localVariableBinding = new LocalVariableBinding((" synthetic" + i).toCharArray(), typeBinding, 0, false); //$NON-NLS-1$
              localVariableBinding.resolvedPosition = resolvedPosition;
              this.codeStream.record(localVariableBinding);
              localVariableBinding.recordInitializationStartPC(0);
              localVariableBinding.recordInitializationEndPC(codeLength);

              frame.putLocal(resolvedPosition,
                  new VerificationTypeInfo(typeBinding));
              switch (typeBinding.id) {
                case TypeIds.T_double:
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding

    for (; i < localsLength; i++) {
      locals[i] = null;
    }
    i = 0;
    locals: for (int max = this.codeStream.allLocalsCounter; i < max; i++) {
      LocalVariableBinding localVariable = this.codeStream.locals[i];
      if (localVariable == null) continue;
      int resolvedPosition = localVariable.resolvedPosition;
      final TypeBinding localVariableTypeBinding = localVariable.type;
      inits: for (int j = 0; j < localVariable.initializationCount; j++) {
        int startPC = localVariable.initializationPCs[j << 1];
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding

    System.arraycopy(this.contents, 0, this.contents = new byte[length + toAdd], 0, length);
  }

  private VerificationTypeInfo retrieveLocal(int currentPC, int resolvedPosition) {
    for (int i = 0, max = this.codeStream.allLocalsCounter; i < max; i++) {
      LocalVariableBinding localVariable = this.codeStream.locals[i];
      if (localVariable == null) continue;
      if (resolvedPosition == localVariable.resolvedPosition) {
        inits: for (int j = 0; j < localVariable.initializationCount; j++) {
          int startPC = localVariable.initializationPCs[j << 1];
          int endPC = localVariable.initializationPCs[(j << 1) + 1];
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding

    new String[] {new String(exceptionType.shortReadableName())},
    location.sourceStart,
    sourceEnd);
}
public void unhandledExceptionFromAutoClose (TypeBinding exceptionType, ASTNode location) {
  LocalVariableBinding localBinding = ((LocalDeclaration)location).binding;
  if (localBinding != null) {
    this.handle(
      IProblem.UnhandledExceptionOnAutoClose,
      new String[] {
          new String(exceptionType.readableName()),
          new String(localBinding.readableName())},
      new String[] {
          new String(exceptionType.shortReadableName()),
          new String(localBinding.shortReadableName())},
      location.sourceStart,
      location.sourceEnd);
  }
}
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding

  // until the point where it is safely handled (Smarter - see comment at the end)
  FlowContext traversedContext = this;
  ArrayList abruptlyExitedLoops = null;
  if (scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_7 && location instanceof ThrowStatement) {
    Expression throwExpression = ((ThrowStatement)location).exception;
    LocalVariableBinding throwArgBinding = throwExpression.localVariableBinding();
    if (throwExpression instanceof SingleNameReference // https://bugs.eclipse.org/bugs/show_bug.cgi?id=350361
        && throwArgBinding instanceof CatchParameterBinding && throwArgBinding.isEffectivelyFinal()) {
      CatchParameterBinding parameter = (CatchParameterBinding) throwArgBinding;
      checkExceptionHandlers(parameter.getPreciseTypes(), location, flowInfo, scope);
      return;
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.