public RecoveredMethod(AbstractMethodDeclaration methodDeclaration, RecoveredElement parent, int bracketBalance, Parser parser){ super(parent, bracketBalance, parser); this.methodDeclaration = methodDeclaration; this.foundOpeningBrace = !bodyStartsAtHeaderEnd(); if(this.foundOpeningBrace) { this.bracketBalance++; } } /*
public void updateSourceEndIfNecessary(int braceStart, int braceEnd){ if (this.methodDeclaration.declarationSourceEnd == 0) { if(parser().rBraceSuccessorStart >= braceEnd) { this.methodDeclaration.declarationSourceEnd = parser().rBraceEnd; this.methodDeclaration.bodyEnd = parser().rBraceStart; } else { this.methodDeclaration.declarationSourceEnd = braceEnd; this.methodDeclaration.bodyEnd = braceStart - 1; } } } public RecoveredElement addAnnotationName(int identifierPtr, int identifierLengthPtr, int annotationStart, int bracketBalanceValue) {
@Override public RecoveredElement add(FieldDeclaration fieldDeclaration, int bracketBalanceValue) { resetPendingModifiers(); return this; // ignore } else { this.updateSourceEndIfNecessary(previousAvailableLineEnd(fieldDeclaration.declarationSourceStart - 1)); return this.parent.add(fieldDeclaration, bracketBalanceValue);
public RecoveredElement add(Block nestedBlockDeclaration, int bracketBalanceValue, boolean isArgument) { /* default behavior is to delegate recording to parent if any, do not consider elements passed the known end (if set) it must be belonging to an enclosing element */ if (this.methodDeclaration.declarationSourceEnd > 0 && nestedBlockDeclaration.sourceStart > this.methodDeclaration.declarationSourceEnd){ resetPendingModifiers(); if (this.parent == null){ return this; // ignore } else { return this.parent.add(nestedBlockDeclaration, bracketBalanceValue); } } /* consider that if the opening brace was not found, it is there */ if (!this.foundOpeningBrace && !isArgument){ this.foundOpeningBrace = true; this.bracketBalance++; } this.methodBody = new RecoveredBlock(nestedBlockDeclaration, this, bracketBalanceValue); if (nestedBlockDeclaration.sourceEnd == 0) return this.methodBody; return this; } /*
if ((typeDeclaration.bits & ASTNode.IsLocalType) != 0 || parser().methodRecoveryActivated || parser().statementRecoveryActivated){ if (this.methodBody == null){ Block block = new Block(0); block.sourceStart = this.methodDeclaration.bodyStart; this.add(block, 1); this.pendingModifiers, this.pendingModifersSourceStart); resetPendingModifiers(); return this.methodBody.add(typeDeclaration, bracketBalanceValue, true); case TypeDeclaration.INTERFACE_DECL : case TypeDeclaration.ANNOTATION_TYPE_DECL : resetPendingModifiers(); this.updateSourceEndIfNecessary(previousAvailableLineEnd(typeDeclaration.declarationSourceStart - 1)); if (this.parent == null) { return this; // ignore this.pendingModifersSourceStart); resetPendingModifiers();
RecoveredMethod element = new RecoveredMethod(methodDeclaration, this, bracketBalanceValue, this.recoveringParser); this.methods[this.methodCount++] = element; element.attach(this.pendingTypeParameters, this.pendingTypeParametersStart); this.pendingTypeParameters = null; element.attach( this.pendingAnnotations, this.pendingAnnotationCount,
public RecoveredElement updateOnClosingBrace(int braceStart, int braceEnd){ if(this.methodDeclaration.isAnnotationMethod()) { this.updateSourceEndIfNecessary(braceStart, braceEnd); if(!this.foundOpeningBrace && this.parent != null) { return this.parent.updateOnClosingBrace(braceStart, braceEnd); } return this; } if(this.parent != null && this.parent instanceof RecoveredType) { int mods = ((RecoveredType)this.parent).typeDeclaration.modifiers; if (TypeDeclaration.kind(mods) == TypeDeclaration.INTERFACE_DECL) { if (!this.foundOpeningBrace) { this.updateSourceEndIfNecessary(braceStart - 1, braceStart - 1); return this.parent.updateOnClosingBrace(braceStart, braceEnd); } } } return super.updateOnClosingBrace(braceStart, braceEnd); } /*
public String toString(int tab) { StringBuffer result = new StringBuffer(tabString(tab)); result.append("Recovered method:\n"); //$NON-NLS-1$ this.methodDeclaration.print(tab + 1, result); if (this.annotations != null) { for (int i = 0; i < this.annotationCount; i++) { result.append("\n"); //$NON-NLS-1$ result.append(this.annotations[i].toString(tab + 1)); } } if (this.localTypes != null) { for (int i = 0; i < this.localTypeCount; i++) { result.append("\n"); //$NON-NLS-1$ result.append(this.localTypes[i].toString(tab + 1)); } } if (this.methodBody != null) { result.append("\n"); //$NON-NLS-1$ result.append(this.methodBody.toString(tab + 1)); } return result.toString(); } /*
for (int i = 0; i < this.methodCount; i++) { result.append("\n"); //$NON-NLS-1$ result.append(this.methods[i].toString(tab + 1));
public void updateFromParserState(){ if(bodyStartsAtHeaderEnd() && this.parent != null){ Parser parser = parser();
public RecoveredElement add(Block nestedBlockDeclaration, int bracketBalanceValue) { /* default behavior is to delegate recording to parent if any, do not consider elements passed the known end (if set) it must be belonging to an enclosing element */ if (this.methodDeclaration.declarationSourceEnd > 0 && nestedBlockDeclaration.sourceStart > this.methodDeclaration.declarationSourceEnd){ resetPendingModifiers(); if (this.parent == null){ return this; // ignore } else { return this.parent.add(nestedBlockDeclaration, bracketBalanceValue); } } /* consider that if the opening brace was not found, it is there */ if (!this.foundOpeningBrace){ this.foundOpeningBrace = true; this.bracketBalance++; } this.methodBody = new RecoveredBlock(nestedBlockDeclaration, this, bracketBalanceValue); if (nestedBlockDeclaration.sourceEnd == 0) return this.methodBody; return this; } /*
} else { if (this.referenceContext instanceof AbstractMethodDeclaration){ element = new RecoveredMethod((AbstractMethodDeclaration) this.referenceContext, null, 0, this); this.lastCheckPoint = ((AbstractMethodDeclaration) this.referenceContext).bodyStart; if(this.statementRecoveryActivated) {
public RecoveredElement add(FieldDeclaration fieldDeclaration, int bracketBalanceValue) { resetPendingModifiers(); return this; // ignore } else { this.updateSourceEndIfNecessary(previousAvailableLineEnd(fieldDeclaration.declarationSourceStart - 1)); return this.parent.add(fieldDeclaration, bracketBalanceValue);
public RecoveredElement add(Block nestedBlockDeclaration, int bracketBalanceValue, boolean isArgument) { /* default behavior is to delegate recording to parent if any, do not consider elements passed the known end (if set) it must be belonging to an enclosing element */ if (this.methodDeclaration.declarationSourceEnd > 0 && nestedBlockDeclaration.sourceStart > this.methodDeclaration.declarationSourceEnd){ resetPendingModifiers(); if (this.parent == null){ return this; // ignore } else { return this.parent.add(nestedBlockDeclaration, bracketBalanceValue); } } /* consider that if the opening brace was not found, it is there */ if (!this.foundOpeningBrace && !isArgument){ this.foundOpeningBrace = true; this.bracketBalance++; } this.methodBody = new RecoveredBlock(nestedBlockDeclaration, this, bracketBalanceValue); if (nestedBlockDeclaration.sourceEnd == 0) return this.methodBody; return this; } /*
RecoveredMethod element = new RecoveredMethod(methodDeclaration, this, bracketBalanceValue, this.recoveringParser); this.methods[this.methodCount++] = element; element.attach(this.pendingTypeParameters, this.pendingTypeParametersStart); this.pendingTypeParameters = null; element.attach( this.pendingAnnotations, this.pendingAnnotationCount,
public RecoveredElement updateOnClosingBrace(int braceStart, int braceEnd){ if(this.methodDeclaration.isAnnotationMethod()) { this.updateSourceEndIfNecessary(braceStart, braceEnd); if(!this.foundOpeningBrace && this.parent != null) { return this.parent.updateOnClosingBrace(braceStart, braceEnd); } return this; } if(this.parent != null && this.parent instanceof RecoveredType) { int mods = ((RecoveredType)this.parent).typeDeclaration.modifiers; if (TypeDeclaration.kind(mods) == TypeDeclaration.INTERFACE_DECL) { if (!this.foundOpeningBrace) { this.updateSourceEndIfNecessary(braceStart - 1, braceStart - 1); return this.parent.updateOnClosingBrace(braceStart, braceEnd); } } } return super.updateOnClosingBrace(braceStart, braceEnd); } /*
public String toString(int tab) { StringBuffer result = new StringBuffer(tabString(tab)); result.append("Recovered method:\n"); //$NON-NLS-1$ this.methodDeclaration.print(tab + 1, result); if (this.annotations != null) { for (int i = 0; i < this.annotationCount; i++) { result.append("\n"); //$NON-NLS-1$ result.append(this.annotations[i].toString(tab + 1)); } } if (this.localTypes != null) { for (int i = 0; i < this.localTypeCount; i++) { result.append("\n"); //$NON-NLS-1$ result.append(this.localTypes[i].toString(tab + 1)); } } if (this.methodBody != null) { result.append("\n"); //$NON-NLS-1$ result.append(this.methodBody.toString(tab + 1)); } return result.toString(); } /*
for (int i = 0; i < this.methodCount; i++) { result.append("\n"); //$NON-NLS-1$ result.append(this.methods[i].toString(tab + 1));
public RecoveredElement add(Block nestedBlockDeclaration, int bracketBalanceValue) { /* default behavior is to delegate recording to parent if any, do not consider elements passed the known end (if set) it must be belonging to an enclosing element */ if (this.methodDeclaration.declarationSourceEnd > 0 && nestedBlockDeclaration.sourceStart > this.methodDeclaration.declarationSourceEnd){ resetPendingModifiers(); if (this.parent == null){ return this; // ignore } else { return this.parent.add(nestedBlockDeclaration, bracketBalanceValue); } } /* consider that if the opening brace was not found, it is there */ if (!this.foundOpeningBrace){ this.foundOpeningBrace = true; this.bracketBalance++; } this.methodBody = new RecoveredBlock(nestedBlockDeclaration, this, bracketBalanceValue); if (nestedBlockDeclaration.sourceEnd == 0) return this.methodBody; return this; } /*
} else { if (this.referenceContext instanceof AbstractMethodDeclaration){ element = new RecoveredMethod((AbstractMethodDeclaration) this.referenceContext, null, 0, this); this.lastCheckPoint = ((AbstractMethodDeclaration) this.referenceContext).bodyStart; if(this.statementRecoveryActivated) {