fixed wrong deprecation warning
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / flow / LabelFlowContext.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2003 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
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpdt.internal.compiler.flow;
12
13 import net.sourceforge.phpdt.core.compiler.CharOperation;
14 import net.sourceforge.phpdt.internal.compiler.ast.ASTNode;
15 import net.sourceforge.phpdt.internal.compiler.codegen.Label;
16 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
17
18 /**
19  * Reflects the context of code analysis, keeping track of enclosing
20  *      try statements, exception handlers, etc...
21  */
22 public class LabelFlowContext extends SwitchFlowContext {
23         
24         public char[] labelName;
25         
26         public LabelFlowContext(
27                 FlowContext parent,
28                 ASTNode associatedNode,
29                 char[] labelName,
30                 Label breakLabel,
31                 BlockScope scope) {
32                         
33                 super(parent, associatedNode, breakLabel);
34                 this.labelName = labelName;
35                 checkLabelValidity(scope);
36         }
37
38         void checkLabelValidity(BlockScope scope) {
39                 
40                 // check if label was already defined above
41                 FlowContext current = parent;
42                 while (current != null) {
43                         char[] currentLabelName;
44                         if (((currentLabelName = current.labelName()) != null)
45                                 && CharOperation.equals(currentLabelName, labelName)) {
46                                 scope.problemReporter().alreadyDefinedLabel(labelName, associatedNode);
47                         }
48                         current = current.parent;
49                 }
50         }
51
52         public String individualToString() {
53
54                 return "Label flow context [label:" + String.valueOf(labelName) + "]"; //$NON-NLS-2$ //$NON-NLS-1$
55         }
56
57         public char[] labelName() {
58
59                 return labelName;
60         }
61 }