KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > compiler > ast > EmptyStatement


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.compiler.ast;
12
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;
19
20 public class EmptyStatement extends Statement {
21
22     public EmptyStatement(int startPosition, int endPosition) {
23         this.sourceStart = startPosition;
24         this.sourceEnd = endPosition;
25     }
26
27     public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
28         return flowInfo;
29     }
30
31     // Report an error if necessary
32
public boolean complainIfUnreachable(FlowInfo flowInfo, BlockScope scope, boolean didAlreadyComplain) {
33         
34         // before 1.4, empty statements are tolerated anywhere
35
if (scope.compilerOptions().complianceLevel < ClassFileConstants.JDK1_4) {
36             return false;
37         }
38         return super.complainIfUnreachable(flowInfo, scope, didAlreadyComplain);
39     }
40     
41     public void generateCode(BlockScope currentScope, CodeStream codeStream){
42         // no bytecode, no need to check for reachability or recording source positions
43
}
44     
45     public StringBuffer JavaDoc printStatement(int tab, StringBuffer JavaDoc output) {
46         return printIndent(tab, output).append(';');
47     }
48         
49     public void resolve(BlockScope scope) {
50         if ((bits & IsUsefulEmptyStatement) == 0) {
51             scope.problemReporter().superfluousSemicolon(this.sourceStart, this.sourceEnd);
52         } else {
53             scope.problemReporter().emptyControlFlowStatement(this.sourceStart, this.sourceEnd);
54         }
55     }
56
57     public void traverse(ASTVisitor visitor, BlockScope scope) {
58         visitor.visit(this, scope);
59         visitor.endVisit(this, scope);
60     }
61     
62
63 }
64
65
Popular Tags