diff --git a/build/scripts/libLicenses.gant b/build/scripts/libLicenses.gant index 29b981ef038e..251288b4f97a 100644 --- a/build/scripts/libLicenses.gant +++ b/build/scripts/libLicenses.gant @@ -172,7 +172,7 @@ libraryLicense(name: "Apache Sanselan", libraryName: "Sanselan", version: "0.98" libraryLicense(name: "Automaton", libraryName: "automaton.jar", version: "1.11", license: "BSD", url: "http://www.brics.dk/automaton/", licenseUrl: "http://www.opensource.org/licenses/bsd-license.php") libraryLicense(name: "DTDParser", version: "1.13", license: "LGPL", url: "http://sourceforge.net/projects/dtdparser/", licenseUrl: "http://www.opensource.org/licenses/lgpl-2.1") libraryLicense(name: "Ganymed", version: "bundled with SVNKit", libraryName: "svnkit.jar", license: "BSD", url: "http://www.ganymed.ethz.ch/ssh2/", licenseUrl: "http://www.ganymed.ethz.ch/ssh2/LICENSE.txt") -libraryLicense(name: "sqljet", version: "bundled with SVNKit", libraryName: "sqljet.jar", license: "GPLv2", url: "http://sqljet.com", licenseUrl: "http://www.opensource.org/licenses/lgpl-2.1") +libraryLicense(name: "sqljet", version: "bundled with SVNKit", libraryName: "sqljet_fix.jar", license: "GPLv2", url: "http://sqljet.com", licenseUrl: "http://www.opensource.org/licenses/lgpl-2.1") libraryLicense(name: "svnkit-javahl", version: "bundled with SVNKit", libraryName: "svnkit-javahl.jar", license: "link (commercial license)", url: "http://www.svnkit.com/", licenseUrl: "http://svnkit.com/license.html") libraryLicense(name: "javahl", version: "1.7.2", libraryName: "javahl.jar", license: "Apache", url: "http://subversion.apache.org", licenseUrl: "http://www.apache.org/licenses/LICENSE-2.0") libraryLicense(name: "Apache Commons HTTPClient", libraryName: "httpclient-4.1.1.jar", version:"4.1.1", license: "Apache 2.0", diff --git a/java/debugger/openapi/src/com/intellij/debugger/engine/DebuggerUtils.java b/java/debugger/openapi/src/com/intellij/debugger/engine/DebuggerUtils.java index 382bcff89b41..96d684a289d3 100644 --- a/java/debugger/openapi/src/com/intellij/debugger/engine/DebuggerUtils.java +++ b/java/debugger/openapi/src/com/intellij/debugger/engine/DebuggerUtils.java @@ -334,19 +334,36 @@ public abstract class DebuggerUtils { return getSuperType(subType, superType) != null; } - public static PsiClass findClass(String className, Project project, final GlobalSearchScope scope) { + @Nullable + public static PsiClass findClass(final String className, Project project, final GlobalSearchScope scope) { ApplicationManager.getApplication().assertReadAccessAllowed(); final PsiManager psiManager = PsiManager.getInstance(project); + final JavaPsiFacade javaPsiFacade = JavaPsiFacade.getInstance(psiManager.getProject()); if (getArrayClass(className) != null) { - return JavaPsiFacade.getInstance(psiManager.getProject()).getElementFactory().getArrayClass(LanguageLevelProjectExtension.getInstance(psiManager.getProject()).getLanguageLevel()); + return javaPsiFacade.getElementFactory().getArrayClass(LanguageLevelProjectExtension.getInstance(psiManager.getProject()).getLanguageLevel()); } if(project.isDefault()) { return null; } final String _className = className.replace('$', '.'); - final PsiClass aClass = JavaPsiFacade.getInstance(psiManager.getProject()).findClass(_className, scope); - if (aClass == null && scope != GlobalSearchScope.allScope(project)) { - return JavaPsiFacade.getInstance(psiManager.getProject()).findClass(_className, GlobalSearchScope.allScope(project)); + PsiClass aClass = javaPsiFacade.findClass(_className, scope); + if (aClass == null) { + if (!_className.equals(className)) { + // try original name if it differs from the normalized name + aClass = javaPsiFacade.findClass(className, scope); + } + } + if (aClass == null) { + final GlobalSearchScope globalScope = GlobalSearchScope.allScope(project); + if (!globalScope.equals(scope)) { + aClass = javaPsiFacade.findClass(_className, globalScope); + if (aClass == null) { + if (!_className.equals(className)) { + // try original name with global scope if the original differs from the normalized name + aClass = javaPsiFacade.findClass(className, globalScope); + } + } + } } return aClass; } diff --git a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java index c3839457750b..208f6e1778a8 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java +++ b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java @@ -61,6 +61,7 @@ import com.intellij.ui.popup.PopupUpdateProcessor; import com.intellij.usageView.UsageInfo; import com.intellij.usages.*; import com.intellij.util.Alarm; +import com.intellij.util.PlatformUtils; import com.intellij.util.Processor; import com.intellij.util.diff.Diff; import com.intellij.util.diff.FilesTooBigForDiffException; @@ -195,7 +196,7 @@ public abstract class ChooseByNameBase { } public boolean isSearchInAnyPlace() { - return mySearchInAnyPlace; + return PlatformUtils.isCidr() || mySearchInAnyPlace; } public void setSearchInAnyPlace(boolean searchInAnyPlace) { diff --git a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/DefaultChooseByNameItemProvider.java b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/DefaultChooseByNameItemProvider.java index 7fbc2a2fdbd4..23bc20e3721d 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/DefaultChooseByNameItemProvider.java +++ b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/DefaultChooseByNameItemProvider.java @@ -19,6 +19,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Computable; +import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiElement; @@ -32,10 +33,7 @@ import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.Nullable; import java.lang.ref.WeakReference; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; +import java.util.*; public class DefaultChooseByNameItemProvider implements ChooseByNameItemProvider { private static final Logger LOG = Logger.getInstance("#com.intellij.ide.util.gotoByName.ChooseByNameIdea"); @@ -53,21 +51,41 @@ public class DefaultChooseByNameItemProvider implements ChooseByNameItemProvider Processor consumer) { String namePattern = getNamePattern(base, pattern); String qualifierPattern = getQualifierPattern(base, pattern); + String modifiedNamePattern = null; if (base.isSearchInAnyPlace() && !namePattern.trim().isEmpty()) { - namePattern = "*" + namePattern + "*"; + modifiedNamePattern = "*" + namePattern + "*"; } boolean empty = namePattern.isEmpty() || namePattern.equals("@"); // TODO[yole]: remove implicit dependency if (empty && !base.canShowListForEmptyPattern()) return; List namesList = new ArrayList(); - getNamesByPattern(base, base.getNames(everywhere), cancelled, namesList, namePattern); + String[] names = base.getNames(everywhere); + getNamesByPattern(base, names, cancelled, namesList, namePattern); if (cancelled.compute()) { throw new ProcessCanceledException(); } sortNamesList(namePattern, namesList); + if (modifiedNamePattern != null) { + final Set matched = new HashSet(namesList); + List additionalNamesList = new ArrayList(); + namePattern = modifiedNamePattern; + getNamesByPattern(base, names, cancelled, additionalNamesList, namePattern); + additionalNamesList = ContainerUtil.filter(additionalNamesList, new Condition() { + @Override + public boolean value(String name) { + return !matched.contains(name); + } + }); + sortNamesList(namePattern, additionalNamesList); + namesList.addAll(additionalNamesList); + } + + if (cancelled.compute()) { + throw new ProcessCanceledException(); + } List sameNameElements = new SmartList(); diff --git a/platform/lang-impl/src/com/intellij/indentation/IndentationParser.java b/platform/lang-impl/src/com/intellij/indentation/IndentationParser.java index 7edfc9f94405..8ac2a889a340 100644 --- a/platform/lang-impl/src/com/intellij/indentation/IndentationParser.java +++ b/platform/lang-impl/src/com/intellij/indentation/IndentationParser.java @@ -40,43 +40,46 @@ public abstract class IndentationParser implements PsiParser { // EOL if (type == myEolTokenType) { // Handle variant with several EOLs - if (startLineMarker == null){ + if (startLineMarker == null) { startLineMarker = builder.mark(); } eolSeen = true; - } else - - // Indent - { - if (type == myIndentTokenType){ + } + else { + if (type == myIndentTokenType) { //noinspection ConstantConditions currentIndent = builder.getTokenText().length(); - } else - - if (eolSeen) { - if (startLineMarker != null){ - startLineMarker.rollbackTo(); - startLineMarker = null; + } + else { + if (!eolSeen && !stack.isEmpty() && currentIndent > 0 && currentIndent < stack.peek().first) { + // sometimes we do not have EOL between indents + eolSeen = true; } - // Close indentation blocks - while (!stack.isEmpty() && currentIndent < stack.peek().first){ - stack.pop().second.done(myBlockElementType); - } - - if (!stack.isEmpty()) { - final Pair pair = stack.peek(); - if (currentIndent == pair.first) { + if (eolSeen) { + if (startLineMarker != null) { + startLineMarker.rollbackTo(); + startLineMarker = null; + } + // Close indentation blocks + while (!stack.isEmpty() && currentIndent < stack.peek().first){ stack.pop().second.done(myBlockElementType); - passEOLsAndIndents(builder); - stack.push(Pair.create(currentIndent, builder.mark())); } - if (currentIndent > pair.first) { - passEOLsAndIndents(builder); - stack.push(Pair.create(currentIndent, builder.mark())); + + if (!stack.isEmpty()) { + final Pair pair = stack.peek(); + if (currentIndent == pair.first) { + stack.pop().second.done(myBlockElementType); + passEOLsAndIndents(builder); + stack.push(Pair.create(currentIndent, builder.mark())); + } + if (currentIndent > pair.first) { + passEOLsAndIndents(builder); + stack.push(Pair.create(currentIndent, builder.mark())); + } } + eolSeen = false; + currentIndent = 0; } - eolSeen = false; - currentIndent = 0; } } advanceLexer(builder); diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionConfigTreeNode.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionConfigTreeNode.java index 9b22317381e7..b28b82abd186 100644 --- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionConfigTreeNode.java +++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionConfigTreeNode.java @@ -20,6 +20,7 @@ */ package com.intellij.profile.codeInspection.ui; +import com.intellij.codeInsight.daemon.HighlightDisplayKey; import com.intellij.codeInspection.ex.Descriptor; import com.intellij.codeInspection.ex.ScopeToolState; import com.intellij.openapi.util.NotNullLazyValue; @@ -108,4 +109,15 @@ public class InspectionConfigTreeNode extends CheckedTreeNode { public void dropCache() { myProperSetting.drop(); } + + @Override + public String toString() { + if (userObject instanceof Descriptor) { + final String displayNameByKey = HighlightDisplayKey.getDisplayNameByKey(((Descriptor)userObject).getKey()); + if (displayNameByKey != null) { + return displayNameByKey; + } + } + return super.toString(); + } } \ No newline at end of file diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/InplaceRefactoring.java b/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/InplaceRefactoring.java index 9439abe27109..293ab0095f42 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/InplaceRefactoring.java +++ b/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/InplaceRefactoring.java @@ -71,6 +71,8 @@ import com.intellij.psi.search.searches.ReferencesSearch; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.refactoring.util.CommonRefactoringUtil; import com.intellij.ui.awt.RelativePoint; +import com.intellij.util.CommonProcessors; +import com.intellij.util.Query; import com.intellij.util.containers.Stack; import com.intellij.util.ui.PositionTracker; import org.jetbrains.annotations.NonNls; @@ -220,8 +222,22 @@ public abstract class InplaceRefactoring { return new MyLookupExpression(getInitialName(), myNameSuggestions, myElementToRename, shouldSelectAll(), myAdvertisementText); } + protected boolean acceptReference(PsiReference reference) { + return true; + } + protected Collection collectRefs(SearchScope referencesSearchScope) { - return ReferencesSearch.search(myElementToRename, referencesSearchScope, false).findAll(); + final Query search = ReferencesSearch.search(myElementToRename, referencesSearchScope, false); + + final CommonProcessors.CollectProcessor processor = new CommonProcessors.CollectProcessor() { + @Override + protected boolean accept(PsiReference reference) { + return acceptReference(reference); + } + }; + + search.forEach(processor); + return processor.getResults(); } protected boolean buildTemplateAndStart(final Collection refs, diff --git a/platform/lang-impl/src/com/intellij/refactoring/safeDelete/SafeDeleteHandler.java b/platform/lang-impl/src/com/intellij/refactoring/safeDelete/SafeDeleteHandler.java index 92ce9a481739..7dc8e6b4238a 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/safeDelete/SafeDeleteHandler.java +++ b/platform/lang-impl/src/com/intellij/refactoring/safeDelete/SafeDeleteHandler.java @@ -129,10 +129,8 @@ public class SafeDeleteHandler implements RefactoringActionHandler { }; - if (elementsToDelete.length > 0) { - SafeDeleteDialog dialog = new SafeDeleteDialog(project, elementsToDelete, callback); - dialog.show(); - } + SafeDeleteDialog dialog = new SafeDeleteDialog(project, elementsToDelete, callback); + dialog.show(); } } } diff --git a/plugins/android/common/src/org/jetbrains/android/compiler/tools/AndroidApkBuilder.java b/plugins/android/common/src/org/jetbrains/android/compiler/tools/AndroidApkBuilder.java index 4fa0175b31a0..70d180c8bec5 100644 --- a/plugins/android/common/src/org/jetbrains/android/compiler/tools/AndroidApkBuilder.java +++ b/plugins/android/common/src/org/jetbrains/android/compiler/tools/AndroidApkBuilder.java @@ -139,7 +139,7 @@ public class AndroidApkBuilder { } final String zipAlignPath = sdkPath + File.separator + AndroidCommonUtils.toolPath(SdkConstants.FN_ZIPALIGN); boolean withAlignment = new File(zipAlignPath).exists(); - String unalignedApk = finalApk + UNALIGNED_SUFFIX; + String unalignedApk = AndroidCommonUtils.addSuffixToFileName(finalApk, UNALIGNED_SUFFIX); Map> map2 = filterUsingKeystoreMessages( finalPackage(dexPath, sourceRoots, externalJars, nativeLibsFolders, withAlignment ? unalignedApk : finalApk, resPackagePath, diff --git a/plugins/android/common/src/org/jetbrains/android/util/AndroidCommonUtils.java b/plugins/android/common/src/org/jetbrains/android/util/AndroidCommonUtils.java index fa569419a208..432be8fbea6d 100644 --- a/plugins/android/common/src/org/jetbrains/android/util/AndroidCommonUtils.java +++ b/plugins/android/common/src/org/jetbrains/android/util/AndroidCommonUtils.java @@ -516,4 +516,15 @@ public class AndroidCommonUtils { } return result.toArray(new File[result.size()]); } + + @NotNull + public static String addSuffixToFileName(@NotNull String path, @NotNull String suffix) { + final int dot = path.lastIndexOf('.'); + if (dot < 0) { + return path + suffix; + } + final String a = path.substring(0, dot); + final String b = path.substring(dot); + return a + suffix + b; + } } diff --git a/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidDexBuilder.java b/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidDexBuilder.java index d0dc6b7ddd36..412989ddb4fa 100644 --- a/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidDexBuilder.java +++ b/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidDexBuilder.java @@ -110,11 +110,9 @@ public class AndroidDexBuilder extends ProjectLevelBuilder { } final ProjectPaths projectPaths = context.getProjectPaths(); - final File dexOutputDir = AndroidJpsUtil.getOutputDirectoryForPackagedFiles(projectPaths, module); - + File dexOutputDir = AndroidJpsUtil.getDirectoryForIntermediateArtifacts(context, module); + dexOutputDir = AndroidJpsUtil.createDirIfNotExist(dexOutputDir, context, BUILDER_NAME); if (dexOutputDir == null) { - context.processMessage(new CompilerMessage(BUILDER_NAME, BuildMessage.Kind.ERROR, AndroidJpsBundle - .message("android.jps.errors.output.dir.not.specified", module.getName()))); success = false; continue; } @@ -125,7 +123,7 @@ public class AndroidDexBuilder extends ProjectLevelBuilder { .message("android.jps.warnings.dex.no.compiled.files", module.getName()))); continue; } - final Set externalLibraries = AndroidJpsUtil.getExternalLibraries(projectPaths, module, platform); + final Set externalLibraries = AndroidJpsUtil.getExternalLibraries(context, module, platform); boolean includeSystemProguardCfg = false; String proguardCfgPath = context.getBuilderParameter(AndroidCommonUtils.PROGUARD_CFG_PATH_OPTION); @@ -175,7 +173,7 @@ public class AndroidDexBuilder extends ProjectLevelBuilder { fileSet.addAll(externalLibraries); jars.addAll(externalLibraries); - AndroidJpsUtil.processClasspath(projectPaths, module, new AndroidDependencyProcessor() { + AndroidJpsUtil.processClasspath(context, module, new AndroidDependencyProcessor() { @Override public void processExternalLibrary(@NotNull File file) { fileSet.add(file.getPath()); @@ -372,7 +370,6 @@ public class AndroidDexBuilder extends ProjectLevelBuilder { return false; } - final ProjectPaths paths = context.getProjectPaths(); final Set classFilesDirs = new HashSet(); final Set libClassFilesDirs = new HashSet(); final Set outputDirs = new HashSet(); @@ -380,7 +377,7 @@ public class AndroidDexBuilder extends ProjectLevelBuilder { AndroidJpsUtil.addSubdirectories(classesDir, classFilesDirs); outputDirs.add(classesDir.getPath()); - AndroidJpsUtil.processClasspath(paths, module, new AndroidDependencyProcessor() { + AndroidJpsUtil.processClasspath(context, module, new AndroidDependencyProcessor() { @Override public void processAndroidLibraryOutputDirectory(@NotNull File dir) { diff --git a/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidJpsUtil.java b/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidJpsUtil.java index 9115b748026a..686dffead6db 100644 --- a/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidJpsUtil.java +++ b/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidJpsUtil.java @@ -37,7 +37,8 @@ class AndroidJpsUtil { private static final Logger LOG = Logger.getInstance("#org.jetbrains.jps.android.AndroidJpsUtil"); @NonNls public static final String ANDROID_STORAGE_DIR = "android"; - @NonNls private static final String RESOURCE_CACHE_STORAGE = "res-cache"; + @NonNls private static final String RESOURCE_CACHE_STORAGE = "res_cache"; + @NonNls private static final String INTERMEDIATE_ARTIFACTS_STORAGE = "intermediate_artifacts"; public static final Condition CLASSES_AND_JARS_FILTER = new Condition() { @Override @@ -142,10 +143,23 @@ class AndroidJpsUtil { return result; } + @NotNull + public static File getDirectoryForIntermediateArtifacts(@NotNull CompileContext context, + @NotNull Module module) { + final File androidStorage = new File(context.getDataManager().getDataStorageRoot(), ANDROID_STORAGE_DIR); + return new File(new File(androidStorage, INTERMEDIATE_ARTIFACTS_STORAGE), module.getName()); + } + @Nullable - public static File getOutputDirectoryForPackagedFiles(@NotNull ProjectPaths paths, @NotNull Module module) { - // todo: return build directory for mavenized modules to place .dex and .apk files into target dir (not target/classes) - return paths.getModuleOutputDir(module, false); + public static File createDirIfNotExist(@NotNull File dir, @NotNull CompileContext context, @NotNull String compilerName) { + if (!dir.exists()) { + if (!dir.mkdirs()) { + context.processMessage(new CompilerMessage(compilerName, BuildMessage.Kind.ERROR, + AndroidJpsBundle.message("android.jps.cannot.create.directory", dir.getPath()))); + return null; + } + } + return dir; } public static void addSubdirectories(@NotNull File baseDir, @NotNull Collection result) { @@ -162,7 +176,9 @@ class AndroidJpsUtil { } @NotNull - public static Set getExternalLibraries(@NotNull ProjectPaths paths, @NotNull Module module, @NotNull AndroidPlatform platform) { + public static Set getExternalLibraries(@NotNull CompileContext context, + @NotNull Module module, + @NotNull AndroidPlatform platform) { final Set result = new HashSet(); final AndroidDependencyProcessor processor = new AndroidDependencyProcessor() { @Override @@ -175,7 +191,7 @@ class AndroidJpsUtil { return type == AndroidDependencyType.EXTERNAL_LIBRARY; } }; - processClasspath(paths, module, processor); + processClasspath(context, module, processor); addAnnotationsJarIfNecessary(platform, result); return result; } @@ -191,18 +207,21 @@ class AndroidJpsUtil { } } - public static void processClasspath(@NotNull ProjectPaths paths, @NotNull Module module, @NotNull AndroidDependencyProcessor processor) { - processClasspath(paths, module, processor, new HashSet(), false); + public static void processClasspath(@NotNull CompileContext context, + @NotNull Module module, + @NotNull AndroidDependencyProcessor processor) { + processClasspath(context, module, processor, new HashSet(), false); } - private static void processClasspath(@NotNull ProjectPaths paths, - @NotNull final Module module, - @NotNull final AndroidDependencyProcessor processor, - @NotNull final Set visitedModules, - final boolean exportedLibrariesOnly) { + private static void processClasspath(@NotNull CompileContext context, + @NotNull final Module module, + @NotNull final AndroidDependencyProcessor processor, + @NotNull final Set visitedModules, + final boolean exportedLibrariesOnly) { if (!visitedModules.add(module.getName())) { return; } + final ProjectPaths paths = context.getProjectPaths(); if (processor.isToProcess(AndroidDependencyType.EXTERNAL_LIBRARY)) { for (ClasspathItem item : module.getClasspath(ClasspathKind.PRODUCTION_RUNTIME, exportedLibrariesOnly)) { @@ -232,25 +251,29 @@ class AndroidJpsUtil { final boolean depLibrary = depFacet != null && depFacet.isLibrary(); final File depClassDir = paths.getModuleOutputDir(depModule, false); - if (depClassDir != null) { - if (depLibrary) { - if (processor.isToProcess(AndroidDependencyType.ANDROID_LIBRARY_PACKAGE)) { - final File packagedClassesJar = new File(depClassDir, AndroidCommonUtils.CLASSES_JAR_FILE_NAME); + if (depLibrary) { + if (processor.isToProcess(AndroidDependencyType.ANDROID_LIBRARY_PACKAGE)) { + final File intArtifactsDir = getDirectoryForIntermediateArtifacts(context, depModule); + final File packagedClassesJar = new File(intArtifactsDir, AndroidCommonUtils.CLASSES_JAR_FILE_NAME); - if (packagedClassesJar.isFile()) { - processor.processAndroidLibraryPackage(packagedClassesJar); - } + if (packagedClassesJar.isFile()) { + processor.processAndroidLibraryPackage(packagedClassesJar); } - if (processor.isToProcess(AndroidDependencyType.ANDROID_LIBRARY_OUTPUT_DIRECTORY)) { + } + if (processor.isToProcess(AndroidDependencyType.ANDROID_LIBRARY_OUTPUT_DIRECTORY)) { + if (depClassDir != null && depClassDir.isDirectory()) { processor.processAndroidLibraryOutputDirectory(depClassDir); } } - else if (processor.isToProcess(AndroidDependencyType.JAVA_MODULE_OUTPUT_DIR) && depFacet == null && depClassDir.isDirectory()) { - // do not support android-app->android-app compile dependencies - processor.processJavaModuleOutputDirectory(depClassDir); - } } - processClasspath(paths, depModule, processor, visitedModules, !depLibrary || exportedLibrariesOnly); + else if (processor.isToProcess(AndroidDependencyType.JAVA_MODULE_OUTPUT_DIR) && + depFacet == null && + depClassDir != null && + depClassDir.isDirectory()) { + // do not support android-app->android-app compile dependencies + processor.processJavaModuleOutputDirectory(depClassDir); + } + processClasspath(context, depModule, processor, visitedModules, !depLibrary || exportedLibrariesOnly); } } } diff --git a/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidLibraryPackagingBuilder.java b/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidLibraryPackagingBuilder.java index ce3943375a6f..ef0c0a770bb3 100644 --- a/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidLibraryPackagingBuilder.java +++ b/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidLibraryPackagingBuilder.java @@ -11,8 +11,6 @@ import org.jetbrains.jps.incremental.BuilderCategory; import org.jetbrains.jps.incremental.CompileContext; import org.jetbrains.jps.incremental.ModuleLevelBuilder; import org.jetbrains.jps.incremental.ProjectBuildException; -import org.jetbrains.jps.incremental.messages.BuildMessage; -import org.jetbrains.jps.incremental.messages.CompilerMessage; import org.jetbrains.jps.incremental.messages.ProgressMessage; import java.io.File; @@ -54,11 +52,9 @@ public class AndroidLibraryPackagingBuilder extends ModuleLevelBuilder { } final ProjectPaths projectPaths = context.getProjectPaths(); - final File outputDirectoryForPackagedFiles = AndroidJpsUtil.getOutputDirectoryForPackagedFiles(projectPaths, module); - - if (outputDirectoryForPackagedFiles == null) { - context.processMessage(new CompilerMessage(BUILDER_NAME, BuildMessage.Kind.ERROR, AndroidJpsBundle - .message("android.jps.errors.output.dir.not.specified", module.getName()))); + File outputDir = AndroidJpsUtil.getDirectoryForIntermediateArtifacts(context, module); + outputDir = AndroidJpsUtil.createDirIfNotExist(outputDir, context, BUILDER_NAME); + if (outputDir == null) { success = false; continue; } @@ -80,7 +76,7 @@ public class AndroidLibraryPackagingBuilder extends ModuleLevelBuilder { if (subdirs.size() > 0) { context.processMessage(new ProgressMessage(AndroidJpsBundle.message("android.jps.progress.library.packaging", module.getName()))); - final File outputJarFile = new File(outputDirectoryForPackagedFiles, AndroidCommonUtils.CLASSES_JAR_FILE_NAME); + final File outputJarFile = new File(outputDir, AndroidCommonUtils.CLASSES_JAR_FILE_NAME); doneSomething = true; try { AndroidCommonUtils.packClassFilesIntoJar(ArrayUtil.EMPTY_STRING_ARRAY, ArrayUtil.toStringArray(subdirs), outputJarFile); diff --git a/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidPackagingBuilder.java b/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidPackagingBuilder.java index 2192dc9b932a..6779cccdac72 100644 --- a/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidPackagingBuilder.java +++ b/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidPackagingBuilder.java @@ -333,8 +333,10 @@ public class AndroidPackagingBuilder extends ProjectLevelBuilder { final String[] sourceRoots = AndroidJpsUtil.toPaths(AndroidJpsUtil.getSourceRootsForModuleAndDependencies(module)); final ProjectPaths paths = context.getProjectPaths(); - final File outputDir = AndroidJpsUtil.getOutputDirectoryForPackagedFiles(paths, module); - if (outputDir == null) { + final File intArtifactsDir = AndroidJpsUtil.getDirectoryForIntermediateArtifacts(context, module); + + final File moduleOutputDir = paths.getModuleOutputDir(module, false); + if (moduleOutputDir == null) { context.processMessage(new CompilerMessage(BUILDER_NAME, BuildMessage.Kind.ERROR, AndroidJpsBundle .message("android.jps.errors.output.dir.not.specified", module.getName()))); return false; @@ -345,13 +347,13 @@ public class AndroidPackagingBuilder extends ProjectLevelBuilder { return false; } - final Set externalJarsSet = AndroidJpsUtil.getExternalLibraries(paths, module, platform); - final File resPackage = getPackagedResourcesFile(module, outputDir); + final Set externalJarsSet = AndroidJpsUtil.getExternalLibraries(context, module, platform); + final File resPackage = getPackagedResourcesFile(module, intArtifactsDir); - final File classesDexFile = new File(outputDir.getPath(), AndroidCommonUtils.CLASSES_FILE_NAME); + final File classesDexFile = new File(intArtifactsDir.getPath(), AndroidCommonUtils.CLASSES_FILE_NAME); final String sdkPath = platform.getSdk().getSdkPath(); - final String outputPath = AndroidJpsUtil.getApkPath(facet, outputDir); + final String outputPath = AndroidJpsUtil.getApkPath(facet, moduleOutputDir); if (outputPath == null) { context.processMessage(new CompilerMessage(BUILDER_NAME, BuildMessage.Kind.ERROR, AndroidJpsBundle .message("android.jps.errors.cannot.compute.output.apk", module.getName()))); @@ -361,7 +363,11 @@ public class AndroidPackagingBuilder extends ProjectLevelBuilder { final String[] nativeLibDirs = collectNativeLibsFolders(facet); final String resPackagePath = release ? resPackage.getPath() + RELEASE_SUFFIX : resPackage.getPath(); - final String outputApkPath = release ? outputPath + UNSIGNED_SUFFIX : outputPath; + + final String outputApkPath = release + ? AndroidCommonUtils.addSuffixToFileName(outputPath, UNSIGNED_SUFFIX) + : outputPath; + final String classesDexFilePath = classesDexFile.getPath(); final String[] externalJars = ArrayUtil.toStringArray(externalJarsSet); @@ -474,10 +480,9 @@ public class AndroidPackagingBuilder extends ProjectLevelBuilder { final ArrayList assetsDirPaths = new ArrayList(); collectAssetDirs(facet, assetsDirPaths); - final File outputDir = AndroidJpsUtil.getOutputDirectoryForPackagedFiles(context.getProjectPaths(), module); + File outputDir = AndroidJpsUtil.getDirectoryForIntermediateArtifacts(context, module); + outputDir = AndroidJpsUtil.createDirIfNotExist(outputDir, context, BUILDER_NAME); if (outputDir == null) { - context.processMessage(new CompilerMessage(BUILDER_NAME, BuildMessage.Kind.ERROR, AndroidJpsBundle - .message("android.jps.errors.output.dir.not.specified", module.getName()))); return false; } diff --git a/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidSourceGeneratingBuilder.java b/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidSourceGeneratingBuilder.java index 265845566c92..de9770c665f8 100644 --- a/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidSourceGeneratingBuilder.java +++ b/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidSourceGeneratingBuilder.java @@ -91,6 +91,12 @@ public class AndroidSourceGeneratingBuilder extends ModuleLevelBuilder { } checkAndroidDependencies(moduleDataMap, context); + if (context.isProjectRebuild()) { + if (!clearAndroidStorages(context, chunk.getModules())) { + return ExitCode.ABORT; + } + } + final Map idlFilesToCompile = new HashMap(); final Map rsFilesToCompile = new HashMap(); @@ -169,6 +175,18 @@ public class AndroidSourceGeneratingBuilder extends ModuleLevelBuilder { return success ? ExitCode.OK : ExitCode.ABORT; } + private static boolean clearAndroidStorages(@NotNull CompileContext context, @NotNull Collection modules) { + for (Module module : modules) { + final File dir = AndroidJpsUtil.getDirectoryForIntermediateArtifacts(context, module); + if (dir.exists() && !FileUtil.delete(dir)) { + context.processMessage( + new CompilerMessage(BUILDER_NAME, BuildMessage.Kind.ERROR, AndroidJpsBundle.message("android.jps.cannot.delete", dir.getPath()))); + return false; + } + } + return true; + } + private static boolean checkVersions(@NotNull Map dataMap, @NotNull CompileContext context) { for (Map.Entry entry : dataMap.entrySet()) { final Module module = entry.getKey(); @@ -581,6 +599,13 @@ public class AndroidSourceGeneratingBuilder extends ModuleLevelBuilder { success = false; continue; } + final File parent = aptOutputDirectory.getParentFile(); + if (parent != null && !parent.exists() && !parent.mkdirs()) { + context.processMessage(new CompilerMessage(ANDROID_APT_COMPILER, BuildMessage.Kind.ERROR, AndroidJpsBundle.message( + "android.jps.cannot.create.directory", parent.getPath()))); + success = false; + continue; + } if (!FileUtil.moveDirWithContent(tmpOutputDir, aptOutputDirectory)) { context.processMessage(new CompilerMessage(ANDROID_APT_COMPILER, BuildMessage.Kind.ERROR, AndroidJpsBundle .message("android.jps.errors.cannot.move.content", tmpOutputDir.getPath(), aptOutputDirectory.getPath()))); diff --git a/plugins/android/src/org/jetbrains/android/compiler/AndroidAptCompiler.java b/plugins/android/src/org/jetbrains/android/compiler/AndroidAptCompiler.java index e06710b619e5..caf9dac270f9 100644 --- a/plugins/android/src/org/jetbrains/android/compiler/AndroidAptCompiler.java +++ b/plugins/android/src/org/jetbrains/android/compiler/AndroidAptCompiler.java @@ -117,6 +117,11 @@ public class AndroidAptCompiler implements SourceGeneratingCompiler { context.addMessage(CompilerMessageCategory.ERROR, "Cannot delete directory " + genRootPath, null, -1, -1); continue; } + final File parent = genRootDir.getParentFile(); + if (parent != null && !parent.exists() && !parent.mkdirs()) { + context.addMessage(CompilerMessageCategory.ERROR, "Cannot create directory " + parent.getPath(), null, -1, -1); + continue; + } if (!FileUtil.moveDirWithContent(tmpOutputDir, genRootDir)) { final String message = "Cannot move content from " + tmpOutputDir.getPath() + " to " + genRootPath; context.addMessage(CompilerMessageCategory.ERROR, message, null, -1, -1); diff --git a/plugins/android/src/org/jetbrains/android/compiler/AndroidPackagingCompiler.java b/plugins/android/src/org/jetbrains/android/compiler/AndroidPackagingCompiler.java index a5e34b7a4ab9..3cf23e95fcd2 100644 --- a/plugins/android/src/org/jetbrains/android/compiler/AndroidPackagingCompiler.java +++ b/plugins/android/src/org/jetbrains/android/compiler/AndroidPackagingCompiler.java @@ -235,7 +235,7 @@ public class AndroidPackagingCompiler implements PackagingCompiler { : item.getResPackagePath(); final String finalPath = unsigned - ? item.getFinalPath() + UNSIGNED_SUFFIX + ? AndroidCommonUtils.addSuffixToFileName(item.getFinalPath(), UNSIGNED_SUFFIX) : item.getFinalPath(); final String[] sourceRoots = AndroidCompileUtil.toOsPaths(item.getSourceRoots()); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/unusedDef/UnusedDefInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/unusedDef/UnusedDefInspection.java index 8cd3b620ca1e..b74bd85d7457 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/unusedDef/UnusedDefInspection.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/unusedDef/UnusedDefInspection.java @@ -147,7 +147,7 @@ public class UnusedDefInspection extends GroovyLocalInspectionBase { } } else if (element instanceof GrVariable) { - toHighlight = ((GrVariable)element).getInitializerGroovy(); + toHighlight = ((GrVariable)element).getNameIdentifierGroovy(); } if (toHighlight == null) toHighlight = element; return toHighlight; diff --git a/plugins/groovy/testdata/highlighting/DefinitionUsedInSwitchCase.groovy b/plugins/groovy/testdata/highlighting/DefinitionUsedInSwitchCase.groovy index db5b2008f5c6..fe8d767a51a1 100644 --- a/plugins/groovy/testdata/highlighting/DefinitionUsedInSwitchCase.groovy +++ b/plugins/groovy/testdata/highlighting/DefinitionUsedInSwitchCase.groovy @@ -14,7 +14,7 @@ * limitations under the License. */ def m = [a: 1, b: 2] -def m1 = [a: 1, b: 2] +def m1 = [a: 1, b: 2] def val = 'a' switch (val) { diff --git a/plugins/groovy/testdata/highlighting/IfIncrementElseReturn.groovy b/plugins/groovy/testdata/highlighting/IfIncrementElseReturn.groovy index db5b2008f5c6..fe8d767a51a1 100644 --- a/plugins/groovy/testdata/highlighting/IfIncrementElseReturn.groovy +++ b/plugins/groovy/testdata/highlighting/IfIncrementElseReturn.groovy @@ -14,7 +14,7 @@ * limitations under the License. */ def m = [a: 1, b: 2] -def m1 = [a: 1, b: 2] +def m1 = [a: 1, b: 2] def val = 'a' switch (val) { diff --git a/plugins/groovy/testdata/highlighting/SwitchControlFlow.groovy b/plugins/groovy/testdata/highlighting/SwitchControlFlow.groovy index bd45c16a39d4..75f8b63eccc8 100644 --- a/plugins/groovy/testdata/highlighting/SwitchControlFlow.groovy +++ b/plugins/groovy/testdata/highlighting/SwitchControlFlow.groovy @@ -16,7 +16,7 @@ def testV(def variable) { def v = "s" def m="10" - def x="10" + def x="10" try { switch (variable) { case 1: diff --git a/plugins/groovy/testdata/highlighting/UnusedVariable.groovy b/plugins/groovy/testdata/highlighting/UnusedVariable.groovy index d4b0eb0364cb..6e67c62fba3e 100644 --- a/plugins/groovy/testdata/highlighting/UnusedVariable.groovy +++ b/plugins/groovy/testdata/highlighting/UnusedVariable.groovy @@ -13,4 +13,4 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -Class clazz = null \ No newline at end of file +Class clazz = null \ No newline at end of file diff --git a/plugins/groovy/testdata/highlighting/UsageInInjection.groovy b/plugins/groovy/testdata/highlighting/UsageInInjection.groovy index 5840ca40e0e8..3b0f5436015a 100644 --- a/plugins/groovy/testdata/highlighting/UsageInInjection.groovy +++ b/plugins/groovy/testdata/highlighting/UsageInInjection.groovy @@ -15,6 +15,6 @@ */ def x = new Date() def y = new Date() -def z = new Date() +def z = new Date() assert false : "should have thrown exception, but returned $x" assert false : "should have thrown exception, but returned ${y}" \ No newline at end of file diff --git a/plugins/groovy/testdata/highlighting/VeryLongDfaWithComplexGenerics.groovy b/plugins/groovy/testdata/highlighting/VeryLongDfaWithComplexGenerics.groovy index 1d67e40d8e71..952de9bdc403 100644 --- a/plugins/groovy/testdata/highlighting/VeryLongDfaWithComplexGenerics.groovy +++ b/plugins/groovy/testdata/highlighting/VeryLongDfaWithComplexGenerics.groovy @@ -19,7 +19,7 @@ class TroubleCase { private Foo fooBaz; private void troubleMethod(boolean b) { - def icDao = (b?fooBaz:fooBar); + def icDao = (b?fooBaz:fooBar); for(Object x: new ArrayList()) { } diff --git a/plugins/properties/src/com/intellij/lang/properties/xml/SoftLazyValue.java b/plugins/properties/src/com/intellij/lang/properties/xml/SoftLazyValue.java new file mode 100644 index 000000000000..237e4276e818 --- /dev/null +++ b/plugins/properties/src/com/intellij/lang/properties/xml/SoftLazyValue.java @@ -0,0 +1,41 @@ +/* + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.lang.properties.xml; + +import org.jetbrains.annotations.NotNull; + +import java.lang.ref.SoftReference; + +/** + * @author Dmitry Avdeev + * Date: 5/25/12 + */ +public abstract class SoftLazyValue { + + private SoftReference myReference; + + public T getValue() { + T t; + if (myReference == null || (t = myReference.get()) == null) { + t = compute(); + myReference = new SoftReference(t); + } + return t; + } + + @NotNull + protected abstract T compute(); +} diff --git a/plugins/properties/src/com/intellij/lang/properties/xml/XmlPropertiesFile.java b/plugins/properties/src/com/intellij/lang/properties/xml/XmlPropertiesFile.java index 14ac2f4629ea..91fb1fe96673 100644 --- a/plugins/properties/src/com/intellij/lang/properties/xml/XmlPropertiesFile.java +++ b/plugins/properties/src/com/intellij/lang/properties/xml/XmlPropertiesFile.java @@ -33,8 +33,25 @@ public class XmlPropertiesFile implements PropertiesFile { private static final Key> KEY = Key.create("xml properties file"); private final XmlFile myFile; - private final List myProperties = new ArrayList(); - private final MultiMap myPropertiesMap = new MultiMap(); + private final SoftLazyValue> myPropertiesMap = new SoftLazyValue>() { + @NotNull + @Override + protected MultiMap compute() { + XmlTag rootTag = myFile.getRootTag(); + if (rootTag == null) { + return MultiMap.emptyInstance(); + } + + XmlTag[] entries = rootTag.findSubTags("entry"); + MultiMap map = new MultiMap(); + + for (XmlTag entry : entries) { + XmlProperty property = new XmlProperty(entry, XmlPropertiesFile.this); + map.putValue(property.getKey(), property); + } + return map; + } + }; @Nullable public static PropertiesFile getPropertiesFile(final PsiFile file) { @@ -55,15 +72,6 @@ public class XmlPropertiesFile implements PropertiesFile { private XmlPropertiesFile(XmlFile file) { myFile = file; - XmlTag rootTag = file.getRootTag(); - if (rootTag != null) { - XmlTag[] entries = rootTag.findSubTags("entry"); - for (XmlTag entry : entries) { - XmlProperty property = new XmlProperty(entry, this); - myProperties.add(property); - myPropertiesMap.putValue(property.getKey(), property); - } - } } @NotNull @@ -75,19 +83,19 @@ public class XmlPropertiesFile implements PropertiesFile { @NotNull @Override public List getProperties() { - return myProperties; + return new ArrayList(myPropertiesMap.getValue().values()); } @Override public IProperty findPropertyByKey(@NotNull @NonNls String key) { - Collection properties = myPropertiesMap.get(key); + Collection properties = myPropertiesMap.getValue().get(key); return properties.isEmpty() ? null : properties.iterator().next(); } @NotNull @Override public List findPropertiesByKey(@NotNull @NonNls String key) { - return new ArrayList(myPropertiesMap.get(key)); + return new ArrayList(myPropertiesMap.getValue().get(key)); } @NotNull diff --git a/plugins/svn4idea/lib/sqljet.jar b/plugins/svn4idea/lib/sqljet_fix.jar similarity index 100% rename from plugins/svn4idea/lib/sqljet.jar rename to plugins/svn4idea/lib/sqljet_fix.jar diff --git a/plugins/svn4idea/svn4idea.iml b/plugins/svn4idea/svn4idea.iml index 34af8777bc56..7a6e12c5d392 100644 --- a/plugins/svn4idea/svn4idea.iml +++ b/plugins/svn4idea/svn4idea.iml @@ -49,7 +49,7 @@ - +