diff --git a/plugins/android/src/META-INF/plugin.xml b/plugins/android/src/META-INF/plugin.xml index 5545106ea523..bb23c6881660 100644 --- a/plugins/android/src/META-INF/plugin.xml +++ b/plugins/android/src/META-INF/plugin.xml @@ -61,10 +61,13 @@ + + + + - diff --git a/plugins/android/src/org/jetbrains/android/AndroidCompletionContributor.java b/plugins/android/src/org/jetbrains/android/AndroidCompletionContributor.java index e5941a62cab2..d6d5cf08bf23 100644 --- a/plugins/android/src/org/jetbrains/android/AndroidCompletionContributor.java +++ b/plugins/android/src/org/jetbrains/android/AndroidCompletionContributor.java @@ -38,6 +38,7 @@ import org.jetbrains.android.facet.AndroidFacet; import org.jetbrains.android.util.AndroidUtils; import org.jetbrains.annotations.NotNull; +import java.util.Arrays; import java.util.Collection; import java.util.Map; @@ -84,10 +85,12 @@ public class AndroidCompletionContributor extends CompletionContributor { addAll(AndroidXmlResourcesUtil.getPossibleRoots(facet), resultSet); return false; } - else if (AndroidDrawableDomUtil.isDrawableResourceFile(xmlFile) || - ColorDomFileDescription.isColorResourceFile(xmlFile)) { + else if (AndroidDrawableDomUtil.isDrawableResourceFile(xmlFile)) { addAll(AndroidDrawableDomUtil.getPossibleRoots(), resultSet); } + else if (ColorDomFileDescription.isColorResourceFile(xmlFile)) { + addAll(Arrays.asList(DrawableStateListDomFileDescription.SELECTOR_TAG_NAME), resultSet); + } } } } diff --git a/plugins/android/src/org/jetbrains/android/dom/AndroidDomExtender.java b/plugins/android/src/org/jetbrains/android/dom/AndroidDomExtender.java index c2cfbc4302de..5309cc1d560d 100644 --- a/plugins/android/src/org/jetbrains/android/dom/AndroidDomExtender.java +++ b/plugins/android/src/org/jetbrains/android/dom/AndroidDomExtender.java @@ -100,12 +100,16 @@ public class AndroidDomExtender extends DomExtender { String... skipNames) { Set skippedAttrSet = new HashSet(); Collections.addAll(skippedAttrSet, skipNames); - XmlAttribute[] existingAttrs = element.getXmlTag().getAttributes(); - for (XmlAttribute attr : existingAttrs) { - if (attr.getNamespace().equals(namespace)) { - skippedAttrSet.add(attr.getLocalName()); + + if (!shouldValidateAttributes(element)) { + XmlAttribute[] existingAttrs = element.getXmlTag().getAttributes(); + for (XmlAttribute attr : existingAttrs) { + if (attr.getNamespace().equals(namespace)) { + skippedAttrSet.add(attr.getLocalName()); + } } } + for (StyleableDefinition styleable : styleables) { for (AttributeDefinition attrDef : styleable.getAttributes()) { String attrName = attrDef.getName(); @@ -117,6 +121,10 @@ public class AndroidDomExtender extends DomExtender { } } + private static boolean shouldValidateAttributes(DomElement element) { + return element instanceof DrawableDomElement; + } + private static boolean mustBeSoft(@NotNull Converter converter, Collection formats) { if (converter instanceof CompositeConverter || converter instanceof ResourceReferenceConverter) { return false; @@ -494,7 +502,11 @@ public class AndroidDomExtender extends DomExtender { AndroidFacet facet = AndroidFacet.getInstance(element); if (facet == null) return; XmlTag tag = element.getXmlTag(); - registerExistingAttributes(facet, tag, registrar, element); + + if (!shouldValidateAttributes(element)) { + registerExistingAttributes(facet, tag, registrar, element); + } + String tagName = tag.getName(); Set registeredSubtags = new HashSet(); if (element instanceof ManifestElement) { @@ -517,13 +529,13 @@ public class AndroidDomExtender extends DomExtender { registerExtensionsForXmlResources(facet, tagName, (XmlResourceElement)element, registrar, registeredSubtags); } else if (element instanceof DrawableDomElement || element instanceof ColorDomElement) { - registerExtensionsForStateList(facet, tagName, element, registrar); + registerExtensionsForDrawable(facet, tagName, element, registrar); } Collections.addAll(registeredSubtags, AndroidDomUtil.getStaticallyDefinedSubtags(element)); if (!(element instanceof LayoutElement) && !(element instanceof ColorDomElement) && - (!(element instanceof DrawableDomElement) || element instanceof UnknownDrawableDomElement)) { + !(element instanceof DrawableDomElement)) { Processor existingSubtagsFilter = element instanceof XmlResourceElement ? new Processor() { public boolean process(String s) { @@ -534,10 +546,10 @@ public class AndroidDomExtender extends DomExtender { } } - private static void registerExtensionsForStateList(AndroidFacet facet, - String tagName, - AndroidDomElement element, - DomExtensionsRegistrar registrar) { + private static void registerExtensionsForDrawable(AndroidFacet facet, + String tagName, + AndroidDomElement element, + DomExtensionsRegistrar registrar) { final String specialStyleableName = AndroidDrawableDomUtil.SPECIAL_STYLEABLE_NAMES.get(tagName); if (specialStyleableName != null) { registerAttributes(facet, element, specialStyleableName, SYSTEM_RESOURCE_PACKAGE, registrar); @@ -551,6 +563,12 @@ public class AndroidDomExtender extends DomExtender { registerAttributes(facet, element, attrDefs.getStateStyleables(), SYSTEM_RESOURCE_PACKAGE, registrar, null); } } + else if (element instanceof LayerListItem) { + registerAttributes(facet, element, "LayerDrawableItem", SYSTEM_RESOURCE_PACKAGE, registrar); + } + else if (element instanceof LevelListItem) { + registerAttributes(facet, element, "LevelListDrawableItem", SYSTEM_RESOURCE_PACKAGE, registrar); + } } @Nullable diff --git a/plugins/android/src/org/jetbrains/android/dom/drawable/AndroidDrawableDomUtil.java b/plugins/android/src/org/jetbrains/android/dom/drawable/AndroidDrawableDomUtil.java index bae6195fd595..522a6b9d598d 100644 --- a/plugins/android/src/org/jetbrains/android/dom/drawable/AndroidDrawableDomUtil.java +++ b/plugins/android/src/org/jetbrains/android/dom/drawable/AndroidDrawableDomUtil.java @@ -29,12 +29,25 @@ import java.util.Map; */ public class AndroidDrawableDomUtil { public static final Map SPECIAL_STYLEABLE_NAMES = new HashMap(); - private static final String[] POSSIBLE_DRAWABLE_ROOTS = new String[] {"selector", "bitmap", "nine-patch"}; + private static final String[] POSSIBLE_DRAWABLE_ROOTS = + new String[]{"selector", "bitmap", "nine-patch", "layer-list", "level-list", "transition", "inset", "clip", "scale", "shape"}; static { SPECIAL_STYLEABLE_NAMES.put("selector", "StateListDrawable"); SPECIAL_STYLEABLE_NAMES.put("bitmap", "BitmapDrawable"); SPECIAL_STYLEABLE_NAMES.put("nine-patch", "NinePatchDrawable"); + SPECIAL_STYLEABLE_NAMES.put("layer-list", "LayerDrawable"); + SPECIAL_STYLEABLE_NAMES.put("inset", "InsetDrawable"); + SPECIAL_STYLEABLE_NAMES.put("clip", "ClipDrawable"); + SPECIAL_STYLEABLE_NAMES.put("scale", "ScaleDrawable"); + + SPECIAL_STYLEABLE_NAMES.put("shape", "GradientDrawable"); + SPECIAL_STYLEABLE_NAMES.put("corners", "DrawableCorners"); + SPECIAL_STYLEABLE_NAMES.put("gradient", "GradientDrawableGradient"); + SPECIAL_STYLEABLE_NAMES.put("padding", "GradientDrawablePadding"); + SPECIAL_STYLEABLE_NAMES.put("size", "GradientDrawableSize"); + SPECIAL_STYLEABLE_NAMES.put("solid", "GradientDrawableSolid"); + SPECIAL_STYLEABLE_NAMES.put("stroke", "GradientDrawableStroke"); } private AndroidDrawableDomUtil() { diff --git a/plugins/android/src/org/jetbrains/android/dom/drawable/InsetOrClipOrScale.java b/plugins/android/src/org/jetbrains/android/dom/drawable/InsetOrClipOrScale.java new file mode 100644 index 000000000000..a56446344ae4 --- /dev/null +++ b/plugins/android/src/org/jetbrains/android/dom/drawable/InsetOrClipOrScale.java @@ -0,0 +1,35 @@ +/* + * Copyright 2000-2011 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.android.dom.drawable; + +import com.intellij.util.xml.Convert; +import com.intellij.util.xml.DefinesXml; +import com.intellij.util.xml.Required; +import org.jetbrains.android.dom.AndroidAttributeValue; +import org.jetbrains.android.dom.ResourceType; +import org.jetbrains.android.dom.converters.ResourceReferenceConverter; +import org.jetbrains.android.dom.resources.ResourceValue; + +/** + * @author Eugene.Kudelevsky + */ +@DefinesXml +public interface InsetOrClipOrScale extends DrawableDomElement { + @Convert(ResourceReferenceConverter.class) + @Required + @ResourceType("drawable") + AndroidAttributeValue getDrawable(); +} diff --git a/plugins/android/src/org/jetbrains/android/dom/drawable/DrawableDomFileDescription.java b/plugins/android/src/org/jetbrains/android/dom/drawable/InsetOrClipOrScaleDomFileDescription.java similarity index 65% rename from plugins/android/src/org/jetbrains/android/dom/drawable/DrawableDomFileDescription.java rename to plugins/android/src/org/jetbrains/android/dom/drawable/InsetOrClipOrScaleDomFileDescription.java index ccab463e38f6..d87e25d3056a 100644 --- a/plugins/android/src/org/jetbrains/android/dom/drawable/DrawableDomFileDescription.java +++ b/plugins/android/src/org/jetbrains/android/dom/drawable/InsetOrClipOrScaleDomFileDescription.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2011 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.jetbrains.android.dom.drawable; import com.intellij.openapi.module.Module; @@ -21,20 +20,19 @@ import com.intellij.psi.xml.XmlFile; import com.intellij.psi.xml.XmlTag; import com.intellij.util.ArrayUtil; import org.jetbrains.android.dom.AndroidResourceDomFileDescription; +import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** - * Created by IntelliJ IDEA. - * User: Eugene.Kudelevsky - * Date: Aug 21, 2009 - * Time: 9:42:38 PM - * To change this template use File | Settings | File Templates. + * @author Eugene.Kudelevsky */ -public class DrawableDomFileDescription extends AndroidResourceDomFileDescription { +public class InsetOrClipOrScaleDomFileDescription extends AndroidResourceDomFileDescription { - public DrawableDomFileDescription() { - super(UnknownDrawableDomElement.class, "shape", "bitmap", "nine-patch", "drawable"); + @NonNls private static final String[] ROOT_TAGS = new String[] {"inset", "clip", "scale"}; + + public InsetOrClipOrScaleDomFileDescription() { + super(InsetOrClipOrScale.class, ROOT_TAGS[0], "drawable"); } @Override @@ -53,8 +51,6 @@ public class DrawableDomFileDescription extends AndroidResourceDomFileDescriptio return false; } - final String rootTagName = rootTag.getName(); - return !DrawableStateListDomFileDescription.SELECTOR_TAG_NAME.equals(rootTagName) && - ArrayUtil.find(BitmapOrNinePatchDomFileDescription.ROOT_TAG_NAMES, rootTag) < 0; + return ArrayUtil.find(ROOT_TAGS, rootTag.getName()) >= 0; } } diff --git a/plugins/android/src/org/jetbrains/android/dom/drawable/UnknownDrawableDomElement.java b/plugins/android/src/org/jetbrains/android/dom/drawable/LayerList.java similarity index 86% rename from plugins/android/src/org/jetbrains/android/dom/drawable/UnknownDrawableDomElement.java rename to plugins/android/src/org/jetbrains/android/dom/drawable/LayerList.java index 82eb7cb2eb8b..7373e47fc71f 100644 --- a/plugins/android/src/org/jetbrains/android/dom/drawable/UnknownDrawableDomElement.java +++ b/plugins/android/src/org/jetbrains/android/dom/drawable/LayerList.java @@ -17,9 +17,12 @@ package org.jetbrains.android.dom.drawable; import com.intellij.util.xml.DefinesXml; +import java.util.List; + /** * @author Eugene.Kudelevsky */ @DefinesXml -public interface UnknownDrawableDomElement extends DrawableDomElement { +public interface LayerList extends DrawableDomElement { + List getItems(); } diff --git a/plugins/android/src/org/jetbrains/android/dom/drawable/LayerListDomFileDescription.java b/plugins/android/src/org/jetbrains/android/dom/drawable/LayerListDomFileDescription.java new file mode 100644 index 000000000000..932f4dd34001 --- /dev/null +++ b/plugins/android/src/org/jetbrains/android/dom/drawable/LayerListDomFileDescription.java @@ -0,0 +1,55 @@ +/* + * Copyright 2000-2011 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.android.dom.drawable; + +import com.intellij.openapi.module.Module; +import com.intellij.psi.xml.XmlFile; +import com.intellij.psi.xml.XmlTag; +import com.intellij.util.ArrayUtil; +import org.jetbrains.android.dom.AndroidResourceDomFileDescription; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * @author Eugene.Kudelevsky + */ +public class LayerListDomFileDescription extends AndroidResourceDomFileDescription { + @NonNls static final String[] POSSIBLE_ROOT_TAGS = {"layer-list", "transition"}; + + public LayerListDomFileDescription() { + super(LayerList.class, POSSIBLE_ROOT_TAGS[0], "drawable"); + } + + @Override + public boolean acceptsOtherRootTagNames() { + return true; + } + + @Override + public boolean isMyFile(@NotNull XmlFile file, @Nullable Module module) { + if (!super.isMyFile(file, module)) { + return false; + } + + final XmlTag rootTag = file.getRootTag(); + if (rootTag == null) { + return false; + } + + return ArrayUtil.find(POSSIBLE_ROOT_TAGS, rootTag.getName()) >= 0; + } +} diff --git a/plugins/android/src/org/jetbrains/android/dom/drawable/LayerListItem.java b/plugins/android/src/org/jetbrains/android/dom/drawable/LayerListItem.java new file mode 100644 index 000000000000..f324ade27f91 --- /dev/null +++ b/plugins/android/src/org/jetbrains/android/dom/drawable/LayerListItem.java @@ -0,0 +1,35 @@ +/* + * Copyright 2000-2011 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.android.dom.drawable; + +import com.intellij.util.xml.Convert; +import org.jetbrains.android.dom.AndroidAttributeValue; +import org.jetbrains.android.dom.ResourceType; +import org.jetbrains.android.dom.converters.ResourceReferenceConverter; +import org.jetbrains.android.dom.resources.ResourceValue; + +import java.util.List; + +/** + * @author Eugene.Kudelevsky + */ +public interface LayerListItem extends DrawableDomElement { + @Convert(ResourceReferenceConverter.class) + @ResourceType("drawable") + AndroidAttributeValue getDrawable(); + + List getBitmaps(); +} diff --git a/plugins/android/src/org/jetbrains/android/dom/drawable/DrawableStateListElement.java b/plugins/android/src/org/jetbrains/android/dom/drawable/LevelList.java similarity index 73% rename from plugins/android/src/org/jetbrains/android/dom/drawable/DrawableStateListElement.java rename to plugins/android/src/org/jetbrains/android/dom/drawable/LevelList.java index 707c378718f5..ba2664ef515c 100644 --- a/plugins/android/src/org/jetbrains/android/dom/drawable/DrawableStateListElement.java +++ b/plugins/android/src/org/jetbrains/android/dom/drawable/LevelList.java @@ -13,15 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.jetbrains.android.dom.drawable; +import com.intellij.util.xml.DefinesXml; + +import java.util.List; + /** - * Created by IntelliJ IDEA. - * User: Eugene.Kudelevsky - * Date: Aug 22, 2009 - * Time: 1:36:56 PM - * To change this template use File | Settings | File Templates. + * @author Eugene.Kudelevsky */ -public interface DrawableStateListElement extends DrawableDomElement { +@DefinesXml +public interface LevelList extends DrawableDomElement { + List getItems(); } diff --git a/plugins/android/src/org/jetbrains/android/dom/drawable/LevelListDomFileDescription.java b/plugins/android/src/org/jetbrains/android/dom/drawable/LevelListDomFileDescription.java new file mode 100644 index 000000000000..340e2872f4b6 --- /dev/null +++ b/plugins/android/src/org/jetbrains/android/dom/drawable/LevelListDomFileDescription.java @@ -0,0 +1,49 @@ +/* + * Copyright 2000-2011 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.android.dom.drawable; + +import com.intellij.openapi.module.Module; +import com.intellij.psi.xml.XmlFile; +import com.intellij.psi.xml.XmlTag; +import org.jetbrains.android.dom.AndroidResourceDomFileDescription; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * @author Eugene.Kudelevsky + */ +public class LevelListDomFileDescription extends AndroidResourceDomFileDescription { + @NonNls static final String LEVEL_LIST_TAG = "level-list"; + + public LevelListDomFileDescription() { + super(LevelList.class, LEVEL_LIST_TAG, "drawable"); + } + + @Override + public boolean isMyFile(@NotNull XmlFile file, @Nullable Module module) { + if (!super.isMyFile(file, module)) { + return false; + } + + final XmlTag rootTag = file.getRootTag(); + if (rootTag == null) { + return false; + } + + return LEVEL_LIST_TAG.equals(rootTag.getName()); + } +} diff --git a/plugins/android/src/org/jetbrains/android/dom/drawable/LevelListItem.java b/plugins/android/src/org/jetbrains/android/dom/drawable/LevelListItem.java new file mode 100644 index 000000000000..28b2323ffd93 --- /dev/null +++ b/plugins/android/src/org/jetbrains/android/dom/drawable/LevelListItem.java @@ -0,0 +1,33 @@ +/* + * Copyright 2000-2011 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.android.dom.drawable; + +import com.intellij.util.xml.Convert; +import com.intellij.util.xml.Required; +import org.jetbrains.android.dom.AndroidAttributeValue; +import org.jetbrains.android.dom.ResourceType; +import org.jetbrains.android.dom.converters.ResourceReferenceConverter; +import org.jetbrains.android.dom.resources.ResourceValue; + +/** + * @author Eugene.Kudelevsky + */ +public interface LevelListItem extends DrawableDomElement { + @Convert(ResourceReferenceConverter.class) + @ResourceType("drawable") + @Required + AndroidAttributeValue getDrawable(); +} diff --git a/plugins/android/src/org/jetbrains/android/dom/drawable/Shape.java b/plugins/android/src/org/jetbrains/android/dom/drawable/Shape.java new file mode 100644 index 000000000000..537d77e8e098 --- /dev/null +++ b/plugins/android/src/org/jetbrains/android/dom/drawable/Shape.java @@ -0,0 +1,33 @@ +/* + * Copyright 2000-2011 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.android.dom.drawable; + +import com.intellij.util.xml.DefinesXml; + +import java.util.List; + +/** + * @author Eugene.Kudelevsky + */ +@DefinesXml +public interface Shape extends DrawableDomElement { + List getCornerss(); + List getGradients(); + List getPaddings(); + List getSizes(); + List getSolids(); + List getStrokes(); +} diff --git a/plugins/android/src/org/jetbrains/android/dom/drawable/ShapeDomFileDescription.java b/plugins/android/src/org/jetbrains/android/dom/drawable/ShapeDomFileDescription.java new file mode 100644 index 000000000000..dace171bf911 --- /dev/null +++ b/plugins/android/src/org/jetbrains/android/dom/drawable/ShapeDomFileDescription.java @@ -0,0 +1,54 @@ +/* + * Copyright 2000-2011 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.android.dom.drawable; + +import com.intellij.openapi.module.Module; +import com.intellij.psi.xml.XmlFile; +import com.intellij.psi.xml.XmlTag; +import org.jetbrains.android.dom.AndroidResourceDomFileDescription; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * @author Eugene.Kudelevsky + */ +public class ShapeDomFileDescription extends AndroidResourceDomFileDescription { + @NonNls static final String SHAPE_ROOT_TAG = "shape"; + + public ShapeDomFileDescription() { + super(Shape.class, SHAPE_ROOT_TAG, "drawable"); + } + + @Override + public boolean acceptsOtherRootTagNames() { + return true; + } + + @Override + public boolean isMyFile(@NotNull XmlFile file, @Nullable Module module) { + if (!super.isMyFile(file, module)) { + return false; + } + + final XmlTag rootTag = file.getRootTag(); + if (rootTag == null) { + return false; + } + + return SHAPE_ROOT_TAG.equals(rootTag.getName()); + } +} diff --git a/plugins/android/testData/dom/color/rootTagCompletion.xml b/plugins/android/testData/dom/color/rootTagCompletion.xml new file mode 100644 index 000000000000..3eaa166c0ef0 --- /dev/null +++ b/plugins/android/testData/dom/color/rootTagCompletion.xml @@ -0,0 +1 @@ +< \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/bitmapHighlighting3.xml b/plugins/android/testData/dom/drawable/bitmapHighlighting3.xml new file mode 100644 index 000000000000..146008f14eab --- /dev/null +++ b/plugins/android/testData/dom/drawable/bitmapHighlighting3.xml @@ -0,0 +1,2 @@ + +android:aba="" /> \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/clipCompletion1.xml b/plugins/android/testData/dom/drawable/clipCompletion1.xml new file mode 100644 index 000000000000..e133131a41db --- /dev/null +++ b/plugins/android/testData/dom/drawable/clipCompletion1.xml @@ -0,0 +1,4 @@ + + +/> \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/clipCompletion1_after.xml b/plugins/android/testData/dom/drawable/clipCompletion1_after.xml new file mode 100644 index 000000000000..77fd7b0022a3 --- /dev/null +++ b/plugins/android/testData/dom/drawable/clipCompletion1_after.xml @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/clipCompletion2.xml b/plugins/android/testData/dom/drawable/clipCompletion2.xml new file mode 100644 index 000000000000..4a6c65fcd31a --- /dev/null +++ b/plugins/android/testData/dom/drawable/clipCompletion2.xml @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/clipHighlighting.xml b/plugins/android/testData/dom/drawable/clipHighlighting.xml new file mode 100644 index 000000000000..5dba1657322d --- /dev/null +++ b/plugins/android/testData/dom/drawable/clipHighlighting.xml @@ -0,0 +1,6 @@ + + +android:aba=""/> \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/incorrectRootTag.xml b/plugins/android/testData/dom/drawable/incorrectRootTag.xml new file mode 100644 index 000000000000..dda4ea645fae --- /dev/null +++ b/plugins/android/testData/dom/drawable/incorrectRootTag.xml @@ -0,0 +1,3 @@ +<resources> + +resources> \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/insetCompletion1.xml b/plugins/android/testData/dom/drawable/insetCompletion1.xml new file mode 100644 index 000000000000..d5a7f3faf04f --- /dev/null +++ b/plugins/android/testData/dom/drawable/insetCompletion1.xml @@ -0,0 +1,4 @@ + + +/> \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/insetCompletion1_after.xml b/plugins/android/testData/dom/drawable/insetCompletion1_after.xml new file mode 100644 index 000000000000..6fb5fde06067 --- /dev/null +++ b/plugins/android/testData/dom/drawable/insetCompletion1_after.xml @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/insetCompletion2.xml b/plugins/android/testData/dom/drawable/insetCompletion2.xml new file mode 100644 index 000000000000..f614be332fbd --- /dev/null +++ b/plugins/android/testData/dom/drawable/insetCompletion2.xml @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/insetHighlighting1.xml b/plugins/android/testData/dom/drawable/insetHighlighting1.xml new file mode 100644 index 000000000000..5dbdafc51b56 --- /dev/null +++ b/plugins/android/testData/dom/drawable/insetHighlighting1.xml @@ -0,0 +1,6 @@ + + +android:aba=""/> \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/insetHighlighting2.xml b/plugins/android/testData/dom/drawable/insetHighlighting2.xml new file mode 100644 index 000000000000..db2463bb15d6 --- /dev/null +++ b/plugins/android/testData/dom/drawable/insetHighlighting2.xml @@ -0,0 +1,3 @@ + + +<inset xmlns:android="http://schemas.android.com/apk/res/android"/> \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/layerListCompletion1.xml b/plugins/android/testData/dom/drawable/layerListCompletion1.xml new file mode 100644 index 000000000000..7d10c8263ad4 --- /dev/null +++ b/plugins/android/testData/dom/drawable/layerListCompletion1.xml @@ -0,0 +1,4 @@ + + + /> + \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/layerListCompletion1_after.xml b/plugins/android/testData/dom/drawable/layerListCompletion1_after.xml new file mode 100644 index 000000000000..e6ea89e49261 --- /dev/null +++ b/plugins/android/testData/dom/drawable/layerListCompletion1_after.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/layerListCompletion2.xml b/plugins/android/testData/dom/drawable/layerListCompletion2.xml new file mode 100644 index 000000000000..fb6242671dc1 --- /dev/null +++ b/plugins/android/testData/dom/drawable/layerListCompletion2.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/layerListCompletion3.xml b/plugins/android/testData/dom/drawable/layerListCompletion3.xml new file mode 100644 index 000000000000..8b6bea3b609f --- /dev/null +++ b/plugins/android/testData/dom/drawable/layerListCompletion3.xml @@ -0,0 +1,7 @@ + + + + /> + + \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/layerListCompletion3_after.xml b/plugins/android/testData/dom/drawable/layerListCompletion3_after.xml new file mode 100644 index 000000000000..a10d5fe95e34 --- /dev/null +++ b/plugins/android/testData/dom/drawable/layerListCompletion3_after.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/layerListHighlighting.xml b/plugins/android/testData/dom/drawable/layerListHighlighting.xml new file mode 100644 index 000000000000..d6534675b49d --- /dev/null +++ b/plugins/android/testData/dom/drawable/layerListHighlighting.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/levelListCompletion1.xml b/plugins/android/testData/dom/drawable/levelListCompletion1.xml new file mode 100644 index 000000000000..bab2e39db751 --- /dev/null +++ b/plugins/android/testData/dom/drawable/levelListCompletion1.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/levelListCompletion2.xml b/plugins/android/testData/dom/drawable/levelListCompletion2.xml new file mode 100644 index 000000000000..fcefd4743d2f --- /dev/null +++ b/plugins/android/testData/dom/drawable/levelListCompletion2.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/levelListCompletion2_after.xml b/plugins/android/testData/dom/drawable/levelListCompletion2_after.xml new file mode 100644 index 000000000000..748f29d5ba7e --- /dev/null +++ b/plugins/android/testData/dom/drawable/levelListCompletion2_after.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/levelListCompletion3.xml b/plugins/android/testData/dom/drawable/levelListCompletion3.xml new file mode 100644 index 000000000000..db83c5150061 --- /dev/null +++ b/plugins/android/testData/dom/drawable/levelListCompletion3.xml @@ -0,0 +1,5 @@ + + + + /> + \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/levelListCompletion3_after.xml b/plugins/android/testData/dom/drawable/levelListCompletion3_after.xml new file mode 100644 index 000000000000..9ddb5dba0bfb --- /dev/null +++ b/plugins/android/testData/dom/drawable/levelListCompletion3_after.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/levelListHighlighting.xml b/plugins/android/testData/dom/drawable/levelListHighlighting.xml new file mode 100644 index 000000000000..6c3d49da7047 --- /dev/null +++ b/plugins/android/testData/dom/drawable/levelListHighlighting.xml @@ -0,0 +1,7 @@ + + + + + + <item/> + \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/scaleCompletion1.xml b/plugins/android/testData/dom/drawable/scaleCompletion1.xml new file mode 100644 index 000000000000..608e4ce6b9f5 --- /dev/null +++ b/plugins/android/testData/dom/drawable/scaleCompletion1.xml @@ -0,0 +1,3 @@ + + \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/scaleCompletion1_after.xml b/plugins/android/testData/dom/drawable/scaleCompletion1_after.xml new file mode 100644 index 000000000000..8d9697106986 --- /dev/null +++ b/plugins/android/testData/dom/drawable/scaleCompletion1_after.xml @@ -0,0 +1,3 @@ + + \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/scaleCompletion2.xml b/plugins/android/testData/dom/drawable/scaleCompletion2.xml new file mode 100644 index 000000000000..ff044ef81631 --- /dev/null +++ b/plugins/android/testData/dom/drawable/scaleCompletion2.xml @@ -0,0 +1,3 @@ + + \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/scaleHighlighting1.xml b/plugins/android/testData/dom/drawable/scaleHighlighting1.xml new file mode 100644 index 000000000000..6c58e59ba4aa --- /dev/null +++ b/plugins/android/testData/dom/drawable/scaleHighlighting1.xml @@ -0,0 +1,5 @@ + +android:aba=""/> \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/scaleHighlighting2.xml b/plugins/android/testData/dom/drawable/scaleHighlighting2.xml new file mode 100644 index 000000000000..6122c75ed9bd --- /dev/null +++ b/plugins/android/testData/dom/drawable/scaleHighlighting2.xml @@ -0,0 +1,4 @@ + +android:aba=""/> \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/scaleHighlighting3.xml b/plugins/android/testData/dom/drawable/scaleHighlighting3.xml new file mode 100644 index 000000000000..e4f4b66008a4 --- /dev/null +++ b/plugins/android/testData/dom/drawable/scaleHighlighting3.xml @@ -0,0 +1,2 @@ + +<scale xmlns:android="http://schemas.android.com/apk/res/android"/> \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/shapeCompletion1.xml b/plugins/android/testData/dom/drawable/shapeCompletion1.xml new file mode 100644 index 000000000000..03302a19836f --- /dev/null +++ b/plugins/android/testData/dom/drawable/shapeCompletion1.xml @@ -0,0 +1,3 @@ + +/> \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/shapeCompletion1_after.xml b/plugins/android/testData/dom/drawable/shapeCompletion1_after.xml new file mode 100644 index 000000000000..d6e2148983a9 --- /dev/null +++ b/plugins/android/testData/dom/drawable/shapeCompletion1_after.xml @@ -0,0 +1,3 @@ + + \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/shapeCompletion2.xml b/plugins/android/testData/dom/drawable/shapeCompletion2.xml new file mode 100644 index 000000000000..2ad6fc556515 --- /dev/null +++ b/plugins/android/testData/dom/drawable/shapeCompletion2.xml @@ -0,0 +1,4 @@ + + + < + \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/shapeHighlighting.xml b/plugins/android/testData/dom/drawable/shapeHighlighting.xml new file mode 100644 index 000000000000..00ebe153cecd --- /dev/null +++ b/plugins/android/testData/dom/drawable/shapeHighlighting.xml @@ -0,0 +1,21 @@ + + + + + + android:dashWidth=""/> + + android:aba=""/> + <aba/> + \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/transitionCompletion1.xml b/plugins/android/testData/dom/drawable/transitionCompletion1.xml new file mode 100644 index 000000000000..a0062698659c --- /dev/null +++ b/plugins/android/testData/dom/drawable/transitionCompletion1.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/transitionCompletion1_after.xml b/plugins/android/testData/dom/drawable/transitionCompletion1_after.xml new file mode 100644 index 000000000000..c9e73d81b192 --- /dev/null +++ b/plugins/android/testData/dom/drawable/transitionCompletion1_after.xml @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/transitionCompletion2.xml b/plugins/android/testData/dom/drawable/transitionCompletion2.xml new file mode 100644 index 000000000000..3da025f3f417 --- /dev/null +++ b/plugins/android/testData/dom/drawable/transitionCompletion2.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/transitionCompletion2_after.xml b/plugins/android/testData/dom/drawable/transitionCompletion2_after.xml new file mode 100644 index 000000000000..24401fced5e9 --- /dev/null +++ b/plugins/android/testData/dom/drawable/transitionCompletion2_after.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/transitionHighlighting1.xml b/plugins/android/testData/dom/drawable/transitionHighlighting1.xml new file mode 100644 index 000000000000..bb48065c93be --- /dev/null +++ b/plugins/android/testData/dom/drawable/transitionHighlighting1.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/transitionHighlighting2.xml b/plugins/android/testData/dom/drawable/transitionHighlighting2.xml new file mode 100644 index 000000000000..c63d8615f68e --- /dev/null +++ b/plugins/android/testData/dom/drawable/transitionHighlighting2.xml @@ -0,0 +1,9 @@ + + + + + + + <bitmap/> + + \ No newline at end of file diff --git a/plugins/android/testSrc/org/jetbrains/android/dom/AndroidColorStateListDomTest.java b/plugins/android/testSrc/org/jetbrains/android/dom/AndroidColorStateListDomTest.java index e86c6615127c..72dcd59c1058 100644 --- a/plugins/android/testSrc/org/jetbrains/android/dom/AndroidColorStateListDomTest.java +++ b/plugins/android/testSrc/org/jetbrains/android/dom/AndroidColorStateListDomTest.java @@ -57,5 +57,9 @@ public class AndroidColorStateListDomTest extends AndroidDomTest { public void testStateListCompletion5() throws Throwable { doTestCompletion(); } + + public void testRootTagCompletion() throws Throwable { + doTestCompletionVariants(getTestName(false) + ".xml", "selector"); + } } diff --git a/plugins/android/testSrc/org/jetbrains/android/dom/AndroidDrawableResourcesDomTest.java b/plugins/android/testSrc/org/jetbrains/android/dom/AndroidDrawableResourcesDomTest.java index a7a5a28f1409..81c84edcab8d 100644 --- a/plugins/android/testSrc/org/jetbrains/android/dom/AndroidDrawableResourcesDomTest.java +++ b/plugins/android/testSrc/org/jetbrains/android/dom/AndroidDrawableResourcesDomTest.java @@ -73,6 +73,10 @@ public class AndroidDrawableResourcesDomTest extends AndroidDomTest { doTestHighlighting(); } + public void testBitmapHighlighting3() throws Throwable { + doTestHighlighting(); + } + public void testBitmapCompletion1() throws Throwable { doTestCompletion(); } @@ -97,6 +101,123 @@ public class AndroidDrawableResourcesDomTest extends AndroidDomTest { doTestOnlyDrawableReferences(); } + public void testLayerListHighlighting() throws Throwable { + doTestHighlighting(); + } + + public void testLayerListCompletion1() throws Throwable { + doTestCompletion(); + } + + public void testLayerListCompletion2() throws Throwable { + doTestOnlyDrawableReferences(); + } + + public void testLayerListCompletion3() throws Throwable { + doTestCompletion(); + } + + public void testLevelListHighlighting() throws Throwable { + doTestHighlighting(); + } + + public void testLevelListCompletion1() throws Throwable { + doTestOnlyDrawableReferences(); + } + + public void testLevelListCompletion2() throws Throwable { + doTestCompletion(); + } + + public void testLevelListCompletion3() throws Throwable { + doTestCompletion(); + } + + public void testTransitionHighlighting1() throws Throwable { + doTestHighlighting(); + } + + public void testTransitionHighlighting2() throws Throwable { + doTestHighlighting(); + } + + public void testTransitionCompletion1() throws Throwable { + doTestCompletion(); + } + + public void testTransitionCompletion2() throws Throwable { + doTestCompletion(); + } + + public void testInsetHighlighting1() throws Throwable { + doTestHighlighting(); + } + + public void testInsetHighlighting2() throws Throwable { + doTestHighlighting(); + } + + public void testInsetCompletion1() throws Throwable { + doTestCompletion(); + } + + public void testInsetCompletion2() throws Throwable { + doTestOnlyDrawableReferences(); + } + + public void testClipHighlighting() throws Throwable { + doTestHighlighting(); + } + + public void testClipCompletion1() throws Throwable { + doTestCompletion(); + } + + public void testClipCompletion2() throws Throwable { + doTestOnlyDrawableReferences(); + } + + public void testScaleHighlighting1() throws Throwable { + doTestHighlighting(); + } + + public void testScaleHighlighting2() throws Throwable { + doTestHighlighting(); + } + + public void testScaleHighlighting3() throws Throwable { + doTestHighlighting(); + } + + public void testScaleCompletion1() throws Throwable { + doTestCompletion(); + } + + public void testScaleCompletion2() throws Throwable { + doTestOnlyDrawableReferences(); + } + + public void testShapeHighlighting() throws Throwable { + doTestHighlighting(); + } + + public void testShapeCompletion1() throws Throwable { + doTestCompletion(); + } + + public void testShapeCompletion2() throws Throwable { + doTestCompletionVariants(getTestName(true) + ".xml", "gradient", "solid", "size", "stroke", "padding", "corners"); + } + + public void testIncorrectRootTag() throws Throwable { + doTestHighlighting(); + } + + public void testRootTagCompletion() throws Throwable { + doTestCompletionVariants(getTestName(true) + ".xml", "selector", "bitmap", "nine-patch", "layer-list", "level-list", "transition", + "inset", "clip", "scale", "shape"); + } + private void doTestOnlyDrawableReferences() throws IOException { VirtualFile file = copyFileToProject(getTestName(true) + ".xml"); myFixture.configureFromExistingVirtualFile(file); @@ -104,13 +225,9 @@ public class AndroidDrawableResourcesDomTest extends AndroidDomTest { List lookupElementStrings = myFixture.getLookupElementStrings(); assertNotNull(lookupElementStrings); for (String s : lookupElementStrings) { - if (!s.startsWith("@android") && !s.startsWith("@drawable")) { + if (!s.startsWith("@android") && !s.startsWith("@drawable") && !s.startsWith("@color")) { fail("Variant " + s + " shouldn't be threre"); } } } - - public void testRootTagCompletion() throws Throwable { - doTestCompletionVariants(getTestName(true) + ".xml", "selector", "bitmap", "nine-patch"); - } } diff --git a/plugins/android/testSrc/org/jetbrains/android/dom/AndroidDrawableResourcesTest.java b/plugins/android/testSrc/org/jetbrains/android/dom/AndroidDrawableResourcesTest.java deleted file mode 100644 index 8c6269b5abcd..000000000000 --- a/plugins/android/testSrc/org/jetbrains/android/dom/AndroidDrawableResourcesTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.android.dom; - -import com.android.sdklib.SdkConstants; - -/** - * @author Eugene.Kudelevsky - */ -public class AndroidDrawableResourcesTest extends AndroidDomTest { - public AndroidDrawableResourcesTest() { - super(true, "dom/other"); - } - - @Override - public void setUp() throws Exception { - super.setUp(); - myFixture.copyFileToProject(SdkConstants.FN_ANDROID_MANIFEST_XML, SdkConstants.FN_ANDROID_MANIFEST_XML); - } - - @Override - protected String getPathToCopy(String testFileName) { - return "res/drawable/" + testFileName; - } - - public void testHighlighting() throws Throwable { - doTestHighlighting("1.xml"); - } -}