This commit is contained in:
Eugene Kudelevsky
2012-07-31 14:55:34 +04:00
parent b3de842fe2
commit 219ebdc2ce
3 changed files with 8 additions and 0 deletions
@@ -81,12 +81,14 @@ public class AndroidResourceReference extends PsiReferenceBase.Poly<XmlElement>
@Override
public PsiElement handleElementRename(String newElementName) throws IncorrectOperationException {
System.out.println("Handle element rename to " + newElementName);
if (newElementName.startsWith(AndroidResourceUtil.NEW_ID_PREFIX)) {
newElementName = AndroidResourceUtil.getResourceNameByReferenceText(newElementName);
}
ResourceValue value = myValue.getValue();
assert value != null;
String resType = value.getResourceType();
System.out.println("Restype: " + resType);
if (resType != null && newElementName != null) {
// todo: do not allow new value resource name to contain dot, because it is impossible to check if it file or value otherwise
@@ -94,6 +96,7 @@ public class AndroidResourceReference extends PsiReferenceBase.Poly<XmlElement>
final String newResName = newElementName.contains(".") // it is file
? AndroidCommonUtils.getResourceName(resType, newElementName)
: newElementName;
System.out.println("New res name: " + newResName);
myValue.setValue(ResourceValue.referenceTo(value.getPrefix(), value.getPackage(), resType, newResName));
}
return myValue.getXmlTag();
@@ -40,6 +40,7 @@ public class LazyValueResourceElementWrapper extends RenameableFakePsiElement im
throw new IncorrectOperationException(
"Cannot find resource '" + myResourceInfo.getName() + "' in file " + myResourceInfo.getContainingFile().getPath());
}
System.out.println("Lazy;set name: " + name);
return new ValueResourceElementWrapper(element).setName(name);
}
@@ -97,6 +98,7 @@ public class LazyValueResourceElementWrapper extends RenameableFakePsiElement im
public static PsiElement computeLazyElement(PsiElement element) {
if (element instanceof LazyValueResourceElementWrapper) {
element = ((LazyValueResourceElementWrapper)element).computeElement();
System.out.println("computed element" + element);
}
return element;
}
@@ -340,6 +340,7 @@ public class ValueResourceElementWrapper implements XmlAttributeValue, ResourceE
@Nullable
public PsiElement setName(@NonNls @NotNull String name) throws IncorrectOperationException {
System.out.println("Wrapper;set name: " + name);
if (AndroidResourceUtil.isIdDeclaration(myWrappee)) {
XmlAttribute attribute = (XmlAttribute)myWrappee.getParent();
attribute.setValue(name);
@@ -350,7 +351,9 @@ public class ValueResourceElementWrapper implements XmlAttributeValue, ResourceE
DomElement domElement = DomManager.getDomManager(getProject()).getDomElement(tag);
assert domElement instanceof ResourceElement;
ResourceElement resElement = (ResourceElement)domElement;
System.out.println("resElement: " + resElement + ", name to set: " + name);
resElement.getName().setValue(name);
System.out.println("setted: " + resElement.getName().getStringValue());
}
return null;
}