Added error "Unreachable code" for if statements
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / phpeditor / php / PHPPartition.java
1 /*
2  * Created on 28.04.2003
3  *
4  */
5 package net.sourceforge.phpeclipse.phpeditor.php;
6
7 import net.sourceforge.phpdt.internal.ui.text.*;
8
9 import org.eclipse.jface.text.IDocument;
10
11 /**
12  * @author slanger
13  * @version $Revision: 1.4 $
14  */
15 public class PHPPartition extends Partition
16 {
17         private boolean fShortTagsEnabled = true;
18         
19     /**
20      * @param document
21      * @param delim
22      * @param contentType
23      * @param parentPartition
24      */
25     public PHPPartition(IDocument document, String parentPartition)
26     {
27         super(
28             document,
29             new char[] { '<', '>' },
30             IPHPPartitions.PHP_PARTITIONING,
31             parentPartition);
32     }
33
34     
35
36     /* (non-Javadoc)
37      * @see net.sourceforge.phpeclipse.phpeditor.php.Partition#allowedPartition(java.lang.String)
38      */
39     protected boolean allowedPartition(String type)
40     {
41         if(type.equals(IPHPPartitions.PHP_PHPDOC_COMMENT))
42                 return true;
43                 
44         return false;
45     }
46
47     /* (non-Javadoc)
48      * @see net.sourceforge.phpeclipse.phpeditor.php.Partition#scan()
49      */
50     protected boolean scan()
51     {
52         int ch;
53         if(fShortTagsEnabled && checkPattern("<?", true))
54         {
55                 scanToEnd();
56         }
57         else if(checkPattern("<?php", false))
58         {
59                 scanToEnd();
60         }    
61         else
62                 return false;
63         
64         return true;    
65     }
66         
67         private void scanToEnd()
68         {
69                 if(isEnd())
70                         return;
71                                 
72                 while(!checkPattern("?>", true))
73                 {
74                         int offset = getOffset();
75                         if(checkPattern("/*", true))
76                         {       
77                                 unread(2);
78                                 return;
79                         }
80                 }               
81         }
82 }