From: incastrix Date: Wed, 23 Dec 2009 17:51:36 +0000 (+0000) Subject: Refactory: remove unused classes, imports, fields and methods. X-Git-Url: http://git.phpeclipse.com Refactory: remove unused classes, imports, fields and methods. --- diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/util/CompoundNameVector.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/util/CompoundNameVector.java new file mode 100644 index 0000000..bb12be0 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/util/CompoundNameVector.java @@ -0,0 +1,84 @@ +/******************************************************************************* + * 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 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.util; + +import net.sourceforge.phpdt.core.compiler.CharOperation; + +public final class CompoundNameVector { + static int INITIAL_SIZE = 10; + + public int size; + + int maxSize; + + char[][][] elements; + + public CompoundNameVector() { + maxSize = INITIAL_SIZE; + size = 0; + elements = new char[maxSize][][]; + } + + public void add(char[][] newElement) { + if (size == maxSize) // knows that size starts <= maxSize + System.arraycopy(elements, 0, + (elements = new char[maxSize *= 2][][]), 0, size); + elements[size++] = newElement; + } + + public void addAll(char[][][] newElements) { + if (size + newElements.length >= maxSize) { + maxSize = size + newElements.length; // assume no more elements + // will be added + System.arraycopy(elements, 0, (elements = new char[maxSize][][]), + 0, size); + } + System.arraycopy(newElements, 0, elements, size, newElements.length); + size += newElements.length; + } + + public boolean contains(char[][] element) { + for (int i = size; --i >= 0;) + if (CharOperation.equals(element, elements[i])) + return true; + return false; + } + + public char[][] elementAt(int index) { + return elements[index]; + } + + public char[][] remove(char[][] element) { + // assumes only one occurrence of the element exists + for (int i = size; --i >= 0;) + if (element == elements[i]) { + // shift the remaining elements down one spot + System.arraycopy(elements, i + 1, elements, i, --size - i); + elements[size] = null; + return element; + } + return null; + } + + public void removeAll() { + for (int i = size; --i >= 0;) + elements[i] = null; + size = 0; + } + + public String toString() { + StringBuffer buffer = new StringBuffer(); + for (int i = 0; i < size; i++) { + buffer.append(CharOperation.toString(elements[i])).append("\n"); //$NON-NLS-1$ + } + return buffer.toString(); + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/util/HashtableOfInt.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/util/HashtableOfInt.java new file mode 100644 index 0000000..751806c --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/util/HashtableOfInt.java @@ -0,0 +1,110 @@ +/******************************************************************************* + * 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 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.util; + +/** + * Hashtable for non-zero int keys. + */ + +public final class HashtableOfInt { + // to avoid using Enumerations, walk the individual tables skipping nulls + public int[] keyTable; + + public Object[] valueTable; + + int elementSize; // number of elements in the table + + int threshold; + + public HashtableOfInt() { + this(13); + } + + public HashtableOfInt(int size) { + this.elementSize = 0; + this.threshold = size; // size represents the expected number of + // elements + int extraRoom = (int) (size * 1.75f); + if (this.threshold == extraRoom) + extraRoom++; + this.keyTable = new int[extraRoom]; + this.valueTable = new Object[extraRoom]; + } + + public boolean containsKey(int key) { + int index = key % valueTable.length; + int currentKey; + while ((currentKey = keyTable[index]) != 0) { + if (currentKey == key) + return true; + index = (index + 1) % keyTable.length; + } + return false; + } + + public Object get(int key) { + int index = key % valueTable.length; + int currentKey; + while ((currentKey = keyTable[index]) != 0) { + if (currentKey == key) + return valueTable[index]; + index = (index + 1) % keyTable.length; + } + return null; + } + + public Object put(int key, Object value) { + int index = key % valueTable.length; + int currentKey; + while ((currentKey = keyTable[index]) != 0) { + if (currentKey == key) + return valueTable[index] = value; + index = (index + 1) % keyTable.length; + } + keyTable[index] = key; + valueTable[index] = value; + + // assumes the threshold is never equal to the size of the table + if (++elementSize > threshold) + rehash(); + return value; + } + + private void rehash() { + HashtableOfInt newHashtable = new HashtableOfInt(elementSize * 2); // double + // the + // number + // of + // expected + // elements + int currentKey; + for (int i = keyTable.length; --i >= 0;) + if ((currentKey = keyTable[i]) != 0) + newHashtable.put(currentKey, valueTable[i]); + + this.keyTable = newHashtable.keyTable; + this.valueTable = newHashtable.valueTable; + this.threshold = newHashtable.threshold; + } + + public int size() { + return elementSize; + } + + public String toString() { + String s = ""; //$NON-NLS-1$ + Object object; + for (int i = 0, length = valueTable.length; i < length; i++) + if ((object = valueTable[i]) != null) + s += keyTable[i] + " -> " + object.toString() + "\n"; //$NON-NLS-2$ //$NON-NLS-1$ + return s; + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/util/HashtableOfIntValues.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/util/HashtableOfIntValues.java new file mode 100644 index 0000000..1423f9e --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/util/HashtableOfIntValues.java @@ -0,0 +1,156 @@ +/******************************************************************************* + * 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.util; + +import net.sourceforge.phpdt.core.compiler.CharOperation; + +/** + * Hashtable of {char[] --> int} + */ +public final class HashtableOfIntValues implements Cloneable { + + public static final int NO_VALUE = Integer.MIN_VALUE; + + // to avoid using Enumerations, walk the individual tables skipping nulls + public char[] keyTable[]; + + public int valueTable[]; + + public int elementSize; // number of elements in the table + + int threshold; + + public HashtableOfIntValues() { + this(13); + } + + public HashtableOfIntValues(int size) { + + this.elementSize = 0; + this.threshold = size; // size represents the expected number of + // elements + int extraRoom = (int) (size * 1.75f); + if (this.threshold == extraRoom) + extraRoom++; + this.keyTable = new char[extraRoom][]; + this.valueTable = new int[extraRoom]; + } + + public Object clone() throws CloneNotSupportedException { + HashtableOfIntValues result = (HashtableOfIntValues) super.clone(); + result.elementSize = this.elementSize; + result.threshold = this.threshold; + + int length = this.keyTable.length; + result.keyTable = new char[length][]; + System.arraycopy(this.keyTable, 0, result.keyTable, 0, length); + + length = this.valueTable.length; + result.valueTable = new int[length]; + System.arraycopy(this.valueTable, 0, result.valueTable, 0, length); + return result; + } + + public boolean containsKey(char[] key) { + + int index = CharOperation.hashCode(key) % valueTable.length; + int keyLength = key.length; + char[] currentKey; + while ((currentKey = keyTable[index]) != null) { + if (currentKey.length == keyLength + && CharOperation.equals(currentKey, key)) + return true; + index = (index + 1) % keyTable.length; + } + return false; + } + + public int get(char[] key) { + + int index = CharOperation.hashCode(key) % valueTable.length; + int keyLength = key.length; + char[] currentKey; + while ((currentKey = keyTable[index]) != null) { + if (currentKey.length == keyLength + && CharOperation.equals(currentKey, key)) + return valueTable[index]; + index = (index + 1) % keyTable.length; + } + return NO_VALUE; + } + + public int put(char[] key, int value) { + + int index = CharOperation.hashCode(key) % valueTable.length; + int keyLength = key.length; + char[] currentKey; + while ((currentKey = keyTable[index]) != null) { + if (currentKey.length == keyLength + && CharOperation.equals(currentKey, key)) + return valueTable[index] = value; + index = (index + 1) % keyTable.length; + } + keyTable[index] = key; + valueTable[index] = value; + + // assumes the threshold is never equal to the size of the table + if (++elementSize > threshold) + rehash(); + return value; + } + + public int removeKey(char[] key) { + + int index = CharOperation.hashCode(key) % valueTable.length; + int keyLength = key.length; + char[] currentKey; + while ((currentKey = keyTable[index]) != null) { + if (currentKey.length == keyLength + && CharOperation.equals(currentKey, key)) { + int value = valueTable[index]; + elementSize--; + keyTable[index] = null; + valueTable[index] = NO_VALUE; + rehash(); + return value; + } + index = (index + 1) % keyTable.length; + } + return NO_VALUE; + } + + private void rehash() { + + HashtableOfIntValues newHashtable = new HashtableOfIntValues( + elementSize * 2); // double the number of expected elements + char[] currentKey; + for (int i = keyTable.length; --i >= 0;) + if ((currentKey = keyTable[i]) != null) + newHashtable.put(currentKey, valueTable[i]); + + this.keyTable = newHashtable.keyTable; + this.valueTable = newHashtable.valueTable; + this.threshold = newHashtable.threshold; + } + + public int size() { + return elementSize; + } + + public String toString() { + String s = ""; //$NON-NLS-1$ + char[] key; + for (int i = 0, length = valueTable.length; i < length; i++) + if ((key = keyTable[i]) != null) + s += new String(key) + " -> " + valueTable[i] + "\n"; //$NON-NLS-2$ //$NON-NLS-1$ + return s; + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/util/HashtableOfLong.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/util/HashtableOfLong.java new file mode 100644 index 0000000..4b80c87 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/util/HashtableOfLong.java @@ -0,0 +1,110 @@ +/******************************************************************************* + * 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 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.util; + +/** + * Hashtable for non-zero long keys. + */ + +public final class HashtableOfLong { + // to avoid using Enumerations, walk the individual tables skipping nulls + public long[] keyTable; + + public Object[] valueTable; + + int elementSize; // number of elements in the table + + int threshold; + + public HashtableOfLong() { + this(13); + } + + public HashtableOfLong(int size) { + this.elementSize = 0; + this.threshold = size; // size represents the expected number of + // elements + int extraRoom = (int) (size * 1.75f); + if (this.threshold == extraRoom) + extraRoom++; + this.keyTable = new long[extraRoom]; + this.valueTable = new Object[extraRoom]; + } + + public boolean containsKey(long key) { + int index = ((int) (key >>> 32)) % valueTable.length; + long currentKey; + while ((currentKey = keyTable[index]) != 0) { + if (currentKey == key) + return true; + index = (index + 1) % keyTable.length; + } + return false; + } + + public Object get(long key) { + int index = ((int) (key >>> 32)) % valueTable.length; + long currentKey; + while ((currentKey = keyTable[index]) != 0) { + if (currentKey == key) + return valueTable[index]; + index = (index + 1) % keyTable.length; + } + return null; + } + + public Object put(long key, Object value) { + int index = ((int) (key >>> 32)) % valueTable.length; + long currentKey; + while ((currentKey = keyTable[index]) != 0) { + if (currentKey == key) + return valueTable[index] = value; + index = (index + 1) % keyTable.length; + } + keyTable[index] = key; + valueTable[index] = value; + + // assumes the threshold is never equal to the size of the table + if (++elementSize > threshold) + rehash(); + return value; + } + + private void rehash() { + HashtableOfLong newHashtable = new HashtableOfLong(elementSize * 2); // double + // the + // number + // of + // expected + // elements + long currentKey; + for (int i = keyTable.length; --i >= 0;) + if ((currentKey = keyTable[i]) != 0) + newHashtable.put(currentKey, valueTable[i]); + + this.keyTable = newHashtable.keyTable; + this.valueTable = newHashtable.valueTable; + this.threshold = newHashtable.threshold; + } + + public int size() { + return elementSize; + } + + public String toString() { + String s = ""; //$NON-NLS-1$ + Object object; + for (int i = 0, length = valueTable.length; i < length; i++) + if ((object = valueTable[i]) != null) + s += keyTable[i] + " -> " + object.toString() + "\n"; //$NON-NLS-2$ //$NON-NLS-1$ + return s; + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/util/SuffixConstants.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/util/SuffixConstants.java new file mode 100644 index 0000000..8dd10d9 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/util/SuffixConstants.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * 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.util; + +public interface SuffixConstants { + // public final static String EXTENSION_class = "class"; //$NON-NLS-1$ + // public final static String EXTENSION_CLASS = "CLASS"; //$NON-NLS-1$ + public final static String EXTENSION_php = "php"; //$NON-NLS-1$ + + public final static String EXTENSION_PHP = "PHP"; //$NON-NLS-1$ + + // public final static String SUFFIX_STRING_class = "." + EXTENSION_class; + // //$NON-NLS-1$ + // public final static String SUFFIX_STRING_CLASS = "." + EXTENSION_CLASS; + // //$NON-NLS-1$ + public final static String SUFFIX_STRING_php = "." + EXTENSION_php; //$NON-NLS-1$ + + public final static String SUFFIX_STRING_PHP = "." + EXTENSION_PHP; //$NON-NLS-1$ + + // public final static char[] SUFFIX_class = + // SUFFIX_STRING_class.toCharArray(); + // public final static char[] SUFFIX_CLASS = + // SUFFIX_STRING_CLASS.toCharArray(); + public final static char[] SUFFIX_php = SUFFIX_STRING_php.toCharArray(); + + public final static char[] SUFFIX_PHP = SUFFIX_STRING_PHP.toCharArray(); + + // public final static String EXTENSION_jar = "jar"; //$NON-NLS-1$ + // public final static String EXTENSION_JAR = "JAR"; //$NON-NLS-1$ + // public final static String EXTENSION_zip = "zip"; //$NON-NLS-1$ + // public final static String EXTENSION_ZIP = "ZIP"; //$NON-NLS-1$ + + // public final static String SUFFIX_STRING_jar = "." + EXTENSION_jar; + // //$NON-NLS-1$ + // public final static String SUFFIX_STRING_JAR = "." + EXTENSION_JAR; + // //$NON-NLS-1$ + // public final static String SUFFIX_STRING_zip = "." + EXTENSION_zip; + // //$NON-NLS-1$ + // public final static String SUFFIX_STRING_ZIP = "." + EXTENSION_ZIP; + // //$NON-NLS-1$ + + // public final static char[] SUFFIX_jar = SUFFIX_STRING_jar.toCharArray(); + // public final static char[] SUFFIX_JAR = SUFFIX_STRING_JAR.toCharArray(); + // public final static char[] SUFFIX_zip = SUFFIX_STRING_zip.toCharArray(); + // public final static char[] SUFFIX_ZIP = SUFFIX_STRING_ZIP.toCharArray(); +} \ No newline at end of file