Bug 40205 automatically insert closing brace: does not handle '//' in strings
200307150800 1. Try this snippet { String s= "//"; void m() <CURSOR> } 2. Insert an opening brace 3. Press <ENTER> The expected closing brace does not get inserted
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaAutoIndentStrategy.java
if (stack == 0)
				return reader.getOffset();
			c= reader.read();
		}
		return -1;
	}
	private static IRegion getSurroundingBlock(IDocument document, int offset) {
		JavaCodeReader reader= new JavaCodeReader();
		try {
			int begin= searchForOpeningPeer(reader, offset, '{', '}', document);
			int end= searchForClosingPeer(reader, offset, '{', '}', document);
			if (begin == -1 || end == -1)
				return null;
			return new Region(begin, end + 1 - begin);
			
		} catch (IOException e) {
			return null;	
		}
	}
	private static CompilationUnitInfo getCompilationUnitForMethod(IDocument document, int offset) {
		try {	
			
			IRegion sourceRange= getSurroundingBlock(document, offset);
			if (sourceRange == null)
				return null;
			String source= document.get(sourceRange.getOffset(), sourceRange.getLength());
	
			StringBuffer contents= new StringBuffer();
			contents.append("class ____C{void ____m()"); 
			final int methodOffset= contents.length();