import net.sourceforge.phpdt.core.JavaModelException;
import net.sourceforge.phpdt.core.Signature;
import net.sourceforge.phpdt.core.compiler.CharOperation;
-import net.sourceforge.phpeclipse.phpeditor.EditorUtility;
+//import net.sourceforge.phpdt.ui.JavaUI;
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+//import net.sourceforge.phpeclipse.phpeditor.EditorUtility;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
return type.getTypeQualifiedName('.');
}
- private static void getTypeQualifiedName(IType type, StringBuffer buf) {
- IType outerType = type.getDeclaringType();
- if (outerType != null) {
- getTypeQualifiedName(outerType, buf);
- buf.append('.');
- }
- buf.append(type.getElementName());
- }
+// private static void getTypeQualifiedName(IType type, StringBuffer buf) {
+// IType outerType = type.getDeclaringType();
+// if (outerType != null) {
+// getTypeQualifiedName(outerType, buf);
+// buf.append('.');
+// }
+// buf.append(type.getElementName());
+// }
/**
* Returns the fully qualified name of the given type using '.' as
if (semi == -1) {
throw new IllegalArgumentException();
}
- String name = refTypeSig.substring(arrayCount + 1, semi);
+ //String name = refTypeSig.substring(arrayCount + 1, semi);
// String[][] resolvedNames= declaringType.resolveType(name);
// if (resolvedNames != null && resolvedNames.length > 0) {
public static IMember toWorkingCopy(IMember member) {
ICompilationUnit cu = member.getCompilationUnit();
if (cu != null && !cu.isWorkingCopy()) {
- ICompilationUnit workingCopy = EditorUtility.getWorkingCopy(cu);
+ ICompilationUnit workingCopy = /*EditorUtility.*/getWorkingCopy(cu);
if (workingCopy != null) {
IJavaElement[] members = workingCopy.findElements(member);
if (members != null && members.length > 0) {
*/
public static ICompilationUnit toWorkingCopy(ICompilationUnit cu) {
if (!cu.isWorkingCopy()) {
- ICompilationUnit workingCopy = EditorUtility.getWorkingCopy(cu);
+ ICompilationUnit workingCopy = /*EditorUtility.*/getWorkingCopy(cu);
if (workingCopy != null) {
return workingCopy;
}
System.arraycopy(args, 0, args = new String[count], 0, count);
return args;
}
+
+ //incastrix
+ /**
+ * Gets the working copy of an compilation unit opened in an editor
+ *
+ * @param part
+ * the editor part
+ * @param cu
+ * the original compilation unit (or another working copy)
+ * @return the working copy of the compilation unit, or null if not found
+ */
+ public static ICompilationUnit getWorkingCopy(ICompilationUnit cu) {
+ if (cu == null)
+ return null;
+ if (cu.isWorkingCopy())
+ return cu;
+
+ return (ICompilationUnit) cu.findSharedWorkingCopy(PHPeclipsePlugin.getDefault()
+ .getBufferFactory());
+ }
+
+ // incastrix
+ /**
+ * Gets the working copy of an member opened in an editor
+ *
+ * @param member
+ * the original member or a member in a working copy
+ * @return the corresponding member in the shared working copy or
+ * <code>null</code> if not found
+ */
+ public static IMember getWorkingCopy(IMember member)
+ throws JavaModelException {
+ ICompilationUnit cu = member.getCompilationUnit();
+ if (cu != null) {
+ ICompilationUnit workingCopy = getWorkingCopy(cu);
+ if (workingCopy != null) {
+ return JavaModelUtil.findMemberInCompilationUnit(workingCopy,
+ member);
+ }
+ }
+ return null;
+ }
}