mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -26,7 +26,6 @@ package com.intellij.codeInsight.daemon.impl.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightUtilBase;
|
||||
import com.intellij.codeInsight.daemon.QuickFixBundle;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.codeInspection.LocalQuickFixAndIntentionActionOnPsiElement;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
|
||||
+13
-12
@@ -48,7 +48,7 @@ public class WrapExpressionFix implements IntentionAction {
|
||||
if (type instanceof PsiClassType) {
|
||||
return (PsiClassType)type;
|
||||
}
|
||||
else if (type instanceof PsiPrimitiveType){
|
||||
else if (type instanceof PsiPrimitiveType) {
|
||||
return ((PsiPrimitiveType)type).getBoxedType(place.getManager(), GlobalSearchScope.allScope(place.getProject()));
|
||||
}
|
||||
return null;
|
||||
@@ -73,10 +73,11 @@ public class WrapExpressionFix implements IntentionAction {
|
||||
if (expectedReturnType == null) return null;
|
||||
PsiMethod[] methods = aClass.getMethods();
|
||||
for (PsiMethod method : methods) {
|
||||
if (method.hasModifierProperty(PsiModifier.STATIC) && method.getParameterList().getParametersCount() == 1 &&
|
||||
method.getParameterList().getParameters()[0].getType().equals(type) &&
|
||||
method.getReturnType() != null &&
|
||||
expectedReturnType.equals(method.getReturnType())) {
|
||||
if (method.hasModifierProperty(PsiModifier.STATIC)
|
||||
&& method.getParameterList().getParametersCount() == 1
|
||||
&& method.getParameterList().getParameters()[0].getType().isAssignableFrom(type)
|
||||
&& method.getReturnType() != null
|
||||
&& expectedReturnType.equals(method.getReturnType())) {
|
||||
return method;
|
||||
}
|
||||
}
|
||||
@@ -108,10 +109,10 @@ public class WrapExpressionFix implements IntentionAction {
|
||||
assert wrapper != null;
|
||||
PsiElementFactory factory = JavaPsiFacade.getInstance(file.getProject()).getElementFactory();
|
||||
@NonNls String methodCallText = "Foo." + wrapper.getName() + "()";
|
||||
PsiMethodCallExpression call = (PsiMethodCallExpression) factory.createExpressionFromText(methodCallText,
|
||||
null);
|
||||
PsiMethodCallExpression call = (PsiMethodCallExpression)factory.createExpressionFromText(methodCallText,
|
||||
null);
|
||||
call.getArgumentList().add(myExpression);
|
||||
((PsiReferenceExpression) call.getMethodExpression().getQualifierExpression()).bindToElement(
|
||||
((PsiReferenceExpression)call.getMethodExpression().getQualifierExpression()).bindToElement(
|
||||
wrapper.getContainingClass());
|
||||
myExpression.replace(call);
|
||||
}
|
||||
@@ -121,7 +122,7 @@ public class WrapExpressionFix implements IntentionAction {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void registerWrapAction (JavaResolveResult[] candidates, PsiExpression[] expressions, HighlightInfo highlightInfo) {
|
||||
public static void registerWrapAction(JavaResolveResult[] candidates, PsiExpression[] expressions, HighlightInfo highlightInfo) {
|
||||
PsiType expectedType = null;
|
||||
PsiExpression expr = null;
|
||||
|
||||
@@ -138,7 +139,7 @@ public class WrapExpressionFix implements IntentionAction {
|
||||
PsiExpression expression = expressions[j];
|
||||
final PsiType exprType = expression.getType();
|
||||
if (exprType != null) {
|
||||
PsiType paramType = parameters[Math.min(j, parameters.length -1)].getType();
|
||||
PsiType paramType = parameters[Math.min(j, parameters.length - 1)].getType();
|
||||
if (paramType instanceof PsiEllipsisType) {
|
||||
paramType = ((PsiEllipsisType)paramType).getComponentType();
|
||||
}
|
||||
@@ -148,7 +149,8 @@ public class WrapExpressionFix implements IntentionAction {
|
||||
if (expectedType == null && classType != null && findWrapper(exprType, classType, paramType instanceof PsiPrimitiveType) != null) {
|
||||
expectedType = paramType;
|
||||
expr = expression;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
expectedType = null;
|
||||
expr = null;
|
||||
continue nextMethod;
|
||||
@@ -161,5 +163,4 @@ public class WrapExpressionFix implements IntentionAction {
|
||||
QuickFixAction.registerQuickFixAction(highlightInfo, expr.getTextRange(), new WrapExpressionFix(expectedType, expr));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,15 +23,17 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class ResourceEntry {
|
||||
private final String myType;
|
||||
private final String myName;
|
||||
private final String myContext;
|
||||
|
||||
public ResourceEntry(@NotNull String type, @NotNull String name) {
|
||||
public ResourceEntry(@NotNull String type, @NotNull String name, @NotNull String context) {
|
||||
myType = type;
|
||||
myName = name;
|
||||
myContext = context;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getType() {
|
||||
return myType;
|
||||
public String getContext() {
|
||||
return myContext;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -39,28 +41,30 @@ public class ResourceEntry {
|
||||
return myName;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getType() {
|
||||
return myType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
ResourceEntry entry = (ResourceEntry)o;
|
||||
ResourceEntry that = (ResourceEntry)o;
|
||||
|
||||
if (!myName.equals(entry.myName)) return false;
|
||||
if (!myType.equals(entry.myType)) return false;
|
||||
if (!myContext.equals(that.myContext)) return false;
|
||||
if (!myName.equals(that.myName)) return false;
|
||||
if (!myType.equals(that.myType)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[" + myType + ":" + myName + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = myType.hashCode();
|
||||
result = 31 * result + myName.hashCode();
|
||||
result = 31 * result + myContext.hashCode();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
+16
-3
@@ -16,6 +16,7 @@
|
||||
package org.jetbrains.android.util;
|
||||
|
||||
import com.android.resources.ResourceType;
|
||||
import com.intellij.util.containers.Stack;
|
||||
import net.n3.nanoxml.IXMLBuilder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -29,6 +30,7 @@ public abstract class ValueResourcesFileParser implements IXMLBuilder {
|
||||
private boolean mySeenResources;
|
||||
private String myLastTypeAttr;
|
||||
private String myLastNameAttr;
|
||||
private final Stack<String> myContextNames = new Stack<String>();
|
||||
|
||||
public ValueResourcesFileParser() {
|
||||
mySeenResources = false;
|
||||
@@ -75,17 +77,28 @@ public abstract class ValueResourcesFileParser implements IXMLBuilder {
|
||||
@Override
|
||||
public void elementAttributesProcessed(String name, String nsPrefix, String nsURI) throws Exception {
|
||||
if (myLastNameAttr != null && name != null) {
|
||||
final String resType = "item".equals(name)
|
||||
final String resTypeStr = "item".equals(name)
|
||||
? myLastTypeAttr
|
||||
: AndroidCommonUtils.getResourceTypeByTagName(name);
|
||||
if (resType != null && ResourceType.getEnum(resType) != null) {
|
||||
process(new ResourceEntry(resType, myLastNameAttr));
|
||||
final ResourceType resType = resTypeStr != null ? ResourceType.getEnum(resTypeStr) : null;
|
||||
if (resType != null) {
|
||||
if (resType == ResourceType.ATTR) {
|
||||
if (!myLastNameAttr.startsWith("android:")) {
|
||||
final String contextName = myContextNames.peek();
|
||||
process(new ResourceEntry(resTypeStr, myLastNameAttr, contextName));
|
||||
}
|
||||
}
|
||||
else {
|
||||
process(new ResourceEntry(resTypeStr, myLastNameAttr, ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
myContextNames.push(myLastNameAttr != null ? myLastNameAttr : "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endElement(String name, String nsPrefix, String nsURI) throws Exception {
|
||||
myContextNames.pop();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+6
-2
@@ -46,7 +46,8 @@ public class AndroidAptValidityState implements ValidityState {
|
||||
for (int j = 0; j < entriesCount; j++) {
|
||||
final String resType = in.readUTF();
|
||||
final String resName = in.readUTF();
|
||||
entries.add(new ResourceEntry(resType, resName));
|
||||
final String resContext = in.readUTF();
|
||||
entries.add(new ResourceEntry(resType, resName, resContext));
|
||||
}
|
||||
final long timestamp = in.readLong();
|
||||
myResources.put(filePath, new ResourceFileData(entries, timestamp));
|
||||
@@ -58,7 +59,8 @@ public class AndroidAptValidityState implements ValidityState {
|
||||
for (int i = 0; i < manifestElementCount; i++) {
|
||||
final String elementType = in.readUTF();
|
||||
final String elementName = in.readUTF();
|
||||
myManifestElements.add(new ResourceEntry(elementType, elementName));
|
||||
final String elementContext = in.readUTF();
|
||||
myManifestElements.add(new ResourceEntry(elementType, elementName, elementContext));
|
||||
}
|
||||
|
||||
final int libPackageCount = in.readInt();
|
||||
@@ -97,6 +99,7 @@ public class AndroidAptValidityState implements ValidityState {
|
||||
for (ResourceEntry resource : resources) {
|
||||
out.writeUTF(resource.getType());
|
||||
out.writeUTF(resource.getName());
|
||||
out.writeUTF(resource.getContext());
|
||||
}
|
||||
out.writeLong(fileData.getTimestamp());
|
||||
}
|
||||
@@ -105,6 +108,7 @@ public class AndroidAptValidityState implements ValidityState {
|
||||
for (ResourceEntry manifestElement : myManifestElements) {
|
||||
out.writeUTF(manifestElement.getType());
|
||||
out.writeUTF(manifestElement.getName());
|
||||
out.writeUTF(manifestElement.getContext());
|
||||
}
|
||||
out.writeInt(myLibPackages.size());
|
||||
|
||||
|
||||
+1
-1
@@ -855,7 +855,7 @@ public class AndroidSourceGeneratingBuilder extends ModuleLevelBuilder {
|
||||
public void elementAttributesProcessed(String name, String nsPrefix, String nsURI) throws Exception {
|
||||
if (myLastName != null && PERMISSION_TAG.equals(name) || PERMISSION_GROUP_TAG.equals(name)) {
|
||||
assert myLastName != null;
|
||||
result.add(new ResourceEntry(name, myLastName));
|
||||
result.add(new ResourceEntry(name, myLastName, ""));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<${ROOT_TAG} xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
</${ROOT_TAG}>
|
||||
@@ -0,0 +1,5 @@
|
||||
<html>
|
||||
<body>
|
||||
<p>This is a built-in file template used to create vertical-oriented layout xml files in Android applications.</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -147,9 +147,6 @@
|
||||
<completion.contributor language="XML" implementationClass="org.jetbrains.android.AndroidCompletionContributor"
|
||||
id="compositieAttributeValues" order="first"/>
|
||||
|
||||
<!--<codeInsight.lineMarkerProvider language="JAVA" implementationClass="org.jetbrains.android.AndroidResourcesLineMarkerProvider"/>
|
||||
<codeInsight.lineMarkerProvider language="XML" implementationClass="org.jetbrains.android.AndroidResourcesLineMarkerProvider"/>-->
|
||||
|
||||
<renamePsiElementProcessor implementation="org.jetbrains.android.AndroidRenameResourceProcessor" order="first"/>
|
||||
<intentionAction>
|
||||
<className>org.jetbrains.android.intentions.AndroidAddStringResourceAction</className>
|
||||
|
||||
@@ -41,6 +41,7 @@ public class AndroidFileTemplateProvider implements FileTemplateGroupDescriptorF
|
||||
@NonNls public static final String VALUE_RESOURCE_FILE_TEMPLATE = "valueResourceFile.xml";
|
||||
@NonNls public static final String RESOURCE_FILE_TEMPLATE = "resourceFile.xml";
|
||||
@NonNls public static final String LAYOUT_RESOURCE_FILE_TEMPLATE = "layoutResourceFile.xml";
|
||||
@NonNls public static final String LAYOUT_RESOURCE_VERTICAL_FILE_TEMPLATE = "layoutResourceFile_vertical.xml";
|
||||
@NonNls public static final String ACTIVITY = "Activity.java";
|
||||
@NonNls public static final String APPLICATION = "Application.java";
|
||||
@NonNls public static final String SERVICE = "Service.java";
|
||||
@@ -53,6 +54,7 @@ public class AndroidFileTemplateProvider implements FileTemplateGroupDescriptorF
|
||||
group.addTemplate(new FileTemplateDescriptor(VALUE_RESOURCE_FILE_TEMPLATE, StdFileTypes.XML.getIcon()));
|
||||
group.addTemplate(new FileTemplateDescriptor(RESOURCE_FILE_TEMPLATE, StdFileTypes.XML.getIcon()));
|
||||
group.addTemplate(new FileTemplateDescriptor(LAYOUT_RESOURCE_FILE_TEMPLATE, StdFileTypes.XML.getIcon()));
|
||||
group.addTemplate(new FileTemplateDescriptor(LAYOUT_RESOURCE_VERTICAL_FILE_TEMPLATE, StdFileTypes.XML.getIcon()));
|
||||
group.addTemplate(new FileTemplateDescriptor(ACTIVITY, StdFileTypes.JAVA.getIcon()));
|
||||
group.addTemplate(new FileTemplateDescriptor(APPLICATION, StdFileTypes.JAVA.getIcon()));
|
||||
group.addTemplate(new FileTemplateDescriptor(SERVICE, StdFileTypes.JAVA.getIcon()));
|
||||
|
||||
@@ -1,372 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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;
|
||||
|
||||
import com.android.resources.ResourceType;
|
||||
import com.intellij.codeHighlighting.Pass;
|
||||
import com.intellij.codeInsight.daemon.GutterIconNavigationHandler;
|
||||
import com.intellij.codeInsight.daemon.LineMarkerInfo;
|
||||
import com.intellij.codeInsight.daemon.LineMarkerProvider;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.psi.xml.XmlAttribute;
|
||||
import com.intellij.psi.xml.XmlAttributeValue;
|
||||
import com.intellij.psi.xml.XmlTag;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.util.ConstantFunction;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import com.intellij.util.xml.GenericAttributeValue;
|
||||
import org.jetbrains.android.dom.resources.Attr;
|
||||
import org.jetbrains.android.dom.resources.DeclareStyleable;
|
||||
import org.jetbrains.android.dom.resources.ResourceElement;
|
||||
import org.jetbrains.android.dom.resources.Resources;
|
||||
import org.jetbrains.android.facet.AndroidFacet;
|
||||
import org.jetbrains.android.resourceManagers.LocalResourceManager;
|
||||
import org.jetbrains.android.util.AndroidCommonUtils;
|
||||
import org.jetbrains.android.util.AndroidResourceUtil;
|
||||
import org.jetbrains.android.util.AndroidUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author coyote
|
||||
*/
|
||||
public class AndroidResourcesLineMarkerProvider implements LineMarkerProvider {
|
||||
private static final Icon ICON = IconLoader.getIcon("/icons/navigate.png");
|
||||
|
||||
public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement psiElement) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void collectSlowLineMarkers(@NotNull List<PsiElement> psiElements, @NotNull Collection<LineMarkerInfo> lineMarkerInfos) {
|
||||
//noinspection ForLoopReplaceableByForEach
|
||||
for (int i = 0; i < psiElements.size(); i++) {
|
||||
PsiElement element = psiElements.get(i);
|
||||
addMarkerInfo(element, lineMarkerInfos);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String getToolTip(@NotNull PsiElement element) {
|
||||
String s = "Go to ";
|
||||
if (element instanceof PsiField) {
|
||||
PsiField field = (PsiField)element;
|
||||
PsiClass resClass = field.getContainingClass();
|
||||
assert resClass != null;
|
||||
PsiClass rClass = resClass.getContainingClass();
|
||||
assert rClass != null;
|
||||
return s + rClass.getName() + '.' + resClass.getName() + '.' + field.getName();
|
||||
}
|
||||
else {
|
||||
final PsiFile file = AndroidUtils.getContainingFile(element);
|
||||
if (file == null) {
|
||||
return s;
|
||||
}
|
||||
final PsiFile originalFile = file.getOriginalFile();
|
||||
String name = originalFile.getName();
|
||||
PsiDirectory dir = originalFile.getContainingDirectory();
|
||||
if (dir == null) return s + name;
|
||||
return s + dir.getName() + '/' + name;
|
||||
}
|
||||
}
|
||||
|
||||
private static LineMarkerInfo createLineMarkerInfo(@NotNull PsiElement element, @NotNull PsiElement... targets) {
|
||||
final String toolTip = targets.length == 1 ? getToolTip(targets[0]) : "Resource not found";
|
||||
return new LineMarkerInfo<PsiElement>(element,
|
||||
element.getTextOffset(),
|
||||
ICON,
|
||||
Pass.UPDATE_OVERRIDEN_MARKERS,
|
||||
new ConstantFunction<PsiElement, String>(toolTip),
|
||||
new MyNavigationHandler(targets));
|
||||
}
|
||||
|
||||
private static LineMarkerInfo createLazyLineMarkerInfo(@NotNull PsiElement element,
|
||||
@NotNull final Computable<PsiElement[]> targetProvider) {
|
||||
return new LineMarkerInfo<PsiElement>(element,
|
||||
element.getTextOffset(),
|
||||
ICON,
|
||||
Pass.UPDATE_OVERRIDEN_MARKERS,
|
||||
new ConstantFunction<PsiElement, String>("Go to resource"),
|
||||
new MyLazyNavigationHandler(targetProvider));
|
||||
}
|
||||
|
||||
private static void annotateXmlAttributeValue(@NotNull XmlAttributeValue attrValue, @NotNull Collection<LineMarkerInfo> result) {
|
||||
final AndroidFacet facet = AndroidFacet.getInstance(attrValue);
|
||||
if (facet != null) {
|
||||
PsiElement parent = attrValue.getParent();
|
||||
if (!(parent instanceof XmlAttribute)) return;
|
||||
final XmlAttribute attr = (XmlAttribute)parent;
|
||||
if (attr.getLocalName().equals("name")) {
|
||||
final XmlTag tag = PsiTreeUtil.getParentOfType(attr, XmlTag.class);
|
||||
if (tag != null) {
|
||||
String fileResType = facet.getLocalResourceManager().getFileResourceType(tag.getContainingFile());
|
||||
final String resType = "values".equals(fileResType) ? AndroidResourceUtil.getResourceTypeByValueResourceTag(tag) : null;
|
||||
if (resType != null) {
|
||||
result.add(createLazyLineMarkerInfo(tag, new Computable<PsiElement[]>() {
|
||||
@Override
|
||||
public PsiElement[] compute() {
|
||||
String name = tag.getAttributeValue("name");
|
||||
return name != null ? AndroidResourceUtil.findResourceFields(facet, resType, name, false) : PsiElement.EMPTY_ARRAY;
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (AndroidResourceUtil.isIdDeclaration(attrValue)) {
|
||||
result.add(createLazyLineMarkerInfo(attrValue, new Computable<PsiElement[]>() {
|
||||
@Override
|
||||
public PsiElement[] compute() {
|
||||
return AndroidResourceUtil.findIdFields(attr);
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void addMarkerInfo(@NotNull final PsiElement element, @NotNull Collection<LineMarkerInfo> result) {
|
||||
if (element instanceof PsiFile) {
|
||||
PsiField[] fields = AndroidResourceUtil.findResourceFieldsForFileResource((PsiFile)element, false);
|
||||
if (fields.length > 0) result.add(createLineMarkerInfo(element, fields));
|
||||
}
|
||||
else if (element instanceof PsiClass) {
|
||||
PsiClass c = (PsiClass)element;
|
||||
if (AndroidUtils.R_CLASS_NAME.equals(c.getName())) {
|
||||
PsiFile containingFile = element.getContainingFile();
|
||||
AndroidFacet facet = AndroidFacet.getInstance(containingFile);
|
||||
if (facet != null && AndroidResourceUtil.isRJavaFile(facet, containingFile)) {
|
||||
LocalResourceManager manager = facet.getLocalResourceManager();
|
||||
annotateRClass((PsiClass)element, result, manager);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (element instanceof XmlAttributeValue) {
|
||||
annotateXmlAttributeValue((XmlAttributeValue)element, result);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Map<MyResourceEntry, List<PsiElement>> buildLocalResourceMap(@NotNull Project project,
|
||||
@NotNull final LocalResourceManager resManager) {
|
||||
final Map<MyResourceEntry, List<PsiElement>> result = new HashMap<MyResourceEntry, List<PsiElement>>();
|
||||
List<Pair<Resources,VirtualFile>> resourceFiles = resManager.getResourceElements();
|
||||
for (Pair<Resources, VirtualFile> pair : resourceFiles) {
|
||||
final Resources res = pair.getFirst();
|
||||
for (ResourceType valueResourceType : AndroidResourceUtil.VALUE_RESOURCE_TYPES) {
|
||||
for (ResourceElement valueResource : AndroidResourceUtil.getValueResourcesFromElement(valueResourceType.getName(), res)) {
|
||||
addResource(valueResourceType.getName(), valueResource, result);
|
||||
}
|
||||
}
|
||||
for (Attr attr : res.getAttrs()) {
|
||||
addResource("attr", attr, result);
|
||||
}
|
||||
for (DeclareStyleable styleable : res.getDeclareStyleables()) {
|
||||
addResource("styleable", styleable, result);
|
||||
for (Attr attr : styleable.getAttrs()) {
|
||||
addResource("attr", attr, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
collectFileResources(project, resManager, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void collectFileResources(Project project,
|
||||
final LocalResourceManager resManager,
|
||||
final Map<MyResourceEntry, List<PsiElement>> result) {
|
||||
final PsiManager psiManager = PsiManager.getInstance(project);
|
||||
ApplicationManager.getApplication().runReadAction(new Runnable() {
|
||||
public void run() {
|
||||
List<VirtualFile> resourceSubdirs = resManager.getResourceSubdirs(null);
|
||||
for (VirtualFile dir : resourceSubdirs) {
|
||||
String resType = AndroidCommonUtils.getResourceTypeByDirName(dir.getName());
|
||||
if (resType != null) {
|
||||
for (VirtualFile resourceFile : dir.getChildren()) {
|
||||
if (!resourceFile.isDirectory()) {
|
||||
PsiFile resourcePsiFile = psiManager.findFile(resourceFile);
|
||||
if (resourcePsiFile != null) {
|
||||
String resName = AndroidCommonUtils.getResourceName(resType, resourceFile.getName());
|
||||
MyResourceEntry key = new MyResourceEntry(resName, resType);
|
||||
List<PsiElement> list = result.get(key);
|
||||
if (list == null) {
|
||||
list = new ArrayList<PsiElement>();
|
||||
result.put(key, list);
|
||||
}
|
||||
list.add(resourcePsiFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void addResource(String resType, ResourceElement resElement, Map<MyResourceEntry, List<PsiElement>> result) {
|
||||
GenericAttributeValue<String> nameValue = resElement.getName();
|
||||
if (nameValue != null) {
|
||||
String name = nameValue.getValue();
|
||||
if (name != null) {
|
||||
MyResourceEntry key = new MyResourceEntry(name, resType);
|
||||
List<PsiElement> list = result.get(key);
|
||||
if (list == null) {
|
||||
list = new ArrayList<PsiElement>();
|
||||
result.put(key, list);
|
||||
}
|
||||
list.add(nameValue.getXmlAttributeValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void annotateRClass(@NotNull PsiClass rClass,
|
||||
@NotNull Collection<LineMarkerInfo> result,
|
||||
@NotNull LocalResourceManager manager) {
|
||||
Map<MyResourceEntry, List<PsiElement>> resourceMap = buildLocalResourceMap(rClass.getProject(), manager);
|
||||
for (PsiClass c : rClass.getInnerClasses()) {
|
||||
for (PsiField field : c.getFields()) {
|
||||
annotateElementNavToResource(field, field, manager, result, resourceMap, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void annotateElementNavToResource(PsiElement element,
|
||||
final PsiField resField,
|
||||
final LocalResourceManager manager,
|
||||
Collection<LineMarkerInfo> result,
|
||||
@Nullable final Map<MyResourceEntry, List<PsiElement>> resourceMap,
|
||||
boolean lazy) {
|
||||
final String fieldName = resField.getName();
|
||||
if (fieldName != null) {
|
||||
final String resType = AndroidResourceUtil.getResourceClassName(resField);
|
||||
if (resType != null) {
|
||||
Computable<PsiElement[]> targetProvider = new Computable<PsiElement[]>() {
|
||||
@Override
|
||||
public PsiElement[] compute() {
|
||||
final List<PsiElement> targets;
|
||||
if (resourceMap != null) {
|
||||
targets = new ArrayList<PsiElement>();
|
||||
if (resType.equals("id")) {
|
||||
targets.addAll(manager.findIdDeclarations(fieldName));
|
||||
}
|
||||
List<PsiElement> resources = resourceMap.get(new MyResourceEntry(fieldName, resType));
|
||||
if (resources != null) {
|
||||
targets.addAll(resources);
|
||||
}
|
||||
}
|
||||
else {
|
||||
targets = manager.findResourcesByField(resField);
|
||||
}
|
||||
return PsiUtilCore.toPsiElementArray(targets);
|
||||
}
|
||||
};
|
||||
if (lazy) {
|
||||
result.add(createLazyLineMarkerInfo(element, targetProvider));
|
||||
}
|
||||
else {
|
||||
PsiElement[] targets = targetProvider.compute();
|
||||
if (targets != null && targets.length > 0) {
|
||||
result.add(createLineMarkerInfo(element, targets));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class MyResourceEntry {
|
||||
final String myName;
|
||||
final String myType;
|
||||
|
||||
private MyResourceEntry(@NotNull String name, @NotNull String type) {
|
||||
myName = name;
|
||||
myType = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
MyResourceEntry that = (MyResourceEntry)o;
|
||||
|
||||
if (!AndroidUtils.equal(myName, that.myName, false)) return false;
|
||||
if (!myType.equals(that.myType)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = 0;
|
||||
for (int i = 0; i < myName.length(); i++) {
|
||||
char c = myName.charAt(i);
|
||||
if (Character.isLetterOrDigit(c)) {
|
||||
result = 31 * result + (int)c;
|
||||
}
|
||||
}
|
||||
result = 31 * result + myType.hashCode();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public static class MyNavigationHandler implements GutterIconNavigationHandler<PsiElement> {
|
||||
private final PsiElement[] myTargets;
|
||||
|
||||
private MyNavigationHandler(@NotNull PsiElement[] targets) {
|
||||
myTargets = targets;
|
||||
}
|
||||
|
||||
public void navigate(MouseEvent event, PsiElement psiElement) {
|
||||
AndroidUtils.navigateTo(myTargets, event != null ? new RelativePoint(event) : null);
|
||||
}
|
||||
|
||||
public PsiElement[] getTargets() {
|
||||
return myTargets;
|
||||
}
|
||||
}
|
||||
|
||||
public static class MyLazyNavigationHandler implements GutterIconNavigationHandler<PsiElement> {
|
||||
private final Computable<PsiElement[]> myTargetProvider;
|
||||
|
||||
private MyLazyNavigationHandler(Computable<PsiElement[]> targetProvider) {
|
||||
myTargetProvider = targetProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void navigate(MouseEvent event, PsiElement psiElement) {
|
||||
PsiElement[] targets = myTargetProvider.compute();
|
||||
if (targets != null && targets.length > 0) {
|
||||
AndroidUtils.navigateTo(targets, event != null ? new RelativePoint(event) : null);
|
||||
}
|
||||
}
|
||||
|
||||
public Computable<PsiElement[]> getTargetProvider() {
|
||||
return myTargetProvider;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,15 +57,8 @@ public class AndroidValueResourcesIndex extends FileBasedIndexExtension<Resource
|
||||
@Override
|
||||
protected void process(@NotNull ResourceEntry entry) {
|
||||
result.put(entry, Collections.<ResourceEntry>emptySet());
|
||||
|
||||
final ResourceEntry typeMarkerEntry = createTypeMarkerEntry(entry.getType());
|
||||
Set<ResourceEntry> set = result.get(typeMarkerEntry);
|
||||
|
||||
if (set == null) {
|
||||
set = new HashSet<ResourceEntry>();
|
||||
result.put(typeMarkerEntry, set);
|
||||
}
|
||||
set.add(entry);
|
||||
addEntryToMap(entry, createTypeMarkerEntry(entry.getType()), result);
|
||||
addEntryToMap(entry, createTypeNameMarkerEntry(entry.getType(), entry.getName()), result);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -73,8 +66,22 @@ public class AndroidValueResourcesIndex extends FileBasedIndexExtension<Resource
|
||||
}
|
||||
};
|
||||
|
||||
private static void addEntryToMap(ResourceEntry entry, ResourceEntry marker, Map<ResourceEntry, Set<ResourceEntry>> result) {
|
||||
Set<ResourceEntry> set = result.get(marker);
|
||||
|
||||
if (set == null) {
|
||||
set = new HashSet<ResourceEntry>();
|
||||
result.put(marker, set);
|
||||
}
|
||||
set.add(entry);
|
||||
}
|
||||
|
||||
public static ResourceEntry createTypeMarkerEntry(String type) {
|
||||
return new ResourceEntry(type, "TYPE_MARKER_RESOURCE");
|
||||
return new ResourceEntry(type, "TYPE_MARKER_RESOURCE", "TYPE_MARKER_CONTEXT");
|
||||
}
|
||||
|
||||
public static ResourceEntry createTypeNameMarkerEntry(String type, String name) {
|
||||
return new ResourceEntry(type, name, "TYPE_MARKER_CONTEXT");
|
||||
}
|
||||
|
||||
private final KeyDescriptor<ResourceEntry> myKeyDescriptor = new KeyDescriptor<ResourceEntry>() {
|
||||
@@ -82,13 +89,15 @@ public class AndroidValueResourcesIndex extends FileBasedIndexExtension<Resource
|
||||
public void save(DataOutput out, ResourceEntry value) throws IOException {
|
||||
out.writeUTF(value.getType());
|
||||
out.writeUTF(value.getName());
|
||||
out.writeUTF(value.getContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceEntry read(DataInput in) throws IOException {
|
||||
final String resType = in.readUTF();
|
||||
final String resName = in.readUTF();
|
||||
return new ResourceEntry(resType, resName);
|
||||
final String resContext = in.readUTF();
|
||||
return new ResourceEntry(resType, resName, resContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -108,7 +117,9 @@ public class AndroidValueResourcesIndex extends FileBasedIndexExtension<Resource
|
||||
out.writeInt(value.size());
|
||||
|
||||
for (ResourceEntry entry : value) {
|
||||
myKeyDescriptor.save(out, entry);
|
||||
out.writeUTF(entry.getType());
|
||||
out.writeUTF(entry.getName());
|
||||
out.writeUTF(entry.getContext());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +134,10 @@ public class AndroidValueResourcesIndex extends FileBasedIndexExtension<Resource
|
||||
final Set<ResourceEntry> result = new HashSet<ResourceEntry>(size);
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
result.add(myKeyDescriptor.read(in));
|
||||
final String type = in.readUTF();
|
||||
final String name = in.readUTF();
|
||||
final String context = in.readUTF();
|
||||
result.add(new ResourceEntry(type, name, context));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -163,6 +177,6 @@ public class AndroidValueResourcesIndex extends FileBasedIndexExtension<Resource
|
||||
|
||||
@Override
|
||||
public int getVersion() {
|
||||
return 0;
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -39,6 +39,7 @@ import com.intellij.xml.refactoring.XmlTagInplaceRenamer;
|
||||
import org.jetbrains.android.facet.AndroidFacet;
|
||||
import org.jetbrains.android.util.AndroidBundle;
|
||||
import org.jetbrains.android.util.AndroidResourceUtil;
|
||||
import org.jetbrains.android.util.AndroidUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -65,7 +66,7 @@ public class CreateTypedResourceFileAction extends CreateElementActionBase {
|
||||
AndroidBundle.message("new.typed.resource.action.description", resourcePresentableName), StdFileTypes.XML.getIcon());
|
||||
myResourceType = resourceFolderType;
|
||||
myResourcePresentableName = resourcePresentableName;
|
||||
myDefaultRootTag = getDefaultRootTabByResourceType(resourceFolderType);
|
||||
myDefaultRootTag = getDefaultRootTagByResourceType(resourceFolderType);
|
||||
myValuesResourceFile = valuesResourceFile;
|
||||
myChooseTagName = chooseTagName;
|
||||
}
|
||||
@@ -180,7 +181,7 @@ public class CreateTypedResourceFileAction extends CreateElementActionBase {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getDefaultRootTabByResourceType(@NotNull ResourceFolderType resourceType) {
|
||||
public static String getDefaultRootTagByResourceType(@NotNull ResourceFolderType resourceType) {
|
||||
switch (resourceType) {
|
||||
case XML:
|
||||
return "PreferenceScreen";
|
||||
@@ -197,7 +198,7 @@ public class CreateTypedResourceFileAction extends CreateElementActionBase {
|
||||
case ANIMATOR:
|
||||
return "set";
|
||||
case LAYOUT:
|
||||
return "LinearLayout";
|
||||
return AndroidUtils.TAG_LINEAR_LAYOUT;
|
||||
default:
|
||||
}
|
||||
throw new IllegalArgumentException("Incorrect resource folder type");
|
||||
|
||||
@@ -1,30 +1,48 @@
|
||||
package org.jetbrains.android.augment;
|
||||
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiType;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiClassImplUtil;
|
||||
import com.intellij.psi.impl.PsiVariableEx;
|
||||
import com.intellij.psi.impl.light.LightFieldBuilder;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Eugene.Kudelevsky
|
||||
*/
|
||||
class AndroidLightField extends LightFieldBuilder {
|
||||
class AndroidLightField extends LightFieldBuilder implements PsiVariableEx {
|
||||
private final PsiClass myContext;
|
||||
private final PsiType myType;
|
||||
private final Object myConstantValue;
|
||||
private final boolean myFinal;
|
||||
|
||||
public AndroidLightField(@NotNull String name,
|
||||
@NotNull PsiClass context,
|
||||
@NotNull PsiType type) {
|
||||
@NotNull PsiType type,
|
||||
boolean isFinal,
|
||||
@Nullable Object constantValue) {
|
||||
super(name, type, context);
|
||||
myContext = context;
|
||||
myType = type;
|
||||
myConstantValue = constantValue;
|
||||
myFinal = isFinal;
|
||||
setContainingClass(context);
|
||||
|
||||
final List<String> modifiers = new ArrayList<String>();
|
||||
modifiers.add(PsiModifier.PUBLIC);
|
||||
modifiers.add(PsiModifier.STATIC);
|
||||
|
||||
if (isFinal) {
|
||||
modifiers.add(PsiModifier.FINAL);
|
||||
}
|
||||
setModifiers(ArrayUtil.toStringArray(modifiers));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -40,6 +58,18 @@ class AndroidLightField extends LightFieldBuilder {
|
||||
|
||||
@Override
|
||||
public PsiElement setName(@NonNls @NotNull String name) throws IncorrectOperationException {
|
||||
return new AndroidLightField(name, myContext, myType);
|
||||
final AndroidLightField field = new AndroidLightField(name, myContext, myType, myFinal, myConstantValue);
|
||||
field.setInitializer(getInitializer());
|
||||
return field;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object computeConstantValue(Set<PsiVariable> visitedVars) {
|
||||
return computeConstantValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object computeConstantValue() {
|
||||
return myConstantValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,8 +44,8 @@ abstract class ManifestInnerClass extends AndroidLightClass {
|
||||
final PsiElementFactory factory = JavaPsiFacade.getElementFactory(getProject());
|
||||
int i = 0;
|
||||
for (Pair<String, String> pair : pairs) {
|
||||
final AndroidLightField field = new AndroidLightField(pair.getFirst(), ManifestInnerClass.this, stringType);
|
||||
field.setModifiers(PsiModifier.PUBLIC, PsiModifier.STATIC);
|
||||
final AndroidLightField field =
|
||||
new AndroidLightField(pair.getFirst(), ManifestInnerClass.this, stringType, true, pair.getSecond());
|
||||
field.setInitializer(factory.createExpressionFromText("\"" + pair.getSecond() + "\"", field));
|
||||
result[i++] = field;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,21 @@
|
||||
package org.jetbrains.android.augment;
|
||||
|
||||
import com.android.resources.ResourceType;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.CachedValue;
|
||||
import com.intellij.psi.util.CachedValueProvider;
|
||||
import com.intellij.psi.util.CachedValuesManager;
|
||||
import com.intellij.psi.util.PsiModificationTracker;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import org.jetbrains.android.compiler.AndroidCompileUtil;
|
||||
import org.jetbrains.android.facet.AndroidFacet;
|
||||
import org.jetbrains.android.resourceManagers.LocalResourceManager;
|
||||
import org.jetbrains.android.util.AndroidResourceUtil;
|
||||
import org.jetbrains.android.util.ResourceEntry;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Eugene.Kudelevsky
|
||||
@@ -43,16 +48,36 @@ class ResourceTypeClass extends AndroidLightClass {
|
||||
static PsiField[] buildResourceFields(@NotNull AndroidFacet facet,
|
||||
@NotNull String resClassName,
|
||||
@NotNull final PsiClass context) {
|
||||
final LocalResourceManager manager = facet.getLocalResourceManager();
|
||||
final Map<String, PsiType> fieldNames = new HashMap<String, PsiType>();
|
||||
final boolean styleable = ResourceType.STYLEABLE.getName().equals(resClassName);
|
||||
final PsiType basicType = styleable ? PsiType.INT.createArrayType() : PsiType.INT;
|
||||
|
||||
for (String resName : manager.getResourceNames(resClassName)) {
|
||||
fieldNames.put(resName, basicType);
|
||||
}
|
||||
|
||||
if (styleable) {
|
||||
for (ResourceEntry entry : manager.getValueResourceEntries(ResourceType.ATTR.getName())) {
|
||||
final String resName = entry.getName();
|
||||
final String resContext = entry.getContext();
|
||||
|
||||
if (resContext.length() > 0) {
|
||||
fieldNames.put(resContext + '_' + resName, PsiType.INT);
|
||||
}
|
||||
}
|
||||
}
|
||||
final PsiField[] result = new PsiField[fieldNames.size()];
|
||||
final PsiElementFactory factory = JavaPsiFacade.getElementFactory(facet.getModule().getProject());
|
||||
final Collection<String> resNames = facet.getLocalResourceManager().getResourceNames(resClassName);
|
||||
final PsiField[] result = new PsiField[resNames.size()];
|
||||
final Module circularDepLibWithSamePackage = AndroidCompileUtil.findCircularDependencyOnLibraryWithSamePackage(facet);
|
||||
final boolean generateNonFinalFields = facet.getConfiguration().LIBRARY_PROJECT || circularDepLibWithSamePackage != null;
|
||||
int i = 0;
|
||||
for (String resName : resNames) {
|
||||
final PsiType type = ResourceType.STYLEABLE.getName().equals(resClassName)
|
||||
? PsiType.INT.createArrayType()
|
||||
: PsiType.INT;
|
||||
final AndroidLightField field = new AndroidLightField(AndroidResourceUtil.getFieldNameByResourceName(resName), context, type);
|
||||
field.setModifiers(PsiModifier.PUBLIC, PsiModifier.STATIC);
|
||||
|
||||
for (Map.Entry<String, PsiType> entry : fieldNames.entrySet()) {
|
||||
final String fieldName = AndroidResourceUtil.getFieldNameByResourceName(entry.getKey());
|
||||
final PsiType type = entry.getValue();
|
||||
final AndroidLightField field =
|
||||
new AndroidLightField(fieldName, context, type, !generateNonFinalFields, generateNonFinalFields ? null : 0);
|
||||
field.setInitializer(factory.createExpressionFromText("0", field));
|
||||
result[i++] = field;
|
||||
}
|
||||
|
||||
@@ -187,21 +187,6 @@ public class AndroidAutogenerator {
|
||||
return null;
|
||||
}
|
||||
|
||||
final AndroidPlatform platform = facet.getConfiguration().getAndroidPlatform();
|
||||
if (platform == null) {
|
||||
context.addMessage(CompilerMessageCategory.ERROR,
|
||||
AndroidBundle.message("android.compilation.error.specify.platform", module.getName()), null, -1, -1);
|
||||
return null;
|
||||
}
|
||||
|
||||
final IAndroidTarget target = platform.getTarget();
|
||||
final int platformToolsRevision = platform.getSdkData().getPlatformToolsRevision();
|
||||
final String[] resPaths = AndroidCompileUtil.collectResourceDirs(facet, false, context);
|
||||
|
||||
if (resPaths.length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final VirtualFile manifestFile = AndroidRootUtil.getManifestFileForCompiler(facet);
|
||||
if (manifestFile == null) {
|
||||
context.addMessage(CompilerMessageCategory.ERROR,
|
||||
@@ -239,18 +224,7 @@ public class AndroidAutogenerator {
|
||||
final String packageDir = packageName.replace('.', '/') + '/';
|
||||
genFilePath2Package.put(packageDir + AndroidCommonUtils.MANIFEST_JAVA_FILE_NAME, packageName);
|
||||
genFilePath2Package.put(packageDir + AndroidCommonUtils.R_JAVA_FILENAME, packageName);
|
||||
|
||||
final String manifestFileOsPath = FileUtil.toSystemDependentName(manifestFile.getPath());
|
||||
|
||||
final Module circularDepLibWithSamePackage = AndroidCompileUtil.findCircularDependencyOnLibraryWithSamePackage(facet);
|
||||
if (circularDepLibWithSamePackage != null && !facet.getConfiguration().LIBRARY_PROJECT) {
|
||||
context.addMessage(CompilerMessageCategory.WARNING, AndroidBundle.message("android.compilation.warning.circular.app.dependency",
|
||||
packageName, module.getName(),
|
||||
circularDepLibWithSamePackage.getName()), null, -1, -1);
|
||||
}
|
||||
final boolean generateNonFinalFields = facet.getConfiguration().LIBRARY_PROJECT || circularDepLibWithSamePackage != null;
|
||||
return new AptAutogenerationItem(target, platformToolsRevision, manifestFileOsPath, packageName, sourceRootPath, resPaths,
|
||||
generateNonFinalFields, genFilePath2Package);
|
||||
return new AptAutogenerationItem(packageName, sourceRootPath, genFilePath2Package);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -678,30 +652,15 @@ public class AndroidAutogenerator {
|
||||
}
|
||||
|
||||
private static class AptAutogenerationItem {
|
||||
final IAndroidTarget myTarget;
|
||||
final int myPlatformToolsRevision;
|
||||
final String myManifestFileOsPath;
|
||||
final String myPackage;
|
||||
final String myOutputDirOsPath;
|
||||
final String[] myResDirOsPaths;
|
||||
final boolean myNonConstantFields;
|
||||
final Map<String, String> myGenFileRelPath2package;
|
||||
|
||||
private AptAutogenerationItem(@NotNull IAndroidTarget target,
|
||||
int platformToolsRevision,
|
||||
@NotNull String manifestFileOsPath,
|
||||
@NotNull String aPackage,
|
||||
private AptAutogenerationItem(@NotNull String aPackage,
|
||||
@NotNull String outputDirOsPath,
|
||||
@NotNull String[] resDirOsPaths,
|
||||
boolean nonConstantFields,
|
||||
@NotNull Map<String, String> genFileRelPath2package) {
|
||||
myTarget = target;
|
||||
myPlatformToolsRevision = platformToolsRevision;
|
||||
myManifestFileOsPath = manifestFileOsPath;
|
||||
myPackage = aPackage;
|
||||
myOutputDirOsPath = outputDirOsPath;
|
||||
myResDirOsPaths = resDirOsPaths;
|
||||
myNonConstantFields = nonConstantFields;
|
||||
myGenFileRelPath2package = genFileRelPath2package;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public class ResourceNamesValidityState implements ValidityState {
|
||||
final String styleableName = styleable.getName().getValue();
|
||||
|
||||
if (styleableName != null) {
|
||||
addValueResources(file, ResourceType.DECLARE_STYLEABLE, styleable.getAttrs(), myResources, styleableName + '_');
|
||||
addValueResources(file, ResourceType.DECLARE_STYLEABLE, styleable.getAttrs(), myResources, styleableName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -105,7 +105,7 @@ public class ResourceNamesValidityState implements ValidityState {
|
||||
ResourceType resType,
|
||||
Collection<? extends ResourceElement> resourceElements,
|
||||
Map<String, ResourceFileData> result,
|
||||
String namePrefix) {
|
||||
String context) {
|
||||
for (ResourceElement element : resourceElements) {
|
||||
final String name = element.getName().getValue();
|
||||
|
||||
@@ -115,7 +115,7 @@ public class ResourceNamesValidityState implements ValidityState {
|
||||
data = new ResourceFileData();
|
||||
result.put(file.getPath(), data);
|
||||
}
|
||||
data.addValueResource(new ResourceEntry(resType.getName(), namePrefix + name));
|
||||
data.addValueResource(new ResourceEntry(resType.getName(), name, context));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -135,7 +135,8 @@ public class ResourceNamesValidityState implements ValidityState {
|
||||
for (int j = 0; j < valueResourcesCount; j++) {
|
||||
final String resType = in.readUTF();
|
||||
final String resName = in.readUTF();
|
||||
valueResources.add(new ResourceEntry(resType, resName));
|
||||
final String resContext = in.readUTF();
|
||||
valueResources.add(new ResourceEntry(resType, resName, resContext));
|
||||
}
|
||||
final long fileTimestamp = in.readLong();
|
||||
myResources.put(filePath, new ResourceFileData(valueResources, fileTimestamp));
|
||||
@@ -172,6 +173,7 @@ public class ResourceNamesValidityState implements ValidityState {
|
||||
for (ResourceEntry resource : valueResources) {
|
||||
out.writeUTF(resource.getType());
|
||||
out.writeUTF(resource.getName());
|
||||
out.writeUTF(resource.getContext());
|
||||
}
|
||||
out.writeLong(data.getTimestamp());
|
||||
}
|
||||
|
||||
+1
-1
@@ -106,7 +106,7 @@ public class CreateFileResourceQuickFix implements LocalQuickFix, IntentionActio
|
||||
}
|
||||
|
||||
try {
|
||||
AndroidResourceUtil.createFileResource(myResourceName, resSubdir, CreateTypedResourceFileAction.getDefaultRootTabByResourceType(
|
||||
AndroidResourceUtil.createFileResource(myResourceName, resSubdir, CreateTypedResourceFileAction.getDefaultRootTagByResourceType(
|
||||
ResourceFolderType.getFolderType(resDirName)), resDirName, false);
|
||||
UndoUtil.markPsiFileForUndo(myFile);
|
||||
}
|
||||
|
||||
@@ -221,6 +221,16 @@ public abstract class ResourceManager {
|
||||
|
||||
@NotNull
|
||||
public Collection<String> getValueResourceNames(@NotNull final String resourceType) {
|
||||
final Set<String> result = new HashSet<String>();
|
||||
|
||||
for (ResourceEntry entry : getValueResourceEntries(resourceType)) {
|
||||
result.add(entry.getName());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Collection<ResourceEntry> getValueResourceEntries(@NotNull final String resourceType) {
|
||||
final ResourceType type = ResourceType.getEnum(resourceType);
|
||||
|
||||
if (type == null) {
|
||||
@@ -232,7 +242,6 @@ public abstract class ResourceManager {
|
||||
final GlobalSearchScope scope = GlobalSearchScope.allScope(myModule.getProject());
|
||||
|
||||
final Map<VirtualFile, Set<ResourceEntry>> file2resourceSet = new HashMap<VirtualFile, Set<ResourceEntry>>();
|
||||
|
||||
for (Set<ResourceEntry> entrySet : index.getValues(AndroidValueResourcesIndex.INDEX_ID, typeMarkerEntry, scope)) {
|
||||
for (ResourceEntry entry : entrySet) {
|
||||
final Collection<VirtualFile> files = index.getContainingFiles(AndroidValueResourcesIndex.INDEX_ID, entry, scope);
|
||||
@@ -248,14 +257,14 @@ public abstract class ResourceManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
final Set<String> result = new HashSet<String>();
|
||||
final List<ResourceEntry> result = new ArrayList<ResourceEntry>();
|
||||
|
||||
for (VirtualFile file : getAllValueResourceFiles()) {
|
||||
final Set<ResourceEntry> entries = file2resourceSet.get(file);
|
||||
|
||||
if (entries != null) {
|
||||
for (ResourceEntry entry : entries) {
|
||||
result.add(entry.getName());
|
||||
result.add(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -371,7 +380,8 @@ public abstract class ResourceManager {
|
||||
}
|
||||
|
||||
final Collection<VirtualFile> files = FileBasedIndex.getInstance()
|
||||
.getContainingFiles(AndroidValueResourcesIndex.INDEX_ID, new ResourceEntry(resourceType, resourceName),
|
||||
.getContainingFiles(AndroidValueResourcesIndex.INDEX_ID,
|
||||
AndroidValueResourcesIndex.createTypeNameMarkerEntry(resourceType, resourceName),
|
||||
GlobalSearchScope.allScope(myModule.getProject()));
|
||||
|
||||
if (files.size() == 0) {
|
||||
|
||||
@@ -770,7 +770,7 @@ public class AndroidResourceUtil {
|
||||
@NotNull String resourceType,
|
||||
boolean valuesResourceFile) throws Exception {
|
||||
FileTemplateManager manager = FileTemplateManager.getInstance();
|
||||
String templateName = getTemplateName(resourceType, valuesResourceFile);
|
||||
String templateName = getTemplateName(resourceType, valuesResourceFile, rootTagName);
|
||||
FileTemplate template = manager.getJ2eeTemplate(templateName);
|
||||
Properties properties = new Properties();
|
||||
if (!valuesResourceFile) {
|
||||
@@ -781,18 +781,20 @@ public class AndroidResourceUtil {
|
||||
return (XmlFile)createdElement;
|
||||
}
|
||||
|
||||
private static String getTemplateName(String resourceType, boolean valuesResourceFile) {
|
||||
private static String getTemplateName(String resourceType, boolean valuesResourceFile, String rootTagName) {
|
||||
if (valuesResourceFile) {
|
||||
return AndroidFileTemplateProvider.VALUE_RESOURCE_FILE_TEMPLATE;
|
||||
}
|
||||
if ("layout".equals(resourceType)) {
|
||||
return AndroidFileTemplateProvider.LAYOUT_RESOURCE_FILE_TEMPLATE;
|
||||
return AndroidUtils.TAG_LINEAR_LAYOUT.equals(rootTagName)
|
||||
? AndroidFileTemplateProvider.LAYOUT_RESOURCE_VERTICAL_FILE_TEMPLATE
|
||||
: AndroidFileTemplateProvider.LAYOUT_RESOURCE_FILE_TEMPLATE;
|
||||
}
|
||||
return AndroidFileTemplateProvider.RESOURCE_FILE_TEMPLATE;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getFieldNameByResourceName(@NotNull String fieldName) {
|
||||
return fieldName.replace('.', '_').replace('-', '_');
|
||||
return fieldName.replace('.', '_').replace('-', '_').replace(':', '_');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,10 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.*;
|
||||
import com.intellij.openapi.roots.DependencyScope;
|
||||
import com.intellij.openapi.roots.ModuleOrderEntry;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.roots.OrderEntry;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
@@ -125,6 +128,7 @@ public class AndroidUtils {
|
||||
@NonNls public static final String ANDROID_LIBRARY_PROPERTY = "android.library";
|
||||
@NonNls public static final String ANDROID_TARGET_PROPERTY = "target";
|
||||
@NonNls public static final String ANDROID_LIBRARY_REFERENCE_PROPERTY_PREFIX = "android.library.reference.";
|
||||
@NonNls public static final String TAG_LINEAR_LAYOUT = "LinearLayout";
|
||||
|
||||
private AndroidUtils() {
|
||||
}
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
package p1.p2;
|
||||
|
||||
public final class R {
|
||||
}
|
||||
@@ -1,10 +1,27 @@
|
||||
package p1.p2;
|
||||
|
||||
import java.lang.Readable;
|
||||
import java.lang.System;
|
||||
|
||||
public class JavaCompletion1 {
|
||||
public void f() {
|
||||
int n1 = R.string.my_string;
|
||||
int n2 = R.string.<error>unknown</error>;
|
||||
<error>int n3 = R.styleable.MyStyleable;</error>
|
||||
int[] n4 = R.styleable.MyStyleable;
|
||||
int n5 = R.attr.myAttr1;
|
||||
n5 = R.attr.myAttr2;
|
||||
n5 = R.attr.<error>android_text</error>;
|
||||
n5 = R.styleable.MyStyleable_myAttr1;
|
||||
<error>n4 = R.styleable.MyStyleable_myAttr1</error>;
|
||||
n5 = R.styleable.<error>MyStyleable_text</error>;
|
||||
|
||||
switch(n1) {
|
||||
case R.string.my_string:
|
||||
System.out.println("abacaba");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,9 @@
|
||||
<resources>
|
||||
<string name="my_string">abacaba</string>
|
||||
<style name="Theme.MyCustomStyle" parent="android:style/Theme.Dialog"></style>
|
||||
<declare-styleable name="MyStyleable"></declare-styleable>
|
||||
<declare-styleable name="MyStyleable">
|
||||
<attr name="myAttr1" format="string"/>
|
||||
<attr name="android:text"/>
|
||||
</declare-styleable>
|
||||
<attr name="myAttr2" format="string"/>
|
||||
</resources>
|
||||
@@ -1,4 +0,0 @@
|
||||
package p1.p2;
|
||||
|
||||
public final class R {
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package p1.p2;
|
||||
|
||||
public final class R {
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package p1.p2.lib;
|
||||
|
||||
import java.lang.System;
|
||||
|
||||
public class JavaHighlighting {
|
||||
public void f(int n) {
|
||||
int m = R.string.myLibResource;
|
||||
switch(n) {
|
||||
case <error>R.string.myLibResource</error>:
|
||||
System.out.println("aba");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package p1.p2;
|
||||
|
||||
public final class R {
|
||||
public static final class layout {
|
||||
public static final int main = 0x7f040000;
|
||||
}
|
||||
|
||||
public static final class string {
|
||||
public static final int myLibResource = 0x7f040001;
|
||||
}
|
||||
|
||||
public static final class id {
|
||||
public static final int myButton = 0x7f090002;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package p1.p2;
|
||||
|
||||
public final class R {
|
||||
public static final class layout {
|
||||
public static final int main = 0x7f040000;
|
||||
}
|
||||
|
||||
public static final class string {
|
||||
public static final int myLibResource = 0x7f040001;
|
||||
}
|
||||
|
||||
public static final class id {
|
||||
public static final int myButton = 0x7f090002;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package p1.p2;
|
||||
|
||||
public final class R {
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package p1.p2;
|
||||
|
||||
public final class R {
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package p1.p2;
|
||||
|
||||
public final class R {
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package p1.p2;
|
||||
|
||||
public final class R {
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package p1.p2;
|
||||
|
||||
public final class R {
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package p1.p2;
|
||||
|
||||
public final class R {
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package p1.p2;
|
||||
|
||||
public final class R {
|
||||
public static final class attr {
|
||||
public static final int at<caret>tr = 0x7f040002;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package p1.p2;
|
||||
|
||||
public final class R {
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package p1.p2;
|
||||
|
||||
public final class R {
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package p1.p2;
|
||||
|
||||
public final class R {
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package p1.p2;
|
||||
|
||||
public final class R {
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<resources>
|
||||
<string name="<caret>str">some text</string>
|
||||
<string name="str2">some text</string>
|
||||
</resources>
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
/* AUTO-GENERATED FILE. DO NOT MODIFY.
|
||||
*
|
||||
* This class was automatically generated by the
|
||||
* aapt tool from the resource data it found. It
|
||||
* should not be modified by hand.
|
||||
*/
|
||||
|
||||
package p1.p2;
|
||||
|
||||
public final class R {
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
/* AUTO-GENERATED FILE. DO NOT MODIFY.
|
||||
*
|
||||
* This class was automatically generated by the
|
||||
* aapt tool from the resource data it found. It
|
||||
* should not be modified by hand.
|
||||
*/
|
||||
|
||||
package p1.p2;
|
||||
|
||||
public final class R {
|
||||
public static final class array {
|
||||
public static final int co<caret>lors=0x7f070000;
|
||||
public static final int planets=0x7f070001;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
/* AUTO-GENERATED FILE. DO NOT MODIFY.
|
||||
*
|
||||
* This class was automatically generated by the
|
||||
* aapt tool from the resource data it found. It
|
||||
* should not be modified by hand.
|
||||
*/
|
||||
|
||||
package p1.p2;
|
||||
|
||||
public final class R {
|
||||
public static final class drawable {
|
||||
public static final int p<caret>ng=0x7f020000;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
/* AUTO-GENERATED FILE. DO NOT MODIFY.
|
||||
*
|
||||
* This class was automatically generated by the
|
||||
* aapt tool from the resource data it found. It
|
||||
* should not be modified by hand.
|
||||
*/
|
||||
|
||||
package p1.p2;
|
||||
|
||||
public final class R {
|
||||
public static final class id {
|
||||
public static final int my<caret>Id1=0x7f090006;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
/* AUTO-GENERATED FILE. DO NOT MODIFY.
|
||||
*
|
||||
* This class was automatically generated by the
|
||||
* aapt tool from the resource data it found. It
|
||||
* should not be modified by hand.
|
||||
*/
|
||||
|
||||
package p1.p2;
|
||||
|
||||
public final class R {
|
||||
public static final class id {
|
||||
public static final int lunc<caret>h=0x7f090006;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
/* AUTO-GENERATED FILE. DO NOT MODIFY.
|
||||
*
|
||||
* This class was automatically generated by the
|
||||
* aapt tool from the resource data it found. It
|
||||
* should not be modified by hand.
|
||||
*/
|
||||
|
||||
package p1.p2;
|
||||
|
||||
public final class R {
|
||||
public static final class id {
|
||||
public static final int lunccccc<caret>h=0x7f090006;
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,7 @@ public class AndroidFindUsagesTest extends AndroidTestCase {
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
myFixture.copyFileToProject(BASE_PATH + "picture3.gif", "res/drawable/picture3.gif");
|
||||
myFixture.copyFileToProject(BASE_PATH + "R.java", "gen/p1/p2/R.java");
|
||||
myFixture.copyFileToProject("R.java", "gen/p1/p2/R.java");
|
||||
}
|
||||
|
||||
public List<UsageInfo> findCodeUsages(String path, String pathInProject) throws Throwable {
|
||||
|
||||
@@ -62,10 +62,10 @@ public class AndroidRenameTest extends AndroidTestCase {
|
||||
myFixture.configureFromExistingVirtualFile(file);
|
||||
myFixture.copyFileToProject(BASE_PATH + "pic.png", "res/drawable/pic.png");
|
||||
myFixture.copyFileToProject(BASE_PATH + "styles.xml", "res/values/styles.xml");
|
||||
myFixture.copyFileToProject(BASE_PATH + "R1.java", R_JAVA_PATH);
|
||||
myFixture.copyFileToProject("R.java", R_JAVA_PATH);
|
||||
renameElementWithTextOccurences("pic1.png");
|
||||
myFixture.checkResultByFile(BASE_PATH + "layout_file_after.xml");
|
||||
myFixture.checkResultByFile(R_JAVA_PATH, BASE_PATH + "R_file_after.java", true);
|
||||
myFixture.checkResultByFile(R_JAVA_PATH, "R.java", true);
|
||||
myFixture.checkResultByFile("res/values/styles.xml", BASE_PATH + "styles_after.xml", true);
|
||||
assertNotNull(myFixture.findFileInTempDir("res/drawable/pic1.png"));
|
||||
}
|
||||
@@ -76,10 +76,10 @@ public class AndroidRenameTest extends AndroidTestCase {
|
||||
myFixture.configureFromExistingVirtualFile(file);
|
||||
myFixture.copyFileToProject(BASE_PATH + "pic.png", "res/drawable/pic.9.png");
|
||||
myFixture.copyFileToProject(BASE_PATH + "styles.xml", "res/values/styles.xml");
|
||||
myFixture.copyFileToProject(BASE_PATH + "R1.java", R_JAVA_PATH);
|
||||
myFixture.copyFileToProject("R.java", R_JAVA_PATH);
|
||||
renameElementWithTextOccurences("pic1.9.png");
|
||||
myFixture.checkResultByFile(BASE_PATH + "layout_file_after.xml");
|
||||
myFixture.checkResultByFile(R_JAVA_PATH, BASE_PATH + "R_file_after.java", true);
|
||||
myFixture.checkResultByFile(R_JAVA_PATH, "R.java", true);
|
||||
myFixture.checkResultByFile("res/values/styles.xml", BASE_PATH + "styles_after.xml", true);
|
||||
assertNotNull(myFixture.findFileInTempDir("res/drawable/pic1.9.png"));
|
||||
}
|
||||
@@ -129,10 +129,10 @@ public class AndroidRenameTest extends AndroidTestCase {
|
||||
VirtualFile file = myFixture.copyFileToProject(BASE_PATH + "layout2.xml", "res/layout/layout2.xml");
|
||||
myFixture.configureFromExistingVirtualFile(file);
|
||||
myFixture.copyFileToProject(BASE_PATH + "strings.xml", "res/values/strings.xml");
|
||||
myFixture.copyFileToProject(BASE_PATH + "R2.java", R_JAVA_PATH);
|
||||
myFixture.copyFileToProject("R.java", R_JAVA_PATH);
|
||||
myFixture.renameElementAtCaret("str1");
|
||||
myFixture.checkResultByFile(BASE_PATH + "layout_value_after.xml");
|
||||
myFixture.checkResultByFile(R_JAVA_PATH, BASE_PATH + "R_value_after.java", true);
|
||||
myFixture.checkResultByFile(R_JAVA_PATH, "R.java", true);
|
||||
myFixture.checkResultByFile("res/values/strings.xml", BASE_PATH + "strings_after.xml", true);
|
||||
}
|
||||
|
||||
@@ -158,12 +158,12 @@ public class AndroidRenameTest extends AndroidTestCase {
|
||||
myFixture.configureFromExistingVirtualFile(file);
|
||||
|
||||
myFixture.copyFileToProject(BASE_PATH + "layoutStrUsage.xml", "res/layout/layoutStrUsage.xml");
|
||||
myFixture.copyFileToProject(BASE_PATH + "R2.java", R_JAVA_PATH);
|
||||
myFixture.copyFileToProject("R.java", R_JAVA_PATH);
|
||||
|
||||
findHandlerAndDoRename();
|
||||
|
||||
myFixture.checkResultByFile(BASE_PATH + "strings_after.xml");
|
||||
myFixture.checkResultByFile(R_JAVA_PATH, BASE_PATH + "R_value_after.java", true);
|
||||
myFixture.checkResultByFile(R_JAVA_PATH, "R.java", true);
|
||||
myFixture.checkResultByFile("res/layout/layoutStrUsage.xml", BASE_PATH + "layoutStrUsage_after.xml", true);
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ public class AndroidRenameTest extends AndroidTestCase {
|
||||
createManifest();
|
||||
VirtualFile file = myFixture.copyFileToProject(BASE_PATH + "RefR3.java", "src/p1/p2/RefR3.java");
|
||||
myFixture.configureFromExistingVirtualFile(file);
|
||||
myFixture.copyFileToProject(BASE_PATH + "R.java", R_JAVA_PATH);
|
||||
myFixture.copyFileToProject("R.java", R_JAVA_PATH);
|
||||
myFixture.copyFileToProject(BASE_PATH + "layout3.xml", "res/layout/layout3.xml");
|
||||
myFixture.copyFileToProject(BASE_PATH + "pic.png", "res/drawable/pic.png");
|
||||
myFixture.renameElementAtCaret("pic1");
|
||||
@@ -200,7 +200,7 @@ public class AndroidRenameTest extends AndroidTestCase {
|
||||
createManifest();
|
||||
VirtualFile file = myFixture.copyFileToProject(BASE_PATH + "RefR4.java", "src/p1/p2/RefR4.java");
|
||||
myFixture.configureFromExistingVirtualFile(file);
|
||||
myFixture.copyFileToProject(BASE_PATH + "R.java", R_JAVA_PATH);
|
||||
myFixture.copyFileToProject("R.java", R_JAVA_PATH);
|
||||
myFixture.copyFileToProject(BASE_PATH + "layout4.xml", "res/layout/layout4.xml");
|
||||
myFixture.copyFileToProject(BASE_PATH + "strings.xml", "res/values/strings.xml");
|
||||
myFixture.renameElementAtCaret("str1");
|
||||
@@ -213,26 +213,26 @@ public class AndroidRenameTest extends AndroidTestCase {
|
||||
createManifest();
|
||||
VirtualFile file = myFixture.copyFileToProject(BASE_PATH + "layout5.xml", "res/layout/layout5.xml");
|
||||
myFixture.configureFromExistingVirtualFile(file);
|
||||
myFixture.copyFileToProject(BASE_PATH + "R5.java", R_JAVA_PATH);
|
||||
myFixture.copyFileToProject("R.java", R_JAVA_PATH);
|
||||
myFixture.renameElementAtCaret("@+id/anchor1");
|
||||
myFixture.checkResultByFile(BASE_PATH + "layout_id_after.xml");
|
||||
myFixture.checkResultByFile(R_JAVA_PATH, BASE_PATH + "R_id_after.java", true);
|
||||
myFixture.checkResultByFile(R_JAVA_PATH, "R.java", true);
|
||||
}
|
||||
|
||||
public void testIdDeclaration() throws Throwable {
|
||||
createManifest();
|
||||
VirtualFile file = myFixture.copyFileToProject(BASE_PATH + "layout6.xml", "res/layout/layout6.xml");
|
||||
myFixture.configureFromExistingVirtualFile(file);
|
||||
myFixture.copyFileToProject(BASE_PATH + "R6.java", R_JAVA_PATH);
|
||||
myFixture.copyFileToProject("R.java", R_JAVA_PATH);
|
||||
myFixture.renameElementAtCaret("@+id/anchor1");
|
||||
myFixture.checkResultByFile(BASE_PATH + "layout_id_after.xml");
|
||||
myFixture.checkResultByFile(R_JAVA_PATH, BASE_PATH + "R_id_after.java", true);
|
||||
myFixture.checkResultByFile(R_JAVA_PATH, "R.java", true);
|
||||
}
|
||||
|
||||
public void testJavaReferenceToId() throws Throwable {
|
||||
createManifest();
|
||||
VirtualFile file = myFixture.copyFileToProject(BASE_PATH + "RefR7.java", "src/p1/p2/RefR7.java");
|
||||
myFixture.copyFileToProject(BASE_PATH + "R.java", R_JAVA_PATH);
|
||||
myFixture.copyFileToProject("R.java", R_JAVA_PATH);
|
||||
myFixture.configureFromExistingVirtualFile(file);
|
||||
myFixture.copyFileToProject(BASE_PATH + "layout7.xml", "res/layout/layout7.xml");
|
||||
myFixture.renameElementAtCaret("anchor1");
|
||||
@@ -243,7 +243,7 @@ public class AndroidRenameTest extends AndroidTestCase {
|
||||
public void testStyleable() throws Throwable {
|
||||
createManifest();
|
||||
VirtualFile file = myFixture.copyFileToProject(BASE_PATH + "RefR8.java", "src/p1/p2/RefR8.java");
|
||||
myFixture.copyFileToProject(BASE_PATH + "R.java", R_JAVA_PATH);
|
||||
myFixture.copyFileToProject("R.java", R_JAVA_PATH);
|
||||
myFixture.configureFromExistingVirtualFile(file);
|
||||
myFixture.copyFileToProject(BASE_PATH + "attrs8.xml", "res/values/attrs8.xml");
|
||||
myFixture.renameElementAtCaret("LabelView1");
|
||||
@@ -254,7 +254,7 @@ public class AndroidRenameTest extends AndroidTestCase {
|
||||
public void testAttr() throws Throwable {
|
||||
createManifest();
|
||||
VirtualFile file = myFixture.copyFileToProject(BASE_PATH + "RefR9.java", "src/p1/p2/RefR9.java");
|
||||
myFixture.copyFileToProject(BASE_PATH + "R.java", R_JAVA_PATH);
|
||||
myFixture.copyFileToProject("R.java", R_JAVA_PATH);
|
||||
myFixture.configureFromExistingVirtualFile(file);
|
||||
myFixture.copyFileToProject(BASE_PATH + "attrs9.xml", "res/values/attrs9.xml");
|
||||
myFixture.renameElementAtCaret("attr1");
|
||||
|
||||
@@ -25,83 +25,6 @@ public class AndroidResourcesLineMarkerTest extends AndroidTestCase {
|
||||
myFixture.copyDirectoryToProject(BASE_PATH + "res", "res");
|
||||
}
|
||||
|
||||
/*public void testRJavaFile() throws Exception {
|
||||
List<LineMarkerInfo> markers = collectMarkers("src/p1/p2/R.java");
|
||||
assertEquals(26, markers.size());
|
||||
for (LineMarkerInfo marker : markers) {
|
||||
PsiField field = (PsiField)marker.getElement();
|
||||
GutterIconNavigationHandler handler = marker.getNavigationHandler();
|
||||
assertInstanceOf(handler, AndroidResourcesLineMarkerProvider.MyNavigationHandler.class);
|
||||
PsiElement[] targets = ((AndroidResourcesLineMarkerProvider.MyNavigationHandler)handler).getTargets();
|
||||
checkTargets(field, targets);
|
||||
}
|
||||
}
|
||||
|
||||
public void testValueResourcesFile() throws Exception {
|
||||
copyRJava();
|
||||
List<LineMarkerInfo> markers = collectMarkers("res/values/ids.xml");
|
||||
assertEquals(3, markers.size());
|
||||
for (LineMarkerInfo marker : markers) {
|
||||
GutterIconNavigationHandler handler = marker.getNavigationHandler();
|
||||
assertInstanceOf(handler, AndroidResourcesLineMarkerProvider.MyLazyNavigationHandler.class);
|
||||
Computable<PsiElement[]> targetProvider = ((AndroidResourcesLineMarkerProvider.MyLazyNavigationHandler)handler).getTargetProvider();
|
||||
PsiElement[] targets = targetProvider.compute();
|
||||
assertNotNull(targets);
|
||||
assertEquals(1, targets.length);
|
||||
for (PsiElement target : targets) {
|
||||
assertInstanceOf(target, PsiField.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void testLayoutFile() throws Exception {
|
||||
copyRJava();
|
||||
List<LineMarkerInfo> markers = collectMarkers("res/layout/layout1.xml");
|
||||
assertEquals(5, markers.size());
|
||||
|
||||
boolean fileMarker = false;
|
||||
|
||||
for (LineMarkerInfo marker : markers) {
|
||||
GutterIconNavigationHandler handler = marker.getNavigationHandler();
|
||||
PsiElement[] targets;
|
||||
if (marker.getElement() instanceof XmlFile) {
|
||||
fileMarker = true;
|
||||
assertInstanceOf(handler, AndroidResourcesLineMarkerProvider.MyNavigationHandler.class);
|
||||
targets = ((AndroidResourcesLineMarkerProvider.MyNavigationHandler)handler).getTargets();
|
||||
}
|
||||
else {
|
||||
assertInstanceOf(handler, AndroidResourcesLineMarkerProvider.MyLazyNavigationHandler.class);
|
||||
Computable<PsiElement[]> targetProvider = ((AndroidResourcesLineMarkerProvider.MyLazyNavigationHandler)handler).getTargetProvider();
|
||||
targets = targetProvider.compute();
|
||||
}
|
||||
assertNotNull(targets);
|
||||
assertEquals(1, targets.length);
|
||||
for (PsiElement target : targets) {
|
||||
assertInstanceOf(target, PsiField.class);
|
||||
}
|
||||
}
|
||||
|
||||
assertTrue("LineMarker for file not found", fileMarker);
|
||||
}
|
||||
|
||||
public void testJavaFileMarkers() throws Exception {
|
||||
copyRJava();
|
||||
List<LineMarkerInfo> markers = collectMarkers("src/p1/p2/Java.java");
|
||||
|
||||
// do not draw line markers on usages of a resource: AndroidGotoDeclarationHandler provides navigation instead
|
||||
assertEquals(0, markers.size());
|
||||
|
||||
for (LineMarkerInfo marker : markers) {
|
||||
PsiReferenceExpression expression = (PsiReferenceExpression)marker.getElement();
|
||||
PsiField field = (PsiField)expression.resolve();
|
||||
GutterIconNavigationHandler handler = marker.getNavigationHandler();
|
||||
assertInstanceOf(handler, AndroidResourcesLineMarkerProvider.MyLazyNavigationHandler.class);
|
||||
Computable<PsiElement[]> targetProvider = ((AndroidResourcesLineMarkerProvider.MyLazyNavigationHandler)handler).getTargetProvider();
|
||||
PsiElement[] targets = targetProvider.compute();
|
||||
checkTargets(field, targets);
|
||||
}
|
||||
}*/
|
||||
|
||||
public void testJavaFileNavigation1() throws Exception {
|
||||
doJavaFileNavigationTest(1, true);
|
||||
}
|
||||
@@ -130,42 +53,12 @@ public class AndroidResourcesLineMarkerTest extends AndroidTestCase {
|
||||
doJavaFileNavigationTest(1, true);
|
||||
}
|
||||
|
||||
/*public void testRJavaFileNavigation1() throws Exception {
|
||||
doRJavaFileNavigationTest(1);
|
||||
}
|
||||
|
||||
public void testRJavaFileNavigation2() throws Exception {
|
||||
doRJavaFileNavigationTest(2);
|
||||
}
|
||||
|
||||
public void testRJavaFileNavigation3() throws Exception {
|
||||
doRJavaFileNavigationTest(3);
|
||||
}
|
||||
|
||||
public void testRJavaFileNavigation4() throws Exception {
|
||||
doRJavaFileNavigationTest(1);
|
||||
}
|
||||
|
||||
public void testRJavaFileNavigation5() throws Exception {
|
||||
doRJavaFileNavigationTest(0);
|
||||
}*/
|
||||
|
||||
/*public void testValueResourcesNavigation() throws Exception {
|
||||
copyRJava();
|
||||
String fileName = getTestName(false) + ".xml";
|
||||
doJavaFileNavigationTest(fileName, "res/values/" + fileName, 1, true, false);
|
||||
}*/
|
||||
|
||||
private void doJavaFileNavigationTest(int expectedTargets, boolean expectedEnabled) throws IOException {
|
||||
copyRJava();
|
||||
String path = "src/p1/p2/" + getTestName(false) + ".java";
|
||||
doJavaFileNavigationTest(path, path, expectedTargets, expectedEnabled, true);
|
||||
}
|
||||
|
||||
/*private void doRJavaFileNavigationTest(int expectedTargets) throws IOException {
|
||||
doJavaFileNavigationTest("src/p1/p2/" + getTestName(false) + ".java", "src/p1/p2/R.java", expectedTargets, true, false);
|
||||
}*/
|
||||
|
||||
private void doJavaFileNavigationTest(String srcPath, String destPath, int expectedTargets, boolean expectedEnabled,
|
||||
boolean testGotoDeclaration) throws IOException {
|
||||
VirtualFile file = myFixture.copyFileToProject(BASE_PATH + srcPath, destPath);
|
||||
@@ -177,51 +70,9 @@ public class AndroidResourcesLineMarkerTest extends AndroidTestCase {
|
||||
assertNotNull(targets);
|
||||
assertEquals(expectedTargets, targets.length);
|
||||
}
|
||||
|
||||
// test Ctrl+Alt+Shift+R
|
||||
/*GotoResourceAction action = new GotoResourceAction();
|
||||
DataContext dataContext = DataManager.getInstance().getDataContextFromFocus().getResult();
|
||||
AnActionEvent event = new AnActionEvent(null, dataContext, "", action.getTemplatePresentation(), ActionManager.getInstance(), 0);
|
||||
action.update(event);
|
||||
assertEquals(expectedEnabled, event.getPresentation().isEnabled());
|
||||
PsiElement[] targets = GotoResourceAction.findTargets(dataContext);
|
||||
assertEquals(expectedTargets, targets.length);*/
|
||||
}
|
||||
|
||||
/*private List<LineMarkerInfo> collectMarkers(String filePath) throws IOException {
|
||||
return collectMarkers(myFixture, BASE_PATH + filePath, filePath);
|
||||
}
|
||||
|
||||
public static List<LineMarkerInfo> collectMarkers(JavaCodeInsightTestFixture fixture, String fromPath, String filePath) {
|
||||
VirtualFile file = fixture.copyFileToProject(fromPath, filePath);
|
||||
fixture.configureFromExistingVirtualFile(file);
|
||||
fixture.doHighlighting();
|
||||
List<LineMarkerInfo> markers = DaemonCodeAnalyzerImpl.getLineMarkers(fixture.getEditor().getDocument(), fixture.getProject());
|
||||
assertNotNull(markers);
|
||||
return markers;
|
||||
}
|
||||
|
||||
private static void checkTargets(PsiField field, PsiElement[] targets) {
|
||||
assertNotNull(targets);
|
||||
assertTrue(targets.length > 0);
|
||||
int expectedTargetCount = getExpectedTargetCount(field.getName());
|
||||
assertEquals(field.getName(), expectedTargetCount, targets.length);
|
||||
}
|
||||
|
||||
private static int getExpectedTargetCount(String fieldName) {
|
||||
if ("png".equals(fieldName)) {
|
||||
return 2;
|
||||
}
|
||||
if ("str2".equals(fieldName)) {
|
||||
return 3;
|
||||
}
|
||||
if ("myId1".equals(fieldName)) {
|
||||
return 3;
|
||||
}
|
||||
return 1;
|
||||
}*/
|
||||
|
||||
private void copyRJava() throws IOException {
|
||||
myFixture.copyFileToProject(BASE_PATH + "src/p1/p2/R.java", "src/p1/p2/R.java");
|
||||
myFixture.copyFileToProject("R.java", "src/p1/p2/R.java");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ abstract class AndroidDomTest extends AndroidTestCase {
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
myFixture.copyFileToProject("dom/R.java", "gen/p1/p2/R.java");
|
||||
myFixture.copyFileToProject("R.java", "gen/p1/p2/R.java");
|
||||
myFixture.enableInspections(AndroidDomInspection.class,
|
||||
AndroidUnknownAttributeInspection.class,
|
||||
AndroidElementNotAllowedInspection.class);
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.util.List;
|
||||
/**
|
||||
* @author Eugene.Kudelevsky
|
||||
*/
|
||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||
public class AndroidLibraryProjectTest extends UsefulTestCase {
|
||||
@NonNls private static final String BASE_PATH = "libModule/";
|
||||
|
||||
@@ -41,6 +42,7 @@ public class AndroidLibraryProjectTest extends UsefulTestCase {
|
||||
|
||||
protected JavaCodeInsightTestFixture myFixture;
|
||||
|
||||
@SuppressWarnings("JUnitTestCaseWithNonTrivialConstructors")
|
||||
public AndroidLibraryProjectTest() {
|
||||
IdeaTestCase.initPlatformPrefix();
|
||||
}
|
||||
@@ -109,7 +111,7 @@ public class AndroidLibraryProjectTest extends UsefulTestCase {
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
private String getTestSdkPath() {
|
||||
private static String getTestSdkPath() {
|
||||
return AndroidTestCase.getAbsoluteTestDataPath() + "/sdk1.5";
|
||||
}
|
||||
|
||||
@@ -141,6 +143,16 @@ public class AndroidLibraryProjectTest extends UsefulTestCase {
|
||||
myFixture.checkHighlighting(true, true, true);
|
||||
}
|
||||
|
||||
public void testJavaHighlighting() {
|
||||
createInitialStructure();
|
||||
myFixture.copyFileToProject(BASE_PATH + "LibR.java", "lib/src/p1/p2/lib/R.java");
|
||||
String to = "lib/src/p1/p2/lib" + getTestName(true) + ".java";
|
||||
VirtualFile file = myFixture.copyFileToProject(BASE_PATH + getTestName(false) + ".java", to);
|
||||
myFixture.configureFromExistingVirtualFile(file);
|
||||
myFixture.doHighlighting();
|
||||
myFixture.checkHighlighting(true, true, true);
|
||||
}
|
||||
|
||||
private void doRename(final VirtualFile file, final String newName) {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
@@ -172,46 +184,9 @@ public class AndroidLibraryProjectTest extends UsefulTestCase {
|
||||
myFixture.checkResultByFile(BASE_PATH + getTestName(true) + "_after.xml");
|
||||
}
|
||||
|
||||
/*public void testRJavaFileMarkers() throws Exception {
|
||||
doTestRJavaFilesMarkers("/app/src/p1/p2/R.java");
|
||||
}
|
||||
|
||||
public void testRJavaFileMarkers1() throws Exception {
|
||||
boolean temp = myLibFacet.getConfiguration().LIBRARY_PROJECT;
|
||||
try {
|
||||
myLibFacet.getConfiguration().LIBRARY_PROJECT = true;
|
||||
doTestRJavaFilesMarkers("/app/src/p1/p2/lib/R.java");
|
||||
}
|
||||
finally {
|
||||
myLibFacet.getConfiguration().LIBRARY_PROJECT = temp;
|
||||
}
|
||||
}
|
||||
|
||||
private void doTestRJavaFilesMarkers(String destPath) {
|
||||
createInitialStructure();
|
||||
List<LineMarkerInfo> markers =
|
||||
AndroidResourcesLineMarkerTest.collectMarkers(myFixture, BASE_PATH + getTestName(false) + ".java", destPath);
|
||||
assertEquals(3, markers.size());
|
||||
for (LineMarkerInfo marker : markers) {
|
||||
PsiField field = (PsiField)marker.getElement();
|
||||
GutterIconNavigationHandler handler = marker.getNavigationHandler();
|
||||
assertInstanceOf(handler, AndroidResourcesLineMarkerProvider.MyNavigationHandler.class);
|
||||
PsiElement[] targets = ((AndroidResourcesLineMarkerProvider.MyNavigationHandler)handler).getTargets();
|
||||
checkTargets(field, targets);
|
||||
}
|
||||
}
|
||||
|
||||
public void testJavaFileMarkers() throws Exception {
|
||||
createInitialStructure();
|
||||
myFixture.copyFileToProject(BASE_PATH + "RJavaFileMarkers.java", "app/src/p1/p2/R.java");
|
||||
List<LineMarkerInfo> markers =
|
||||
AndroidResourcesLineMarkerTest.collectMarkers(myFixture, BASE_PATH + getTestName(false) + ".java", "/app/src/p1/p2/Java.java");
|
||||
assertEquals(0, markers.size());
|
||||
}*/
|
||||
|
||||
public void testJavaNavigation() throws Exception {
|
||||
createInitialStructure();
|
||||
myFixture.copyFileToProject(BASE_PATH + "RJavaFileMarkers.java", "app/src/p1/p2/R.java");
|
||||
myFixture.copyFileToProject("R.java", "app/src/p1/p2/R.java");
|
||||
VirtualFile file = myFixture.copyFileToProject(BASE_PATH + getTestName(false) + ".java", "/app/src/p1/p2/Java.java");
|
||||
myFixture.configureFromExistingVirtualFile(file);
|
||||
|
||||
@@ -224,47 +199,6 @@ public class AndroidLibraryProjectTest extends UsefulTestCase {
|
||||
assertEquals("main.xml", ((PsiFile)targetElement).getName());
|
||||
}
|
||||
|
||||
/*public void testLayoutFileMarkers() throws Exception {
|
||||
createInitialStructure();
|
||||
myFixture.copyFileToProject(BASE_PATH + "RJavaFileMarkers.java", "app/src/p1/p2/R.java");
|
||||
myFixture.copyFileToProject(BASE_PATH + "RJavaFileMarkers.java", "app/src/p1/p2/lib/R.java");
|
||||
myFixture.copyFileToProject(BASE_PATH + "RJavaFileMarkers.java", "lib/src/p1/p2/lib/R.java");
|
||||
List<LineMarkerInfo> markers =
|
||||
AndroidResourcesLineMarkerTest.collectMarkers(myFixture, BASE_PATH + "res/layout/main.xml", "lib/res/layout/main.xml");
|
||||
assertEquals(2, markers.size());
|
||||
|
||||
boolean fileMarker = false;
|
||||
|
||||
for (LineMarkerInfo marker : markers) {
|
||||
GutterIconNavigationHandler handler = marker.getNavigationHandler();
|
||||
PsiElement[] targets;
|
||||
if (marker.getElement() instanceof XmlFile) {
|
||||
fileMarker = true;
|
||||
assertInstanceOf(handler, AndroidResourcesLineMarkerProvider.MyNavigationHandler.class);
|
||||
targets = ((AndroidResourcesLineMarkerProvider.MyNavigationHandler)handler).getTargets();
|
||||
assertNotNull(targets);
|
||||
}
|
||||
else {
|
||||
assertInstanceOf(handler, AndroidResourcesLineMarkerProvider.MyLazyNavigationHandler.class);
|
||||
Computable<PsiElement[]> targetProvider = ((AndroidResourcesLineMarkerProvider.MyLazyNavigationHandler)handler).getTargetProvider();
|
||||
targets = targetProvider.compute();
|
||||
assertNotNull(targets);
|
||||
}
|
||||
assertEquals(3, targets.length);
|
||||
for (PsiElement target : targets) {
|
||||
assertInstanceOf(target, PsiField.class);
|
||||
}
|
||||
}
|
||||
|
||||
assertTrue("LineMarker for file not found", fileMarker);
|
||||
}
|
||||
|
||||
public static void checkTargets(PsiField field, PsiElement[] targets) {
|
||||
assertNotNull(targets);
|
||||
assertTrue(targets.length > 0);
|
||||
assertEquals(field.getName(), 1, targets.length);
|
||||
}*/
|
||||
|
||||
public void testFileResourceFindUsages() throws Throwable {
|
||||
doFindUsagesTest("xml", "lib/res/layout/");
|
||||
}
|
||||
@@ -308,9 +242,9 @@ public class AndroidLibraryProjectTest extends UsefulTestCase {
|
||||
myFixture.copyFileToProject(BASE_PATH + "FindUsagesStyles.xml", "app/res/values/styles.xml");
|
||||
myFixture.copyFileToProject(BASE_PATH + "FindUsagesStyles.xml", "lib/res/values/styles.xml");
|
||||
myFixture.copyFileToProject(BASE_PATH + "picture1.png", "lib/res/drawable/picture1.png");
|
||||
myFixture.copyFileToProject(BASE_PATH + "FindUsagesR.java", "app/src/p1/p2/R.java");
|
||||
myFixture.copyFileToProject(BASE_PATH + "FindUsagesR1.java", "app/src/p1/p2/lib/R.java");
|
||||
myFixture.copyFileToProject(BASE_PATH + "FindUsagesR1.java", "lib/src/p1/p2/lib/R.java");
|
||||
myFixture.copyFileToProject("R.java", "app/src/p1/p2/R.java");
|
||||
myFixture.copyFileToProject(BASE_PATH + "LibR.java", "app/src/p1/p2/lib/R.java");
|
||||
myFixture.copyFileToProject(BASE_PATH + "LibR.java", "lib/src/p1/p2/lib/R.java");
|
||||
Collection<UsageInfo> references = findCodeUsages(getTestName(false) + "." + extension, dir);
|
||||
assertEquals(6, references.size());
|
||||
}
|
||||
|
||||
+1
-1
@@ -190,7 +190,7 @@ public class AndroidAddStringResourceActionTest extends AndroidTestCase {
|
||||
if (stringsXml != null) {
|
||||
myFixture.copyFileToProject(BASE_PATH + stringsXml, "res/values/strings.xml");
|
||||
}
|
||||
myFixture.copyFileToProject(BASE_PATH + "R.java", "src/p1/p2/R.java");
|
||||
myFixture.copyFileToProject("R.java", "src/p1/p2/R.java");
|
||||
myFixture.configureFromExistingVirtualFile(javaFile);
|
||||
final PsiFile javaPsiFile = myFixture.getFile();
|
||||
assertTrue(new AndroidAddStringResourceAction().isAvailable(myFixture.getProject(), myFixture.getEditor(), javaPsiFile));
|
||||
|
||||
Reference in New Issue
Block a user