Bug 108312 [typing] Smart semicolong option should support anonymizing a class
1) Place the caret between the closing parenthesis ')' and semicolon ';'. 2) Type an open brace '{'. 3) Type Enter key (carriage return). See that closing brace '}' is automatically added, but semicolon ';' is illegally misplaced. ----------------- Bug.java ------------------------ class Bug { Object object=new Object(); }
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/SmartSemicolonAutoEditStrategy.java
*
	 * @param document the document being modified
	 * @param position the position in <code>document</code> of a closing parenthesis
	 * @param partitioning the document partitioning
	 * @return the position in <code>document</code> of the matching parenthesis, or -1 if none can be found
	 */
	private static int findOpeningParenMatch(IDocument document, int position, String partitioning) {
		final char CLOSING_PAREN= ')';
		final char OPENING_PAREN= '(';
		Assert.isTrue(position < document.getLength());
		Assert.isTrue(position >= 0);
		Assert.isTrue(isDefaultPartition(document, position, partitioning));
		try {
			Assert.isTrue(document.getChar(position) == CLOSING_PAREN);
			int depth= 1;
			while (true) {
				position= scanBackward(document, position - 1, partitioning, -1, new char[] {CLOSING_PAREN, OPENING_PAREN});
				if (position == -1)
					return -1;
				if (document.getChar(position) == CLOSING_PAREN)
					depth++;
				else
					depth--;
				if (depth == 0)
					return position;
			}
		} catch (BadLocationException e) {
			return -1;
		}
	}