01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.internal.compiler.ast;
11:
12: import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
13: import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
14: import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
15: import org.eclipse.jdt.internal.compiler.flow.FlowContext;
16: import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
17: import org.eclipse.jdt.internal.compiler.ASTVisitor;
18:
19: public class EmptyStatement extends Statement {
20:
21: public EmptyStatement(int startPosition, int endPosition) {
22: this .sourceStart = startPosition;
23: this .sourceEnd = endPosition;
24: }
25:
26: public FlowInfo analyseCode(BlockScope currentScope,
27: FlowContext flowContext, FlowInfo flowInfo) {
28: return flowInfo;
29: }
30:
31: // Report an error if necessary
32: public boolean complainIfUnreachable(FlowInfo flowInfo,
33: BlockScope scope, boolean didAlreadyComplain) {
34:
35: // before 1.4, empty statements are tolerated anywhere
36: if (scope.compilerOptions().complianceLevel < ClassFileConstants.JDK1_4) {
37: return false;
38: }
39: return super .complainIfUnreachable(flowInfo, scope,
40: didAlreadyComplain);
41: }
42:
43: public void generateCode(BlockScope currentScope,
44: CodeStream codeStream) {
45: // no bytecode, no need to check for reachability or recording source positions
46: }
47:
48: public StringBuffer printStatement(int tab, StringBuffer output) {
49: return printIndent(tab, output).append(';');
50: }
51:
52: public void resolve(BlockScope scope) {
53: if ((bits & IsUsefulEmptyStatement) == 0) {
54: scope.problemReporter().super fluousSemicolon(
55: this .sourceStart, this .sourceEnd);
56: } else {
57: scope.problemReporter().emptyControlFlowStatement(
58: this .sourceStart, this .sourceEnd);
59: }
60: }
61:
62: public void traverse(ASTVisitor visitor, BlockScope scope) {
63: visitor.visit(this, scope);
64: visitor.endVisit(this, scope);
65: }
66:
67: }
|