Examples of LocalDeclaration


Examples of org.eclipse.jdt.internal.compiler.ast.LocalDeclaration

          // convert it to a simple try statement tagged as MALFORMED
          tryStatement.setFlags(tryStatement.getFlags() | ASTNode.MALFORMED);
          break;
        default:
          for (int i = 0; i < resourcesLength; i++) {
            LocalDeclaration localDeclaration = localDeclarations[i];
            VariableDeclarationExpression variableDeclarationExpression = convertToVariableDeclarationExpression(localDeclaration);
            int start = variableDeclarationExpression.getStartPosition();
            int end = localDeclaration.declarationEnd;
            variableDeclarationExpression.setSourceRange(start, end - start + 1);
            tryStatement.resources().add(variableDeclarationExpression);
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.ast.LocalDeclaration

      }
    }
  }
}
public void acceptLocalVariable(LocalVariableBinding binding) {
  LocalDeclaration local = binding.declaration;
  IJavaElement parent = findLocalElement(local.sourceStart); // findLocalElement() cannot find local variable
  LocalVariable localVar = null;
  if(parent != null) {
    localVar = new LocalVariable(
        (JavaElement)parent,
        new String(local.name),
        local.declarationSourceStart,
        local.declarationSourceEnd,
        local.sourceStart,
        local.sourceEnd,
        Util.typeSignature(local.type),
        local.annotations,
        local.modifiers,
        local.getKind() == AbstractVariableDeclaration.PARAMETER);
  }
  if (localVar != null) {
    addElement(localVar);
    if(SelectionEngine.DEBUG){
      System.out.print("SELECTION - accept local variable("); //$NON-NLS-1$
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.ast.LocalDeclaration

        compilationResult);
    methodDeclaration.scope = new MethodScope(typeDeclaration.scope, null,
        false);
    methodDeclaration.returnType = createMockBinaryTypeReference(binaryTypeBinding);

    LocalDeclaration localDeclaration = new LocalDeclaration(null, 0, 0);
    localDeclaration.type = createMockBinaryTypeReference(binaryTypeBinding);
    methodDeclaration.statements = new Statement[] {localDeclaration};

    SingleMemberAnnotation annotation = new SingleMemberAnnotation(
        createMockBinaryTypeReference(binaryTypeBinding), 0);
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.ast.LocalDeclaration

      }
    }
  }
}
public void acceptLocalVariable(LocalVariableBinding binding, org.eclipse.jdt.internal.compiler.env.ICompilationUnit unit) {
  LocalDeclaration local = binding.declaration;
  IJavaElement parent = null;
  if (binding.declaringScope.isLambdaSubscope() && unit instanceof ICompilationUnit) {
    HashSet existingElements = new HashSet();
    HashMap knownScopes = new HashMap();
    parent = this.handleFactory.createElement(binding.declaringScope, local.sourceStart, (ICompilationUnit) unit, existingElements, knownScopes);
  } else {   
    parent = findLocalElement(local.sourceStart, binding.declaringScope.methodScope()); // findLocalElement() cannot find local variable
  }
  LocalVariable localVar = null;
  if(parent != null) {
    localVar = new LocalVariable(
        (JavaElement)parent,
        new String(local.name),
        local.declarationSourceStart,
        local.declarationSourceEnd,
        local.sourceStart,
        local.sourceEnd,
        local.type == null ? Signature.createTypeSignature(binding.type.readableName(), true) : Util.typeSignature(local.type),
        local.annotations,
        local.modifiers,
        local.getKind() == AbstractVariableDeclaration.PARAMETER);
  }
  if (localVar != null) {
    addElement(localVar);
    if(SelectionEngine.DEBUG){
      System.out.print("SELECTION - accept local variable("); //$NON-NLS-1$
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.ast.LocalDeclaration

  private void removeLocals(Statement[] statements, int start, int end) {
    if (statements != null) {
      for (int i = 0; i < statements.length; i++) {
        if (statements[i] instanceof LocalDeclaration) {
          LocalDeclaration localDeclaration = (LocalDeclaration) statements[i];
          int j = indexOfFisrtNameAfter(start);
          done : while (j != -1) {
            int nameStart = this.potentialVariableNameStarts[j];
            if (start <= nameStart && nameStart <= end) {
              if (CharOperation.equals(this.potentialVariableNames[j], localDeclaration.name, false)) {
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.ast.LocalDeclaration

          }
        } else if (i == statementsLength - 1 && insertNewLineAfterLastStatement) {
          this.scribe.printNewLine();
        }
      } else if (statement instanceof LocalDeclaration) {
        LocalDeclaration currentLocal = (LocalDeclaration) statement;
        if (i < (statementsLength - 1)) {
          /*
           * We need to check that the next statement is a local declaration
           */
          if (statements[i + 1] instanceof LocalDeclaration) {
            LocalDeclaration nextLocal = (LocalDeclaration) statements[i + 1];
            if (currentLocal.declarationSourceStart != nextLocal.declarationSourceStart) {
              this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
              this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT);
              if (i != statementsLength - 1) {
                if (!(statement instanceof EmptyStatement) && !(statements[i + 1] instanceof EmptyStatement)) {
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.ast.LocalDeclaration

           */
          this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
          this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT);
          this.scribe.printNewLine();
        } else if (statement instanceof LocalDeclaration) {
          LocalDeclaration currentLocal = (LocalDeclaration) statement;
          if (i < (statementsLength - 1)) {
            /*
             * We need to check that the next statement is a local declaration
             */
            if (statements[i + 1] instanceof LocalDeclaration) {
              LocalDeclaration nextLocal = (LocalDeclaration) statements[i + 1];
              if (currentLocal.declarationSourceStart != nextLocal.declarationSourceStart) {
                /*
                 * Print the semi-colon
                 */
                this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.ast.LocalDeclaration

          // convert it to a simple try statement tagged as MALFORMED
          tryStatement.setFlags(tryStatement.getFlags() | ASTNode.MALFORMED);
          break;
        default:
          for (int i = 0; i < resourcesLength; i++) {
            LocalDeclaration localDeclaration = localDeclarations[i];
            VariableDeclarationExpression variableDeclarationExpression = convertToVariableDeclarationExpression(localDeclaration);
            int start = variableDeclarationExpression.getStartPosition();
            int end = localDeclaration.declarationEnd;
            variableDeclarationExpression.setSourceRange(start, end - start + 1);
            tryStatement.resources().add(variableDeclarationExpression);
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.ast.LocalDeclaration

    int visibleTypeAnnotationsCounter = 0;

    for (int i = 0, max = this.codeStream.allLocalsCounter; i < max; i++) {
      LocalVariableBinding localVariable = this.codeStream.locals[i];
      if (localVariable.isCatchParameter()) continue;
      LocalDeclaration declaration = localVariable.declaration;
      if (declaration == null
          || (declaration.isArgument() && ((declaration.bits & ASTNode.IsUnionType) == 0))
          || (localVariable.initializationCount == 0)
          || ((declaration.bits & ASTNode.HasTypeAnnotations) == 0)) {
        continue;
      }
      int targetType = ((localVariable.tagBits & TagBits.IsResource) == 0) ? AnnotationTargetTypeConstants.LOCAL_VARIABLE : AnnotationTargetTypeConstants.RESOURCE_VARIABLE;
      declaration.getAllAnnotationContexts(targetType, localVariable, allTypeAnnotationContexts);
    }
   
    ExceptionLabel[] exceptionLabels = this.codeStream.exceptionLabels;
    for (int i = 0, max = this.codeStream.exceptionLabelsCounter; i < max; i++) {
      ExceptionLabel exceptionLabel = exceptionLabels[i];
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.ast.LocalDeclaration

              startPosition = fieldDeclaration.sourceStart;
              endPosition = fieldDeclaration.sourceEnd;
            }
          } else if (binding instanceof AptSourceLocalVariableBinding){
            AptSourceLocalVariableBinding parameterBinding = (AptSourceLocalVariableBinding) binding;
            LocalDeclaration parameterDeclaration = parameterBinding.declaration;
            if (parameterDeclaration != null) {
              MethodBinding methodBinding = parameterBinding.methodBinding;
              if (methodBinding != null) {
                referenceContext = methodBinding.sourceMethod();
              }
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.