public RecoveredElement add(Statement stmt, int bracketBalanceValue) { if (this.alreadyCompletedLocalInitialization || !(stmt instanceof Expression)) { return super.add(stmt, bracketBalanceValue); } else { this.alreadyCompletedLocalInitialization = true; this.localDeclaration.initialization = (Expression)stmt; this.localDeclaration.declarationSourceEnd = stmt.sourceEnd; this.localDeclaration.declarationEnd = stmt.sourceEnd; return this; } } public void attach(RecoveredAnnotation[] annots, int annotCount, int mods, int modsSourceStart) {
@Override public String toString(int tab){ return tabString(tab) + "Recovered statement:\n" + this.statement.print(tab + 1, new StringBuffer(10)); //$NON-NLS-1$ } public Statement updatedStatement(int depth, Set<TypeDeclaration> knownTypes){
public void updateParseTree(){ updatedStatement(0, new HashSet<TypeDeclaration>()); } /*
if (recoveredBlock != null) { RecoveredStatement recoveredStatement = recoveredBlock.statementCount > 0 ? recoveredBlock.statements[recoveredBlock.statementCount - 1] : null; ASTNode parseTree = recoveredStatement != null ? recoveredStatement.updatedStatement(0, new HashSet<TypeDeclaration>()) : null; if (parseTree != null) { if ((parseTree.sourceStart == 0 || parseTree.sourceEnd == 0) || (parseTree.sourceStart >= statementStart && parseTree.sourceEnd <= statementEnd)) { recoveredBlock.statements[recoveredBlock.statementCount - 1] = new RecoveredStatement(statement, recoveredBlock, 0); statement = null; } else if (recoveredStatement instanceof RecoveredLocalVariable && statement instanceof Expression) {
public String toString(int tab) { StringBuffer result = new StringBuffer(tabString(tab)); result.append("Recovered block:\n"); //$NON-NLS-1$ this.blockDeclaration.print(tab + 1, result); if (this.statements != null) { for (int i = 0; i < this.statementCount; i++) { result.append("\n"); //$NON-NLS-1$ result.append(this.statements[i].toString(tab + 1)); } } return result.toString(); } /*
public RecoveredElement add(Statement stmt, int bracketBalanceValue, boolean delegatedByParent) { resetPendingModifiers(); /* do not consider a nested block starting passed the block end (if set) it must be belonging to an enclosing block */ if (this.blockDeclaration.sourceEnd != 0 && stmt.sourceStart > this.blockDeclaration.sourceEnd){ if (delegatedByParent) return this; //ignore return this.parent.add(stmt, bracketBalanceValue); } RecoveredStatement element = new RecoveredStatement(stmt, this, bracketBalanceValue); attach(element); if (stmt.sourceEnd == 0) return element; return this; } /*
return this.add(init, 1); return super.updateOnOpeningBrace(braceStart, braceEnd);
@Override public RecoveredElement updateOnClosingBrace(int braceStart, int braceEnd){ if ((--this.bracketBalance <= 0) && (this.parent != null)){ this.updateSourceEndIfNecessary(braceStart, braceEnd); return this.parent.updateOnClosingBrace(braceStart, braceEnd); } return this; } @Override
for(int i = 0; i < statements.length; i++) { if (statements[i] == null) break; ASTNode node = statements[i].parseTree(); if ((node.sourceStart >= start && node.sourceEnd <= end)) { if (!found) { statements[i] = new RecoveredStatement(stmt, blk, 0); found = true; blk.statementCount = i + 1;
if (recoveredBlock != null) { RecoveredStatement recoveredStatement = recoveredBlock.statementCount > 0 ? recoveredBlock.statements[recoveredBlock.statementCount - 1] : null; ASTNode parseTree = recoveredStatement != null ? recoveredStatement.updatedStatement(0, new HashSet<TypeDeclaration>()) : null; if (parseTree != null) { if ((parseTree.sourceStart == 0 || parseTree.sourceEnd == 0) || (parseTree.sourceStart >= statementStart && parseTree.sourceEnd <= statementEnd)) { recoveredBlock.statements[recoveredBlock.statementCount - 1] = new RecoveredStatement(statement, recoveredBlock, 0); statement = null; } else if (recoveredStatement instanceof RecoveredLocalVariable && statement instanceof Expression) {
public String toString(int tab) { StringBuffer result = new StringBuffer(tabString(tab)); result.append("Recovered block:\n"); //$NON-NLS-1$ this.blockDeclaration.print(tab + 1, result); if (this.statements != null) { for (int i = 0; i < this.statementCount; i++) { result.append("\n"); //$NON-NLS-1$ result.append(this.statements[i].toString(tab + 1)); } } return result.toString(); } /*
public RecoveredElement add(Statement stmt, int bracketBalanceValue, boolean delegatedByParent) { resetPendingModifiers(); /* do not consider a nested block starting passed the block end (if set) it must be belonging to an enclosing block */ if (this.blockDeclaration.sourceEnd != 0 && stmt.sourceStart > this.blockDeclaration.sourceEnd){ if (delegatedByParent) return this; //ignore return this.parent.add(stmt, bracketBalanceValue); } RecoveredStatement element = new RecoveredStatement(stmt, this, bracketBalanceValue); attach(element); if (stmt.sourceEnd == 0) return element; return this; } /*
return this.add(init, 1); return super.updateOnOpeningBrace(braceStart, braceEnd);
public RecoveredElement updateOnClosingBrace(int braceStart, int braceEnd){ if ((--this.bracketBalance <= 0) && (this.parent != null)){ this.updateSourceEndIfNecessary(braceStart, braceEnd); return this.parent.updateOnClosingBrace(braceStart, braceEnd); } return this; } }
for(int i = 0; i < statements.length; i++) { if (statements[i] == null) break; ASTNode node = statements[i].parseTree(); if ((node.sourceStart >= start && node.sourceEnd <= end)) { if (!found) { statements[i] = new RecoveredStatement(stmt, blk, 0); found = true; blk.statementCount = i + 1;
public RecoveredElement add(Statement stmt, int bracketBalanceValue) { if (this.alreadyCompletedLocalInitialization || !(stmt instanceof Expression)) { return super.add(stmt, bracketBalanceValue); } else { this.alreadyCompletedLocalInitialization = true; this.localDeclaration.initialization = (Expression)stmt; this.localDeclaration.declarationSourceEnd = stmt.sourceEnd; this.localDeclaration.declarationEnd = stmt.sourceEnd; return this; } } public void attach(RecoveredAnnotation[] annots, int annotCount, int mods, int modsSourceStart) {
public void updateParseTree(){ updatedStatement(0, new HashSet()); } /*
if (recoveredBlock != null) { RecoveredStatement recoveredStatement = recoveredBlock.statementCount > 0 ? recoveredBlock.statements[recoveredBlock.statementCount - 1] : null; ASTNode parseTree = recoveredStatement != null ? recoveredStatement.updatedStatement(0, new HashSet<TypeDeclaration>()) : null; if (parseTree != null) { if ((parseTree.sourceStart == 0 || parseTree.sourceEnd == 0) || (parseTree.sourceStart >= statementStart && parseTree.sourceEnd <= statementEnd)) { recoveredBlock.statements[recoveredBlock.statementCount - 1] = new RecoveredStatement(statement, recoveredBlock, 0); statement = null; } else if (recoveredStatement instanceof RecoveredLocalVariable && statement instanceof Expression) {
public String toString(int tab){ return tabString(tab) + "Recovered statement:\n" + this.statement.print(tab + 1, new StringBuffer(10)); //$NON-NLS-1$ } public Statement updatedStatement(int depth, Set<TypeDeclaration> knownTypes){
@Override public String toString(int tab) { StringBuffer result = new StringBuffer(tabString(tab)); result.append("Recovered block:\n"); //$NON-NLS-1$ this.blockDeclaration.print(tab + 1, result); if (this.statements != null) { for (int i = 0; i < this.statementCount; i++) { result.append("\n"); //$NON-NLS-1$ result.append(this.statements[i].toString(tab + 1)); } } return result.toString(); } /*