make compilable in 3.2 latest integration build, removed reference to no longer exist...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / parser / ParserUtil.java
1 package net.sourceforge.phpdt.internal.compiler.parser;
2
3 import java.util.List;
4
5 import net.sourceforge.phpdt.core.ICompilationUnit;
6 import net.sourceforge.phpdt.core.IType;
7 import net.sourceforge.phpdt.core.JavaCore;
8 import net.sourceforge.phpdt.core.JavaModelException;
9 import net.sourceforge.phpdt.internal.compiler.ast.ImportReference;
10 import net.sourceforge.phpdt.internal.compiler.ast.SingleTypeReference;
11
12 import org.eclipse.core.resources.IFile;
13
14 public class ParserUtil {
15
16         public static SingleTypeReference getTypeReference(Scanner scanner, List includesList, char[] ident) {
17                 String identStr = new String(ident);
18                 ImportReference ir;
19                 IFile file = null;
20                 for (int i = 0; i < includesList.size(); i++) {
21                         ir = (ImportReference) includesList.get(i);
22                         file = ir.getFile();
23                         if (file != null) {
24                                 ICompilationUnit unit = JavaCore.createCompilationUnitFrom(file);
25                                 if (unit != null) {
26                                         try {
27                                                 // TODO avoid recursion here. Sometimes we get a java.lang.StackOverflowError
28                                                 IType[] types = unit.getAllTypes();
29                                                 if (types != null) {
30                                                         for (int j = 0; j < types.length; j++) {
31                                                                 if (types[j].getElementName().equals(identStr)) {
32                                                                         return new SingleTypeReference(file, ident, scanner.getCurrentTokenStartPosition(), scanner
33                                                                                         .getCurrentTokenEndPosition());
34                                                                 }
35                                                         }
36                                                 }
37                                         } catch (JavaModelException e) {
38                                                 e.printStackTrace();
39                                         }
40                                 }
41                         }
42                 }
43                 return null;
44         }
45 }