Change to openFileInTextEditor to fix ticket issue #650.
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / parser / UninitializedVariableHandler.java
1 package net.sourceforge.phpdt.internal.compiler.parser;
2
3 import java.util.ArrayList;
4
5 public class UninitializedVariableHandler {
6
7         private class Function {
8                 private int count;
9
10                 private String name;
11
12                 public Function(String name, int count) {
13                         this.name = name;
14                         this.count = count;
15                 }
16         }
17
18         private String functionName = null;
19
20         private int argumentCount = 0;
21
22         private ArrayList functions = new ArrayList();
23
24         public UninitializedVariableHandler() {
25                 add("ereg", 3);
26                 add("eregi", 3);
27                 add("fsockopen", 3);
28                 add("preg_match", 3);
29                 add("preg_match_all", 3);
30                 add("preg_replace", 5);
31                 add("preg_replace_callback", 5);
32         }
33
34         private void add(String name, int countFrom) {
35                 functions.add(new Function(name, countFrom));
36         }
37
38         protected boolean reportError() {
39                 if (functionName != null) {
40                         for (int i = 0; i < functions.size(); i++) {
41                                 Function function = (Function) functions.get(i);
42                                 if (functionName.equalsIgnoreCase(function.name)
43                                                 && argumentCount >= function.count) {
44                                         return false;
45                                 }
46                         }
47                 }
48                 return true;
49         }
50
51         public void setFunctionName(String functionName) {
52                 this.functionName = functionName;
53         }
54
55         public void incrementArgumentCount() {
56                 argumentCount++;
57         }
58 }