public boolean removeBetweenSeparators ( Issue issue , IXtextDocument document , String beginSeparator , String endSeparator ) throws BadLocationException { int offset = issue . getOffset ( ) ; int length = issue . getLength ( ) ; // Skip spaces before the identifier until the separator int index = offset - 1 ; char c = document . getChar ( index ) ; while ( Character . isWhitespace ( c ) ) { index -- ; c = document . getChar ( index ) ; } // Test if it previous non-space character is the separator boolean foundSeparator = document . getChar ( index ) == beginSeparator . charAt ( 0 ) ; if ( foundSeparator ) { index -- ; c = document . getChar ( index ) ; // Skip the previous spaces while ( Character . isWhitespace ( c ) ) { index -- ; c = document . getChar ( index ) ; } length = length + ( offset - index - 1 ) ; offset = index + 1 ; // Skip spaces after the identifier until the separator index = offset + length ; c = document . getChar ( index ) ; while ( Character . isWhitespace ( c ) ) { index ++ ; c = document . getChar ( index ) ; } // Test if it next non-space character is the separator foundSeparator = document . getChar ( index ) == endSeparator . charAt ( 0 ) ; if ( foundSeparator ) { index ++ ; length = index - offset ; document . replace ( offset , length , "" ) ; //$NON-NLS-1$ } } return foundSeparator ; }
Remove the element related to the issue and the whitespaces before the element until the begin separator and the whitespaces after the element until the end separator .