aboutsummaryrefslogtreecommitdiffstats
path: root/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2012-12-04 09:50:58 -0800
committerTor Norbye <tnorbye@google.com>2012-12-04 14:01:25 -0800
commitba7270b2b13b437bd9b384a47672d6b7820e6d81 (patch)
tree73245034395dd9f6ce61550ce644fcd9d9cbb33c /eclipse/plugins/com.android.ide.eclipse.tests/src/com/android
parent474bd94478a8ced503e292b17c7e5962de414d99 (diff)
downloadsdk-ba7270b2b13b437bd9b384a47672d6b7820e6d81.zip
sdk-ba7270b2b13b437bd9b384a47672d6b7820e6d81.tar.gz
sdk-ba7270b2b13b437bd9b384a47672d6b7820e6d81.tar.bz2
Add namespace elements from code completion lazily
The XmlUtils.lookupNamespace() method would unconditionally insert a namespace declaration if called with a namespace that is not already declared in the document. This had the negative effect that simply bringing up the code completion dialog on a custom view would immediately insert the app namespace declaration, even if the user didn't select one of the app namespace attributes. Furthermore, this edit would sometimes result in the caret being placed in the wrong place after insertion. This changeset adds a new parameter to the lookupNamespace() method, "create", which lets the caller deliberately decide whether the new namespace element should be created. Second, code completion now only inserts the namespace declaration as part of the completion apply handler, meaning you only get the namespace if you pick one of the custom attributes. It also uses a document position to ensure that the insert and caret positions are preserved properly and take the namespace insertion into account. Change-Id: I21cf678df454b09460139fe35d33ca88b8e91757
Diffstat (limited to 'eclipse/plugins/com.android.ide.eclipse.tests/src/com/android')
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LayoutMetadataTest.java4
1 files changed, 2 insertions, 2 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LayoutMetadataTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LayoutMetadataTest.java
index fa9e18f..c71064e 100644
--- a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LayoutMetadataTest.java
+++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LayoutMetadataTest.java
@@ -53,11 +53,11 @@ public class LayoutMetadataTest extends AdtProjectTest {
assertNull(LayoutMetadata.getProperty(node, "foo"));
Element element = (Element) node;
- String prefix = XmlUtils.lookupNamespacePrefix(element, TOOLS_URI, null);
+ String prefix = XmlUtils.lookupNamespacePrefix(element, TOOLS_URI, null, false);
if (prefix == null) {
// Add in new prefix...
prefix = XmlUtils.lookupNamespacePrefix(element,
- TOOLS_URI, TOOLS_PREFIX);
+ TOOLS_URI, TOOLS_PREFIX, true);
}
element.setAttribute(prefix + ':' + "foo", "bar");
}