Refactory: remove unused classes, imports, fields and methods.
authorincastrix <incastrix>
Wed, 23 Dec 2009 17:50:58 +0000 (17:50 +0000)
committerincastrix <incastrix>
Wed, 23 Dec 2009 17:50:58 +0000 (17:50 +0000)
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/batch/FileFinder.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/ParserUtil.java [new file with mode: 0644]

diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/batch/FileFinder.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/batch/FileFinder.java
new file mode 100644 (file)
index 0000000..aa8ab54
--- /dev/null
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * 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-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.compiler.batch;
+
+import java.io.File;
+
+public class FileFinder {
+       private static final int INITIAL_SIZE = 10;
+
+       public String[] resultFiles = new String[INITIAL_SIZE];
+
+       public int count = 0;
+
+       public void find(File f, String pattern, boolean verbose) {
+               if (verbose) {
+                       // System.out.println(Main.bind("scanning.start",f.getAbsolutePath()));
+                       // //$NON-NLS-1$
+               }
+               find0(f, pattern, verbose);
+               System.arraycopy(this.resultFiles, 0,
+                               (this.resultFiles = new String[this.count]), 0, this.count);
+       }
+
+       public void find0(File f, String pattern, boolean verbose) {
+               if (f.isDirectory()) {
+                       String[] files = f.list();
+                       if (files == null)
+                               return;
+                       for (int i = 0, max = files.length; i < max; i++) {
+                               File current = new File(f, files[i]);
+                               if (current.isDirectory()) {
+                                       find0(current, pattern, verbose);
+                               } else {
+                                       if (current.getName().toUpperCase().endsWith(pattern)) {
+                                               int length;
+                                               if ((length = this.resultFiles.length) == this.count) {
+                                                       System
+                                                                       .arraycopy(
+                                                                                       this.resultFiles,
+                                                                                       0,
+                                                                                       (this.resultFiles = new String[length * 2]),
+                                                                                       0, length);
+                                               }
+                                               this.resultFiles[this.count++] = current
+                                                               .getAbsolutePath();
+                                               if (verbose && (this.count % 100) == 0)
+                                                       System.out.print('.');
+                                       }
+                               }
+                       }
+               }
+       }
+}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/ParserUtil.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/ParserUtil.java
new file mode 100644 (file)
index 0000000..f81eb3c
--- /dev/null
@@ -0,0 +1,53 @@
+package net.sourceforge.phpdt.internal.compiler.parser;
+
+import java.util.List;
+
+import net.sourceforge.phpdt.core.ICompilationUnit;
+import net.sourceforge.phpdt.core.IType;
+import net.sourceforge.phpdt.core.JavaCore;
+import net.sourceforge.phpdt.core.JavaModelException;
+import net.sourceforge.phpdt.internal.compiler.ast.ImportReference;
+import net.sourceforge.phpdt.internal.compiler.ast.SingleTypeReference;
+
+import org.eclipse.core.resources.IFile;
+
+public class ParserUtil {
+
+       public static SingleTypeReference getTypeReference(Scanner scanner,
+                       List includesList, char[] ident) {
+               String identStr = new String(ident);
+               ImportReference ir;
+               IFile file = null;
+               for (int i = 0; i < includesList.size(); i++) {
+                       ir = (ImportReference) includesList.get(i);
+                       file = ir.getFile();
+                       if (file != null) {
+                               ICompilationUnit unit = JavaCore
+                                               .createCompilationUnitFrom(file);
+                               if (unit != null) {
+                                       try {
+                                               // TODO avoid recursion here. Sometimes we get a
+                                               // java.lang.StackOverflowError
+                                               IType[] types = unit.getAllTypes();
+                                               if (types != null) {
+                                                       for (int j = 0; j < types.length; j++) {
+                                                               if (types[j].getElementName().equals(identStr)) {
+                                                                       return new SingleTypeReference(
+                                                                                       file,
+                                                                                       ident,
+                                                                                       scanner
+                                                                                                       .getCurrentTokenStartPosition(),
+                                                                                       scanner
+                                                                                                       .getCurrentTokenEndPosition());
+                                                               }
+                                                       }
+                                               }
+                                       } catch (JavaModelException e) {
+                                               e.printStackTrace();
+                                       }
+                               }
+                       }
+               }
+               return null;
+       }
+}