if (elseToken.getOffset() + elseToken.getLength() <= offset && offset + length < elseRegion.getOffset()) return elseStatement != null;
	private boolean isClosed(IDocument document, int offset, int length) {		CompilationUnitInfo info= getCompilationUnitForMethod(document, offset, fPartitioning);		if (info == null)			return false;		CompilationUnit compilationUnit= null;		try {			ASTParser parser= ASTParser.newParser(AST.JLS3);			parser.setSource(info.buffer);			compilationUnit= (CompilationUnit) parser.createAST(null);		} catch (ArrayIndexOutOfBoundsException x) {			// work around for parser problem			return false;		}		IProblem[] problems= compilationUnit.getProblems();		for (int i= 0; i != problems.length; ++i) {			if (problems[i].getID() == IProblem.UnmatchedBracket)				return true;		}		final int relativeOffset= offset - info.delta;		ASTNode node= NodeFinder.perform(compilationUnit, relativeOffset, length);		if (length == 0) {			while (node != null && (relativeOffset == node.getStartPosition() || relativeOffset == node.getStartPosition() + node.getLength()))				node= node.getParent();		}				if (node == null)			return false;		switch (node.getNodeType()) {		case ASTNode.BLOCK:			return getBlockBalance(document, offset, fPartitioning) <= 0;		case ASTNode.IF_STATEMENT:			{				IfStatement ifStatement= (IfStatement) node;				Expression expression= ifStatement.getExpression();				IRegion expressionRegion= createRegion(expression, info.delta);				Statement thenStatement= ifStatement.getThenStatement();				IRegion thenRegion= createRegion(thenStatement, info.delta);				// between expression and then statement				if (expressionRegion.getOffset() + expressionRegion.getLength() <= offset && offset + length <= thenRegion.getOffset())					return thenStatement != null;				Statement elseStatement= ifStatement.getElseStatement();				IRegion elseRegion= createRegion(elseStatement, info.delta);				IRegion elseToken= null;				if (elseStatement != null) {					int sourceOffset= thenRegion.getOffset() + thenRegion.getLength();					int sourceLength= elseRegion.getOffset() - sourceOffset;					elseToken= getToken(document, new Region(sourceOffset, sourceLength), ITerminalSymbols.TokenNameelse);				}				// between 'else' keyword and else statement				if (elseToken.getOffset() + elseToken.getLength() <= offset && offset + length < elseRegion.getOffset())					return elseStatement != null;			}			break;		case ASTNode.WHILE_STATEMENT:		case ASTNode.FOR_STATEMENT:			{				Expression expression= node.getNodeType() == ASTNode.WHILE_STATEMENT ? ((WhileStatement) node).getExpression() : ((ForStatement) node).getExpression();				IRegion expressionRegion= createRegion(expression, info.delta);				Statement body= node.getNodeType() == ASTNode.WHILE_STATEMENT ? ((WhileStatement) node).getBody() : ((ForStatement) node).getBody();				IRegion bodyRegion= createRegion(body, info.delta);				// between expression and body statement				if (expressionRegion.getOffset() + expressionRegion.getLength() <= offset && offset + length <= bodyRegion.getOffset())					return body != null;			}			break;		case ASTNode.DO_STATEMENT:			{				DoStatement doStatement= (DoStatement) node;				IRegion doRegion= createRegion(doStatement, info.delta);				Statement body= doStatement.getBody();				IRegion bodyRegion= createRegion(body, info.delta);				if (doRegion.getOffset() + doRegion.getLength() <= offset && offset + length <= bodyRegion.getOffset())					return body != null;			}			break;		}		return true;	}