Examples of RecoveredElement


Examples of org.aspectj.org.eclipse.jdt.internal.compiler.parser.RecoveredElement

* Recovery state is inferred from the current state of the parser (reduced node stack).
*/
public RecoveredElement buildInitialRecoveryState(){
  /* recovery in unit structure */
  if (referenceContext instanceof CompilationUnitDeclaration){
    RecoveredElement element = super.buildInitialRecoveryState();
    flushAssistState();
    flushElementStack();
    return element;
  }

  /* recovery in method body */
  lastCheckPoint = 0;

  RecoveredElement element = null;
  if (referenceContext instanceof AbstractMethodDeclaration){
    element = new RecoveredMethod((AbstractMethodDeclaration) referenceContext, null, 0, this);
    lastCheckPoint = ((AbstractMethodDeclaration) referenceContext).bodyStart;
  } else {
    /* Initializer bodies are parsed in the context of the type declaration, we must thus search it inside */
    if (referenceContext instanceof TypeDeclaration){
      TypeDeclaration type = (TypeDeclaration) referenceContext;
      for (int i = 0; i < type.fields.length; i++){
        FieldDeclaration field = type.fields[i];         
        if (field != null
            && field.getKind() == AbstractVariableDeclaration.INITIALIZER
            && field.declarationSourceStart <= scanner.initialPosition
            && scanner.initialPosition <= field.declarationSourceEnd
            && scanner.eofPosition <= field.declarationSourceEnd+1){
          element = new RecoveredInitializer(field, null, 1, this);
          lastCheckPoint = field.declarationSourceStart;         
          break;
        }
      }
    }
  }

  if (element == null) return element;

  /* add initial block */
  Block block = new Block(0);
  int lastStart = blockStarts[0];
  block.sourceStart = lastStart;
  element = element.add(block, 1);
  int blockIndex = 1// ignore first block start, since manually rebuilt here

  for(int i = 0; i <= astPtr; i++){
    ASTNode node = astStack[i];
   
    if(node instanceof ForeachStatement && ((ForeachStatement)node).action == null) {
      node = ((ForeachStatement)node).elementVariable;
    }

    /* check for intermediate block creation, so recovery can properly close them afterwards */
    int nodeStart = node.sourceStart;
    for (int j = blockIndex; j <= realBlockPtr; j++){
      if (blockStarts[j] >= 0) {
        if (blockStarts[j] > nodeStart){
          blockIndex = j; // shift the index to the new block
          break;
        }
        if (blockStarts[j] != lastStart){ // avoid multiple block if at same position
          block = new Block(0);
          block.sourceStart = lastStart = blockStarts[j];
          element = element.add(block, 1);
        }
      } else {
        if (-blockStarts[j] > nodeStart){
          blockIndex = j; // shift the index to the new block
          break;
        }
        block = new Block(0);
        block.sourceStart = lastStart = -blockStarts[j];
        element = element.add(block, 1);
      }
      blockIndex = j+1; // shift the index to the new block
    }
    if (node instanceof LocalDeclaration){
      LocalDeclaration local = (LocalDeclaration) node;
      if (local.declarationSourceEnd == 0){
        element = element.add(local, 0);
        if (local.initialization == null){
          lastCheckPoint = local.sourceEnd + 1;
        } else {
          lastCheckPoint = local.initialization.sourceEnd + 1;
        }
      } else {
        element = element.add(local, 0);
        lastCheckPoint = local.declarationSourceEnd + 1;
      }
      continue;
    }   
    if (node instanceof AbstractMethodDeclaration){
      AbstractMethodDeclaration method = (AbstractMethodDeclaration) node;
      if (method.declarationSourceEnd == 0){
        element = element.add(method, 0);
        lastCheckPoint = method.bodyStart;
      } else {
        element = element.add(method, 0);
        lastCheckPoint = method.declarationSourceEnd + 1;
      }
      continue;
    }
    if (node instanceof Initializer){
      Initializer initializer = (Initializer) node;
      if (initializer.declarationSourceEnd == 0){
        element = element.add(initializer, 1);
        lastCheckPoint = initializer.sourceStart;       
      } else {
        element = element.add(initializer, 0);
        lastCheckPoint = initializer.declarationSourceEnd + 1;
      }
      continue;
    }   
    if (node instanceof FieldDeclaration){
      FieldDeclaration field = (FieldDeclaration) node;
      if (field.declarationSourceEnd == 0){
        element = element.add(field, 0);
        if (field.initialization == null){
          lastCheckPoint = field.sourceEnd + 1;
        } else {
          lastCheckPoint = field.initialization.sourceEnd + 1;
        }
      } else {
        element = element.add(field, 0);
        lastCheckPoint = field.declarationSourceEnd + 1;
      }
      continue;
    }
    if (node instanceof TypeDeclaration){
      TypeDeclaration type = (TypeDeclaration) node;
      if (type.declarationSourceEnd == 0){
        element = element.add(type, 0)
        lastCheckPoint = type.bodyStart;
      } else {
        element = element.add(type, 0);       
        lastCheckPoint = type.declarationSourceEnd + 1;
      }
      continue;
    }
    if (node instanceof ImportReference){
      ImportReference importRef = (ImportReference) node;
      element = element.add(importRef, 0);
      lastCheckPoint = importRef.declarationSourceEnd + 1;
    }
  }
  if (this.currentToken == TokenNameRBRACE) {
    this.currentToken = 0; // closing brace has already been taken care of
  }

  /* might need some extra block (after the last reduced node) */
  int pos = this.assistNode == null ? lastCheckPoint : this.assistNode.sourceStart;
  for (int j = blockIndex; j <= realBlockPtr; j++){
    if (blockStarts[j] >= 0) {
      if ((blockStarts[j] < pos) && (blockStarts[j] != lastStart)){ // avoid multiple block if at same position
        block = new Block(0);
        block.sourceStart = lastStart = blockStarts[j];
        element = element.add(block, 1);
      }
    } else {
      if ((blockStarts[j] < pos)){ // avoid multiple block if at same position
        block = new Block(0);
        block.sourceStart = lastStart = -blockStarts[j];
        element = element.add(block, 1);
      }
    }
  }
 
  return element;
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.parser.RecoveredElement

  this.elementInfoStack[this.elementPtr] = info;
}
public void recoveryExitFromVariable() {
  if(currentElement != null && currentElement instanceof RecoveredField
    && !(currentElement instanceof RecoveredInitializer)) {
    RecoveredElement oldElement = currentElement;
    super.recoveryExitFromVariable();
    if(oldElement != currentElement) {
      popElement(K_FIELD_INITIALIZER_DELIMITER);
    }
  } else {
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.parser.RecoveredElement

  } else {
    super.recoveryExitFromVariable();
  }
}
public void recoveryTokenCheck() {
  RecoveredElement oldElement = currentElement;
  switch (currentToken) {
    case TokenNameLBRACE :
      super.recoveryTokenCheck();
      if(currentElement instanceof RecoveredInitializer) {
        if(oldElement instanceof RecoveredField) {
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.parser.RecoveredElement

* Recovery state is inferred from the current state of the parser (reduced node stack).
*/
public RecoveredElement buildInitialRecoveryState(){
  /* recovery in unit structure */
  if (this.referenceContext instanceof CompilationUnitDeclaration){
    RecoveredElement element = super.buildInitialRecoveryState();
    flushAssistState();
    flushElementStack();
    return element;
  }

  /* recovery in method body */
  this.lastCheckPoint = 0;

  RecoveredElement element = null;
  if (this.referenceContext instanceof AbstractMethodDeclaration){
    element = new RecoveredMethod((AbstractMethodDeclaration) this.referenceContext, null, 0, this);
    this.lastCheckPoint = ((AbstractMethodDeclaration) this.referenceContext).bodyStart;
  } else {
    /* Initializer bodies are parsed in the context of the type declaration, we must thus search it inside */
    if (this.referenceContext instanceof TypeDeclaration){
      TypeDeclaration type = (TypeDeclaration) this.referenceContext;
      FieldDeclaration[] fields = type.fields;
      int length = fields == null ? 0 : fields.length;
      for (int i = 0; i < length; i++){
        FieldDeclaration field = fields[i];
        if (field != null
            && field.getKind() == AbstractVariableDeclaration.INITIALIZER
            && field.declarationSourceStart <= this.scanner.initialPosition
            && this.scanner.initialPosition <= field.declarationSourceEnd
            && this.scanner.eofPosition <= field.declarationSourceEnd+1){
          element = new RecoveredInitializer(field, null, 1, this);
          this.lastCheckPoint = field.declarationSourceStart;
          break;
        }
      }
    }
  }

  if (element == null) return element;

  /* add initial block */
  Block block = new Block(0);
  int lastStart = this.blockStarts[0];
  block.sourceStart = lastStart;
  element = element.add(block, 1);
  int blockIndex = 1// ignore first block start, since manually rebuilt here

  for(int i = 0; i <= this.astPtr; i++){
    ASTNode node = this.astStack[i];

    if(node instanceof ForeachStatement && ((ForeachStatement)node).action == null) {
      node = ((ForeachStatement)node).elementVariable;
    }

    /* check for intermediate block creation, so recovery can properly close them afterwards */
    int nodeStart = node.sourceStart;
    for (int j = blockIndex; j <= this.realBlockPtr; j++){
      if (this.blockStarts[j] >= 0) {
        if (this.blockStarts[j] > nodeStart){
          blockIndex = j; // shift the index to the new block
          break;
        }
        if (this.blockStarts[j] != lastStart){ // avoid multiple block if at same position
          block = new Block(0);
          block.sourceStart = lastStart = this.blockStarts[j];
          element = element.add(block, 1);
        }
      } else {
        if (-this.blockStarts[j] > nodeStart){
          blockIndex = j; // shift the index to the new block
          break;
        }
        block = new Block(0);
        block.sourceStart = lastStart = -this.blockStarts[j];
        element = element.add(block, 1);
      }
      blockIndex = j+1; // shift the index to the new block
    }
    if (node instanceof LocalDeclaration){
      LocalDeclaration local = (LocalDeclaration) node;
      if (local.declarationSourceEnd == 0){
        element = element.add(local, 0);
        if (local.initialization == null){
          this.lastCheckPoint = local.sourceEnd + 1;
        } else {
          this.lastCheckPoint = local.initialization.sourceEnd + 1;
        }
      } else {
        element = element.add(local, 0);
        this.lastCheckPoint = local.declarationSourceEnd + 1;
      }
      continue;
    }
    if (node instanceof AbstractMethodDeclaration){
      AbstractMethodDeclaration method = (AbstractMethodDeclaration) node;
      if (method.declarationSourceEnd == 0){
        element = element.add(method, 0);
        this.lastCheckPoint = method.bodyStart;
      } else {
        element = element.add(method, 0);
        this.lastCheckPoint = method.declarationSourceEnd + 1;
      }
      continue;
    }
    if (node instanceof Initializer){
      Initializer initializer = (Initializer) node;
      if (initializer.declarationSourceEnd == 0){
        element = element.add(initializer, 1);
        this.lastCheckPoint = initializer.sourceStart;
      } else {
        element = element.add(initializer, 0);
        this.lastCheckPoint = initializer.declarationSourceEnd + 1;
      }
      continue;
    }
    if (node instanceof FieldDeclaration){
      FieldDeclaration field = (FieldDeclaration) node;
      if (field.declarationSourceEnd == 0){
        element = element.add(field, 0);
        if (field.initialization == null){
          this.lastCheckPoint = field.sourceEnd + 1;
        } else {
          this.lastCheckPoint = field.initialization.sourceEnd + 1;
        }
      } else {
        element = element.add(field, 0);
        this.lastCheckPoint = field.declarationSourceEnd + 1;
      }
      continue;
    }
    if (node instanceof TypeDeclaration){
      TypeDeclaration type = (TypeDeclaration) node;
      if (type.declarationSourceEnd == 0){
        element = element.add(type, 0);
        this.lastCheckPoint = type.bodyStart;
      } else {
        element = element.add(type, 0);
        this.lastCheckPoint = type.declarationSourceEnd + 1;
      }
      continue;
    }
    if (node instanceof ImportReference){
      ImportReference importRef = (ImportReference) node;
      element = element.add(importRef, 0);
      this.lastCheckPoint = importRef.declarationSourceEnd + 1;
    }
  }
  if (this.currentToken == TokenNameRBRACE) {
    this.currentToken = 0; // closing brace has already been taken care of
  }

  /* might need some extra block (after the last reduced node) */
  int pos = this.assistNode == null ? this.lastCheckPoint : this.assistNode.sourceStart;
  for (int j = blockIndex; j <= this.realBlockPtr; j++){
    if (this.blockStarts[j] >= 0) {
      if ((this.blockStarts[j] < pos) && (this.blockStarts[j] != lastStart)){ // avoid multiple block if at same position
        block = new Block(0);
        block.sourceStart = lastStart = this.blockStarts[j];
        element = element.add(block, 1);
      }
    } else {
      if ((this.blockStarts[j] < pos)){ // avoid multiple block if at same position
        block = new Block(0);
        block.sourceStart = lastStart = -this.blockStarts[j];
        element = element.add(block, 1);
      }
    }
  }

  return element;
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.parser.RecoveredElement

  this.elementObjectInfoStack[this.elementPtr] = objectInfo;
}
public void recoveryExitFromVariable() {
  if(this.currentElement != null && this.currentElement instanceof RecoveredField
    && !(this.currentElement instanceof RecoveredInitializer)) {
    RecoveredElement oldElement = this.currentElement;
    super.recoveryExitFromVariable();
    if(oldElement != this.currentElement) {
      popElement(K_FIELD_INITIALIZER_DELIMITER);
    }
  } else {
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.parser.RecoveredElement

  } else {
    super.recoveryExitFromVariable();
  }
}
public void recoveryTokenCheck() {
  RecoveredElement oldElement = this.currentElement;
  switch (this.currentToken) {
    case TokenNameLBRACE :
      super.recoveryTokenCheck();
      if(this.currentElement instanceof RecoveredInitializer) {
        if(oldElement instanceof RecoveredField) {
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.parser.RecoveredElement

* Recovery state is inferred from the current state of the parser (reduced node stack).
*/
public RecoveredElement buildInitialRecoveryState(){
  /* recovery in unit structure */
  if (this.referenceContext instanceof CompilationUnitDeclaration){
    RecoveredElement element = super.buildInitialRecoveryState();
    flushAssistState();
    flushElementStack();
    return element;
  }

  /* recovery in method body */
  this.lastCheckPoint = 0;

  RecoveredElement element = null;
  if (this.referenceContext instanceof AbstractMethodDeclaration){
    element = new RecoveredMethod((AbstractMethodDeclaration) this.referenceContext, null, 0, this);
    this.lastCheckPoint = ((AbstractMethodDeclaration) this.referenceContext).bodyStart;
  } else {
    /* Initializer bodies are parsed in the context of the type declaration, we must thus search it inside */
    if (this.referenceContext instanceof TypeDeclaration){
      TypeDeclaration type = (TypeDeclaration) this.referenceContext;
      FieldDeclaration[] fields = type.fields;
      int length = fields == null ? 0 : fields.length;
      for (int i = 0; i < length; i++){
        FieldDeclaration field = fields[i];
        if (field != null
            && field.getKind() == AbstractVariableDeclaration.INITIALIZER
            && field.declarationSourceStart <= this.scanner.initialPosition
            && this.scanner.initialPosition <= field.declarationSourceEnd
            && this.scanner.eofPosition <= field.declarationSourceEnd+1){
          element = new RecoveredInitializer(field, null, 1, this);
          this.lastCheckPoint = field.declarationSourceStart;
          break;
        }
      }
    }
  }

  if (element == null) return element;

  /* add initial block */
  Block block = new Block(0);
  int lastStart = this.blockStarts[0];
  block.sourceStart = lastStart;
  element = element.add(block, 1);
  int blockIndex = 1// ignore first block start, since manually rebuilt here

  for(int i = 0; i <= this.astPtr; i++){
    ASTNode node = this.astStack[i];

    if(node instanceof ForeachStatement && ((ForeachStatement)node).action == null) {
      node = ((ForeachStatement)node).elementVariable;
    }

    /* check for intermediate block creation, so recovery can properly close them afterwards */
    int nodeStart = node.sourceStart;
    for (int j = blockIndex; j <= this.realBlockPtr; j++){
      if (this.blockStarts[j] >= 0) {
        if (this.blockStarts[j] > nodeStart){
          blockIndex = j; // shift the index to the new block
          break;
        }
        if (this.blockStarts[j] != lastStart){ // avoid multiple block if at same position
          block = new Block(0);
          block.sourceStart = lastStart = this.blockStarts[j];
          element = element.add(block, 1);
        }
      } else {
        if (-this.blockStarts[j] > nodeStart){
          blockIndex = j; // shift the index to the new block
          break;
        }
        block = new Block(0);
        block.sourceStart = lastStart = -this.blockStarts[j];
        element = element.add(block, 1);
      }
      blockIndex = j+1; // shift the index to the new block
    }
    if (node instanceof LocalDeclaration){
      LocalDeclaration local = (LocalDeclaration) node;
      if (local.declarationSourceEnd == 0){
        element = element.add(local, 0);
        if (local.initialization == null){
          this.lastCheckPoint = local.sourceEnd + 1;
        } else {
          this.lastCheckPoint = local.initialization.sourceEnd + 1;
        }
      } else {
        element = element.add(local, 0);
        this.lastCheckPoint = local.declarationSourceEnd + 1;
      }
      continue;
    }
    if (node instanceof AbstractMethodDeclaration){
      AbstractMethodDeclaration method = (AbstractMethodDeclaration) node;
      if (method.declarationSourceEnd == 0){
        element = element.add(method, 0);
        this.lastCheckPoint = method.bodyStart;
      } else {
        element = element.add(method, 0);
        this.lastCheckPoint = method.declarationSourceEnd + 1;
      }
      continue;
    }
    if (node instanceof Initializer){
      Initializer initializer = (Initializer) node;
      if (initializer.declarationSourceEnd == 0){
        element = element.add(initializer, 1);
        this.lastCheckPoint = initializer.sourceStart;
      } else {
        element = element.add(initializer, 0);
        this.lastCheckPoint = initializer.declarationSourceEnd + 1;
      }
      continue;
    }
    if (node instanceof FieldDeclaration){
      FieldDeclaration field = (FieldDeclaration) node;
      if (field.declarationSourceEnd == 0){
        element = element.add(field, 0);
        if (field.initialization == null){
          this.lastCheckPoint = field.sourceEnd + 1;
        } else {
          this.lastCheckPoint = field.initialization.sourceEnd + 1;
        }
      } else {
        element = element.add(field, 0);
        this.lastCheckPoint = field.declarationSourceEnd + 1;
      }
      continue;
    }
    if (node instanceof TypeDeclaration){
      TypeDeclaration type = (TypeDeclaration) node;
      if (type.declarationSourceEnd == 0){
        element = element.add(type, 0);
        this.lastCheckPoint = type.bodyStart;
      } else {
        element = element.add(type, 0);
        this.lastCheckPoint = type.declarationSourceEnd + 1;
      }
      continue;
    }
    if (node instanceof ImportReference){
      ImportReference importRef = (ImportReference) node;
      element = element.add(importRef, 0);
      this.lastCheckPoint = importRef.declarationSourceEnd + 1;
    }
  }
  if (this.currentToken == TokenNameRBRACE) {
    this.currentToken = 0; // closing brace has already been taken care of
  }

  /* might need some extra block (after the last reduced node) */
  int pos = this.assistNode == null ? this.lastCheckPoint : this.assistNode.sourceStart;
  for (int j = blockIndex; j <= this.realBlockPtr; j++){
    if (this.blockStarts[j] >= 0) {
      if ((this.blockStarts[j] < pos) && (this.blockStarts[j] != lastStart)){ // avoid multiple block if at same position
        block = new Block(0);
        block.sourceStart = lastStart = this.blockStarts[j];
        element = element.add(block, 1);
      }
    } else {
      if ((this.blockStarts[j] < pos)){ // avoid multiple block if at same position
        block = new Block(0);
        block.sourceStart = lastStart = -this.blockStarts[j];
        element = element.add(block, 1);
      }
    }
  }

  return element;
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.parser.RecoveredElement

  this.elementObjectInfoStack[this.elementPtr] = objectInfo;
}
public void recoveryExitFromVariable() {
  if(this.currentElement != null && this.currentElement instanceof RecoveredField
    && !(this.currentElement instanceof RecoveredInitializer)) {
    RecoveredElement oldElement = this.currentElement;
    super.recoveryExitFromVariable();
    if(oldElement != this.currentElement) {
      popElement(K_FIELD_INITIALIZER_DELIMITER);
    }
  } else {
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.parser.RecoveredElement

  } else {
    super.recoveryExitFromVariable();
  }
}
public void recoveryTokenCheck() {
  RecoveredElement oldElement = this.currentElement;
  switch (this.currentToken) {
    case TokenNameLBRACE :
      super.recoveryTokenCheck();
      if(this.currentElement instanceof RecoveredInitializer) {
        if(oldElement instanceof RecoveredField) {
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.parser.RecoveredElement

* Recovery state is inferred from the current state of the parser (reduced node stack).
*/
public RecoveredElement buildInitialRecoveryState(){
  /* recovery in unit structure */
  if (this.referenceContext instanceof CompilationUnitDeclaration){
    RecoveredElement element = super.buildInitialRecoveryState();
    flushAssistState();
    flushElementStack();
    this.snapShot = null;
    return element;
  }

  /* recovery in method body */
  this.lastCheckPoint = 0;

  RecoveredElement element = null;
  if (this.referenceContext instanceof AbstractMethodDeclaration){
    element = new RecoveredMethod((AbstractMethodDeclaration) this.referenceContext, null, 0, this);
    this.lastCheckPoint = ((AbstractMethodDeclaration) this.referenceContext).bodyStart;
  } else {
    /* Initializer bodies are parsed in the context of the type declaration, we must thus search it inside */
    if (this.referenceContext instanceof TypeDeclaration){
      TypeDeclaration type = (TypeDeclaration) this.referenceContext;
      FieldDeclaration[] fields = type.fields;
      int length = fields == null ? 0 : fields.length;
      for (int i = 0; i < length; i++){
        FieldDeclaration field = fields[i];
        if (field != null
            && field.getKind() == AbstractVariableDeclaration.INITIALIZER
            && field.declarationSourceStart <= this.scanner.initialPosition
            && this.scanner.initialPosition <= field.declarationSourceEnd
            && this.scanner.eofPosition <= field.declarationSourceEnd+1){
          element = new RecoveredInitializer(field, null, 1, this);
          this.lastCheckPoint = field.declarationSourceStart;
          break;
        }
      }
    }
  }

  if (element == null) return element;

  /* add initial block */
  Block block = new Block(0);
  int lastStart = this.blockStarts[0];
  block.sourceStart = lastStart;
  element = element.add(block, 1);
  int blockIndex = 1// ignore first block start, since manually rebuilt here

  ASTNode node = null, lastNode = null;
  for (int i = 0; i <= this.astPtr; i++, lastNode = node) {
    node = this.astStack[i];
    if(node instanceof ForeachStatement && ((ForeachStatement)node).action == null) {
      node = ((ForeachStatement)node).elementVariable;
    }
    /* check for intermediate block creation, so recovery can properly close them afterwards */
    int nodeStart = node.sourceStart;
    for (int j = blockIndex; j <= this.realBlockPtr; j++){
      if (this.blockStarts[j] >= 0) {
        if (this.blockStarts[j] > nodeStart){
          blockIndex = j; // shift the index to the new block
          break;
        }
        if (this.blockStarts[j] != lastStart){ // avoid multiple block if at same position
          block = new Block(0, lastNode instanceof LambdaExpression);
          block.sourceStart = lastStart = this.blockStarts[j];
          element = element.add(block, 1);
        }
      } else {
        if (-this.blockStarts[j] > nodeStart){
          blockIndex = j; // shift the index to the new block
          break;
        }
        block = new Block(0);
        block.sourceStart = lastStart = -this.blockStarts[j];
        element = element.add(block, 1);
      }
      blockIndex = j+1; // shift the index to the new block
    }
   
    if (node instanceof LocalDeclaration){
      LocalDeclaration local = (LocalDeclaration) node;
      if (local.declarationSourceEnd == 0){
        element = element.add(local, 0);
        if (local.initialization == null){
          this.lastCheckPoint = local.sourceEnd + 1;
        } else {
          this.lastCheckPoint = local.initialization.sourceEnd + 1;
        }
      } else {
        element = element.add(local, 0);
        this.lastCheckPoint = local.declarationSourceEnd + 1;
      }
      continue;
    }
    if (node instanceof AbstractMethodDeclaration){
      AbstractMethodDeclaration method = (AbstractMethodDeclaration) node;
      if (method.declarationSourceEnd == 0){
        element = element.add(method, 0);
        this.lastCheckPoint = method.bodyStart;
      } else {
        element = element.add(method, 0);
        this.lastCheckPoint = method.declarationSourceEnd + 1;
      }
      continue;
    }
    if (node instanceof Initializer){
      Initializer initializer = (Initializer) node;
      if (initializer.declarationSourceEnd == 0){
        element = element.add(initializer, 1);
        this.lastCheckPoint = initializer.sourceStart;
      } else {
        element = element.add(initializer, 0);
        this.lastCheckPoint = initializer.declarationSourceEnd + 1;
      }
      continue;
    }
    if (node instanceof FieldDeclaration){
      FieldDeclaration field = (FieldDeclaration) node;
      if (field.declarationSourceEnd == 0){
        element = element.add(field, 0);
        if (field.initialization == null){
          this.lastCheckPoint = field.sourceEnd + 1;
        } else {
          this.lastCheckPoint = field.initialization.sourceEnd + 1;
        }
      } else {
        element = element.add(field, 0);
        this.lastCheckPoint = field.declarationSourceEnd + 1;
      }
      continue;
    }
    if (node instanceof TypeDeclaration){
      TypeDeclaration type = (TypeDeclaration) node;
      if (type.declarationSourceEnd == 0){
        element = element.add(type, 0);
        this.lastCheckPoint = type.bodyStart;
      } else {
        element = element.add(type, 0);
        this.lastCheckPoint = type.declarationSourceEnd + 1;
      }
      continue;
    }
    if (this.assistNode != null && node instanceof Statement) {
      Statement stmt = (Statement) node;
      if (!(stmt instanceof Expression) || ((Expression) stmt).statementExpression()) {
        if (this.assistNode.sourceStart >= stmt.sourceStart && this.assistNode.sourceEnd <= stmt.sourceEnd) {
          element.add(stmt, 0);
          this.lastCheckPoint = stmt.sourceEnd + 1;
          this.isOrphanCompletionNode = false;
        }
      }
      continue;
    }
    if (node instanceof ImportReference){
      ImportReference importRef = (ImportReference) node;
      element = element.add(importRef, 0);
      this.lastCheckPoint = importRef.declarationSourceEnd + 1;
    }
  }
  if (this.currentToken == TokenNameRBRACE && !isIndirectlyInsideLambdaExpression()) {
    this.currentToken = 0; // closing brace has already been taken care of
  }

  /* might need some extra block (after the last reduced node) */
  /* For block bodied lambdas we should create a block even though the lambda header appears before it, so elements from within don't get misattributed. */
  int pos = this.assistNode == null ? this.lastCheckPoint : this.assistNode.sourceStart;
  boolean createLambdaBlock = lastNode instanceof LambdaExpression && ((LambdaExpression) node).body() instanceof Block;
  for (int j = blockIndex; j <= this.realBlockPtr; j++){
    if (this.blockStarts[j] >= 0) {
      if ((this.blockStarts[j] < pos || createLambdaBlock) && (this.blockStarts[j] != lastStart)){ // avoid multiple block if at same position
        block = new Block(0, createLambdaBlock);
        block.sourceStart = lastStart = this.blockStarts[j];
        element = element.add(block, 1);
        createLambdaBlock = false;
      }
    } else {
      if ((this.blockStarts[j] < pos)){ // avoid multiple block if at same position
        block = new Block(0);
        block.sourceStart = lastStart = -this.blockStarts[j];
        element = element.add(block, 1);
      }
    }
  }

  return element;
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.