/** * @see com.habelitz.jsobjectizer.jsom.api.statement.base.StatementBlockElementContainer#removeStatementBlockElement(com.habelitz.jsobjectizer.jsom.api.statement.StatementBlockElement, bool) * * __TEST__ */ public void removeStatementBlockElement( StatementBlockElement pStatementBlockElement, bool pRemovingOfSurroundingHiddenTokensEnabled) { bool elementRemoved = false; if (mHasSwitchLabels) { if (mLabels == null) { resolveSwitchLabels(); } foreach (SwitchLabel label in mLabels) { if (label.hasStatementBlockElement(pStatementBlockElement)) { label.removeStatementBlockElement( pStatementBlockElement, pRemovingOfSurroundingHiddenTokensEnabled); elementRemoved = true; break; } } } if (!elementRemoved) { // The stated statement block element doesn't belong to 'this'. throw new JSourceObjectizerException( CommonJSOMMessages .getStatementBlockElementDoesNotExistMessage( pStatementBlockElement.getJSOMType().ToString() + " (" + pStatementBlockElement.getLineNumber() + ':' + pStatementBlockElement.getCharPositionInLine() + ")", getLineNumber() + ":" + getCharPositionInLine())); } }
/** * @see com.habelitz.jsobjectizer.jsom.api.statement.base.StatementBlockElementContainer#removeStatementBlockElement(com.habelitz.jsobjectizer.jsom.api.statement.StatementBlockElement, bool) * * __TEST__ */ public void removeStatementBlockElement( StatementBlockElement pStatementBlockElement, bool pRemovingOfSurroundingHiddenTokensEnabled) { AST2StatementBlockElement removedElement = null; // If the elements haven't been resolve the passed statement block // element can't belong to this. if (mElements != null) { int offset = mElements.IndexOf((AST2StatementBlockElement)pStatementBlockElement); if (offset != -1) { removedElement = mElements[offset]; mElements.RemoveAt(offset); } } if (removedElement == null) { // The stated statement block element doesn't belong to 'this'. throw new JSourceObjectizerException( CommonJSOMMessages.getStatementBlockElementDoesNotExistMessage( pStatementBlockElement.getJSOMType().ToString() + " (" + pStatementBlockElement.getLineNumber() + ':' + pStatementBlockElement.getCharPositionInLine() + ")", getLineNumber() + ":" + getCharPositionInLine())); } // If still here a matching statement block element has been found. if (pRemovingOfSurroundingHiddenTokensEnabled) { removeTreeNode( removedElement, ChangeTokenBorder.FARTHEST_NEWLINE_EXCLUDING, ChangeTokenBorder.NEXT_NEWLINE_INCLUDING); } else { removeTreeNode(removedElement); } }