aboutsummaryrefslogtreecommitdiff
path: root/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/descriptors/CustomViewDescriptorService.java
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2011-06-03 09:41:54 -0700
committerTor Norbye <tnorbye@google.com>2011-06-08 13:10:55 -0700
commitcffc2d59e9d60edfa63a446e81c9e81a12692caa (patch)
tree6e71549c80a52139bccc2f16836bb4ab0f1d5a46 /eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/descriptors/CustomViewDescriptorService.java
parent9e96cab20e1a21a5c5054a9dcdc95f69c615ea84 (diff)
downloadsdk-cffc2d59e9d60edfa63a446e81c9e81a12692caa.tar.gz
Code completion improvements inside custom views
This CL fixes several issues when using code completion inside a tag that is a custom view. In that case we don't have a valid descriptor which specifies the allowable children, which meant completing inside any of the children, even if they are standard Android widgets, would not locate names and attributes. This fixes that, along with handling dots in tag names which caused other code completion problems. Change-Id: If0f007322c6aa00363ab32baf6191a3d3ffb9883
Diffstat (limited to 'eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/descriptors/CustomViewDescriptorService.java')
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/descriptors/CustomViewDescriptorService.java40
1 files changed, 20 insertions, 20 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/descriptors/CustomViewDescriptorService.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/descriptors/CustomViewDescriptorService.java
index be9fe34a4..de8a83d90 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/descriptors/CustomViewDescriptorService.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/descriptors/CustomViewDescriptorService.java
@@ -21,6 +21,7 @@ import static com.android.sdklib.SdkConstants.CLASS_VIEWGROUP;
import com.android.ide.common.resources.platform.ViewClassInfo;
import com.android.ide.eclipse.adt.internal.editors.descriptors.AttributeDescriptor;
import com.android.ide.eclipse.adt.internal.editors.descriptors.DescriptorsUtils;
+import com.android.ide.eclipse.adt.internal.editors.descriptors.ElementDescriptor;
import com.android.ide.eclipse.adt.internal.sdk.AndroidTargetData;
import com.android.ide.eclipse.adt.internal.sdk.Sdk;
import com.android.sdklib.IAndroidTarget;
@@ -167,7 +168,8 @@ public final class CustomViewDescriptorService {
String name = DescriptorsUtils.getBasename(fqcn);
ViewElementDescriptor descriptor = new CustomViewDescriptor(name, fqcn,
getAttributeDescriptor(type, parentDescriptor),
- parentDescriptor.hasChildren());
+ getLayoutAttributeDescriptors(type, parentDescriptor),
+ parentDescriptor.getChildren());
descriptor.setSuperClass(parentDescriptor);
synchronized (mCustomDescriptorMap) {
@@ -249,9 +251,16 @@ public final class CustomViewDescriptorService {
// its parent does not.
boolean isViewGroup = fqcn.equals(CLASS_VIEWGROUP);
boolean hasChildren = isViewGroup || parentDescriptor.hasChildren();
+ ViewElementDescriptor[] children = null;
+ if (hasChildren && builtInList != null) {
+ // We can't figure out what the allowable children are by just
+ // looking at the class, so assume any View is valid
+ children = builtInList.toArray(new ViewElementDescriptor[builtInList.size()]);
+ }
ViewElementDescriptor descriptor = new CustomViewDescriptor(name, fqcn,
getAttributeDescriptor(type, parentDescriptor),
- hasChildren);
+ getLayoutAttributeDescriptors(type, parentDescriptor),
+ children);
descriptor.setSuperClass(parentDescriptor);
// add it to the map
@@ -291,11 +300,15 @@ public final class CustomViewDescriptorService {
return parentDescriptor.getAttributes();
}
- private class CustomViewDescriptor extends ViewElementDescriptor {
- private boolean mHasChildren;
+ private AttributeDescriptor[] getLayoutAttributeDescriptors(IType type,
+ ViewElementDescriptor parentDescriptor) {
+ return parentDescriptor.getLayoutAttributes();
+ }
+ private class CustomViewDescriptor extends ViewElementDescriptor {
public CustomViewDescriptor(String name, String fqcn, AttributeDescriptor[] attributes,
- boolean hasChildren) {
+ AttributeDescriptor[] layoutAttributes,
+ ElementDescriptor[] children) {
super(
fqcn, // xml name
name, // ui name
@@ -303,25 +316,12 @@ public final class CustomViewDescriptorService {
fqcn, // tooltip
null, // sdk_url
attributes,
- null, // layout attributes
- null, // children
+ layoutAttributes,
+ children,
false // mandatory
);
- mHasChildren = hasChildren;
}
- /**
- * {@inheritDoc}
- * <p>
- * Custom views can accept children even if we have no information about
- * allowed children.
- */
- @Override
- public boolean hasChildren() {
- return mHasChildren;
- }
-
-
@Override
public Image getGenericIcon() {
// Java source file icon. We could use the Java class icon here