JDT codeassist module, nothing changed yet
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / codeassist / complete / CompletionOnMemberAccess.java
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/codeassist/complete/CompletionOnMemberAccess.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/codeassist/complete/CompletionOnMemberAccess.java
new file mode 100644 (file)
index 0000000..8933d7c
--- /dev/null
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Common Public License v0.5 
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package net.sourceforge.phpdt.internal.codeassist.complete;
+
+/*
+ * Completion node build by the parser in any case it was intending to
+ * reduce an access to a member (field reference or message send) 
+ * containing the completion identifier.
+ * e.g.
+ *
+ *     class X {
+ *    void foo() {
+ *      bar().fred[cursor]
+ *    }
+ *  }
+ *
+ *     ---> class X {
+ *         void foo() {
+ *           <CompleteOnMemberAccess:bar().fred>
+ *         }
+ *       }
+ *
+ * The source range of the completion node denotes the source range
+ * which should be replaced by the completion.
+ */
+
+import net.sourceforge.phpdt.internal.compiler.ast.*;
+import net.sourceforge.phpdt.internal.compiler.lookup.*;
+
+public class CompletionOnMemberAccess extends FieldReference {
+       
+       public CompletionOnMemberAccess(char[] source, long pos) {
+               super(source, pos);
+       }
+       
+       public TypeBinding resolveType(BlockScope scope) {
+               TypeBinding receiverType = receiver.resolveType(scope);
+               if (receiverType == null || receiverType.isBaseType())
+                       throw new CompletionNodeFound();
+               else
+                       throw new CompletionNodeFound(this, receiverType, scope);
+               // array types are passed along to find the length field
+       }
+       
+       public String toStringExpression() {
+
+               return "<CompleteOnMemberAccess:" //$NON-NLS-1$
+                                               + super.toStringExpression() + ">"; //$NON-NLS-1$
+       }
+}
\ No newline at end of file