1 /*******************************************************************************
2 * Copyright (c) 2000, 2004 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.internal.compiler.ast;
13 import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
14 import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
15 import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
16 import org.eclipse.jdt.internal.compiler.flow.FlowContext;
17 import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
18 import org.eclipse.jdt.internal.compiler.ASTVisitor;
20 public class EmptyStatement extends Statement {
22 public EmptyStatement(int startPosition, int endPosition) {
23 this.sourceStart = startPosition;
24 this.sourceEnd = endPosition;
27 public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
31 // Report an error if necessary
32 public boolean complainIfUnreachable(FlowInfo flowInfo, BlockScope scope, boolean didAlreadyComplain) {
34 // before 1.4, empty statements are tolerated anywhere
35 if (scope.environment().options.complianceLevel < ClassFileConstants.JDK1_4) {
38 return super.complainIfUnreachable(flowInfo, scope, didAlreadyComplain);
41 public void generateCode(BlockScope currentScope, CodeStream codeStream){
42 // no bytecode, no need to check for reachability or recording source positions
45 public StringBuffer printStatement(int tab, StringBuffer output) {
46 return printIndent(tab, output).append(';');
49 public void resolve(BlockScope scope) {
50 if ((bits & IsUsefulEmptyStatementMASK) == 0) {
51 scope.problemReporter().superfluousSemicolon(this.sourceStart, this.sourceEnd);
53 scope.problemReporter().emptyControlFlowStatement(this.sourceStart, this.sourceEnd);
57 public void traverse(ASTVisitor visitor, BlockScope scope) {
58 visitor.visit(this, scope);
59 visitor.endVisit(this, scope);