Merge remote-tracking branch 'origin/master'

This commit is contained in:
Alexander Lobas
2012-04-02 15:46:47 +04:00
28 changed files with 315 additions and 104 deletions
@@ -333,8 +333,12 @@ public class EvaluatorBuilderImpl implements EvaluatorBuilder {
}
// constructs binary evaluator handling unboxing and numeric promotion issues
private static BinaryExpressionEvaluator createBinaryEvaluator(
Evaluator lResult, final PsiType lType, Evaluator rResult, final PsiType rType, final IElementType operation, final @NotNull PsiType expressionExpectedType) {
private static BinaryExpressionEvaluator createBinaryEvaluator(Evaluator lResult,
PsiType lType,
Evaluator rResult,
@NotNull PsiType rType,
@NotNull IElementType operation,
@NotNull PsiType expressionExpectedType) {
// handle unboxing if neccesary
if (isUnboxingInBinaryExpressionApplicable(lType, rType, operation)) {
if (rType instanceof PsiClassType && UnBoxingEvaluator.isTypeUnboxable(rType.getCanonicalText())) {
@@ -71,7 +71,7 @@ public class VirtualFileManagerImpl extends VirtualFileManagerEx {
bus.connect().subscribe(VFS_CHANGES, new BulkVirtualFileListenerAdapter(myVirtualFileListenerMulticaster.getMulticaster()));
}
public void registerFileSystem(VirtualFileSystem fileSystem) {
public void registerFileSystem(@NotNull VirtualFileSystem fileSystem) {
myCollector.addExplicitExtension(fileSystem.getProtocol(), fileSystem);
if (!(fileSystem instanceof CachingVirtualFileSystem)) {
fileSystem.addVirtualFileListener(myVirtualFileListenerMulticaster.getMulticaster());
@@ -79,7 +79,7 @@ public class VirtualFileManagerImpl extends VirtualFileManagerEx {
myPhysicalFileSystems.add(fileSystem);
}
public void unregisterFileSystem(VirtualFileSystem fileSystem) {
public void unregisterFileSystem(@NotNull VirtualFileSystem fileSystem) {
myCollector.removeExplicitExtension(fileSystem.getProtocol(), fileSystem);
fileSystem.removeVirtualFileListener(myVirtualFileListenerMulticaster.getMulticaster());
myPhysicalFileSystems.remove(fileSystem);
@@ -121,7 +121,7 @@ public class LineMarkersPass extends ProgressableTextEditorHighlightingPass impl
myMarkers = mergeLineMarkers(lineMarkers);
}
private List<LineMarkerInfo> mergeLineMarkers(List<LineMarkerInfo> markers) {
private List<LineMarkerInfo> mergeLineMarkers(@NotNull List<LineMarkerInfo> markers) {
List<MergeableLineMarkerInfo> forMerge = new ArrayList<MergeableLineMarkerInfo>();
final Iterator<LineMarkerInfo> iterator = markers.iterator();
while (iterator.hasNext()) {
@@ -154,7 +154,7 @@ public class LineMarkersPass extends ProgressableTextEditorHighlightingPass impl
return result;
}
public static List<LineMarkerProvider> getMarkerProviders(Language language, Project project) {
public static List<LineMarkerProvider> getMarkerProviders(@NotNull Language language, @NotNull Project project) {
return DumbService.getInstance(project).filterByDumbAwareness(LineMarkerProviders.INSTANCE.allForLanguage(language));
}
@@ -239,6 +239,7 @@ public class LineMarkersPass extends ProgressableTextEditorHighlightingPass impl
}
}
@NotNull
public Collection<LineMarkerInfo> queryLineMarkers() {
if (myFile.getNode() == null) {
// binary file? see IDEADEV-2809
@@ -255,7 +256,7 @@ public class LineMarkersPass extends ProgressableTextEditorHighlightingPass impl
}
@NotNull
public static LineMarkerInfo createMethodSeparatorLineMarker(PsiElement startFrom, EditorColorsManager colorsManager) {
public static LineMarkerInfo createMethodSeparatorLineMarker(@NotNull PsiElement startFrom, @NotNull EditorColorsManager colorsManager) {
LineMarkerInfo info = new LineMarkerInfo<PsiElement>(
startFrom,
startFrom.getTextRange(),
@@ -117,7 +117,7 @@ public final class QuickFixAction {
}
private static void addAvailableActionsForGroups(@NotNull HighlightInfo info,
Editor editor,
@NotNull Editor editor,
@NotNull PsiFile file,
@NotNull List<HighlightInfo.IntentionActionDescriptor> outList,
int group,
@@ -278,7 +278,8 @@ public class SelfElementInfo implements SmartPointerElementInfo {
@Override
public int elementHashCode() {
return myVirtualFile == null ? 0 : myVirtualFile.hashCode();
VirtualFile virtualFile = myVirtualFile;
return virtualFile == null ? 0 : virtualFile.hashCode();
}
@Override
@@ -182,23 +182,26 @@ public class InjectedLanguageUtil {
public static PsiFile findInjectedPsiNoCommit(@NotNull PsiFile host, int offset) {
PsiElement injected = findInjectedElementNoCommit(host, offset);
if (injected != null) {
return injected.getContainingFile();
}
return null;
return injected == null ? null : injected.getContainingFile();
}
// consider injected elements
public static PsiElement findElementAtNoCommit(@NotNull PsiFile file, int offset) {
if (!InjectedLanguageManager.getInstance(file.getProject()).isInjectedFragment(file)) {
PsiElement injected = findInjectedElementNoCommit(file, offset);
FileViewProvider viewProvider = file.getViewProvider();
Trinity<PsiElement, PsiElement, Language> result = null;
if (!(viewProvider instanceof InjectedFileViewProvider)) {
PsiDocumentManager documentManager = PsiDocumentManager.getInstance(file.getProject());
result = tryOffset(file, offset, documentManager);
PsiElement injected = result.first;
if (injected != null) {
return injected;
}
}
//PsiElement at = file.findElementAt(offset);
FileViewProvider viewProvider = file.getViewProvider();
return viewProvider.findElementAt(offset, viewProvider.getBaseLanguage());
Language baseLanguage = viewProvider.getBaseLanguage();
if (result != null && baseLanguage == result.third) {
return result.second; // already queried
}
return viewProvider.findElementAt(offset, baseLanguage);
}
private static final InjectedPsiCachedValueProvider INJECTED_PSI_PROVIDER = new InjectedPsiCachedValueProvider();
@@ -271,24 +274,39 @@ public class InjectedLanguageUtil {
Project project = hostFile.getProject();
if (InjectedLanguageManager.getInstance(project).isInjectedFragment(hostFile)) return null;
final PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project);
Trinity<PsiElement, PsiElement, Language> result = tryOffset(hostFile, offset, documentManager);
PsiElement injected = result.first;
return injected;
}
// returns (injected psi, leaf element at the offset, language of the leaf element)
// since findElementAt() is expensive, we trying to reuse its result
@NotNull
private static Trinity<PsiElement,PsiElement,Language> tryOffset(@NotNull PsiFile hostFile, final int offset, @NotNull PsiDocumentManager documentManager) {
FileViewProvider provider = hostFile.getViewProvider();
Language leafLanguage = null;
PsiElement leafElement = null;
for (Language language : provider.getLanguages()) {
PsiElement element = provider.findElementAt(offset, language);
if (element != null) {
if (leafLanguage == null) {
leafLanguage = language;
leafElement = element;
}
PsiElement injected = findInside(element, hostFile, offset, documentManager);
if (injected != null) return injected;
if (injected != null) return Trinity.create(injected,element, language);
}
// maybe we are at the border between two psi elements, then try to find injection at the end of the left element
if (offset != 0) {
element = provider.findElementAt(offset-1, language);
if (element != null && element.getTextRange().getEndOffset() == offset) {
PsiElement injected = findInside(element, hostFile, offset, documentManager);
if (injected != null) return injected;
if (offset != 0 && (element == null || element.getTextRange().getStartOffset() == offset)) {
PsiElement leftElement = provider.findElementAt(offset-1, language);
if (leftElement != null && leftElement.getTextRange().getEndOffset() == offset) {
PsiElement injected = findInside(leftElement, hostFile, offset, documentManager);
if (injected != null) return Trinity.create(injected, element, language);
}
}
}
return null;
return Trinity.create(null, leafElement, leafLanguage);
}
private static PsiElement findInside(@NotNull PsiElement element, @NotNull PsiFile hostFile, final int hostOffset, @NotNull final PsiDocumentManager documentManager) {
@@ -110,6 +110,7 @@ public class OpenFileDescriptor implements Navigatable {
return myLogicalColumn;
}
@Override
public void navigate(boolean requestFocus) {
if (!canNavigate()) {
throw new IllegalStateException("Navigation is not possible with null project");
@@ -157,21 +158,25 @@ public class OpenFileDescriptor implements Navigatable {
private void navigateInProjectView() {
SelectInContext context = new SelectInContext() {
@Override
@NotNull
public Project getProject() {
return myProject;
}
@Override
@NotNull
public VirtualFile getVirtualFile() {
return myFile;
}
@Override
@Nullable
public Object getSelectorInFile() {
return null;
}
@Override
@Nullable
public FileEditorProvider getFileEditorProvider() {
return null;
@@ -217,6 +222,7 @@ public class OpenFileDescriptor implements Navigatable {
int end = editor.getDocument().getLineEndOffset(line);
final TextRange range = new TextRange(start, end);
editor.getFoldingModel().runBatchFoldingOperation(new Runnable() {
@Override
public void run() {
for (FoldRegion region : allRegions) {
if (!region.isExpanded() && range.intersects(TextRange.create(region))) /*region.getStartOffset() <= offset && offset <= region.getEndOffset()*/ {
@@ -231,10 +237,12 @@ public class OpenFileDescriptor implements Navigatable {
e.getScrollingModel().scrollToCaret(ScrollType.CENTER);
}
@Override
public boolean canNavigate() {
return myProject != null;
}
@Override
public boolean canNavigateToSource() {
return myProject != null;
}
@@ -400,7 +400,7 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
component.projectOpened();
}
catch (Throwable e) {
LOG.error(e);
LOG.error(component.toString(), e);
}
}
}
@@ -962,7 +962,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
return closeProject(project, true, false, true);
}
public boolean closeProject(final Project project, final boolean save, final boolean dispose, boolean checkCanClose) {
public boolean closeProject(@NotNull final Project project, final boolean save, final boolean dispose, boolean checkCanClose) {
if (isLight(project)) {
throw new AssertionError("must not close light project");
}
@@ -25,7 +25,7 @@
<option name="READONLY_FRAGMENT_BACKGROUND" value="cfe7ff"/>
<option name="ADDED_LINES_COLOR" value="edfced"/>
<option name="MODIFIED_LINES_COLOR" value="fcf2f2"/>
<option name="MODIFIED_LINES_COLOR" value="e0f0ff"/>
<option name="CONSOLE_BACKGROUND_KEY" value="ffffff" />
</colors>
@@ -41,7 +41,7 @@ public class TestDataProvider implements DataProvider {
@Override
public Object getData(@NonNls String dataId) {
if (myProject.isDisposed()) {
throw new RuntimeException("TestDataProvider is already disposed.\n" +
throw new RuntimeException("TestDataProvider is already disposed for " + myProject + "\n" +
"If you closed a project in test, please reset IdeaTestApplication.setDataProvider.");
}
@@ -1,9 +1,12 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* Copyright 2000-2012 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.
@@ -20,10 +23,7 @@ import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.EditorFactory;
import com.intellij.openapi.editor.ScrollType;
import com.intellij.openapi.editor.colors.EditorColors;
import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.editor.colors.*;
import com.intellij.openapi.editor.ex.DocumentEx;
import com.intellij.openapi.editor.ex.EditorEx;
import com.intellij.openapi.editor.ex.EditorGutterComponentEx;
@@ -59,17 +59,15 @@ public class LineStatusTrackerDrawing {
}
static TextAttributes getAttributesFor(final Range range) {
final EditorColorsScheme globalScheme = EditorColorsManager.getInstance().getGlobalScheme();
final Color stripeColor = globalScheme.getAttributes(getDiffColor(range)).getErrorStripeColor();
final Color stripeColor = getDiffColor(range);
final TextAttributes textAttributes = new TextAttributes(null, stripeColor, null, EffectType.BOXED, Font.PLAIN);
textAttributes.setErrorStripeColor(stripeColor);
return textAttributes;
}
private static void paintGutterFragment(final Editor editor, final Graphics g, final Rectangle r, final TextAttributesKey diffAttributeKey) {
private static void paintGutterFragment(final Editor editor, final Graphics g, final Rectangle r, final Color stripeColor) {
final EditorGutterComponentEx gutter = ((EditorEx)editor).getGutterComponentEx();
final Color stripeColor = editor.getColorsScheme().getAttributes(diffAttributeKey).getErrorStripeColor();
g.setColor(brighter(stripeColor));
g.setColor(stripeColor);
final int endX = gutter.getWhitespaceSeparatorOffset();
final int x = r.x + r.width - 5;
@@ -260,14 +258,15 @@ public class LineStatusTrackerDrawing {
});
}
private static TextAttributesKey getDiffColor(Range range) {
private static Color getDiffColor(Range range) {
final EditorColorsScheme globalScheme = EditorColorsManager.getInstance().getGlobalScheme();
switch (range.getType()) {
case Range.INSERTED:
return DiffColors.DIFF_INSERTED;
return globalScheme.getColor(EditorColors.ADDED_LINES_COLOR);
case Range.DELETED:
return DiffColors.DIFF_DELETED;
return globalScheme.getAttributes(DiffColors.DIFF_DELETED).getEffectColor();
case Range.MODIFIED:
return DiffColors.DIFF_MODIFIED;
return globalScheme.getColor(EditorColors.MODIFIED_LINES_COLOR);
default:
assert false;
return null;
@@ -64,6 +64,9 @@ public class AndroidCommonUtils {
@NonNls public static final String PROGUARD_CFG_PATH_OPTION = "ANDROID_PROGUARD_CFG_PATH";
@NonNls public static final String DIRECTORY_FOR_LOGS_NAME = "proguard_logs";
@NonNls public static final String PROGUARD_OUTPUT_JAR_NAME = "obfuscated_sources.jar";
@NonNls public static final String INCLUDE_SYSTEM_PROGUARD_FILE_OPTION = "INCLUDE_SYSTEM_PROGUARD_FILE";
@NonNls public static final String SYSTEM_PROGUARD_CFG_FILE_NAME = "proguard-android.txt";
@NonNls private static final String PROGUARD_HOME_ENV_VARIABLE = "PROGUARD_HOME";
private AndroidCommonUtils() {
}
@@ -287,18 +290,33 @@ public class AndroidCommonUtils {
@NotNull
public static Map<AndroidCompilerMessageKind, List<String>> launchProguard(@NotNull IAndroidTarget target,
@NotNull String sdkOsPath,
@NotNull String proguardConfigFileOsPath,
@NotNull String inputJarOsPath,
@NotNull String[] externalJarOsPaths,
@NotNull String outputJarFileOsPath,
@Nullable String logDirOutputOsPath) throws IOException {
int sdkToolsRevision,
@NotNull String sdkOsPath,
@NotNull String proguardConfigFileOsPath,
boolean includeSystemProguardFile,
@NotNull String inputJarOsPath,
@NotNull String[] externalJarOsPaths,
@NotNull String outputJarFileOsPath,
@Nullable String logDirOutputOsPath) throws IOException {
final List<String> commands = new ArrayList<String>();
final String toolOsPath = sdkOsPath + File.separator + SdkConstants.OS_SDK_TOOLS_PROGUARD_BIN_FOLDER + SdkConstants.FN_PROGUARD;
commands.add(toolOsPath);
commands.add("@" + quotePath(proguardConfigFileOsPath));
final String proguardHome = sdkOsPath + File.separator + SdkConstants.FD_TOOLS + File.separator + SdkConstants.FD_PROGUARD;
final String systemProguardCfgPath = proguardHome + File.separator + SYSTEM_PROGUARD_CFG_FILE_NAME;
if (isIncludingInProguardSupported(sdkToolsRevision)) {
if (includeSystemProguardFile) {
commands.add("-include");
commands.add(quotePath(systemProguardCfgPath));
}
commands.add("-include");
commands.add(quotePath(proguardConfigFileOsPath));
}
else {
commands.add("@" + quotePath(proguardConfigFileOsPath));
}
commands.add("-injars");
@@ -341,7 +359,10 @@ public class AndroidCommonUtils {
}
LOG.info(command2string(commands));
return AndroidExecutionUtil.doExecute(ArrayUtil.toStringArray(commands));
final Map<String, String> home = System.getenv().containsKey(PROGUARD_HOME_ENV_VARIABLE)
? Collections.<String, String>emptyMap()
: Collections.singletonMap(PROGUARD_HOME_ENV_VARIABLE, proguardHome);
return AndroidExecutionUtil.doExecute(ArrayUtil.toStringArray(commands), home);
}
private static String quotePath(String path) {
@@ -363,4 +384,8 @@ public class AndroidCommonUtils {
public static String toolPath(@NotNull String toolFileName) {
return SdkConstants.OS_SDK_TOOLS_FOLDER + toolFileName;
}
public static boolean isIncludingInProguardSupported(int sdkToolsRevision) {
return sdkToolsRevision == -1 || sdkToolsRevision >= 17;
}
}
@@ -18,10 +18,7 @@ package org.jetbrains.android.util;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* Abstract external tool for compiler.
@@ -34,8 +31,15 @@ public final class AndroidExecutionUtil {
}
@NotNull
public static Map<AndroidCompilerMessageKind, List<String>> doExecute(String... argv) throws IOException {
public static Map<AndroidCompilerMessageKind, List<String>> doExecute(String... argv) throws IOException {
return doExecute(argv, Collections.<String, String>emptyMap());
}
@NotNull
public static Map<AndroidCompilerMessageKind, List<String>> doExecute(String[] argv, Map<? extends String, ? extends String> enviroment)
throws IOException {
ProcessBuilder builder = new ProcessBuilder(argv);
builder.environment().putAll(enviroment);
ProcessResult result = readProcessOutput(builder.start());
Map<AndroidCompilerMessageKind, List<String>> messages = result.getMessages();
int code = result.getExitCode();
@@ -128,7 +128,11 @@ public class AndroidDexBuilder extends ProjectLevelBuilder {
}
final Set<String> externalLibraries = AndroidJpsUtil.getExternalLibraries(projectPaths, module);
// todo: read proguard options from Android facet settings if there is no settings in the context
final String proguardCfgPath = context.getBuilderParameter(AndroidCommonUtils.PROGUARD_CFG_PATH_OPTION);
final String includeSystemProguardCfgOption = context.getBuilderParameter(AndroidCommonUtils.INCLUDE_SYSTEM_PROGUARD_FILE_OPTION);
final boolean includeSystemProguardCfg = Boolean.parseBoolean(includeSystemProguardCfgOption);
final Set<String> fileSet;
try {
@@ -137,7 +141,7 @@ public class AndroidDexBuilder extends ProjectLevelBuilder {
FileUtil.toSystemDependentName(dexOutputDir.getPath() + '/' + AndroidCommonUtils.PROGUARD_OUTPUT_JAR_NAME);
if (!runProguardIfNecessary(facet, classesDir, androidSdk, target, externalLibraries, context,
outputJarPath, proguardCfgPath, proguardStateStorage)) {
outputJarPath, proguardCfgPath, includeSystemProguardCfg, proguardStateStorage)) {
success = false;
continue;
}
@@ -271,6 +275,7 @@ public class AndroidDexBuilder extends ProjectLevelBuilder {
@NotNull CompileContext context,
@NotNull String outputJarPath,
@NotNull String proguardCfgPath,
boolean includeSystemProguardCfg,
@NotNull AndroidFileSetStorage proguardStateStorage) throws IOException {
final Module module = facet.getModule();
@@ -333,8 +338,9 @@ public class AndroidDexBuilder extends ProjectLevelBuilder {
context.processMessage(new ProgressMessage(AndroidJpsBundle.message("android.jps.progress.proguard", module.getName())));
// todo: pass sdk revision
final Map<AndroidCompilerMessageKind, List<String>> messages =
AndroidCommonUtils.launchProguard(target, sdk.getSdkPath(), proguardCfgPath, inputJarOsPath,
AndroidCommonUtils.launchProguard(target, -1, sdk.getSdkPath(), proguardCfgPath, includeSystemProguardCfg, inputJarOsPath,
externalJarOsPaths, outputJarPath, logsDirOsPath);
AndroidJpsUtil.addMessages(context, messages, BUILDER_NAME);
@@ -401,4 +401,5 @@ android.launch.ddms.title=DDMS
android.launch.ddms.already.launched.error=DDMS is already launched
android.disable.adb.service.title=Disable ADB service
android.launch.hierarchy.viewer.action=Hierarchy Viewer
android.launch.draw.9.patch.action=Draw 9 Patch
android.launch.draw.9.patch.action=Draw 9 Patch
android.facet.settings.include.system.proguard=Include system proguard file
@@ -41,6 +41,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.*;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.*;
import com.intellij.psi.JavaPsiFacade;
@@ -82,7 +83,8 @@ public class AndroidCompileUtil {
@NonNls private static final String RESOURCES_CACHE_DIR_NAME = "res-cache";
@NonNls private static final String GEN_MODULE_PREFIX = "~generated_";
@NonNls public static final String PROGUARD_CFG_FILE_NAME = "proguard.cfg";
@NonNls public static final String PROGUARD_CFG_FILE_NAME = "proguard-project.txt";
@NonNls public static final String OLD_PROGUARD_CFG_FILE_NAME = "proguard.cfg";
@NonNls
private static final String[] SCALA_TEST_CONFIGURATIONS =
@@ -115,9 +117,21 @@ public class AndroidCompileUtil {
}
@Nullable
public static VirtualFile getDefaultProguardConfigFile(@NotNull AndroidFacet facet) {
final VirtualFile root = AndroidRootUtil.getMainContentRoot(facet);
return root != null ? root.findChild(PROGUARD_CFG_FILE_NAME) : null;
public static Pair<VirtualFile, Boolean> getDefaultProguardConfigFile(@NotNull AndroidFacet facet) {
VirtualFile root = AndroidRootUtil.getMainContentRoot(facet);
if (root == null) {
return null;
}
final VirtualFile proguardCfg = root.findChild(PROGUARD_CFG_FILE_NAME);
if (proguardCfg != null) {
return new Pair<VirtualFile, Boolean>(proguardCfg, true);
}
final VirtualFile oldProguardCfg = root.findChild(OLD_PROGUARD_CFG_FILE_NAME);
if (oldProguardCfg != null) {
return new Pair<VirtualFile, Boolean>(oldProguardCfg, false);
}
return null;
}
static void addMessages(final CompileContext context, final Map<CompilerMessageCategory, List<String>> messages) {
@@ -820,19 +834,19 @@ public class AndroidCompileUtil {
}
@Nullable
public static String getProguardConfigFilePathIfShouldRun(@NotNull AndroidFacet facet, CompileContext context) {
final String path = context.getCompileScope().
getUserData(AndroidProguardCompiler.PROGUARD_CFG_PATH_KEY);
public static ProguardRunningOptions getProguardConfigFilePathIfShouldRun(@NotNull AndroidFacet facet, CompileContext context) {
final String path = context.getCompileScope().getUserData(AndroidProguardCompiler.PROGUARD_CFG_PATH_KEY);
if (path != null) {
return path;
final Boolean includeSystemProguardFile = context.getCompileScope().
getUserData(AndroidProguardCompiler.INCLUDE_SYSTEM_PROGUARD_FILE);
return new ProguardRunningOptions(path, Boolean.TRUE.equals(includeSystemProguardFile));
}
final AndroidFacetConfiguration configuration = facet.getConfiguration();
if (configuration.RUN_PROGUARD) {
final VirtualFile proguardCfgFile = AndroidRootUtil.getProguardCfgFile(facet);
if (proguardCfgFile != null) {
return FileUtil.toSystemDependentName(proguardCfgFile.getPath());
}
final String proguardCfgPath = proguardCfgFile != null ? FileUtil.toSystemDependentName(proguardCfgFile.getPath()) : null;
return new ProguardRunningOptions(proguardCfgPath, configuration.isIncludeSystemProguardCfgPath());
}
return null;
}
@@ -40,6 +40,7 @@ import java.util.Set;
public class AndroidProguardCompiler implements ClassPostProcessingCompiler {
private static final Logger LOG = Logger.getInstance("#org.jetbrains.android.compiler.AndroidProguardCompiler");
public static Key<String> PROGUARD_CFG_PATH_KEY = Key.create(AndroidCommonUtils.PROGUARD_CFG_PATH_OPTION);
public static Key<Boolean> INCLUDE_SYSTEM_PROGUARD_FILE = Key.create(AndroidCommonUtils.INCLUDE_SYSTEM_PROGUARD_FILE_OPTION);
@NotNull
@Override
@@ -57,13 +58,16 @@ public class AndroidProguardCompiler implements ClassPostProcessingCompiler {
continue;
}
final String proguardCfgPath = AndroidCompileUtil.getProguardConfigFilePathIfShouldRun(facet, context);
if (proguardCfgPath == null) {
final ProguardRunningOptions proguardRunningOptions = AndroidCompileUtil.getProguardConfigFilePathIfShouldRun(facet, context);
if (proguardRunningOptions == null) {
continue;
}
final String proguardCfgPath = proguardRunningOptions.getProguardCfgFile();
if (proguardCfgPath.length() == 0) {
context.addMessage(CompilerMessageCategory.ERROR, "Proguard config file path is not specified", null, -1, -1);
if (proguardCfgPath == null || proguardCfgPath.length() == 0) {
context
.addMessage(CompilerMessageCategory.ERROR, "Proguard config file path is not specified for module " + module.getName(), null,
-1, -1);
continue;
}
@@ -131,8 +135,9 @@ public class AndroidProguardCompiler implements ClassPostProcessingCompiler {
final VirtualFile outputDir = AndroidDexCompiler.getOutputDirectoryForDex(module);
final String outputJarOsPath = FileUtil.toSystemDependentName(outputDir.getPath() + '/' + AndroidCommonUtils.PROGUARD_OUTPUT_JAR_NAME);
items.add(new MyProcessingItem(module, sdkPath, platform.getTarget(), proguardConfigFile, outputJarOsPath, classFilesDir,
classFilesDirs.toArray(new VirtualFile[classFilesDirs.size()]),
items.add(new MyProcessingItem(module, sdkPath, platform.getTarget(), platform.getSdkData().getSdkToolsRevision(),
proguardConfigFile, proguardRunningOptions.isIncludeSystemProguardFile(), outputJarOsPath,
classFilesDir, classFilesDirs.toArray(new VirtualFile[classFilesDirs.size()]),
libClassFilesDirs.toArray(new VirtualFile[libClassFilesDirs.size()]),
externalJars.toArray(new VirtualFile[externalJars.size()]), logsDirOsPath));
}
@@ -163,9 +168,10 @@ public class AndroidProguardCompiler implements ClassPostProcessingCompiler {
final String logsDirOsPath = processingItem.getLogsDirectoryOsPath();
final Map<CompilerMessageCategory, List<String>> messages = AndroidCompileUtil.toCompilerMessageCategoryKeys(
AndroidCommonUtils
.launchProguard(processingItem.getTarget(), processingItem.getSdkOsPath(), proguardConfigFileOsPath, inputJarOsPath,
externalJarOsPaths, processingItem.getOutputJarOsPath(), logsDirOsPath));
AndroidCommonUtils.launchProguard(processingItem.getTarget(), processingItem.getSdkToolsRevision(),
processingItem.getSdkOsPath(), proguardConfigFileOsPath,
processingItem.isIncludeSystemProguardFile(), inputJarOsPath, externalJarOsPaths,
processingItem.getOutputJarOsPath(), logsDirOsPath));
CompilerUtil.refreshIOFile(new File(processingItem.getOutputJarOsPath()));
@@ -208,6 +214,7 @@ public class AndroidProguardCompiler implements ClassPostProcessingCompiler {
private static class MyProcessingItem implements ProcessingItem {
private final Module myModule;
private final IAndroidTarget myTarget;
private final int mySdkToolsRevision;
private final String myOutputJarOsPath;
private final VirtualFile myMainClassFilesDir;
private final VirtualFile[] myClassFilesDirs;
@@ -215,21 +222,26 @@ public class AndroidProguardCompiler implements ClassPostProcessingCompiler {
private final VirtualFile[] myExternalJars;
private final String myLogsDirectoryOsPath;
private final VirtualFile myProguardConfigFile;
private final boolean myIncludeSystemProguardFile;
private final String mySdkOsPath;
private MyProcessingItem(@NotNull Module module,
@NotNull String sdkOsPath,
@NotNull IAndroidTarget target,
int sdkToolsRevision,
@NotNull VirtualFile proguardConfigFile,
boolean includeSystemProguardFile,
@NotNull String outputJarOsPath,
@NotNull VirtualFile mainClassFilesDir,
@NotNull VirtualFile[] classFilesDirs,
@NotNull VirtualFile[] libCLassFilesDirs,
@NotNull VirtualFile[] externalJars,
@NotNull VirtualFile[] externalJars,
@Nullable String logsDirectoryOsPath) {
myModule = module;
myTarget = target;
mySdkToolsRevision = sdkToolsRevision;
myProguardConfigFile = proguardConfigFile;
myIncludeSystemProguardFile = includeSystemProguardFile;
myOutputJarOsPath = outputJarOsPath;
myMainClassFilesDir = mainClassFilesDir;
mySdkOsPath = sdkOsPath;
@@ -269,6 +281,10 @@ public class AndroidProguardCompiler implements ClassPostProcessingCompiler {
return myProguardConfigFile;
}
public boolean isIncludeSystemProguardFile() {
return myIncludeSystemProguardFile;
}
@NotNull
public VirtualFile[] getExternalJars() {
return myExternalJars;
@@ -279,6 +295,10 @@ public class AndroidProguardCompiler implements ClassPostProcessingCompiler {
return myTarget;
}
public int getSdkToolsRevision() {
return mySdkToolsRevision;
}
@Nullable
public String getLogsDirectoryOsPath() {
return myLogsDirectoryOsPath;
@@ -0,0 +1,25 @@
package org.jetbrains.android.compiler;
import org.jetbrains.annotations.Nullable;
/**
* @author Eugene.Kudelevsky
*/
public class ProguardRunningOptions {
private final String myProguardCfgFile;
private final boolean myIncludeSystemProguardFile;
public ProguardRunningOptions(@Nullable String proguardCfgFile, boolean includeSystemProguardFile) {
myProguardCfgFile = proguardCfgFile;
myIncludeSystemProguardFile = includeSystemProguardFile;
}
@Nullable
public String getProguardCfgFile() {
return myProguardCfgFile;
}
public boolean isIncludeSystemProguardFile() {
return myIncludeSystemProguardFile;
}
}
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.android.exportSignedPackage.ApkStep">
<grid id="27dc6" binding="myContentPanel" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="27dc6" binding="myContentPanel" layout-manager="GridLayoutManager" row-count="5" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="486" height="157"/>
@@ -18,7 +18,7 @@
</component>
<vspacer id="6d187">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="c25aa" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="myApkPathField">
@@ -52,6 +52,14 @@
</constraints>
<properties/>
</component>
<component id="33b04" class="javax.swing.JCheckBox" binding="myIncludeSystemProguardFileCheckBox" default-binding="true">
<constraints>
<grid row="3" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<text value="&amp;Include system proguard file"/>
</properties>
</component>
</children>
</grid>
</form>
@@ -42,6 +42,7 @@ import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
@@ -79,6 +80,7 @@ class ApkStep extends ExportSignedPackageWizardStep {
public static final String APK_PATH_PROPERTY_UNSIGNED = "ExportedUnsignedApkPath";
public static final String RUN_PROGUARD_PROPERTY = "AndroidRunProguardForReleaseBuild";
public static final String PROGUARD_CFG_PATH_PROPERTY = "AndroidProguardConfigPath";
public static final String INCLUDE_SYSTEM_PROGUARD_FILE_PROPERTY = "AndroidIncludeSystemProguardFile";
private TextFieldWithBrowseButton myApkPathField;
private JPanel myContentPanel;
@@ -86,6 +88,7 @@ class ApkStep extends ExportSignedPackageWizardStep {
private JCheckBox myProguardCheckBox;
private JBLabel myProguardConfigFilePathLabel;
private TextFieldWithBrowseButton myProguardConfigFilePathField;
private JCheckBox myIncludeSystemProguardFileCheckBox;
private final ExportSignedPackageWizard myWizard;
private boolean myInited;
@@ -140,6 +143,7 @@ class ApkStep extends ExportSignedPackageWizardStep {
final boolean enabled = myProguardCheckBox.isSelected();
myProguardConfigFilePathLabel.setEnabled(enabled);
myProguardConfigFilePathField.setEnabled(enabled);
myIncludeSystemProguardFileCheckBox.setEnabled(enabled);
}
});
@@ -149,7 +153,8 @@ class ApkStep extends ExportSignedPackageWizardStep {
@Override
public void _init() {
if (myInited) return;
Module module = myWizard.getFacet().getModule();
final AndroidFacet facet = myWizard.getFacet();
Module module = facet.getModule();
PropertiesComponent properties = PropertiesComponent.getInstance(module.getProject());
String lastModule = properties.getValue(ChooseModuleStep.MODULE_PROPERTY);
@@ -172,29 +177,41 @@ class ApkStep extends ExportSignedPackageWizardStep {
selected = Boolean.parseBoolean(runProguardPropValue);
}
else {
selected = myWizard.getFacet().getConfiguration().RUN_PROGUARD;
selected = facet.getConfiguration().RUN_PROGUARD;
}
myProguardCheckBox.setSelected(selected);
myProguardConfigFilePathLabel.setEnabled(selected);
myProguardConfigFilePathField.setEnabled(selected);
myIncludeSystemProguardFileCheckBox.setEnabled(selected);
final AndroidPlatform platform = AndroidPlatform.getInstance(module);
final int sdkToolsRevision = platform != null ? platform.getSdkData().getSdkToolsRevision() : -1;
myIncludeSystemProguardFileCheckBox.setVisible(AndroidCommonUtils.isIncludingInProguardSupported(sdkToolsRevision));
final String proguardCfgPath = properties.getValue(PROGUARD_CFG_PATH_PROPERTY);
if (proguardCfgPath != null &&
LocalFileSystem.getInstance().refreshAndFindFileByPath(proguardCfgPath) != null) {
myProguardConfigFilePathField.setText(FileUtil.toSystemDependentName(proguardCfgPath));
final String includeSystemProguardFile = properties.getValue(INCLUDE_SYSTEM_PROGUARD_FILE_PROPERTY);
myIncludeSystemProguardFileCheckBox.setSelected(Boolean.parseBoolean(includeSystemProguardFile));
}
else {
final AndroidFacetConfiguration configuration = myWizard.getFacet().getConfiguration();
final AndroidFacetConfiguration configuration = facet.getConfiguration();
if (configuration.RUN_PROGUARD) {
final VirtualFile proguardCfgFile = AndroidRootUtil.getProguardCfgFile(myWizard.getFacet());
final VirtualFile proguardCfgFile = AndroidRootUtil.getProguardCfgFile(facet);
if (proguardCfgFile != null) {
myProguardConfigFilePathField.setText(FileUtil.toSystemDependentName(proguardCfgFile.getPath()));
}
myIncludeSystemProguardFileCheckBox.setSelected(facet.getConfiguration().isIncludeSystemProguardCfgPath());
}
else {
final VirtualFile proguardConfigFile = AndroidCompileUtil.getDefaultProguardConfigFile(myWizard.getFacet());
if (proguardConfigFile != null) {
myProguardConfigFilePathField.setText(FileUtil.toSystemDependentName(proguardConfigFile.getPath()));
final Pair<VirtualFile, Boolean> pair = AndroidCompileUtil.getDefaultProguardConfigFile(facet);
if (pair != null) {
myProguardConfigFilePathField.setText(FileUtil.toSystemDependentName(pair.getFirst().getPath()));
myIncludeSystemProguardFileCheckBox.setSelected(pair.getSecond());
}
else {
myIncludeSystemProguardFileCheckBox.setSelected(true);
}
}
}
@@ -368,12 +385,14 @@ class ApkStep extends ExportSignedPackageWizardStep {
throw new CommitStepException(AndroidBundle.message("android.extract.package.specify.proguard.cfg.path.error"));
}
properties.setValue(PROGUARD_CFG_PATH_PROPERTY, proguardCfgPath);
properties.setValue(INCLUDE_SYSTEM_PROGUARD_FILE_PROPERTY, Boolean.toString(myIncludeSystemProguardFileCheckBox.isSelected()));
if (!new File(proguardCfgPath).isFile()) {
throw new CommitStepException("Cannot find file " + proguardCfgPath);
}
compileScope.putUserData(AndroidProguardCompiler.PROGUARD_CFG_PATH_KEY, proguardCfgPath);
compileScope.putUserData(AndroidProguardCompiler.INCLUDE_SYSTEM_PROGUARD_FILE, myIncludeSystemProguardFileCheckBox.isSelected());
}
manager.make(compileScope, new CompileStatusNotification() {
@@ -49,6 +49,7 @@ import java.util.List;
public class AndroidFacetConfiguration implements FacetConfiguration {
@NonNls private static final String RES_OVERLAY_FOLDERS_ELEMENT_NAME = "resOverlayFolders";
@NonNls private static final String PATH_ELEMENT_NAME = "path";
@NonNls private static final String INCLUDE_SYSTEM_PROGUARD_FILE_ELEMENT_NAME = "includeSystemProguardFile";
public String GEN_FOLDER_RELATIVE_PATH_APT = "/" + SdkConstants.FD_GEN_SOURCES;
public String GEN_FOLDER_RELATIVE_PATH_AIDL = "/" + SdkConstants.FD_GEN_SOURCES;
@@ -86,6 +87,8 @@ public class AndroidFacetConfiguration implements FacetConfiguration {
public boolean RUN_PROGUARD = false;
public String PROGUARD_CFG_PATH = "/" + AndroidCompileUtil.PROGUARD_CFG_FILE_NAME;
private boolean myIncludeSystemProguardCfgPath = true;
private AndroidFacet myFacet = null;
public void init(@NotNull Module module, @NotNull VirtualFile contentRoot) {
@@ -149,11 +152,26 @@ public class AndroidFacetConfiguration implements FacetConfiguration {
public void readExternal(Element element) throws InvalidDataException {
DefaultJDOMExternalizer.readExternal(this, element);
readResOverlayFolders(element);
final Element includeSystemProguardFile = element.getChild(INCLUDE_SYSTEM_PROGUARD_FILE_ELEMENT_NAME);
if (includeSystemProguardFile != null) {
final String includeSystemProguardFileValue = includeSystemProguardFile.getValue();
if (includeSystemProguardFileValue != null) {
myIncludeSystemProguardCfgPath = Boolean.parseBoolean(includeSystemProguardFileValue);
return;
}
}
myIncludeSystemProguardCfgPath = false;
}
public void writeExternal(Element element) throws WriteExternalException {
DefaultJDOMExternalizer.writeExternal(this, element);
writeResOverlayFolders(element);
final Element includeSystemProguerdFile = new Element(INCLUDE_SYSTEM_PROGUARD_FILE_ELEMENT_NAME);
includeSystemProguerdFile.setText(Boolean.toString(myIncludeSystemProguardCfgPath));
element.addContent(includeSystemProguerdFile);
}
private void readResOverlayFolders(final Element element) throws InvalidDataException {
@@ -179,4 +197,12 @@ public class AndroidFacetConfiguration implements FacetConfiguration {
}
element.addContent(resOverlayFoldersElement);
}
public boolean isIncludeSystemProguardCfgPath() {
return myIncludeSystemProguardCfgPath;
}
public void setIncludeSystemProguardCfgPath(boolean includeSystemProguardCfgPath) {
myIncludeSystemProguardCfgPath = includeSystemProguardCfgPath;
}
}
@@ -115,7 +115,7 @@
</vspacer>
</children>
</grid>
<grid id="84519" layout-manager="GridLayoutManager" row-count="7" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="84519" layout-manager="GridLayoutManager" row-count="8" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="4" right="0"/>
<constraints>
<tabbedpane title="Compiler"/>
@@ -198,7 +198,7 @@
</grid>
<vspacer id="e716a">
<constraints>
<grid row="6" column="0" row-span="1" col-span="2" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
<grid row="7" column="0" row-span="1" col-span="2" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<grid id="4c810" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
@@ -327,6 +327,14 @@
<text resource-bundle="messages/AndroidBundle" key="android.facet.settings.proguard.cfg.label"/>
</properties>
</component>
<component id="6630f" class="javax.swing.JCheckBox" binding="myIncludeSystemProguardFileCheckBox" default-binding="true">
<constraints>
<grid row="6" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/AndroidBundle" key="android.facet.settings.include.system.proguard"/>
</properties>
</component>
</children>
</grid>
</children>
@@ -42,7 +42,9 @@ import org.jetbrains.android.compiler.AndroidAutogeneratorMode;
import org.jetbrains.android.compiler.AndroidCompileUtil;
import org.jetbrains.android.maven.AndroidMavenProvider;
import org.jetbrains.android.maven.AndroidMavenUtil;
import org.jetbrains.android.sdk.AndroidPlatform;
import org.jetbrains.android.util.AndroidBundle;
import org.jetbrains.android.util.AndroidCommonUtils;
import org.jetbrains.android.util.AndroidUtils;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
@@ -97,6 +99,7 @@ public class AndroidFacetEditorTab extends FacetEditorTab {
private JBCheckBox myRunProguardCheckBox;
private JBLabel myProguardConfigFileLabel;
private TextFieldWithBrowseButton myProguardConfigFileTextField;
private JCheckBox myIncludeSystemProguardFileCheckBox;
public AndroidFacetEditorTab(FacetEditorContext context, AndroidFacetConfiguration androidFacetConfiguration) {
final Project project = context.getProject();
@@ -162,6 +165,7 @@ public class AndroidFacetEditorTab extends FacetEditorTab {
final boolean enabled = myRunProguardCheckBox.isSelected();
myProguardConfigFileLabel.setEnabled(enabled);
myProguardConfigFileTextField.setEnabled(enabled);
myIncludeSystemProguardFileCheckBox.setEnabled(enabled);
}
});
@@ -328,6 +332,9 @@ public class AndroidFacetEditorTab extends FacetEditorTab {
if (myConfiguration.RUN_PROGUARD != myRunProguardCheckBox.isSelected()) {
return true;
}
if (myConfiguration.isIncludeSystemProguardCfgPath() != myIncludeSystemProguardFileCheckBox.isSelected()) {
return true;
}
return false;
}
@@ -459,6 +466,7 @@ public class AndroidFacetEditorTab extends FacetEditorTab {
}
myConfiguration.RUN_PROGUARD = myRunProguardCheckBox.isSelected();
myConfiguration.setIncludeSystemProguardCfgPath(myIncludeSystemProguardFileCheckBox.isSelected());
boolean useCustomAptSrc = myUseCustomSourceDirectoryRadio.isSelected();
@@ -563,6 +571,12 @@ public class AndroidFacetEditorTab extends FacetEditorTab {
myRunProguardCheckBox.setSelected(runProguard);
myProguardConfigFileLabel.setEnabled(runProguard);
myProguardConfigFileTextField.setEnabled(runProguard);
myIncludeSystemProguardFileCheckBox.setEnabled(runProguard);
myIncludeSystemProguardFileCheckBox.setSelected(configuration.isIncludeSystemProguardCfgPath());
final AndroidPlatform platform = configuration.getAndroidPlatform();
final int sdkToolsRevision = platform != null ? platform.getSdkData().getSdkToolsRevision() : -1;
myIncludeSystemProguardFileCheckBox.setVisible(AndroidCommonUtils.isIncludingInProguardSupported(sdkToolsRevision));
myGenerateRJavaWhenChanged.setSelected(configuration.REGENERATE_R_JAVA);
myGenerateIdlWhenChanged.setSelected(configuration.REGENERATE_JAVA_BY_AIDL);
@@ -1,6 +1,5 @@
package org.jetbrains.android.inspections.lint;
import com.android.sdklib.SdkConstants;
import com.android.tools.lint.checks.BuiltinIssueRegistry;
import com.android.tools.lint.client.api.IssueRegistry;
import com.android.tools.lint.client.api.LintDriver;
@@ -28,6 +27,7 @@ import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.android.compiler.AndroidCompileUtil;
import org.jetbrains.android.facet.AndroidFacet;
import org.jetbrains.android.facet.AndroidRootUtil;
import org.jetbrains.android.util.AndroidBundle;
@@ -71,7 +71,8 @@ public class AndroidLintExternalAnnotator extends ExternalAnnotator<State, State
}
}
else if (fileType == FileTypes.PLAIN_TEXT) {
if (!SdkConstants.FN_PROGUARD_CFG.equals(file.getName())) {
if (!AndroidCompileUtil.PROGUARD_CFG_FILE_NAME.equals(file.getName()) &&
!AndroidCompileUtil.OLD_PROGUARD_CFG_FILE_NAME.equals(file.getName())) {
return null;
}
}
@@ -83,7 +83,7 @@ public class AndroidTestConfigurationProducer extends JavaRuntimeConfigurationPr
@Nullable
private RunnerAndConfigurationSettings createClassConfiguration(PsiElement element, ConfigurationContext context) {
PsiClass elementClass = PsiTreeUtil.getParentOfType(element, PsiClass.class);
PsiClass elementClass = PsiTreeUtil.getParentOfType(element, PsiClass.class, false);
while (elementClass != null) {
if (JUnitUtil.isTestClass(elementClass)) {
RunnerAndConfigurationSettings settings =
@@ -64,27 +64,32 @@ public class AndroidSdkData {
private IAndroidTarget[] myTargets = null;
private final int myPlatformToolsRevision;
private final int mySdkToolsRevision;
public AndroidSdkData(@NotNull SdkManager sdkManager, @NotNull String sdkDirOsPath) {
mySdkManager = sdkManager;
myPlatformToolsRevision = parsePackageRevision(sdkDirOsPath, SdkConstants.FD_PLATFORM_TOOLS);
mySdkToolsRevision = parsePackageRevision(sdkDirOsPath, SdkConstants.FD_TOOLS);
}
final File platformToolsPropFile =
new File(sdkDirOsPath + File.separatorChar + SdkConstants.FD_PLATFORM_TOOLS + File.separatorChar + SdkConstants.FN_SOURCE_PROP);
int platformToolsRevision = -1;
if (platformToolsPropFile.exists() && platformToolsPropFile.isFile()) {
private static int parsePackageRevision(@NotNull String sdkDirOsPath, @NotNull String packageDirName) {
final File propFile =
new File(sdkDirOsPath + File.separatorChar + packageDirName + File.separatorChar + SdkConstants.FN_SOURCE_PROP);
int revisionNumber = -1;
if (propFile.exists() && propFile.isFile()) {
final Map<String, String> map =
ProjectProperties.parsePropertyFile(new BufferingFileWrapper(platformToolsPropFile), new MessageBuildingSdkLog());
ProjectProperties.parsePropertyFile(new BufferingFileWrapper(propFile), new MessageBuildingSdkLog());
final String revision = map.get("Pkg.Revision");
if (revision != null) {
try {
platformToolsRevision = Integer.parseInt(revision);
revisionNumber = Integer.parseInt(revision);
}
catch (NumberFormatException e) {
LOG.info(e);
}
}
}
myPlatformToolsRevision = platformToolsRevision > 0 ? platformToolsRevision : -1;
return revisionNumber > 0 ? revisionNumber : -1;
}
@NotNull
@@ -151,6 +156,10 @@ public class AndroidSdkData {
return myPlatformToolsRevision;
}
public int getSdkToolsRevision() {
return mySdkToolsRevision;
}
@Nullable
public static AndroidSdkData parse(@NotNull String path, @NotNull ISdkLog log) {
final SdkManager manager = AndroidCommonUtils.createSdkManager(path, log);
+1 -1
View File
@@ -27,6 +27,6 @@ try {
System.out.println result
}
}
catch (e) {
catch (Throwable e) {
e.printStackTrace()
}