/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * 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
import net.sourceforge.phpdt.core.CompletionRequestorAdapter;
import net.sourceforge.phpdt.core.ICompilationUnit;
-import net.sourceforge.phpdt.core.JavaModelException;
import net.sourceforge.phpdt.core.compiler.IProblem;
-
-
/**
* A completion requestor to collect informations on local variables.
* This class is used for guessing variable names like arrays, collections, etc.
return (LocalVariable[]) vector.toArray(new LocalVariable[vector.size()]);
}
- LocalVariable[] findLocalCollections() throws JavaModelException {
- Vector vector= new Vector();
-
- for (Iterator iterator= fLocalVariables.iterator(); iterator.hasNext();) {
- LocalVariable localVariable= (LocalVariable) iterator.next();
-
- String typeName= qualify(localVariable.typeName);
-
- if (typeName == null)
- continue;
-
- if (isSubclassOf(typeName, "java.util.Collection")) //$NON-NLS-1$
- vector.add(localVariable);
- }
-
- return (LocalVariable[]) vector.toArray(new LocalVariable[vector.size()]);
- }
+// LocalVariable[] findLocalCollections() throws JavaModelException {
+// Vector vector= new Vector();
+//
+// for (Iterator iterator= fLocalVariables.iterator(); iterator.hasNext();) {
+// LocalVariable localVariable= (LocalVariable) iterator.next();
+//
+// String typeName= qualify(localVariable.typeName);
+//
+// if (typeName == null)
+// continue;
+//
+// if (isSubclassOf(typeName, "java.util.Collection")) //$NON-NLS-1$
+// vector.add(localVariable);
+// }
+//
+// return (LocalVariable[]) vector.toArray(new LocalVariable[vector.size()]);
+// }
String simplifyTypeName(String qualifiedName) {
return (String) fTypes.get(qualifiedName);
}
- private LocalVariable[] findLocalIntegers() {
- Vector vector= new Vector();
-
- for (Iterator iterator= fLocalVariables.iterator(); iterator.hasNext();) {
- LocalVariable localVariable= (LocalVariable) iterator.next();
-
- if (localVariable.typeName.equals("int")) //$NON-NLS-1$
- vector.add(localVariable);
- }
-
- return (LocalVariable[]) vector.toArray(new LocalVariable[vector.size()]);
- }
-
- private LocalVariable[] findLocalIterator() throws JavaModelException {
- Vector vector= new Vector();
-
- for (Iterator iterator= fLocalVariables.iterator(); iterator.hasNext();) {
- LocalVariable localVariable= (LocalVariable) iterator.next();
-
- String typeName= qualify(localVariable.typeName);
-
- if (typeName == null)
- continue;
-
- if (isSubclassOf(typeName, "java.util.Iterator")) //$NON-NLS-1$
- vector.add(localVariable);
- }
-
- return (LocalVariable[]) vector.toArray(new LocalVariable[vector.size()]);
- }
-
private static boolean isArray(String type) {
return type.endsWith("[]"); //$NON-NLS-1$
}
// returns fully qualified name if successful
- private String qualify(String typeName) throws JavaModelException {
- if (fUnit == null)
- return null;
-
+// private String qualify(String typeName) throws JavaModelException {
+// if (fUnit == null)
+// return null;
+//
// IType[] types= fUnit.getTypes();
//
// if (types.length == 0)
// return null;
//
// return resolvedTypeNames[0][0] + '.' + resolvedTypeNames[0][1];
- return null;
- }
+// }
// type names must be fully qualified
- private boolean isSubclassOf(String typeName0, String typeName1) throws JavaModelException {
- if (typeName0.equals(typeName1))
- return true;
-
- if (fUnit == null)
- return false;
-
+// private boolean isSubclassOf(String typeName0, String typeName1) throws JavaModelException {
+// if (typeName0.equals(typeName1))
+// return true;
+//
+// if (fUnit == null)
+// return false;
+//
// IJavaProject project= fUnit.getJavaProject();
+//
// IType type0= project.findType(typeName0);
+// if (type0 == null)
+// return false;
+//
// IType type1= project.findType(typeName1);
+// if (type1 == null)
+// return false;
//
// ITypeHierarchy hierarchy= type0.newSupertypeHierarchy(null);
// IType[] superTypes= hierarchy.getAllSupertypes(type0);
// for (int i= 0; i < superTypes.length; i++)
// if (superTypes[i].equals(type1))
// return true;
-
- return false;
- }
+//
+// return false;
+// }
/*
- * @see org.eclipse.jdt.core.ICompletionRequestor#acceptClass(char[], char[], char[], int, int, int, int)
+ * @see net.sourceforge.phpdt.core.ICompletionRequestor#acceptClass(char[], char[], char[], int, int, int, int)
*/
public void acceptClass(char[] packageName, char[] className, char[] completionName, int modifiers,
int completionStart, int completionEnd, int relevance)
}
/*
- * @see org.eclipse.jdt.core.ICompletionRequestor#acceptInterface(char[], char[], char[], int, int, int, int)
+ * @see net.sourceforge.phpdt.core.ICompletionRequestor#acceptInterface(char[], char[], char[], int, int, int, int)
*/
public void acceptInterface(char[] packageName, char[] interfaceName, char[] completionName,
int modifiers, int completionStart, int completionEnd, int relevance)