Syntax highlighting is changeable.
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / flow / InitializationFlowContext.java
index b5a4b2b..11a8759 100644 (file)
@@ -1,19 +1,19 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials 
- * are made available under the terms of the Common Public License v0.5 
+ * are made available under the terms of the Common Public License v1.0
  * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
  * 
  * Contributors:
  *     IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
 package net.sourceforge.phpdt.internal.compiler.flow;
 
-import net.sourceforge.phpdt.internal.compiler.ast.AstNode;
 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
 import net.sourceforge.phpdt.internal.compiler.lookup.ReferenceBinding;
 import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
+import net.sourceforge.phpeclipse.internal.compiler.ast.ASTNode;
 
 /**
  * Reflects the context of code analysis, keeping track of enclosing
@@ -23,19 +23,19 @@ public class InitializationFlowContext extends ExceptionHandlingFlowContext {
 
        public int exceptionCount;
        public TypeBinding[] thrownExceptions = new TypeBinding[5];
-       public AstNode[] exceptionThrowers = new AstNode[5];
+       public ASTNode[] exceptionThrowers = new ASTNode[5];
        public FlowInfo[] exceptionThrowerFlowInfos = new FlowInfo[5];
-
+       
        public InitializationFlowContext(
                FlowContext parent,
-               AstNode associatedNode,
+               ASTNode associatedNode,
                BlockScope scope) {
                super(
                        parent,
                        associatedNode,
-                       new ReferenceBinding[] { scope.getJavaLangThrowable()},
-               // tolerate any kind of exception, but record them
-               scope, FlowInfo.DeadEnd);
+                       NoExceptions, // no exception allowed by default
+                       scope, 
+                       FlowInfo.DEAD_END);
        }
 
        public void checkInitializerExceptions(
@@ -51,13 +51,24 @@ public class InitializationFlowContext extends ExceptionHandlingFlowContext {
                }
        }
 
+       public String individualToString() {
+               
+               StringBuffer buffer = new StringBuffer("Initialization flow context"); //$NON-NLS-1$
+               for (int i = 0; i < exceptionCount; i++) {
+                       buffer.append('[').append(thrownExceptions[i].readableName());
+                       buffer.append('-').append(exceptionThrowerFlowInfos[i].toString()).append(']');
+               }
+               return buffer.toString();
+       }
+       
        public void recordHandlingException(
                ReferenceBinding exceptionType,
                UnconditionalFlowInfo flowInfo,
                TypeBinding raisedException,
-               AstNode invocationSite,
+               ASTNode invocationSite,
                boolean wasMasked) {
                        
+               // even if unreachable code, need to perform unhandled exception diagnosis
                int size = thrownExceptions.length;
                if (exceptionCount == size) {
                        System.arraycopy(
@@ -69,7 +80,7 @@ public class InitializationFlowContext extends ExceptionHandlingFlowContext {
                        System.arraycopy(
                                exceptionThrowers,
                                0,
-                               (exceptionThrowers = new AstNode[size * 2]),
+                               (exceptionThrowers = new ASTNode[size * 2]),
                                0,
                                size);
                        System.arraycopy(
@@ -83,4 +94,4 @@ public class InitializationFlowContext extends ExceptionHandlingFlowContext {
                exceptionThrowers[exceptionCount] = invocationSite;
                exceptionThrowerFlowInfos[exceptionCount++] = flowInfo.copy();
        }       
-}
\ No newline at end of file
+}