Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2000, 2013 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: IBM Corporation - initial API and implementation Stephan Herrmann - Contributions for bug 349326 - [1.7] new warning for missing try-with-resources bug 368546 - [compiler][resource] Avoid remaining false positives found when compiling the Eclipse SDK bug 345305 - [compiler][null] Compiler misidentifies a case of "variable can only be null" bug 383368 - [compiler][null] syntactic null analysis for field references bug 402993 - [null] Follow up of bug 401088: Missing warning about redundant null check /
 
 package org.eclipse.jdt.internal.compiler.ast;
 
 
 public class Block extends Statement {
 
 	public Statement[] statements;
 	public int explicitDeclarations;
 	// the number of explicit declaration , used to create scope
 	public BlockScope scope;
 
 public Block(int explicitDeclarations) {
 	this. = explicitDeclarations;
 }
 
 public FlowInfo analyseCode(BlockScope currentScopeFlowContext flowContextFlowInfo flowInfo) {
 	// empty block
 	if (this. == null)	return flowInfo;
 	int complaintLevel = (flowInfo.reachMode() & .) != 0 ? . : .;
 	boolean enableSyntacticNullAnalysisForFields = currentScope.compilerOptions().;
 	for (int i = 0, max = this..lengthi < maxi++) {
 		Statement stat = this.[i];
 		if ((complaintLevel = stat.complainIfUnreachable(flowInfothis.complaintLeveltrue)) < .) {
 			flowInfo = stat.analyseCode(this.flowContextflowInfo);
 		}
 		// record the effect of stat on the finally block of an enclosing try-finally, if any:
 		flowContext.mergeFinallyNullInfo(flowInfo);
 		if (enableSyntacticNullAnalysisForFields) {
 		}
 	}
 	if (this. > 0) {
 		// if block has its own scope analyze tracking vars now:
 		this..checkUnclosedCloseables(flowInfoflowContextnullnull);
 		// cleanup assignment info for locals that are scoped to this block:
 		LocalVariableBinding[] locals = this..;
 		if (locals != null) {
 			int numLocals = this..;
 			for (int i = 0; i < numLocalsi++) {
 				flowInfo.resetAssignmentInfo(locals[i]);
 			}
 		}
 	}
 	return flowInfo;
 }
Code generation for a block
 
 public void generateCode(BlockScope currentScopeCodeStream codeStream) {
 	if ((this. & ) == 0) {
 		return;
 	}
 	int pc = codeStream.position;
 	if (this. != null) {
 		for (int i = 0, max = this..lengthi < maxi++) {
 			this.[i].generateCode(this.codeStream);
 		}
 	} // for local variable debug attributes
 	if (this. != currentScope) { // was really associated with its own scope
 		codeStream.exitUserScope(this.);
 	}
 	codeStream.recordPositionsFrom(pcthis.);
 }
 
 public boolean isEmptyBlock() {
 	return this. == null;
 }
 
 public StringBuffer printBody(int indentStringBuffer output) {
 	if (this. == nullreturn output;
 	for (int i = 0; i < this..lengthi++) {
 		this.[i].printStatement(indent + 1, output);
 		output.append('\n');
 	}
 	return output;
 }
 
 public StringBuffer printStatement(int indentStringBuffer output) {
 	printIndent(indentoutput);
 	output.append("{\n"); //$NON-NLS-1$
	printBody(indentoutput);
	return printIndent(indentoutput).append('}');
public void resolve(BlockScope upperScope) {
	if ((this. & ) != 0) {
	}
	if (this. != null) {
		this. =
upperScope
new BlockScope(upperScopethis.);
		for (int i = 0, length = this..lengthi < lengthi++) {
			this.[i].resolve(this.);
		}
	}
public void resolveUsing(BlockScope givenScope) {
	if ((this. & ) != 0) {
	}
	// this optimized resolve(...) is sent only on none empty blocks
	this. = givenScope;
	if (this. != null) {
		for (int i = 0, length = this..lengthi < lengthi++) {
			this.[i].resolve(this.);
		}
	}
public void traverse(ASTVisitor visitorBlockScope blockScope) {
	if (visitor.visit(thisblockScope)) {
		if (this. != null) {
			for (int i = 0, length = this..lengthi < lengthi++)
				this.[i].traverse(visitorthis.);
		}
	}
	visitor.endVisit(thisblockScope);
Dispatch the call on its last statement.
public void branchChainTo(BranchLabel label) {
	if (this. != null) {
		this.[this..length - 1].branchChainTo(label);
	}
New to GrepCode? Check out our FAQ X