diff --git a/RegExpSupport/src/org/intellij/lang/regexp/RegExpCompletionContributor.java b/RegExpSupport/src/org/intellij/lang/regexp/RegExpCompletionContributor.java index f6f6078d65a9..15832dd473d9 100644 --- a/RegExpSupport/src/org/intellij/lang/regexp/RegExpCompletionContributor.java +++ b/RegExpSupport/src/org/intellij/lang/regexp/RegExpCompletionContributor.java @@ -83,7 +83,7 @@ public class RegExpCompletionContributor extends CompletionContributor { } private static LookupElement createLookupElement(String name, String type, Icon icon) { - return LookupElementBuilder.create(name).setTypeText(type).setIcon(icon); + return LookupElementBuilder.create(name).withTypeText(type).withIcon(icon); } private static class PropertyNameCompletionProvider extends CompletionProvider { diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactManagerImpl.java b/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactManagerImpl.java index bc857548ca2b..2e7c490790d3 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactManagerImpl.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactManagerImpl.java @@ -285,7 +285,7 @@ public class ArtifactManagerImpl extends ArtifactManager implements ProjectCompo ContainerUtil.addIfNotNull(request, requestsToRemove); } - Set newRequests = LocalFileSystem.getInstance().replaceWatchedRoots(requestsToRemove, toAdd, true); + Set newRequests = LocalFileSystem.getInstance().replaceWatchedRoots(requestsToRemove, toAdd, null); for (LocalFileSystem.WatchRequest request : newRequests) { myWatchedOutputs.put(request.getRootPath(), request); } diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/FrameVariablesTree.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/FrameVariablesTree.java index 3df80be7866f..ba9a9ff48172 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/FrameVariablesTree.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/FrameVariablesTree.java @@ -29,8 +29,6 @@ import com.intellij.debugger.engine.evaluation.EvaluateException; import com.intellij.debugger.engine.evaluation.EvaluationContextImpl; import com.intellij.debugger.engine.evaluation.TextWithImports; import com.intellij.debugger.engine.evaluation.TextWithImportsImpl; -import com.intellij.debugger.engine.evaluation.expression.EvaluatorBuilderImpl; -import com.intellij.debugger.engine.evaluation.expression.ExpressionEvaluator; import com.intellij.debugger.engine.events.DebuggerCommandImpl; import com.intellij.debugger.impl.DebuggerContextImpl; import com.intellij.debugger.impl.DebuggerSession; @@ -523,15 +521,7 @@ public class FrameVariablesTree extends DebuggerTree { boolean isConstant = (var instanceof PsiEnumConstant) || (modifierList != null && modifierList.hasModifierProperty(PsiModifier.STATIC) && modifierList.hasModifierProperty(PsiModifier.FINAL)); if (!isConstant) { - final TextWithImportsImpl textWithImports = new TextWithImportsImpl(reference); - try { - final ExpressionEvaluator evaluator = EvaluatorBuilderImpl.build(textWithImports, reference, myPosition); - evaluator.evaluate(myEvalContext); - //collect only expressions that do not produce any exceptions on evaluation - myExpressions.add(textWithImports); - } - catch (EvaluateException ignored) { - } + myExpressions.add(new TextWithImportsImpl(reference)); } } } diff --git a/java/idea-ui/src/com/intellij/ide/impl/NewProjectUtil.java b/java/idea-ui/src/com/intellij/ide/impl/NewProjectUtil.java index 5bb0502d480b..31c8b4da9b64 100644 --- a/java/idea-ui/src/com/intellij/ide/impl/NewProjectUtil.java +++ b/java/idea-ui/src/com/intellij/ide/impl/NewProjectUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 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. @@ -79,12 +79,12 @@ public class NewProjectUtil { try { if (StorageScheme.DIRECTORY_BASED == dialog.getStorageScheme()) { - final File ideaDir = new File(projectFilePath + File.separator + ".idea"); + final File ideaDir = new File(projectFilePath, Project.DIRECTORY_STORE_FOLDER); if (!ideaDir.exists() && !ideaDir.mkdirs()) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { - Messages.showErrorDialog("Unable to create '.idea' directory at: " + projectFilePath, "Project initialization failed"); + Messages.showErrorDialog("Unable to create '.idea' directory at: " + projectFilePath, "Project Initialization Failed"); } }); diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectNameStep.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectNameStep.java index cadc59d215f2..d3762a8d0903 100644 --- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectNameStep.java +++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectNameStep.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 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. @@ -24,6 +24,7 @@ import com.intellij.ide.util.projectWizard.importSources.impl.ProjectFromSources import com.intellij.openapi.application.ApplicationInfo; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.options.ConfigurationException; +import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.text.StringUtil; import com.intellij.projectImport.ProjectFormatPanel; @@ -111,7 +112,7 @@ public class ProjectNameStep extends ModuleWizardStep { return getProjectFileDirectory() + "/" + myNamePathComponent.getNameValue() + ProjectFileType.DOT_DEFAULT_EXTENSION; } else { - return getProjectFileDirectory() + "/" + ".idea"; + return getProjectFileDirectory() + "/" + Project.DIRECTORY_STORE_FOLDER; } } else { diff --git a/java/idea-ui/src/com/intellij/ide/util/projectWizard/ProjectNameStep.java b/java/idea-ui/src/com/intellij/ide/util/projectWizard/ProjectNameStep.java index 8429763d75b2..4ceaff1e3615 100644 --- a/java/idea-ui/src/com/intellij/ide/util/projectWizard/ProjectNameStep.java +++ b/java/idea-ui/src/com/intellij/ide/util/projectWizard/ProjectNameStep.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 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. @@ -21,7 +21,7 @@ import com.intellij.ide.highlighter.ProjectFileType; import com.intellij.openapi.application.ApplicationInfo; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.options.ConfigurationException; -import com.intellij.openapi.project.ProjectCoreUtil; +import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; @@ -118,18 +118,17 @@ public class ProjectNameStep extends ModuleWizardStep { boolean shouldContinue = true; final String path = myWizardContext.isCreatingNewProject() && myWizardContext.getProjectStorageFormat() == DIRECTORY_BASED - ? getProjectFileDirectory() + "/" + ProjectCoreUtil.DIRECTORY_BASED_PROJECT_DIR - : getProjectFilePath(); + ? getProjectFileDirectory() + "/" + Project.DIRECTORY_STORE_FOLDER : getProjectFilePath(); final File projectFile = new File(path); if (projectFile.exists()) { final String title = myWizardContext.isCreatingNewProject() ? IdeBundle.message("title.new.project") : IdeBundle.message("title.add.module"); final String message = myWizardContext.isCreatingNewProject() && myWizardContext.getProjectStorageFormat() == DIRECTORY_BASED - ? IdeBundle.message("prompt.overwrite.project.folder", ProjectCoreUtil.DIRECTORY_BASED_PROJECT_DIR, - projectFile.getParentFile().getAbsolutePath()) - : IdeBundle.message("prompt.overwrite.project.file", projectFile.getAbsolutePath(), - myWizardContext.getPresentationName()); + ? IdeBundle.message("prompt.overwrite.project.folder", + Project.DIRECTORY_STORE_FOLDER, projectFile.getParentFile().getAbsolutePath()) + : IdeBundle.message("prompt.overwrite.project.file", + projectFile.getAbsolutePath(), myWizardContext.getPresentationName()); int answer = Messages.showYesNoDialog(message, title, Messages.getQuestionIcon()); shouldContinue = answer == 0; } diff --git a/java/idea-ui/src/com/intellij/openapi/vcs/checkout/ProjectDirCheckoutListener.java b/java/idea-ui/src/com/intellij/openapi/vcs/checkout/ProjectDirCheckoutListener.java index 5dbf42c56ce3..4909d7657b50 100644 --- a/java/idea-ui/src/com/intellij/openapi/vcs/checkout/ProjectDirCheckoutListener.java +++ b/java/idea-ui/src/com/intellij/openapi/vcs/checkout/ProjectDirCheckoutListener.java @@ -1,3 +1,18 @@ +/* + * 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.openapi.vcs.checkout; import com.intellij.ide.impl.ProjectUtil; @@ -9,16 +24,15 @@ import java.io.File; /** * @author irengrig - * Date: 5/27/11 - * Time: 12:57 PM + * @since 5/27/11 */ public class ProjectDirCheckoutListener implements CheckoutListener { @Override public boolean processCheckedOutDirectory(Project project, File directory) { - if (new File(directory, ".idea").exists()) { - int rc = Messages - .showYesNoDialog(project, VcsBundle.message("checkout.open.project.dir.prompt", ProjectCheckoutListener.getProductNameWithArticle(), - directory.getPath()), VcsBundle.message("checkout.title"), Messages.getQuestionIcon()); + if (new File(directory, Project.DIRECTORY_STORE_FOLDER).exists()) { + String message = VcsBundle.message("checkout.open.project.dir.prompt", + ProjectCheckoutListener.getProductNameWithArticle(), directory.getPath()); + int rc = Messages.showYesNoDialog(project, message, VcsBundle.message("checkout.title"), Messages.getQuestionIcon()); if (rc == 0) { ProjectUtil.openProject(directory.getPath(), project, false); } diff --git a/java/idea-ui/src/com/intellij/projectImport/ProjectOpenProcessorBase.java b/java/idea-ui/src/com/intellij/projectImport/ProjectOpenProcessorBase.java index fc7bec2af9f1..7ede6a8a3f66 100644 --- a/java/idea-ui/src/com/intellij/projectImport/ProjectOpenProcessorBase.java +++ b/java/idea-ui/src/com/intellij/projectImport/ProjectOpenProcessorBase.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 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. @@ -151,7 +151,7 @@ public abstract class ProjectOpenProcessorBase e } wizardContext.setProjectJdk(jdk); - final String dotIdeaFilePath = wizardContext.getProjectFileDirectory() + File.separator + ".idea"; + final String dotIdeaFilePath = wizardContext.getProjectFileDirectory() + File.separator + Project.DIRECTORY_STORE_FOLDER; final String projectFilePath = wizardContext.getProjectFileDirectory() + File.separator + wizardContext.getProjectName() + ProjectFileType.DOT_DEFAULT_EXTENSION; diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/ClassByNameMerger.java b/java/java-impl/src/com/intellij/codeInsight/completion/ClassByNameMerger.java index a3bff10b30a0..c17677ef3476 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/ClassByNameMerger.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/ClassByNameMerger.java @@ -43,7 +43,7 @@ public class ClassByNameMerger implements Consumer { if (lastElement != null) { if (lastElement.getLookupString().equals(element.getLookupString())) { number++; - lastElement = LookupElementBuilder.create(element.getLookupString()).setTailText(" (" + number + " variants...)", true); + lastElement = LookupElementBuilder.create(element.getLookupString()).withTailText(" (" + number + " variants...)", true); return; } diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaLookupElementBuilder.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaLookupElementBuilder.java index 4e4be0bb501b..d5956b46b97b 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaLookupElementBuilder.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaLookupElementBuilder.java @@ -36,7 +36,8 @@ public class JavaLookupElementBuilder { public static LookupElementBuilder forField(@NotNull PsiField field, final String lookupString, final @Nullable PsiClass qualifierClass) { - final LookupElementBuilder builder = LookupElementBuilder.create(field, lookupString).setIcon(field.getIcon(Iconable.ICON_FLAG_VISIBILITY)); + final LookupElementBuilder builder = LookupElementBuilder.create(field, lookupString).withIcon( + field.getIcon(Iconable.ICON_FLAG_VISIBILITY)); return setBoldIfInClass(field, qualifierClass, builder); } @@ -48,14 +49,14 @@ public class JavaLookupElementBuilder { @NotNull String lookupString, final @NotNull PsiSubstitutor substitutor, @Nullable PsiClass qualifierClass) { LookupElementBuilder builder = LookupElementBuilder.create(method, lookupString) - .setIcon(method.getIcon(Iconable.ICON_FLAG_VISIBILITY)) - .setPresentableText(method.getName()) - .setTailText(PsiFormatUtil.formatMethod(method, substitutor, - PsiFormatUtil.SHOW_PARAMETERS, - PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_TYPE)); + .withIcon(method.getIcon(Iconable.ICON_FLAG_VISIBILITY)) + .withPresentableText(method.getName()) + .withTailText(PsiFormatUtil.formatMethod(method, substitutor, + PsiFormatUtil.SHOW_PARAMETERS, + PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_TYPE)); final PsiType returnType = method.getReturnType(); if (returnType != null) { - builder = builder.setTypeText(substitutor.substitute(returnType).getPresentableText()); + builder = builder.withTypeText(substitutor.substitute(returnType).getPresentableText()); } builder = setBoldIfInClass(method, qualifierClass, builder); return builder; @@ -63,7 +64,7 @@ public class JavaLookupElementBuilder { private static LookupElementBuilder setBoldIfInClass(@NotNull PsiMember member, @Nullable PsiClass psiClass, @NotNull LookupElementBuilder builder) { if (psiClass != null && member.getManager().areElementsEquivalent(member.getContainingClass(), psiClass)) { - return builder.setBold(); + return builder.bold(); } return builder; } @@ -81,9 +82,9 @@ public class JavaLookupElementBuilder { final String lookupString, final boolean withLocation) { final LookupElementBuilder builder = - LookupElementBuilder.create(psiClass, lookupString).setIcon(psiClass.getIcon(Iconable.ICON_FLAG_VISIBILITY)); + LookupElementBuilder.create(psiClass, lookupString).withIcon(psiClass.getIcon(Iconable.ICON_FLAG_VISIBILITY)); if (withLocation) { - return builder.setTailText(" (" + PsiFormatUtil.getPackageDisplayName(psiClass) + ")", true); + return builder.withTailText(" (" + PsiFormatUtil.getPackageDisplayName(psiClass) + ")", true); } return builder; } diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaMemberNameCompletionContributor.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaMemberNameCompletionContributor.java index a97bf10446ce..5bb12243485f 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaMemberNameCompletionContributor.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaMemberNameCompletionContributor.java @@ -345,9 +345,9 @@ public class JavaMemberNameCompletionContributor extends CompletionContributor { if (ourClassParent.isAnnotationType() && matcher.prefixMatches(PsiAnnotation.DEFAULT_REFERENCED_METHOD_NAME)) { set.add(LookupElementBuilder.create(PsiAnnotation.DEFAULT_REFERENCED_METHOD_NAME) - .setIcon(PlatformIcons.METHOD_ICON) - .setTailText("()") - .setInsertHandler(ParenthesesInsertHandler.NO_PARAMETERS)); + .withIcon(PlatformIcons.METHOD_ICON) + .withTailText("()") + .withInsertHandler(ParenthesesInsertHandler.NO_PARAMETERS)); } addLookupItems(set, null, matcher, element.getProject(), getUnresolvedReferences(ourClassParent, true)); diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/SameSignatureCallParametersProvider.java b/java/java-impl/src/com/intellij/codeInsight/completion/SameSignatureCallParametersProvider.java index 3597e2cb00d4..ce72dc0c1eb8 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/SameSignatureCallParametersProvider.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/SameSignatureCallParametersProvider.java @@ -86,7 +86,7 @@ class SameSignatureCallParametersProvider extends CompletionProvider set = new LinkedHashSet(); - set.add(JavaLookupElementBuilder.forField(myField).setTypeText(myField.getType().getPresentableText())); + set.add(JavaLookupElementBuilder.forField(myField).withTypeText(myField.getType().getPresentableText())); PsiField[] fields = myClass.getFields(); for (PsiField otherField : fields) { if (!myDefaultFieldName.equals(otherField.getName())) { PsiType otherType = otherField.getType(); for (PsiType type : myExpectedTypes) { if (type.equals(otherType)) { - set.add(JavaLookupElementBuilder.forField(otherField).setTypeText(otherType.getPresentableText())); + set.add(JavaLookupElementBuilder.forField(otherField).withTypeText(otherType.getPresentableText())); } } } diff --git a/java/java-impl/src/com/intellij/psi/impl/source/javadoc/JavadocManagerImpl.java b/java/java-impl/src/com/intellij/psi/impl/source/javadoc/JavadocManagerImpl.java index 72f9fa1ac5b7..5c4ef0dfb9bc 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/javadoc/JavadocManagerImpl.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/javadoc/JavadocManagerImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 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. @@ -15,6 +15,7 @@ */ package com.intellij.psi.impl.source.javadoc; +import com.intellij.codeInspection.SuppressionUtil; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.project.Project; import com.intellij.pom.java.LanguageLevel; @@ -53,7 +54,7 @@ public class JavadocManagerImpl implements JavadocManager { myInfos.add(new SimpleDocTagInfo("code", PsiElement.class, true, LanguageLevel.JDK_1_5)); //Not a standard tag, but added by IDEA for inspection suppression - myInfos.add(new SimpleDocTagInfo("noinspection", PsiElement.class, false, LanguageLevel.JDK_1_3)); + myInfos.add(new SimpleDocTagInfo(SuppressionUtil.SUPPRESS_INSPECTIONS_TAG_NAME, PsiElement.class, false, LanguageLevel.JDK_1_3)); myInfos.add(new ParamDocTagInfo()); myInfos.add(new ReturnDocTagInfo()); diff --git a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/JavaLangClassMemberReference.java b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/JavaLangClassMemberReference.java index af68ee1a409b..26dd7417e3fd 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/JavaLangClassMemberReference.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/JavaLangClassMemberReference.java @@ -127,7 +127,7 @@ public class JavaLangClassMemberReference extends PsiReferenceBase elements = new ArrayList(); for (PsiMethod method : psiClass.getMethods()) { if (type == Type.DECLARED_METHOD || isPublic(method)) { - elements.add(JavaLookupElementBuilder.forMethod(method, PsiSubstitutor.EMPTY).setInsertHandler(this)); + elements.add(JavaLookupElementBuilder.forMethod(method, PsiSubstitutor.EMPTY).withInsertHandler(this)); } } return elements.toArray(); diff --git a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JavaClassReference.java b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JavaClassReference.java index 3d2e68299439..f06185756f76 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JavaClassReference.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JavaClassReference.java @@ -563,7 +563,7 @@ public class JavaClassReference extends GenericReference implements PsiJavaRefer return null; } } - return JavaLookupElementBuilder.forClass(clazz, name, true).addLookupString(qname).addLookupString(clazz.getName()); + return JavaLookupElementBuilder.forClass(clazz, name, true).withLookupString(qname).withLookupString(clazz.getName()); } @Override diff --git a/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureDialog.java b/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureDialog.java index 95ad17bdbe61..c42b42c46da6 100644 --- a/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureDialog.java +++ b/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureDialog.java @@ -347,7 +347,7 @@ public class JavaChangeSignatureDialog extends ChangeSignatureDialogBase insertHandler) { + return withInsertHandler(insertHandler); + } + + public LookupElementBuilder withInsertHandler(@Nullable InsertHandler insertHandler) { return new LookupElementBuilder(myLookupString, myObject, insertHandler, myRenderer, myHardcodedPresentation, myAllLookupStrings, myCaseSensitive); } + /** + * @deprecated use {@link #withRenderer(LookupElementRenderer)} + */ public LookupElementBuilder setRenderer(@Nullable LookupElementRenderer renderer) { + return withRenderer(renderer); + } + public LookupElementBuilder withRenderer(@Nullable LookupElementRenderer renderer) { return new LookupElementBuilder(myLookupString, myObject, myInsertHandler, renderer, myHardcodedPresentation, myAllLookupStrings, myCaseSensitive); } @@ -91,7 +104,14 @@ public class LookupElementBuilder extends LookupElement { return myAllLookupStrings; } + /** + * @deprecated use {@link #withIcon(javax.swing.Icon)} + */ public LookupElementBuilder setIcon(@Nullable Icon icon) { + return withIcon(icon); + } + + public LookupElementBuilder withIcon(@Nullable Icon icon) { final LookupElementPresentation presentation = copyPresentation(); presentation.setIcon(icon); return new LookupElementBuilder(myLookupString, myObject, myInsertHandler, null, presentation, @@ -109,7 +129,13 @@ public class LookupElementBuilder extends LookupElement { return presentation; } + /** + * @deprecated use {@link #withLookupString(String)} + */ public LookupElementBuilder addLookupString(@NotNull String another) { + return withLookupString(another); + } + public LookupElementBuilder withLookupString(@NotNull String another) { final THashSet set = new THashSet(myAllLookupStrings); set.add(another); return new LookupElementBuilder(myLookupString, myObject, myInsertHandler, myRenderer, myHardcodedPresentation, @@ -120,33 +146,63 @@ public class LookupElementBuilder extends LookupElement { return myCaseSensitive; } + /** + * @deprecated use {@link #withCaseSensitivity(boolean)} + */ + public LookupElementBuilder setCaseSensitive(boolean caseSensitive) { + return withCaseSensitivity(caseSensitive); + } /** * @param caseSensitive if this lookup item should be completed in the same letter case as prefix * @return modified builder * @see com.intellij.codeInsight.completion.CompletionResultSet#caseInsensitive() */ - public LookupElementBuilder setCaseSensitive(boolean caseSensitive) { + public LookupElementBuilder withCaseSensitivity(boolean caseSensitive) { return new LookupElementBuilder(myLookupString, myObject, myInsertHandler, myRenderer, myHardcodedPresentation, myAllLookupStrings, caseSensitive); } + /** + * @deprecated use {@link #withItemTextForeground(java.awt.Color)} + */ public LookupElementBuilder setItemTextForeground(@NotNull Color itemTextForeground) { + return withItemTextForeground(itemTextForeground); + } + public LookupElementBuilder withItemTextForeground(@NotNull Color itemTextForeground) { final LookupElementPresentation presentation = copyPresentation(); presentation.setItemTextForeground(itemTextForeground); return new LookupElementBuilder(myLookupString, myObject, myInsertHandler, null, presentation, myAllLookupStrings, myCaseSensitive); } + /** + * @deprecated use {@link #withItemTextUnderlined(boolean)} + */ public LookupElementBuilder setItemTextUnderlined(boolean underlined) { + return withItemTextUnderlined(underlined); + } + public LookupElementBuilder withItemTextUnderlined(boolean underlined) { final LookupElementPresentation presentation = copyPresentation(); presentation.setItemTextUnderlined(underlined); return new LookupElementBuilder(myLookupString, myObject, myInsertHandler, null, presentation, myAllLookupStrings, myCaseSensitive); } + /** + * @deprecated use {@link #withTypeText(String)} + */ public LookupElementBuilder setTypeText(@Nullable String typeText) { - return setTypeText(typeText, false); + return withTypeText(typeText); + } + public LookupElementBuilder withTypeText(@Nullable String typeText) { + return withTypeText(typeText, false); } + /** + * @deprecated use {@link #withTypeText(String, boolean)} + */ public LookupElementBuilder setTypeText(@Nullable String typeText, boolean grayed) { + return withTypeText(typeText, grayed); + } + public LookupElementBuilder withTypeText(@Nullable String typeText, boolean grayed) { final LookupElementPresentation presentation = copyPresentation(); presentation.setTypeText(typeText); presentation.setTypeGrayed(grayed); @@ -154,40 +210,82 @@ public class LookupElementBuilder extends LookupElement { myAllLookupStrings, myCaseSensitive); } + /** + * @deprecated use {@link #withPresentableText(String)} + */ public LookupElementBuilder setPresentableText(@NotNull String presentableText) { + return withPresentableText(presentableText); + } + public LookupElementBuilder withPresentableText(@NotNull String presentableText) { final LookupElementPresentation presentation = copyPresentation(); presentation.setItemText(presentableText); return new LookupElementBuilder(myLookupString, myObject, myInsertHandler, null, presentation, myAllLookupStrings, myCaseSensitive); } + /** + * @deprecated use {@link #bold()} + */ public LookupElementBuilder setBold() { - return setBold(true); + return bold(); + } + public LookupElementBuilder bold() { + return withBoldness(true); } + /** + * @deprecated use {@link #withBoldness(boolean)} + */ public LookupElementBuilder setBold(boolean bold) { + return withBoldness(bold); + } + public LookupElementBuilder withBoldness(boolean bold) { final LookupElementPresentation presentation = copyPresentation(); presentation.setItemTextBold(bold); return new LookupElementBuilder(myLookupString, myObject, myInsertHandler, null, presentation, myAllLookupStrings, myCaseSensitive); } + /** + * @deprecated use {@link #strikeout()} + */ public LookupElementBuilder setStrikeout() { - return setStrikeout(true); + return strikeout(); + } + public LookupElementBuilder strikeout() { + return withStrikeoutness(true); } + /** + * @deprecated use {@link #withStrikeoutness(boolean)} + */ public LookupElementBuilder setStrikeout(boolean strikeout) { + return withStrikeoutness(strikeout); + } + public LookupElementBuilder withStrikeoutness(boolean strikeout) { final LookupElementPresentation presentation = copyPresentation(); presentation.setStrikeout(strikeout); return new LookupElementBuilder(myLookupString, myObject, myInsertHandler, null, presentation, myAllLookupStrings, myCaseSensitive); } + /** + * @deprecated use {@link #withTailText(String)} + */ public LookupElementBuilder setTailText(@Nullable String tailText) { - return setTailText(tailText, false); + return withTailText(tailText); + } + public LookupElementBuilder withTailText(@Nullable String tailText) { + return withTailText(tailText, false); } + /** + * @deprecated use {@link #withTailText(String, boolean)} + */ public LookupElementBuilder setTailText(@Nullable String tailText, boolean grayed) { + return withTailText(tailText, grayed); + } + public LookupElementBuilder withTailText(@Nullable String tailText, boolean grayed) { final LookupElementPresentation presentation = copyPresentation(); presentation.setTailText(tailText, grayed); return new LookupElementBuilder(myLookupString, myObject, myInsertHandler, null, presentation, diff --git a/platform/lang-api/src/com/intellij/openapi/project/ProjectUtil.java b/platform/lang-api/src/com/intellij/openapi/project/ProjectUtil.java index 8d2fcbcf2eaf..507ce096b74c 100644 --- a/platform/lang-api/src/com/intellij/openapi/project/ProjectUtil.java +++ b/platform/lang-api/src/com/intellij/openapi/project/ProjectUtil.java @@ -16,11 +16,11 @@ package com.intellij.openapi.project; import com.intellij.ide.DataManager; -import com.intellij.openapi.fileTypes.InternalFileType; import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.fileEditor.UniqueVFilePathBuilder; import com.intellij.openapi.fileTypes.FileType; +import com.intellij.openapi.fileTypes.InternalFileType; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleUtil; import com.intellij.openapi.roots.JdkOrderEntry; @@ -40,7 +40,9 @@ import javax.swing.*; /** * @author max */ -public class ProjectUtil extends ProjectCoreUtil { +public class ProjectUtil { + /** @deprecated use {@linkplain Project#DIRECTORY_STORE_FOLDER} (to remove in IDEA 13) */ + @SuppressWarnings("UnusedDeclaration") @NonNls public static final String DIRECTORY_BASED_PROJECT_DIR = Project.DIRECTORY_STORE_FOLDER; private ProjectUtil() { } @@ -121,6 +123,16 @@ public class ProjectUtil extends ProjectCoreUtil { return ProjectLocator.getInstance().guessProjectForFile(file); } + public static boolean isProjectOrWorkspaceFile(final VirtualFile file) { + return isProjectOrWorkspaceFile(file, file.getFileType()); + } + + public static boolean isProjectOrWorkspaceFile(final VirtualFile file, + final FileType fileType) { + if (fileType instanceof InternalFileType) return true; + return file.getPath().contains("/"+ Project.DIRECTORY_STORE_FOLDER +"/"); + } + @NotNull public static Project guessCurrentProject(JComponent component) { Project project = null; diff --git a/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettingsManager.java b/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettingsManager.java index 83dc90f17df1..da21f16bf4b6 100644 --- a/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettingsManager.java +++ b/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettingsManager.java @@ -25,6 +25,7 @@ import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.WriteExternalException; import org.jdom.Element; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; public class CodeStyleSettingsManager implements PersistentStateComponent { @@ -56,7 +57,7 @@ public class CodeStyleSettingsManager implements PersistentStateComponent() { - public void handleInsert(final InsertionContext context, final LookupElement item) { - final Document document = context.getEditor().getDocument(); - document.deleteString(context.getEditor().getCaretModel().getOffset(), document.getTextLength()); - } - }), count-i)); + resultSet.addElement(PrioritizedLookupElement.withPriority(LookupElementBuilder.create((String)o).withInsertHandler( + new InsertHandler() { + public void handleInsert(final InsertionContext context, final LookupElement item) { + final Document document = context.getEditor().getDocument(); + document.deleteString(context.getEditor().getCaretModel().getOffset(), document.getTextLength()); + } + }), count-i)); } } result.stopHere(); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/enter/BaseIndentEnterHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/enter/BaseIndentEnterHandler.java index bb059ff0e01d..9eed043cfb20 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/enter/BaseIndentEnterHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/enter/BaseIndentEnterHandler.java @@ -55,11 +55,13 @@ public class BaseIndentEnterHandler extends EnterHandlerDelegateAdapter { private final String myLineCommentPrefix; private final TokenSet myWhitespaceTokens; - public BaseIndentEnterHandler(final Language language, - final TokenSet indentTokens, - final IElementType lineCommentType, - final String lineCommentPrefix, - final TokenSet whitespaceTokens) { + public BaseIndentEnterHandler( + final Language language, + final TokenSet indentTokens, + final IElementType lineCommentType, + final String lineCommentPrefix, + final TokenSet whitespaceTokens) + { myLanguage = language; myIndentTokens = indentTokens; myLineCommentType = lineCommentType; @@ -67,12 +69,14 @@ public class BaseIndentEnterHandler extends EnterHandlerDelegateAdapter { myWhitespaceTokens = whitespaceTokens; } - public Result preprocessEnter(@NotNull final PsiFile file, - @NotNull final Editor editor, - @NotNull final Ref caretOffset, - @NotNull final Ref caretAdvance, - @NotNull final DataContext dataContext, - final EditorActionHandler originalHandler) { + public Result preprocessEnter( + @NotNull final PsiFile file, + @NotNull final Editor editor, + @NotNull final Ref caretOffset, + @NotNull final Ref caretAdvance, + @NotNull final DataContext dataContext, + final EditorActionHandler originalHandler) + { final Project project = PlatformDataKeys.PROJECT.getData(dataContext); if (project == null) { return Result.Continue; @@ -100,7 +104,6 @@ public class BaseIndentEnterHandler extends EnterHandlerDelegateAdapter { final int lineNumber = document.getLineNumber(caret); - final int lineStartOffset = document.getLineStartOffset(lineNumber); final int previousLineStartOffset = lineNumber > 0 ? document.getLineStartOffset(lineNumber - 1) : lineStartOffset; final EditorHighlighter highlighter = ((EditorEx)editor).getHighlighter(); @@ -119,6 +122,10 @@ public class BaseIndentEnterHandler extends EnterHandlerDelegateAdapter { editor.getCaretModel().moveToLogicalPosition(new LogicalPosition(lineNumber + 1, 1)); return Result.Stop; } + else if (iterator.getStart() < lineStartOffset) { + EditorModificationUtil.insertStringAtCaret(editor, "\n" + lineIndent); + return Result.Stop; + } } if (LanguageFormatting.INSTANCE.forLanguage(myLanguage) != null) { diff --git a/platform/lang-impl/src/com/intellij/conversion/impl/ConversionContextImpl.java b/platform/lang-impl/src/com/intellij/conversion/impl/ConversionContextImpl.java index 182efd3e61f9..662f83029d90 100644 --- a/platform/lang-impl/src/com/intellij/conversion/impl/ConversionContextImpl.java +++ b/platform/lang-impl/src/com/intellij/conversion/impl/ConversionContextImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 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. @@ -29,6 +29,7 @@ import com.intellij.openapi.components.ExpandMacroToPathMap; import com.intellij.openapi.components.StorageScheme; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.module.impl.ModuleManagerImpl; +import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.impl.libraries.LibraryImpl; import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar; import com.intellij.openapi.util.Condition; @@ -82,7 +83,7 @@ public class ConversionContextImpl implements ConversionContext { if (myProjectFile.isDirectory()) { myStorageScheme = StorageScheme.DIRECTORY_BASED; myProjectBaseDir = myProjectFile; - mySettingsBaseDir = new File(myProjectBaseDir.getAbsolutePath(), ".idea"); + mySettingsBaseDir = new File(myProjectBaseDir.getAbsolutePath(), Project.DIRECTORY_STORE_FOLDER); modulesFile = new File(mySettingsBaseDir, "modules.xml"); myWorkspaceFile = new File(mySettingsBaseDir, "workspace.xml"); } diff --git a/platform/lang-impl/src/com/intellij/formatting/AbstractBlockAlignmentProcessor.java b/platform/lang-impl/src/com/intellij/formatting/AbstractBlockAlignmentProcessor.java index 945a8c453d3f..329cab1f1e7a 100644 --- a/platform/lang-impl/src/com/intellij/formatting/AbstractBlockAlignmentProcessor.java +++ b/platform/lang-impl/src/com/intellij/formatting/AbstractBlockAlignmentProcessor.java @@ -88,7 +88,7 @@ public abstract class AbstractBlockAlignmentProcessor implements BlockAlignmentP LOG.error(String.format("Please create dedicated ticket at the tracker with the content of the current editor attached%n%n" + "Formatting error - code block %s is set to be shifted right because of its alignment with " + "block %s more than once. I.e. moving the former block because of alignment algorithm causes " - + "subsequent block to be shifted right as well - cyclic dependency. Debug info: %s", + + "subsequent block to be shifted right as well - cyclic dependency.%nDebug info: %s", offsetResponsibleBlock.getTextRange(), context.targetBlock.getTextRange(), context.targetBlock.getDebugInfo() )); blocksCausedRealignment.add(context.targetBlock); diff --git a/platform/lang-impl/src/com/intellij/ide/structureView/impl/TemplateLanguageStructureViewBuilder.java b/platform/lang-impl/src/com/intellij/ide/structureView/impl/TemplateLanguageStructureViewBuilder.java index 2b67e2216d2a..53b2d3bdd88c 100644 --- a/platform/lang-impl/src/com/intellij/ide/structureView/impl/TemplateLanguageStructureViewBuilder.java +++ b/platform/lang-impl/src/com/intellij/ide/structureView/impl/TemplateLanguageStructureViewBuilder.java @@ -17,15 +17,16 @@ package com.intellij.ide.structureView.impl; import com.intellij.ide.IdeBundle; import com.intellij.ide.impl.StructureViewWrapperImpl; -import com.intellij.ide.structureView.*; +import com.intellij.ide.structureView.StructureView; +import com.intellij.ide.structureView.StructureViewBuilder; +import com.intellij.ide.structureView.StructureViewFactoryEx; +import com.intellij.ide.structureView.StructureViewWrapper; import com.intellij.ide.structureView.newStructureView.StructureViewComponent; import com.intellij.lang.Language; import com.intellij.lang.LanguageStructureViewBuilder; import com.intellij.lang.PsiStructureViewFactory; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; -import com.intellij.openapi.application.Result; -import com.intellij.openapi.command.WriteCommandAction; import com.intellij.openapi.fileEditor.FileEditor; import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.fileTypes.FileTypeManager; @@ -224,25 +225,21 @@ public abstract class TemplateLanguageStructureViewBuilder implements StructureV } private void updateTemplateDataFileView() { - new WriteCommandAction(myProject) { - protected void run(Result result) throws Throwable { - final TemplateLanguageFileViewProvider provider = getViewProvider(); - final Language newDataLanguage = provider == null ? null : provider.getTemplateDataLanguage(); + final TemplateLanguageFileViewProvider provider = getViewProvider(); + final Language newDataLanguage = provider == null ? null : provider.getTemplateDataLanguage(); - if (myBaseStructureViewDescriptor != null) { - if (myTemplateDataLanguage == newDataLanguage) return; + if (myBaseStructureViewDescriptor != null) { + if (myTemplateDataLanguage == newDataLanguage) return; - Disposer.dispose(myBaseStructureViewDescriptor.structureView); - } + Disposer.dispose(myBaseStructureViewDescriptor.structureView); + } - if (newDataLanguage != null) { - myBaseStructureViewDescriptor = createBaseLanguageStructureView(myFileEditor, newDataLanguage); - if (myStructureViewComposite != null) { - myStructureViewComposite.setStructureView(myBaseLanguageViewDescriptorIndex, myBaseStructureViewDescriptor); - } - } + if (newDataLanguage != null) { + myBaseStructureViewDescriptor = createBaseLanguageStructureView(myFileEditor, newDataLanguage); + if (myStructureViewComposite != null) { + myStructureViewComposite.setStructureView(myBaseLanguageViewDescriptorIndex, myBaseStructureViewDescriptor); } - }.execute(); + } } @NotNull diff --git a/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java b/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java index 37a1d1b304d5..eafe609d3463 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java +++ b/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java @@ -29,7 +29,6 @@ import com.intellij.navigation.ItemPresentation; import com.intellij.openapi.Disposable; import com.intellij.openapi.MnemonicHelper; import com.intellij.openapi.actionSystem.*; -import com.intellij.openapi.application.AccessToken; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.editor.Editor; @@ -115,7 +114,6 @@ public class FileStructurePopup implements Disposable { private Map myCheckBoxes = new HashMap(); private String myTestSearchFilter; private final ActionCallback myTreeHasBuilt = new ActionCallback(); - private FilteringTreeStructure.FilteringNode myInitialNode; private boolean myInitialNodeIsLeaf; public FileStructurePopup(StructureViewModel structureViewModel, @@ -186,6 +184,11 @@ public class FileStructurePopup implements Disposable { final FileStructurePopupFilter filter = new FileStructurePopupFilter(); myFilteringStructure = new FilteringTreeStructure(filter, myTreeStructure, ApplicationManager.getApplication().isUnitTestMode()); myAbstractTreeBuilder = new FilteringTreeBuilder(myTree, filter, myFilteringStructure, null) { + @Override + public void initRootNode() { + + } + @Override protected boolean validateNode(Object child) { return StructureViewComponent.isValid(child); @@ -203,8 +206,8 @@ public class FileStructurePopup implements Disposable { } }; - //myAbstractTreeBuilder.getUi().setPassthroughMode(true); - myAbstractTreeBuilder.getUi().getUpdater().setDelay(0); + myAbstractTreeBuilder.getUi().setPassthroughMode(true); + //myAbstractTreeBuilder.getUi().getUpdater().setDelay(1); myInitialPsiElement = getCurrentElement(getPsiFile(myProject)); //myAbstractTreeBuilder.setCanYieldUpdate(true); Disposer.register(this, myAbstractTreeBuilder); @@ -269,19 +272,16 @@ public class FileStructurePopup implements Disposable { } IdeFocusManager.getInstance(myProject).requestFocus(myTree, true); + myFilteringStructure.rebuild(); myAbstractTreeBuilder.queueUpdate().doWhenDone(new Runnable() { @Override public void run() { myTreeHasBuilt.setDone(); - ApplicationManager.getApplication().invokeLater(new Runnable() { + //noinspection SSBasedInspection + SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { - myFilteringStructure.rebuild(); - myAbstractTreeBuilder.queueUpdate(true).doWhenDone(new Runnable() { - @Override - public void run() { - selectPsiElement(myInitialPsiElement); - } - }); + selectPsiElement(myInitialPsiElement); } }); } @@ -303,21 +303,20 @@ public class FileStructurePopup implements Disposable { filter = prefix; ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { - final AccessToken token = ApplicationManager.getApplication().acquireReadActionLock(); - try { - myAbstractTreeBuilder.refilter(null, false, false).doWhenProcessed(new Runnable() { - @Override - public void run() { - myTree.repaint(); - //if (mySpeedSearch.isPopupActive()) { - // mySpeedSearch.refreshSelection(); - //} - } - }); - } - finally { - token.finish(); - } + ApplicationManager.getApplication().runReadAction(new Runnable() { + @Override + public void run() { + myAbstractTreeBuilder.refilter(null, false, false).doWhenProcessed(new Runnable() { + @Override + public void run() { + myTree.repaint(); + //if (mySpeedSearch.isPopupActive()) { + // mySpeedSearch.refreshSelection(); + //} + } + }); + } + }); } }); } @@ -345,7 +344,7 @@ public class FileStructurePopup implements Disposable { } } if (!changed) { - myAbstractTreeBuilder.getUi().select(node, null); + myAbstractTreeBuilder.select(node); if (myAbstractTreeBuilder.getSelectedElements().isEmpty()) { TreeUtil.selectFirstNode(myTree); } @@ -549,7 +548,9 @@ public class FileStructurePopup implements Disposable { myShouldNarrowDown = checkBox.isSelected(); PropertiesComponent.getInstance().setValue(narrowDownPropertyKey, Boolean.toString(myShouldNarrowDown)); - myAbstractTreeBuilder.queueUpdate(); + if (mySpeedSearch.isPopupActive() && !StringUtil.isEmpty(mySpeedSearch.getEnteredPrefix())) { + myAbstractTreeBuilder.queueUpdate(); + } } }); @@ -592,20 +593,19 @@ public class FileStructurePopup implements Disposable { final Object sel = selection; final Runnable runnable = new Runnable() { public void run() { - final AccessToken token = ApplicationManager.getApplication().acquireReadActionLock(); - try { - myAbstractTreeBuilder.refilter(sel, true, false).doWhenProcessed(new Runnable() { - @Override - public void run() { - if (mySpeedSearch.isPopupActive()) { - mySpeedSearch.refreshSelection(); + ApplicationManager.getApplication().runReadAction(new Runnable() { + @Override + public void run() { + myAbstractTreeBuilder.refilter(sel, true, false).doWhenProcessed(new Runnable() { + @Override + public void run() { + if (mySpeedSearch.isPopupActive()) { + mySpeedSearch.refreshSelection(); + } } - } - }); - } - finally { - token.finish(); - } + }); + } + }); } }; if (ApplicationManager.getApplication().isUnitTestMode()) { @@ -681,7 +681,7 @@ public class FileStructurePopup implements Disposable { } @Nullable - private static String getText(Object node) { + private static String getText(final Object node) { String text = String.valueOf(node); if (text != null) { if (node instanceof StructureViewComponent.StructureViewTreeElementWrapper) { @@ -697,14 +697,14 @@ public class FileStructurePopup implements Disposable { } if (node instanceof StructureViewComponent.StructureViewTreeElementWrapper) { - final AccessToken token = ApplicationManager.getApplication().acquireReadActionLock(); - try { - final ItemPresentation presentation = ((StructureViewComponent.StructureViewTreeElementWrapper)node).getValue().getPresentation(); - return presentation.getPresentableText(); - } - finally { - token.finish(); - } + return ApplicationManager.getApplication().runReadAction(new Computable() { + @Nullable + @Override + public String compute() { + final ItemPresentation presentation = ((StructureViewComponent.StructureViewTreeElementWrapper)node).getValue().getPresentation(); + return presentation.getPresentableText(); + } + }); } return null; diff --git a/platform/lang-impl/src/com/intellij/openapi/module/impl/scopes/LibraryRuntimeClasspathScope.java b/platform/lang-impl/src/com/intellij/openapi/module/impl/scopes/LibraryRuntimeClasspathScope.java index 90ad86b3980b..00c16f26dfcb 100644 --- a/platform/lang-impl/src/com/intellij/openapi/module/impl/scopes/LibraryRuntimeClasspathScope.java +++ b/platform/lang-impl/src/com/intellij/openapi/module/impl/scopes/LibraryRuntimeClasspathScope.java @@ -103,6 +103,15 @@ public class LibraryRuntimeClasspathScope extends GlobalSearchScope { return value; } + @Override + public LinkedHashSet visitModuleOrderEntry(ModuleOrderEntry moduleOrderEntry, LinkedHashSet value) { + final Module depModule = moduleOrderEntry.getModule(); + if (depModule != null) { + ContainerUtil.addAll(value, ModuleRootManager.getInstance(depModule).getSourceRoots()); + } + return value; + } + public LinkedHashSet visitJdkOrderEntry(final JdkOrderEntry jdkOrderEntry, final LinkedHashSet value) { final Sdk jdk = jdkOrderEntry.getJdk(); if (jdk != null && processedSdk.add(jdk)) { diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/ProjectRootManagerComponent.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/ProjectRootManagerComponent.java index 475b28f951c2..6246ec1d7e23 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/ProjectRootManagerComponent.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/ProjectRootManagerComponent.java @@ -61,7 +61,6 @@ public class ProjectRootManagerComponent extends ProjectRootManagerImpl { private Set myRootsToWatch = new HashSet(); public ProjectRootManagerComponent(Project project, - FileTypeManager fileTypeManager, DirectoryIndex directoryIndex, StartupManager startupManager) { super(project, directoryIndex); @@ -146,16 +145,16 @@ public class ProjectRootManagerComponent extends ProjectRootManagerImpl { protected void addRootsToWatch() { final Set rootPaths = getAllRoots(false); if (rootPaths == null) return; - myRootsToWatch = LocalFileSystem.getInstance().replaceWatchedRoots(myRootsToWatch, rootPaths, true); + myRootsToWatch = LocalFileSystem.getInstance().replaceWatchedRoots(myRootsToWatch, rootPaths, null); } - private void beforeRootsChange(boolean filetypes) { + private void beforeRootsChange(boolean fileTypes) { if (myProject.isDisposed()) return; - getBatchSession(filetypes).beforeRootsChanged(); + getBatchSession(fileTypes).beforeRootsChanged(); } - private void rootsChanged(boolean filetypes) { - getBatchSession(filetypes).rootsChanged(); + private void rootsChanged(boolean fileTypes) { + getBatchSession(fileTypes).rootsChanged(); } private void doUpdateOnRefresh() { @@ -176,24 +175,24 @@ public class ProjectRootManagerComponent extends ProjectRootManagerImpl { return false; } - protected void fireBeforeRootsChangeEvent(boolean filetypes) { + protected void fireBeforeRootsChangeEvent(boolean fileTypes) { isFiringEvent = true; try { myProject.getMessageBus() .syncPublisher(ProjectTopics.PROJECT_ROOTS) - .beforeRootsChange(new ModuleRootEventImpl(myProject, filetypes)); + .beforeRootsChange(new ModuleRootEventImpl(myProject, fileTypes)); } finally { isFiringEvent= false; } } - protected void fireRootsChangedEvent(boolean filetypes) { + protected void fireRootsChangedEvent(boolean fileTypes) { isFiringEvent = true; try { myProject.getMessageBus() .syncPublisher(ProjectTopics.PROJECT_ROOTS) - .rootsChanged(new ModuleRootEventImpl(myProject, filetypes)); + .rootsChanged(new ModuleRootEventImpl(myProject, fileTypes)); } finally { isFiringEvent = false; diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/JarDirectoryWatcherImpl.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/JarDirectoryWatcherImpl.java index a0b9b4a42731..638956e670ac 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/JarDirectoryWatcherImpl.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/JarDirectoryWatcherImpl.java @@ -60,24 +60,7 @@ public class JarDirectoryWatcherImpl implements JarDirectoryWatcher { } } - if (flatRoots.isEmpty()) { - myWatchRequests = fs.replaceWatchedRoots(myWatchRequests, recursiveRoots, true); - } - else if (recursiveRoots.isEmpty()) { - myWatchRequests = fs.replaceWatchedRoots(myWatchRequests, flatRoots, false); - } - else { - fs.removeWatchedRoots(myWatchRequests); - final int rootsTotal = flatRoots.size() + recursiveRoots.size(); - if (rootsTotal > 0) { - myWatchRequests = new ArrayList(rootsTotal); - myWatchRequests.addAll(fs.addRootsToWatch(flatRoots, false)); - myWatchRequests.addAll(fs.addRootsToWatch(recursiveRoots, true)); - } - else { - myWatchRequests = Collections.emptySet(); - } - } + myWatchRequests = fs.replaceWatchedRoots(myWatchRequests, recursiveRoots, flatRoots); if (myBusConnection == null) { myBusConnection = ApplicationManager.getApplication().getMessageBus().connect(); diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/actions/ModuleDeleteProvider.java b/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/actions/ModuleDeleteProvider.java index 778fa7c4e0ee..1f1da6ee17a1 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/actions/ModuleDeleteProvider.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/actions/ModuleDeleteProvider.java @@ -61,7 +61,8 @@ public class ModuleDeleteProvider implements DeleteProvider, TitledHandler { for (Module module : modules) { final File moduleFile = new File(module.getModuleFilePath()); final File projectFile = new File(module.getProject().getProjectFilePath()); - if (moduleFile.getParent().equals(projectFile.getParent()) && moduleFile.getParentFile().getName().equals(".idea")) { + if (moduleFile.getParent().equals(projectFile.getParent()) && + moduleFile.getParentFile().getName().equals(Project.DIRECTORY_STORE_FOLDER)) { return true; } } diff --git a/platform/lang-impl/src/com/intellij/openapi/vcs/CommitCompletionContributor.java b/platform/lang-impl/src/com/intellij/openapi/vcs/CommitCompletionContributor.java index b576ecce3acf..b8d399cfda41 100644 --- a/platform/lang-impl/src/com/intellij/openapi/vcs/CommitCompletionContributor.java +++ b/platform/lang-impl/src/com/intellij/openapi/vcs/CommitCompletionContributor.java @@ -51,7 +51,7 @@ public class CommitCompletionContributor extends CompletionContributor { VirtualFile virtualFile = change.getVirtualFile(); if (virtualFile != null) { insensitive.addElement(LookupElementBuilder.create(virtualFile.getName()). - setIcon(VirtualFilePresentation.getIcon(virtualFile))); + withIcon(VirtualFilePresentation.getIcon(virtualFile))); } } } diff --git a/platform/lang-impl/src/com/intellij/platform/PlatformProjectViewStructureProvider.java b/platform/lang-impl/src/com/intellij/platform/PlatformProjectViewStructureProvider.java index f3fa3450af7d..bd2681310c9a 100644 --- a/platform/lang-impl/src/com/intellij/platform/PlatformProjectViewStructureProvider.java +++ b/platform/lang-impl/src/com/intellij/platform/PlatformProjectViewStructureProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 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. @@ -49,7 +49,7 @@ public class PlatformProjectViewStructureProvider implements TreeStructureProvid for (AbstractTreeNode moduleChild : moduleChildren) { if (moduleChild instanceof PsiDirectoryNode) { final PsiDirectory value = ((PsiDirectoryNode)moduleChild).getValue(); - if (value.getName().equals(".idea") && Registry.is("projectView.hide.dot.idea")) { + if (value.getName().equals(Project.DIRECTORY_STORE_FOLDER) && Registry.is("projectView.hide.dot.idea")) { continue; } } diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileInfoManager.java b/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileInfoManager.java index dba08af5c4eb..ba6f006d248c 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileInfoManager.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileInfoManager.java @@ -87,18 +87,18 @@ public class FileInfoManager implements Disposable { public static LookupElementBuilder getFileLookupItem(PsiElement psiElement, String encoded, Icon icon) { if (!(psiElement instanceof PsiFile) || !(psiElement.isPhysical())) { - return LookupElementBuilder.create(psiElement, encoded).setIcon(icon); + return LookupElementBuilder.create(psiElement, encoded).withIcon(icon); } return getFileInfoManager()._getLookupItem((PsiFile)psiElement, encoded, icon); } public LookupElementBuilder _getLookupItem(@NotNull final PsiFile file, String name, Icon icon) { - LookupElementBuilder builder = LookupElementBuilder.create(file, name).setIcon(icon); + LookupElementBuilder builder = LookupElementBuilder.create(file, name).withIcon(icon); final String info = _getInfo(file); if (info != null) { - return builder.setTailText(String.format(" (%s)", info), true); + return builder.withTailText(String.format(" (%s)", info), true); } return builder; diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReference.java b/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReference.java index 7173fa966295..2f743d22866a 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReference.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReference.java @@ -292,7 +292,7 @@ public class FileReference implements FileReferenceOwner, PsiPolyVariantReferenc if (!encoded.equals(name)) { final Icon icon = psiElement.getIcon(Iconable.ICON_FLAG_READ_STATUS | Iconable.ICON_FLAG_VISIBILITY); LookupElementBuilder item = FileInfoManager.getFileLookupItem(candidates[i], encoded, icon); - encodedVariants.add(item.setTailText(" (" + name + ")")); + encodedVariants.add(item.withTailText(" (" + name + ")")); } else { encodedVariants.add(variants[i]); diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/MyLookupExpression.java b/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/MyLookupExpression.java index 4040e569fb5e..7db3a3693faf 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/MyLookupExpression.java +++ b/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/MyLookupExpression.java @@ -74,7 +74,7 @@ public class MyLookupExpression extends Expression { final Iterator iterator = names.iterator(); for (int i = 0; i < lookupElements.length; i++) { final String suggestion = iterator.next(); - lookupElements[i] = LookupElementBuilder.create(suggestion).setInsertHandler(new InsertHandler() { + lookupElements[i] = LookupElementBuilder.create(suggestion).withInsertHandler(new InsertHandler() { @Override public void handleInsert(InsertionContext context, LookupElement item) { if (shouldSelectAll) return; diff --git a/platform/lang-impl/src/com/intellij/ui/TextFieldWithAutoCompletionListProvider.java b/platform/lang-impl/src/com/intellij/ui/TextFieldWithAutoCompletionListProvider.java index 459e493aff15..55670f9262dc 100644 --- a/platform/lang-impl/src/com/intellij/ui/TextFieldWithAutoCompletionListProvider.java +++ b/platform/lang-impl/src/com/intellij/ui/TextFieldWithAutoCompletionListProvider.java @@ -108,21 +108,21 @@ public abstract class TextFieldWithAutoCompletionListProvider implements Comp public LookupElementBuilder createLookupBuilder(@NotNull final T item) { LookupElementBuilder builder = LookupElementBuilder.create(item, getLookupString(item)) - .setIcon(getIcon(item)); + .withIcon(getIcon(item)); final InsertHandler handler = createInsertHandler(item); if (handler != null) { - builder = builder.setInsertHandler(handler); + builder = builder.withInsertHandler(handler); } final String tailText = getTailText(item); if (tailText != null) { - builder = builder.setTailText(tailText, true); + builder = builder.withTailText(tailText, true); } final String typeText = getTypeText(item); if (typeText != null) { - builder = builder.setTypeText(typeText); + builder = builder.withTypeText(typeText); } return builder; } diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/LocalFileSystem.java b/platform/platform-api/src/com/intellij/openapi/vfs/LocalFileSystem.java index b0bd675cb721..34b27fb12735 100644 --- a/platform/platform-api/src/com/intellij/openapi/vfs/LocalFileSystem.java +++ b/platform/platform-api/src/com/intellij/openapi/vfs/LocalFileSystem.java @@ -149,13 +149,14 @@ public abstract class LocalFileSystem extends NewVirtualFileSystem { @NotNull final String rootPath, final boolean watchRecursively) { final Set requests = watchRequest != null ? singleton(watchRequest) : Collections.emptySet(); - final Set result = replaceWatchedRoots(requests, singleton(rootPath), watchRecursively); + final Set result = watchRecursively ? replaceWatchedRoots(requests, singleton(rootPath), null) + : replaceWatchedRoots(requests, null, singleton(rootPath)); return result.size() == 1 ? result.iterator().next() : null; } public abstract Set replaceWatchedRoots(@NotNull final Collection watchRequests, - @NotNull final Collection rootPaths, - final boolean watchRecursively); + @Nullable final Collection recursiveRoots, + @Nullable final Collection flatRoots); public abstract void registerAuxiliaryFileOperationsHandler(@NotNull LocalFileOperationsHandler handler); diff --git a/platform/platform-impl/src/com/intellij/ide/RecentProjectsManagerBase.java b/platform/platform-impl/src/com/intellij/ide/RecentProjectsManagerBase.java index 32bbb17a7969..f322798e6d9a 100644 --- a/platform/platform-impl/src/com/intellij/ide/RecentProjectsManagerBase.java +++ b/platform/platform-impl/src/com/intellij/ide/RecentProjectsManagerBase.java @@ -74,7 +74,7 @@ public abstract class RecentProjectsManagerBase implements PersistentStateCompon } if (myState.lastPath != null) { File lastFile = new File(myState.lastPath); - if (lastFile.isDirectory() && !new File(lastFile, ProjectCoreUtil.DIRECTORY_BASED_PROJECT_DIR).exists()) { + if (lastFile.isDirectory() && !new File(lastFile, Project.DIRECTORY_STORE_FOLDER).exists()) { myState.lastPath = null; } } @@ -243,7 +243,7 @@ public abstract class RecentProjectsManagerBase implements PersistentStateCompon public static boolean isValidProjectPath(String projectPath) { final File file = new File(projectPath); - return file.exists() && (!file.isDirectory() || new File(file, ProjectCoreUtil.DIRECTORY_BASED_PROJECT_DIR).exists()); + return file.exists() && (!file.isDirectory() || new File(file, ProjectUtil.DIRECTORY_BASED_PROJECT_DIR).exists()); } private class MyProjectManagerListener extends ProjectManagerAdapter { diff --git a/platform/platform-impl/src/com/intellij/ide/impl/ProjectUtil.java b/platform/platform-impl/src/com/intellij/ide/impl/ProjectUtil.java index fb7fe752e57c..6104f9e28042 100644 --- a/platform/platform-impl/src/com/intellij/ide/impl/ProjectUtil.java +++ b/platform/platform-impl/src/com/intellij/ide/impl/ProjectUtil.java @@ -103,7 +103,7 @@ public class ProjectUtil { } if (path.endsWith(ProjectFileType.DOT_DEFAULT_EXTENSION) || - virtualFile.isDirectory() && virtualFile.findChild(ProjectCoreUtil.DIRECTORY_BASED_PROJECT_DIR) != null) { + virtualFile.isDirectory() && virtualFile.findChild(Project.DIRECTORY_STORE_FOLDER) != null) { return openProject(path, projectToClose, forceOpenInNewFrame); } @@ -146,8 +146,9 @@ public class ProjectUtil { return null; } - if (file.isDirectory() && !new File(file, ProjectCoreUtil.DIRECTORY_BASED_PROJECT_DIR).exists()) { - Messages.showErrorDialog(IdeBundle.message("error.project.file.does.not.exist", new File(file, ProjectCoreUtil.DIRECTORY_BASED_PROJECT_DIR).getPath()), CommonBundle.getErrorTitle()); + if (file.isDirectory() && !new File(file, Project.DIRECTORY_STORE_FOLDER).exists()) { + String message = IdeBundle.message("error.project.file.does.not.exist", new File(file, Project.DIRECTORY_STORE_FOLDER).getPath()); + Messages.showErrorDialog(message, CommonBundle.getErrorTitle()); return null; } @@ -269,10 +270,10 @@ public class ProjectUtil { } /** - * @deprecated use {@linkplain com.intellij.openapi.project.ProjectCoreUtil#isProjectOrWorkspaceFile(com.intellij.openapi.vfs.VirtualFile)} (to remove in IDEA 13) + * @deprecated use {@linkplain com.intellij.openapi.project.ProjectUtil#isProjectOrWorkspaceFile(com.intellij.openapi.vfs.VirtualFile)} (to remove in IDEA 13) */ @SuppressWarnings("UnusedDeclaration") public static boolean isProjectOrWorkspaceFile(final VirtualFile file) { - return ProjectCoreUtil.isProjectOrWorkspaceFile(file); + return com.intellij.openapi.project.ProjectUtil.isProjectOrWorkspaceFile(file); } } diff --git a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ProjectStoreImpl.java b/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ProjectStoreImpl.java index 7c25f4a98211..d9d5059bd4a3 100644 --- a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ProjectStoreImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ProjectStoreImpl.java @@ -285,7 +285,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject final VirtualFile baseDir = getProjectBaseDir(); assert baseDir != null : "project file: " + getProjectFile(); - final VirtualFile ideaDir = baseDir.findChild(".idea"); + final VirtualFile ideaDir = baseDir.findChild(Project.DIRECTORY_STORE_FOLDER); if (ideaDir != null && ideaDir.isValid()) { final VirtualFile nameFile = ideaDir.findChild(".name"); if (nameFile != null && nameFile.isValid()) { diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/LocalFileSystemImpl.java b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/LocalFileSystemImpl.java index b2d1cacfe972..7c1eb96e1263 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/LocalFileSystemImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/LocalFileSystemImpl.java @@ -15,7 +15,6 @@ */ package com.intellij.openapi.vfs.impl.local; -import com.intellij.openapi.application.AccessToken; import com.intellij.openapi.application.Application; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.components.ApplicationComponent; @@ -37,6 +36,7 @@ import com.intellij.util.TimeoutUtil; import com.intellij.util.containers.HashSet; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; import java.io.File; @@ -323,28 +323,26 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap final Application application = ApplicationManager.getApplication(); if (application.isDisposeInProgress() || !myWatcher.isOperational()) return; - final AccessToken token = application.acquireReadActionLock(); - try { - synchronized (myLock) { - final WatchRequestImpl[] watchRequests = normalizeRootsForRefresh(); - final List myRecursiveRoots = new ArrayList(); - final List myFlatRoots = new ArrayList(); + application.runReadAction(new Runnable() { + public void run() { + synchronized (myLock) { + final WatchRequestImpl[] watchRequests = normalizeRootsForRefresh(); + final List myRecursiveRoots = new ArrayList(); + final List myFlatRoots = new ArrayList(); - for (WatchRequestImpl watchRequest : watchRequests) { - if (watchRequest.isToWatchRecursively()) { - myRecursiveRoots.add(watchRequest.myFSRootPath); - } - else { - myFlatRoots.add(watchRequest.myFSRootPath); + for (WatchRequestImpl watchRequest : watchRequests) { + if (watchRequest.isToWatchRecursively()) { + myRecursiveRoots.add(watchRequest.myFSRootPath); + } + else { + myFlatRoots.add(watchRequest.myFSRootPath); + } } + + myWatcher.setWatchRoots(myRecursiveRoots, myFlatRoots); } - - myWatcher.setWatchRoots(myRecursiveRoots, myFlatRoots); } - } - finally { - token.finish(); - } + }); } private class StoreRefreshStatusThread extends Thread { @@ -374,8 +372,11 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap if (rootPaths.isEmpty() || !myWatcher.isOperational()) { return Collections.emptySet(); } + else if (watchRecursively) { + return replaceWatchedRoots(Collections.emptySet(), rootPaths, null); + } else { - return replaceWatchedRoots(Collections.emptySet(), rootPaths, watchRecursively); + return replaceWatchedRoots(Collections.emptySet(), null, rootPaths); } } @@ -383,26 +384,27 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap public void removeWatchedRoots(@NotNull final Collection watchRequests) { if (watchRequests.isEmpty()) return; - final AccessToken token = ApplicationManager.getApplication().acquireReadActionLock(); - try { - synchronized (myLock) { - final boolean update = doRemoveWatchedRoots(watchRequests); - if (update) { - myNormalizedTree = null; - setUpFileWatcher(); + ApplicationManager.getApplication().runReadAction(new Runnable() { + public void run() { + synchronized (myLock) { + final boolean update = doRemoveWatchedRoots(watchRequests); + if (update) { + myNormalizedTree = null; + setUpFileWatcher(); + } } } - } - finally { - token.finish(); - } + }); } @Override public Set replaceWatchedRoots(@NotNull final Collection watchRequests, - @NotNull final Collection rootPaths, - final boolean watchRecursively) { - if (rootPaths.isEmpty() || !myWatcher.isOperational()) { + @Nullable final Collection _recursiveRoots, + @Nullable final Collection _flatRoots) { + final Collection recursiveRoots = _recursiveRoots != null ? _recursiveRoots : Collections.emptyList(); + final Collection flatRoots = _flatRoots != null ? _flatRoots : Collections.emptyList(); + + if (recursiveRoots.isEmpty() && flatRoots.isEmpty() || !myWatcher.isOperational()) { removeWatchedRoots(watchRequests); return Collections.emptySet(); } @@ -410,47 +412,55 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap final Set result = new HashSet(); final Set filesToSync = new HashSet(); - final AccessToken token = ApplicationManager.getApplication().acquireReadActionLock(); - try { - synchronized (myLock) { - final boolean update = doAddRootsToWatch(rootPaths, watchRecursively, result, filesToSync) || - doRemoveWatchedRoots(watchRequests); - if (update) { - myNormalizedTree = null; - setUpFileWatcher(); + ApplicationManager.getApplication().runReadAction(new Runnable() { + public void run() { + synchronized (myLock) { + final boolean update = doAddRootsToWatch(recursiveRoots, flatRoots, result, filesToSync) || + doRemoveWatchedRoots(watchRequests); + if (update) { + myNormalizedTree = null; + setUpFileWatcher(); + } } } - } - finally { - token.finish(); - } + }); - syncFiles(filesToSync, watchRecursively); + syncFiles(filesToSync); return result; } - private boolean doAddRootsToWatch(@NotNull final Collection roots, - final boolean recursively, + private boolean doAddRootsToWatch(@NotNull final Collection recursiveRoots, + @NotNull final Collection flatRoots, @NotNull final Set results, @NotNull final Set filesToSync) { boolean update = false; - for (String root : roots) { - final WatchRequestImpl result = new WatchRequestImpl(root, recursively); - final boolean alreadyWatched = isAlreadyWatched(result); + for (String root : recursiveRoots) { + final WatchRequestImpl request = new WatchRequestImpl(root, true); + final boolean alreadyWatched = isAlreadyWatched(request); + + request.myDominated = alreadyWatched; + myRootsToWatch.add(request); + results.add(request); + + update |= !alreadyWatched; + } + + for (String root : flatRoots) { + final WatchRequestImpl request = new WatchRequestImpl(root, false); + final boolean alreadyWatched = isAlreadyWatched(request); if (!alreadyWatched) { final VirtualFile existingFile = findFileByPathIfCached(root); - if (existingFile != null) { - if (existingFile.isDirectory() && !recursively && existingFile instanceof NewVirtualFile) { - filesToSync.addAll(((NewVirtualFile)existingFile).getCachedChildren()); - } + if (existingFile != null && existingFile.isDirectory() && existingFile instanceof NewVirtualFile) { + filesToSync.addAll(((NewVirtualFile)existingFile).getCachedChildren()); } } - result.myDominated = alreadyWatched; - myRootsToWatch.add(result); - results.add(result); + + request.myDominated = alreadyWatched; + myRootsToWatch.add(request); + results.add(request); update |= !alreadyWatched; } @@ -458,7 +468,7 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap return update; } - private void syncFiles(@NotNull final Set filesToSync, final boolean watchRecursively) { + private void syncFiles(@NotNull final Set filesToSync) { if (filesToSync.isEmpty() || ApplicationManager.getApplication().isUnitTestMode()) return; for (VirtualFile file : filesToSync) { @@ -466,7 +476,8 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap ((NewVirtualFile)file).markDirtyRecursively(); } } - refreshFiles(filesToSync, true, watchRecursively, null); + + refreshFiles(filesToSync, true, false, null); } private boolean doRemoveWatchedRoots(@NotNull final Collection watchRequests) { diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/win32/Win32LocalFileSystem.java b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/win32/Win32LocalFileSystem.java index 3f1829355b65..7bfd2404feda 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/win32/Win32LocalFileSystem.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/win32/Win32LocalFileSystem.java @@ -20,10 +20,12 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.io.FileAttributes; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.impl.local.LocalFileSystemBase; import com.intellij.util.ArrayUtil; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.io.FileNotFoundException; import java.util.Arrays; @@ -198,7 +200,9 @@ public class Win32LocalFileSystem extends LocalFileSystemBase { } @Override - public Set replaceWatchedRoots(@NotNull Collection watchRequests, @NotNull Collection rootPaths, boolean watchRecursively) { + public Set replaceWatchedRoots(@NotNull Collection watchRequests, + @Nullable Collection recursiveRoots, + @Nullable Collection flatRoots) { throw new UnsupportedOperationException(); } diff --git a/platform/platform-impl/src/com/intellij/platform/PlatformProjectOpenProcessor.java b/platform/platform-impl/src/com/intellij/platform/PlatformProjectOpenProcessor.java index a7b06b60a032..5b931e46d00f 100644 --- a/platform/platform-impl/src/com/intellij/platform/PlatformProjectOpenProcessor.java +++ b/platform/platform-impl/src/com/intellij/platform/PlatformProjectOpenProcessor.java @@ -30,6 +30,7 @@ import com.intellij.openapi.project.impl.ProjectManagerImpl; import com.intellij.openapi.startup.StartupManager; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.util.Ref; +import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.wm.ToolWindowManager; import com.intellij.projectImport.ProjectAttachProcessor; @@ -93,7 +94,7 @@ public class PlatformProjectOpenProcessor extends ProjectOpenProcessor { if (!baseDir.isDirectory()) { baseDir = virtualFile.getParent(); while (baseDir != null) { - if (new File(baseDir.getPath(), ".idea").exists()) { + if (new File(FileUtil.toSystemDependentName(baseDir.getPath()), Project.DIRECTORY_STORE_FOLDER).exists()) { break; } baseDir = baseDir.getParent(); @@ -103,7 +104,7 @@ public class PlatformProjectOpenProcessor extends ProjectOpenProcessor { } } - final File projectDir = new File(baseDir.getPath(), ".idea"); + final File projectDir = new File(FileUtil.toSystemDependentName(baseDir.getPath()), Project.DIRECTORY_STORE_FOLDER); Project[] openProjects = ProjectManager.getInstance().getOpenProjects(); if (!forceOpenInNewFrame && openProjects.length > 0) { diff --git a/platform/platform-resources-en/src/messages/VcsBundle.properties b/platform/platform-resources-en/src/messages/VcsBundle.properties index 335c78606e83..931c2770b753 100644 --- a/platform/platform-resources-en/src/messages/VcsBundle.properties +++ b/platform/platform-resources-en/src/messages/VcsBundle.properties @@ -405,7 +405,7 @@ show.diff.progress.title=Loading content... show.diff.progress.title.detailed=Loading content for {0} checkout.open.project.prompt=You have checked out {0} project file:\n{1}\nWould you like to open it? checkout.open.project.dir.prompt=You have checked out {0} project:\n{1}\nWould you like to open it? -checkout.title=Checkout from Version Control +checkout.title=Checkout From Version Control checkout.create.project.prompt=Would you like to create {0} project for the sources you have checked out to {1}? checkout.open.directory.prompt=Would you like to open the directory {0}? new.changelist.duplicate.name.error=A changelist with that name already exists diff --git a/platform/platform-tests/testSrc/com/intellij/psi/util/NameUtilTest.java b/platform/platform-tests/testSrc/com/intellij/psi/util/NameUtilTest.java index 25557ed4462b..72ac2b2fccac 100644 --- a/platform/platform-tests/testSrc/com/intellij/psi/util/NameUtilTest.java +++ b/platform/platform-tests/testSrc/com/intellij/psi/util/NameUtilTest.java @@ -230,6 +230,7 @@ public class NameUtilTest extends UsefulTestCase { } public void testMiddleMatchingFirstLetterSensitive() { + assertTrue(NameUtil.buildCompletionMatcher(" cl", 1, true, true).matches("getClass")); assertTrue(NameUtil.buildCompletionMatcher(" EUC-", 1, true, true).matches("x-EUC-TW")); assertTrue(NameUtil.buildCompletionMatcher(" a", 1, true, true).matches("aaa")); assertFalse(NameUtil.buildCompletionMatcher(" a", 1, true, true).matches("Aaa")); diff --git a/platform/projectModel-impl/src/com/intellij/core/CoreProjectLoader.java b/platform/projectModel-impl/src/com/intellij/core/CoreProjectLoader.java index 4751b1f8811a..0aa2cd6bd96a 100644 --- a/platform/projectModel-impl/src/com/intellij/core/CoreProjectLoader.java +++ b/platform/projectModel-impl/src/com/intellij/core/CoreProjectLoader.java @@ -40,7 +40,7 @@ import java.io.IOException; */ public class CoreProjectLoader { public static void loadProject(MockProject project, @NotNull VirtualFile virtualFile) throws IOException, JDOMException { - if (virtualFile.isDirectory() && virtualFile.findChild(".idea") != null) { + if (virtualFile.isDirectory() && virtualFile.findChild(Project.DIRECTORY_STORE_FOLDER) != null) { project.setBaseDir(virtualFile); loadDirectoryProject(project, virtualFile); } @@ -51,7 +51,7 @@ public class CoreProjectLoader { } private static void loadDirectoryProject(Project project, VirtualFile projectDir) throws IOException, JDOMException { - VirtualFile dotIdea = projectDir.findChild(".idea"); + VirtualFile dotIdea = projectDir.findChild(Project.DIRECTORY_STORE_FOLDER); VirtualFile modulesXml = dotIdea.findChild("modules.xml"); StorageData storageData = loadStorageFile(project, modulesXml); final Element moduleManagerState = storageData.getState("ProjectModuleManager"); diff --git a/platform/projectModel-impl/src/com/intellij/openapi/components/impl/ModulePathMacroManager.java b/platform/projectModel-impl/src/com/intellij/openapi/components/impl/ModulePathMacroManager.java index 996b0711b5c1..64344d657826 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/components/impl/ModulePathMacroManager.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/components/impl/ModulePathMacroManager.java @@ -21,6 +21,7 @@ import com.intellij.application.options.ReplacePathToMacroMap; import com.intellij.openapi.application.PathMacros; import com.intellij.openapi.components.ExpandMacroToPathMap; import com.intellij.openapi.module.Module; +import com.intellij.openapi.project.Project; import org.jetbrains.annotations.Nullable; import java.io.File; @@ -67,7 +68,7 @@ public class ModulePathMacroManager extends BasePathMacroManager { // rather than the .idea directory itself is considered the module root // (so that a Ruby IDE project doesn't break if its directory is moved together with the .idea directory) File moduleDirParent = moduleDirFile.getParentFile(); - if (moduleDirParent != null && moduleDirFile.getName().equals(".idea")) { + if (moduleDirParent != null && moduleDirFile.getName().equals(Project.DIRECTORY_STORE_FOLDER)) { moduleDirFile = moduleDirParent; } String moduleDir = moduleDirFile.getPath(); diff --git a/platform/testFramework/src/com/intellij/mock/MockLocalFileSystem.java b/platform/testFramework/src/com/intellij/mock/MockLocalFileSystem.java index ed6438d539cc..c6a83a5074b5 100644 --- a/platform/testFramework/src/com/intellij/mock/MockLocalFileSystem.java +++ b/platform/testFramework/src/com/intellij/mock/MockLocalFileSystem.java @@ -93,7 +93,9 @@ public class MockLocalFileSystem extends LocalFileSystem { } @Override - public Set replaceWatchedRoots(@NotNull Collection watchRequests, @NotNull Collection rootPaths, boolean watchRecursively) { + public Set replaceWatchedRoots(@NotNull Collection watchRequests, + @Nullable Collection recursiveRoots, + @Nullable Collection flatRoots) { throw new UnsupportedOperationException("Not implemented in " + getClass().getName()); } diff --git a/platform/util/src/com/intellij/psi/codeStyle/NameUtil.java b/platform/util/src/com/intellij/psi/codeStyle/NameUtil.java index 7454213968ce..1fd815e56922 100644 --- a/platform/util/src/com/intellij/psi/codeStyle/NameUtil.java +++ b/platform/util/src/com/intellij/psi/codeStyle/NameUtil.java @@ -439,7 +439,7 @@ public class NameUtil { return skipWords(name, patternIndex, nameIndex); } - if ((patternIndex == 0 || patternIndex == 1 && myPattern[0] == ' ') && + if ((patternIndex == 0 || patternIndex == 1 && myPattern[0] == ' ' && nameIndex == 0) && myOptions != MatchingCaseSensitivity.NONE && name.charAt(nameIndex) != myPattern[patternIndex]) { return null; } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java index 20543125c31c..d0440382c300 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java @@ -110,6 +110,7 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj private final String myOkActionText; private final ZipperUpdater myZipperUpdater; private final Runnable myRefreshDetails; + private CommitAction myCommitAction; private static class MyUpdateButtonsRunnable implements Runnable { private CommitChangeListDialog myDialog; @@ -595,15 +596,15 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj protected Action[] createActions() { final List actions = new ArrayList(); - CommitAction commitAction = null; + myCommitAction = null; if (myShowVcsCommit) { - commitAction = new CommitAction(); - actions.add(commitAction); + myCommitAction = new CommitAction(); + actions.add(myCommitAction); myHelpId = outCommitHelpId; } if (myExecutors != null) { - if (commitAction != null) { - commitAction.setOptions(myExecutorActions); + if (myCommitAction != null) { + myCommitAction.setOptions(myExecutorActions); } else { actions.addAll(Arrays.asList(myExecutorActions)); } @@ -1167,10 +1168,14 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj private void updateButtons() { if (myDisposed) return; - setOKActionEnabled(hasDiffs()); + final boolean enabled = hasDiffs(); + setOKActionEnabled(enabled); + if (myCommitAction != null) { + myCommitAction.setEnabled(enabled); + } if (myExecutorActions != null) { for (Action executorAction : myExecutorActions) { - executorAction.setEnabled(hasDiffs()); + executorAction.setEnabled(enabled); } } myOKButtonUpdateAlarm.cancelAllRequests(); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/projectlevelman/FileWatchRequestModifier.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/projectlevelman/FileWatchRequestModifier.java index b2fb77cc96aa..24e44013b13c 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/projectlevelman/FileWatchRequestModifier.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/projectlevelman/FileWatchRequestModifier.java @@ -64,7 +64,7 @@ public class FileWatchRequestModifier implements Runnable { } } - final Set requests = myLfs.replaceWatchedRoots(toRemove, toAdd.keySet(), true); + final Set requests = myLfs.replaceWatchedRoots(toRemove, toAdd.keySet(), null); for (LocalFileSystem.WatchRequest request : requests) { myDirectoryMappingWatches.put(toAdd.get(request.getRootPath()), request); } diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/maturity/SuppressionAnnotationInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/maturity/SuppressionAnnotationInspection.java index 5f6b5bdc0c16..d0d872c192f3 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/maturity/SuppressionAnnotationInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/maturity/SuppressionAnnotationInspection.java @@ -15,6 +15,7 @@ */ package com.siyeh.ig.maturity; +import com.intellij.codeInspection.SuppressionUtil; import com.intellij.psi.JavaTokenType; import com.intellij.psi.PsiAnnotation; import com.intellij.psi.PsiComment; @@ -55,9 +56,8 @@ public class SuppressionAnnotationInspection extends BaseInspection { && !tokenType.equals(JavaTokenType.C_STYLE_COMMENT)) { return; } - @NonNls final String strippedComment = - commentText.substring(2).trim(); - if (strippedComment.startsWith("noinspection")) { + @NonNls final String strippedComment = commentText.substring(2).trim(); + if (strippedComment.startsWith(SuppressionUtil.SUPPRESS_INSPECTIONS_TAG_NAME)) { registerError(comment); } } diff --git a/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/java/LanguageReference.java b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/java/LanguageReference.java index 1fd3dd69b22f..1cd96284c005 100644 --- a/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/java/LanguageReference.java +++ b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/java/LanguageReference.java @@ -58,12 +58,12 @@ final class LanguageReference extends StringLiteralReference { final FileType ft = l.getAssociatedFileType(); if (ft != null) { - return LookupElementBuilder.create(s).setIcon(ft.getIcon()).setTypeText(ft.getDescription()); + return LookupElementBuilder.create(s).withIcon(ft.getIcon()).withTypeText(ft.getDescription()); // } else if (l == StdLanguages.EL) { // // IDEA-10012 // return new LanguageLookupValue(s, StdFileTypes.JSP.getIcon(), "Expression Language"); } - return LookupElementBuilder.create(s).setIcon(EmptyIcon.ICON_16); + return LookupElementBuilder.create(s).withIcon(EmptyIcon.ICON_16); } }); } diff --git a/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/java/RegExpEnumReference.java b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/java/RegExpEnumReference.java index d0938816e5e1..d81f28336689 100644 --- a/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/java/RegExpEnumReference.java +++ b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/java/RegExpEnumReference.java @@ -50,7 +50,7 @@ final class RegExpEnumReference extends StringLiteralReference { } return ContainerUtil.map2Array(values, new Function() { public Object fun(String s) { - return LookupElementBuilder.create(s).setIcon(PlatformIcons.ENUM_ICON); + return LookupElementBuilder.create(s).withIcon(PlatformIcons.ENUM_ICON); } }); } 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 11b219a2037e..fa569419a208 100644 --- a/plugins/android/common/src/org/jetbrains/android/util/AndroidCommonUtils.java +++ b/plugins/android/common/src/org/jetbrains/android/util/AndroidCommonUtils.java @@ -27,6 +27,7 @@ import com.intellij.execution.process.ProcessAdapter; import com.intellij.execution.process.ProcessEvent; import com.intellij.execution.process.ProcessOutputTypes; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.io.FileUtil; @@ -452,4 +453,67 @@ public class AndroidCommonUtils { public static boolean contains2Identifiers(String packageName) { return packageName.split("\\.").length >= 2; } + + public static boolean directoriesContainSameContent(@NotNull File dir1, @NotNull File dir2, @Nullable FileFilter filter) + throws IOException { + if (dir1.exists() != dir2.exists()) { + return false; + } + + final File[] children1 = getFilteredChildren(dir1, filter); + final File[] children2 = getFilteredChildren(dir2, filter); + + if (children1 == null || children2 == null) { + return children1 == children2; + } + + if (children1.length != children2.length) { + return false; + } + + for (int i = 0; i < children1.length; i++) { + final File child1 = children1[i]; + final File child2 = children2[i]; + + if (!Comparing.equal(child1.getName(), child2.getName())) { + return false; + } + + final boolean childDir = child1.isDirectory(); + if (childDir != child2.isDirectory()) { + return false; + } + + if (childDir) { + if (!directoriesContainSameContent(child1, child2, filter)) { + return false; + } + } + else { + final String content1 = readFile(child1); + final String content2 = readFile(child2); + + if (!Comparing.equal(content1, content2)) { + return false; + } + } + } + return true; + } + + @Nullable + private static File[] getFilteredChildren(@NotNull File dir, @Nullable FileFilter filter) { + final File[] children = dir.listFiles(); + if (children == null || children.length == 0 || filter == null) { + return children; + } + + final List result = new ArrayList(); + for (File child : children) { + if (child.isDirectory() || filter.accept(child)) { + result.add(child); + } + } + return result.toArray(new File[result.size()]); + } } diff --git a/plugins/android/common/src/org/jetbrains/android/util/JavaFilesFilter.java b/plugins/android/common/src/org/jetbrains/android/util/JavaFilesFilter.java new file mode 100644 index 000000000000..471fd09d1579 --- /dev/null +++ b/plugins/android/common/src/org/jetbrains/android/util/JavaFilesFilter.java @@ -0,0 +1,21 @@ +package org.jetbrains.android.util; + +import com.intellij.openapi.util.io.FileUtil; + +import java.io.File; +import java.io.FileFilter; + +/** + * @author Eugene.Kudelevsky + */ +public class JavaFilesFilter implements FileFilter { + public static JavaFilesFilter INSTANCE = new JavaFilesFilter(); + + private JavaFilesFilter() { + } + + @Override + public boolean accept(File file) { + return "java".equals(FileUtil.getExtension(file.getName())); + } +} diff --git a/plugins/android/jps-plugin/src/messages/AndroidJpsBundle.properties b/plugins/android/jps-plugin/src/messages/AndroidJpsBundle.properties index baa5947ccfa5..f3573c965f86 100644 --- a/plugins/android/jps-plugin/src/messages/AndroidJpsBundle.properties +++ b/plugins/android/jps-plugin/src/messages/AndroidJpsBundle.properties @@ -23,4 +23,5 @@ android.jps.cannot.create.directory=Cannot create directory {0} android.jps.cannot.delete=Cannot delete {0} android.jps.errors.cannot.find.proguard.cfg=[{0}] Cannot find proguard config file android.jps.cannot.find.file=Cannot find file {0} -android.jps.errors.cannot.compute.output.apk=[{0}] Cannot compute output path for APK \ No newline at end of file +android.jps.errors.cannot.compute.output.apk=[{0}] Cannot compute output path for APK +android.jps.errors.cannot.move.content=Cannot move content from {0} to {1} \ No newline at end of file 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 ca20576e2201..c982ef16a5ae 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 @@ -346,7 +346,8 @@ public class AndroidSourceGeneratingBuilder extends ModuleLevelBuilder { final MyModuleData moduleData = moduleDataMap.get(module); if (!LOG.assertTrue(moduleData != null)) { - context.processMessage(new CompilerMessage(ANDROID_IDL_COMPILER, BuildMessage.Kind.ERROR, AndroidJpsBundle.message("android.jps.internal.error"))); + context.processMessage( + new CompilerMessage(ANDROID_IDL_COMPILER, BuildMessage.Kind.ERROR, AndroidJpsBundle.message("android.jps.internal.error"))); success = false; continue; } @@ -355,7 +356,8 @@ public class AndroidSourceGeneratingBuilder extends ModuleLevelBuilder { if (!aidlOutputDirectory.exists() && !aidlOutputDirectory.mkdirs()) { context.processMessage( - new CompilerMessage(ANDROID_IDL_COMPILER, BuildMessage.Kind.ERROR, AndroidJpsBundle.message("android.jps.cannot.create.directory", aidlOutputDirectory.getPath()))); + new CompilerMessage(ANDROID_IDL_COMPILER, BuildMessage.Kind.ERROR, + AndroidJpsBundle.message("android.jps.cannot.create.directory", aidlOutputDirectory.getPath()))); success = false; continue; } @@ -560,25 +562,39 @@ public class AndroidSourceGeneratingBuilder extends ModuleLevelBuilder { } context.processMessage(new ProgressMessage(AndroidJpsBundle.message("android.jps.progress.aapt", module.getName()))); - // clear directory, because it may contain obsolete files (ex. if package name was changed) - if (!clearDirectory(aptOutputDirectory, context, ANDROID_APT_COMPILER)) { - success = false; - continue; + File tmpOutputDir = null; + try { + tmpOutputDir = FileUtil.createTempDirectory("android_apt_output", "tmp"); + final Map> messages = + AndroidApt.compile(target, -1, manifestFile.getPath(), packageName, tmpOutputDir.getPath(), resPaths, + ArrayUtil.toStringArray(depLibPackagesSet), generateNonFinalFields); + + AndroidJpsUtil.addMessages(context, messages, ANDROID_APT_COMPILER, module.getName()); + + if (messages.get(AndroidCompilerMessageKind.ERROR).size() > 0) { + success = false; + storage.update(module.getName(), null); + } + else { + if (!AndroidCommonUtils.directoriesContainSameContent(tmpOutputDir, aptOutputDirectory, JavaFilesFilter.INSTANCE)) { + if (!deleteAndMarkRecursively(aptOutputDirectory, context, ANDROID_APT_COMPILER)) { + 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()))); + continue; + } + markDirtyRecursively(aptOutputDirectory, context, ANDROID_APT_COMPILER); + } + storage.update(module.getName(), newState); + } } - - final Map> messages = - AndroidApt.compile(target, -1, manifestFile.getPath(), packageName, aptOutputDirectory.getPath(), resPaths, - ArrayUtil.toStringArray(depLibPackagesSet), generateNonFinalFields); - - AndroidJpsUtil.addMessages(context, messages, ANDROID_APT_COMPILER, module.getName()); - - if (messages.get(AndroidCompilerMessageKind.ERROR).size() > 0) { - success = false; - storage.update(module.getName(), null); - } - else { - storage.update(module.getName(), newState); - markDirtyRecursively(aptOutputDirectory, context, ANDROID_APT_COMPILER); + finally { + if (tmpOutputDir != null) { + FileUtil.delete(tmpOutputDir); + } } } catch (IOException e) { @@ -602,7 +618,8 @@ public class AndroidSourceGeneratingBuilder extends ModuleLevelBuilder { return true; } - private static boolean clearDirectoryIfNotEmpty(@NotNull File dir, @NotNull CompileContext context, String compilerName) throws IOException { + private static boolean clearDirectoryIfNotEmpty(@NotNull File dir, @NotNull CompileContext context, String compilerName) + throws IOException { if (dir.isDirectory()) { final String[] list = dir.list(); if (list != null && list.length > 0) { @@ -886,7 +903,8 @@ public class AndroidSourceGeneratingBuilder extends ModuleLevelBuilder { if (!AndroidCommonUtils.contains2Identifiers(packageName)) { context.processMessage(new CompilerMessage(BUILDER_NAME, facet.isLibrary() ? BuildMessage.Kind.WARNING : BuildMessage.Kind.ERROR, - AndroidJpsBundle.message("android.jps.errors.incorrect.package.name", module.getName()))); + AndroidJpsBundle + .message("android.jps.errors.incorrect.package.name", module.getName()))); success = false; continue; } diff --git a/plugins/android/resources/messages/AndroidBundle.properties b/plugins/android/resources/messages/AndroidBundle.properties index 31228d4d4850..fe04ab7dd0b6 100644 --- a/plugins/android/resources/messages/AndroidBundle.properties +++ b/plugins/android/resources/messages/AndroidBundle.properties @@ -215,7 +215,7 @@ android.export.package.new.key.alias.label=&Alias: android.key.password.label=Pa&ssword: android.cannot.run.library.project.error=The module cannot be Android library project android.compilation.error.specify.platform=Android SDK is not specified for module {0} -android.compilation.error.manifest.not.found=AndroidManifest.xml file not found. Please, check Android facet settings. +android.compilation.error.manifest.not.found=[{0}] AndroidManifest.xml file not found. Please, check Android facet settings. android.compilation.error.apt.gen.not.specified=AAPT destination directory not specified for module {0} android.compilation.error.apk.path.not.specified=Final APK path not specified for module {0} android.restart.logcat.action.text=Restart diff --git a/plugins/android/src/org/jetbrains/android/compiler/AndroidAptCompiler.java b/plugins/android/src/org/jetbrains/android/compiler/AndroidAptCompiler.java index 1cd6304f0d25..e06710b619e5 100644 --- a/plugins/android/src/org/jetbrains/android/compiler/AndroidAptCompiler.java +++ b/plugins/android/src/org/jetbrains/android/compiler/AndroidAptCompiler.java @@ -36,6 +36,7 @@ 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.android.util.JavaFilesFilter; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -87,19 +88,8 @@ public class AndroidAptCompiler implements SourceGeneratingCompiler { return EMPTY_GENERATION_ITEM_ARRAY; } - // we have one item per module there, so clear output directory final String genRootPath = FileUtil.toSystemDependentName(outputRootDirectory.getPath()); final File genRootDir = new File(genRootPath); - if (genRootDir.exists()) { - if (!FileUtil.delete(genRootDir)) { - context.addMessage(CompilerMessageCategory.ERROR, "Cannot delete directory " + genRootPath, null, -1, -1); - return EMPTY_GENERATION_ITEM_ARRAY; - } - if (!genRootDir.mkdir()) { - context.addMessage(CompilerMessageCategory.ERROR, "Cannot create directory " + genRootPath, null, -1, -1); - return EMPTY_GENERATION_ITEM_ARRAY; - } - } List results = new ArrayList(items.length); boolean toRefresh = false; @@ -112,17 +102,27 @@ public class AndroidAptCompiler implements SourceGeneratingCompiler { continue; } - final String outputDirOsPath = FileUtil.toSystemDependentName(outputRootDirectory.getPath()); - + File tmpOutputDir = null; try { - Map> messages = AndroidCompileUtil.toCompilerMessageCategoryKeys( - AndroidApt.compile(aptItem.myAndroidTarget, aptItem.myPlatformToolsRevision, - aptItem.myManifestFile.getPath(), aptItem.myPackage, - outputDirOsPath, aptItem.myResourcesPaths, - aptItem.myLibraryPackages, aptItem.myNonConstantFields)); + tmpOutputDir = FileUtil.createTempDirectory("android_apt_output", "tmp"); + Map> messages = AndroidCompileUtil.toCompilerMessageCategoryKeys(AndroidApt.compile( + aptItem.myAndroidTarget, aptItem.myPlatformToolsRevision, aptItem.myManifestFile.getPath(), aptItem.myPackage, + tmpOutputDir.getPath(), aptItem.myResourcesPaths, aptItem.myLibraryPackages, aptItem.myNonConstantFields)); toRefresh = true; - AndroidCompileUtil.addMessages(context, messages); + AndroidCompileUtil.addMessages(context, messages, aptItem.myModule); + if (messages.get(CompilerMessageCategory.ERROR).isEmpty()) { + if (!AndroidCommonUtils.directoriesContainSameContent(tmpOutputDir, genRootDir, JavaFilesFilter.INSTANCE)) { + if (genRootDir.exists() && !FileUtil.delete(genRootDir)) { + context.addMessage(CompilerMessageCategory.ERROR, "Cannot delete directory " + genRootPath, 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); + continue; + } + } results.add(aptItem); } } @@ -135,6 +135,11 @@ public class AndroidAptCompiler implements SourceGeneratingCompiler { } }); } + finally { + if (tmpOutputDir != null) { + FileUtil.delete(tmpOutputDir); + } + } } } @@ -197,7 +202,7 @@ public class AndroidAptCompiler implements SourceGeneratingCompiler { } public String getPath() { - return myPackage.replace('.', '/') + '/' + AndroidCommonUtils.R_JAVA_FILENAME; + return "FAKE"; } public ValidityState getValidityState() { @@ -257,8 +262,8 @@ public class AndroidAptCompiler implements SourceGeneratingCompiler { VirtualFile manifestFile = AndroidRootUtil.getManifestFileForCompiler(facet); if (manifestFile == null) { - myContext.addMessage(CompilerMessageCategory.ERROR, AndroidBundle.message("android.compilation.error.manifest.not.found"), - null, -1, -1); + myContext.addMessage(CompilerMessageCategory.ERROR, + AndroidBundle.message("android.compilation.error.manifest.not.found", module.getName()), null, -1, -1); continue; } diff --git a/plugins/android/src/org/jetbrains/android/compiler/AndroidAutogenerator.java b/plugins/android/src/org/jetbrains/android/compiler/AndroidAutogenerator.java index f55194b82d43..19a5c589b0ac 100644 --- a/plugins/android/src/org/jetbrains/android/compiler/AndroidAutogenerator.java +++ b/plugins/android/src/org/jetbrains/android/compiler/AndroidAutogenerator.java @@ -120,8 +120,8 @@ public class AndroidAutogenerator { final VirtualFile manifestFile = AndroidRootUtil.getManifestFileForCompiler(facet); if (manifestFile == null) { - context.addMessage(CompilerMessageCategory.ERROR, AndroidBundle.message("android.compilation.error.manifest.not.found"), - null, -1, -1); + context.addMessage(CompilerMessageCategory.ERROR, + AndroidBundle.message("android.compilation.error.manifest.not.found", module.getName()), null, -1, -1); return null; } @@ -207,8 +207,8 @@ public class AndroidAutogenerator { final VirtualFile manifestFile = AndroidRootUtil.getManifestFileForCompiler(facet); if (manifestFile == null) { - context.addMessage(CompilerMessageCategory.ERROR, AndroidBundle.message("android.compilation.error.manifest.not.found"), - null, -1, -1); + context.addMessage(CompilerMessageCategory.ERROR, + AndroidBundle.message("android.compilation.error.manifest.not.found", module.getName()), null, -1, -1); return null; } @@ -314,7 +314,7 @@ public class AndroidAutogenerator { } } } - AndroidCompileUtil.addMessages(context, AndroidCompileUtil.toCompilerMessageCategoryKeys(messages)); + AndroidCompileUtil.addMessages(context, AndroidCompileUtil.toCompilerMessageCategoryKeys(messages), module); for (Map.Entry entry : item.myGenFileRelPath2package.entrySet()) { final String path = item.myOutputDirOsPath + '/' + entry.getKey(); diff --git a/plugins/android/src/org/jetbrains/android/compiler/AndroidBuildConfigGeneratingCompiler.java b/plugins/android/src/org/jetbrains/android/compiler/AndroidBuildConfigGeneratingCompiler.java index 13c7b9a2e76a..c012114e7b38 100644 --- a/plugins/android/src/org/jetbrains/android/compiler/AndroidBuildConfigGeneratingCompiler.java +++ b/plugins/android/src/org/jetbrains/android/compiler/AndroidBuildConfigGeneratingCompiler.java @@ -50,8 +50,8 @@ public class AndroidBuildConfigGeneratingCompiler implements SourceGeneratingCom final VirtualFile manifestFile = AndroidRootUtil.getManifestFileForCompiler(facet); if (manifestFile == null) { - context.addMessage(CompilerMessageCategory.ERROR, AndroidBundle.message("android.compilation.error.manifest.not.found"), - null, -1, -1); + context.addMessage(CompilerMessageCategory.ERROR, + AndroidBundle.message("android.compilation.error.manifest.not.found", module.getName()), null, -1, -1); continue; } diff --git a/plugins/android/src/org/jetbrains/android/compiler/AndroidCompileUtil.java b/plugins/android/src/org/jetbrains/android/compiler/AndroidCompileUtil.java index 18d8c0461d49..10551667f969 100644 --- a/plugins/android/src/org/jetbrains/android/compiler/AndroidCompileUtil.java +++ b/plugins/android/src/org/jetbrains/android/compiler/AndroidCompileUtil.java @@ -131,8 +131,8 @@ public class AndroidCompileUtil { return null; } - static void addMessages(final CompileContext context, final Map> messages) { - addMessages(context, messages, null); + static void addMessages(final CompileContext context, final Map> messages, Module module) { + addMessages(context, messages, null, module); } public static void addMessages(@NotNull Map> messages, @@ -147,8 +147,10 @@ public class AndroidCompileUtil { } } - static void addMessages(final CompileContext context, final Map> messages, - @Nullable final Map presentableFilesMap) { + static void addMessages(final CompileContext context, + final Map> messages, + @Nullable final Map presentableFilesMap, + final Module module) { ApplicationManager.getApplication().runReadAction(new Runnable() { public void run() { if (context.getProject().isDisposed()) return; @@ -165,7 +167,7 @@ public class AndroidCompileUtil { line = Integer.parseInt(matcher.group(2)); } } - context.addMessage(category, message, url, line, -1); + context.addMessage(category, '[' + module.getName() + "] " + message, url, line, -1); } } } diff --git a/plugins/android/src/org/jetbrains/android/compiler/AndroidDexCompiler.java b/plugins/android/src/org/jetbrains/android/compiler/AndroidDexCompiler.java index 6bf0caea5cc6..a1b6abf4ab76 100644 --- a/plugins/android/src/org/jetbrains/android/compiler/AndroidDexCompiler.java +++ b/plugins/android/src/org/jetbrains/android/compiler/AndroidDexCompiler.java @@ -217,7 +217,7 @@ public class AndroidDexCompiler implements ClassPostProcessingCompiler { Map> messages = AndroidCompileUtil.toCompilerMessageCategoryKeys( AndroidDxWrapper.execute(dexItem.myModule, dexItem.myAndroidTarget, outputDirPath, files)); - addMessages(messages); + addMessages(messages, dexItem.myModule); if (messages.get(CompilerMessageCategory.ERROR).isEmpty()) { results.add(dexItem); } @@ -226,11 +226,11 @@ public class AndroidDexCompiler implements ClassPostProcessingCompiler { return results.toArray(new ProcessingItem[results.size()]); } - private void addMessages(Map> messages) { + private void addMessages(Map> messages, Module module) { for (CompilerMessageCategory category : messages.keySet()) { List messageList = messages.get(category); for (String message : messageList) { - myContext.addMessage(category, message, null, -1, -1); + myContext.addMessage(category, '[' + module.getName() + "] " + message, null, -1, -1); } } } diff --git a/plugins/android/src/org/jetbrains/android/compiler/AndroidIdlCompiler.java b/plugins/android/src/org/jetbrains/android/compiler/AndroidIdlCompiler.java index 3c99381a17b2..072bce300872 100644 --- a/plugins/android/src/org/jetbrains/android/compiler/AndroidIdlCompiler.java +++ b/plugins/android/src/org/jetbrains/android/compiler/AndroidIdlCompiler.java @@ -20,6 +20,7 @@ import com.android.sdklib.SdkConstants; import com.intellij.facet.FacetManager; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.compiler.*; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.ProjectFileIndex; @@ -48,6 +49,8 @@ import java.util.Map; * @author Alexey Efimov */ public class AndroidIdlCompiler implements SourceGeneratingCompiler { + private static final Logger LOG = Logger.getInstance("#org.jetbrains.android.compiler.AndroidIdlCompiler"); + private static final GenerationItem[] EMPTY_GENERATION_ITEM_ARRAY = {}; private final Project myProject; @@ -218,6 +221,7 @@ public class AndroidIdlCompiler implements SourceGeneratingCompiler { } } catch (final IOException e) { + LOG.info(e); ApplicationManager.getApplication().runReadAction(new Runnable() { public void run() { if (context.getProject().isDisposed()) return; diff --git a/plugins/android/src/org/jetbrains/android/compiler/AndroidMavenResourcesCompiler.java b/plugins/android/src/org/jetbrains/android/compiler/AndroidMavenResourcesCompiler.java index 91c1a2dc595a..a31f6172d142 100644 --- a/plugins/android/src/org/jetbrains/android/compiler/AndroidMavenResourcesCompiler.java +++ b/plugins/android/src/org/jetbrains/android/compiler/AndroidMavenResourcesCompiler.java @@ -103,7 +103,7 @@ public class AndroidMavenResourcesCompiler implements SourceGeneratingCompiler { } Map> messages = AndroidMavenExecutor.generateResources(genItem.myModule); - AndroidCompileUtil.addMessages(context, messages); + AndroidCompileUtil.addMessages(context, messages, genItem.myModule); if (messages.get(CompilerMessageCategory.ERROR).isEmpty()) { results.add(genItem); } diff --git a/plugins/android/src/org/jetbrains/android/compiler/AndroidPackagingCompiler.java b/plugins/android/src/org/jetbrains/android/compiler/AndroidPackagingCompiler.java index 4d4dd37aa8e7..a5e34b7a4ab9 100644 --- a/plugins/android/src/org/jetbrains/android/compiler/AndroidPackagingCompiler.java +++ b/plugins/android/src/org/jetbrains/android/compiler/AndroidPackagingCompiler.java @@ -18,6 +18,7 @@ package org.jetbrains.android.compiler; import com.intellij.compiler.CompilerIOUtil; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.compiler.*; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleManager; import com.intellij.openapi.project.Project; @@ -51,6 +52,7 @@ import java.util.*; * @author yole */ public class AndroidPackagingCompiler implements PackagingCompiler { + private static final Logger LOG = Logger.getInstance("#org.jetbrains.android.compiler.AndroidPackagingCompiler"); public static final String UNSIGNED_SUFFIX = ".unsigned"; @@ -245,9 +247,10 @@ public class AndroidPackagingCompiler implements PackagingCompiler { item.getAdditionalNativeLibs(), finalPath, unsigned, item.mySdkPath, item.getCustomKeystorePath(), new ExcludedSourcesFilter(project))); - AndroidCompileUtil.addMessages(context, messages); + AndroidCompileUtil.addMessages(context, messages, item.myModule); } catch (final IOException e) { + LOG.info(e); ApplicationManager.getApplication().runReadAction(new Runnable() { public void run() { if (context.getProject().isDisposed()) return; diff --git a/plugins/android/src/org/jetbrains/android/compiler/AndroidPngFilesCachingCompiler.java b/plugins/android/src/org/jetbrains/android/compiler/AndroidPngFilesCachingCompiler.java index c89daceea841..290ab987ea6e 100644 --- a/plugins/android/src/org/jetbrains/android/compiler/AndroidPngFilesCachingCompiler.java +++ b/plugins/android/src/org/jetbrains/android/compiler/AndroidPngFilesCachingCompiler.java @@ -101,7 +101,7 @@ public class AndroidPngFilesCachingCompiler implements SourceGeneratingCompiler final Map> messages = AndroidCompileUtil.toCompilerMessageCategoryKeys( AndroidApt.crunch(item.getTarget(), Collections.singletonList(resDirOsPath), resCacheDirOsPath)); - AndroidCompileUtil.addMessages(context, messages, null); + AndroidCompileUtil.addMessages(context, messages, module); if (context.getMessages(CompilerMessageCategory.ERROR).length == 0) { processedItems.add(item); } diff --git a/plugins/android/src/org/jetbrains/android/compiler/AndroidProguardCompiler.java b/plugins/android/src/org/jetbrains/android/compiler/AndroidProguardCompiler.java index 4328f0c353c8..c97dd11195f0 100644 --- a/plugins/android/src/org/jetbrains/android/compiler/AndroidProguardCompiler.java +++ b/plugins/android/src/org/jetbrains/android/compiler/AndroidProguardCompiler.java @@ -175,7 +175,7 @@ public class AndroidProguardCompiler implements ClassPostProcessingCompiler { CompilerUtil.refreshIOFile(new File(processingItem.getOutputJarOsPath())); - AndroidCompileUtil.addMessages(context, messages); + AndroidCompileUtil.addMessages(context, messages, processingItem.myModule); if (messages.get(CompilerMessageCategory.ERROR).isEmpty()) { processedItems.add(item); diff --git a/plugins/android/src/org/jetbrains/android/compiler/AndroidRenderscriptCompiler.java b/plugins/android/src/org/jetbrains/android/compiler/AndroidRenderscriptCompiler.java index 313236f033d6..b1e6f16e6248 100644 --- a/plugins/android/src/org/jetbrains/android/compiler/AndroidRenderscriptCompiler.java +++ b/plugins/android/src/org/jetbrains/android/compiler/AndroidRenderscriptCompiler.java @@ -6,6 +6,7 @@ import com.intellij.facet.FacetManager; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.compiler.*; import com.intellij.openapi.compiler.ex.CompileContextEx; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.ProjectFileIndex; @@ -36,6 +37,7 @@ import java.util.*; * @author Eugene.Kudelevsky */ public class AndroidRenderscriptCompiler implements SourceGeneratingCompiler { + private static final Logger LOG = Logger.getInstance("#org.jetbrains.android.compiler.AndroidRenderscriptCompiler"); private static final GenerationItem[] EMPTY_GENERATION_ITEM_ARRAY = {}; @@ -209,6 +211,7 @@ public class AndroidRenderscriptCompiler implements SourceGeneratingCompiler { } } catch (final IOException e) { + LOG.info(e); ApplicationManager.getApplication().runReadAction(new Runnable() { public void run() { if (context.getProject().isDisposed()) return; diff --git a/plugins/android/src/org/jetbrains/android/compiler/AndroidResourcesPackagingCompiler.java b/plugins/android/src/org/jetbrains/android/compiler/AndroidResourcesPackagingCompiler.java index fbbbda9760f9..e583dbaafca3 100644 --- a/plugins/android/src/org/jetbrains/android/compiler/AndroidResourcesPackagingCompiler.java +++ b/plugins/android/src/org/jetbrains/android/compiler/AndroidResourcesPackagingCompiler.java @@ -66,8 +66,8 @@ public class AndroidResourcesPackagingCompiler implements ClassPostProcessingCom final String[] assetDirPaths = ArrayUtil.toStringArray(assetDirPathsList); if (manifestFile == null) { - context.addMessage(CompilerMessageCategory.ERROR, AndroidBundle.message("android.compilation.error.manifest.not.found"), - null, -1, -1); + context.addMessage(CompilerMessageCategory.ERROR, + AndroidBundle.message("android.compilation.error.manifest.not.found", module.getName()), null, -1, -1); continue; } AndroidFacetConfiguration configuration = facet.getConfiguration(); @@ -156,7 +156,8 @@ public class AndroidResourcesPackagingCompiler implements ClassPostProcessingCom } catch (IOException e) { LOG.info(e); - context.addMessage(CompilerMessageCategory.ERROR, "Cannot preprocess AndroidManifest.xml for debug build", + context.addMessage(CompilerMessageCategory.ERROR, + '[' + item.myModule.getName() + "] Cannot preprocess AndroidManifest.xml for debug build", item.myManifestFile.getUrl(), -1, -1); return; } @@ -182,9 +183,10 @@ public class AndroidResourcesPackagingCompiler implements ClassPostProcessingCom } })); - AndroidCompileUtil.addMessages(context, messages, presentableFilesMap); + AndroidCompileUtil.addMessages(context, messages, presentableFilesMap, item.myModule); } catch (final IOException e) { + LOG.info(e); ApplicationManager.getApplication().runReadAction(new Runnable() { public void run() { if (context.getProject().isDisposed()) return; diff --git a/plugins/android/src/org/jetbrains/android/dom/converters/OnClickConverter.java b/plugins/android/src/org/jetbrains/android/dom/converters/OnClickConverter.java index abd1d86db155..a5538b242372 100644 --- a/plugins/android/src/org/jetbrains/android/dom/converters/OnClickConverter.java +++ b/plugins/android/src/org/jetbrains/android/dom/converters/OnClickConverter.java @@ -153,11 +153,11 @@ public class OnClickConverter extends Converter implements CustomReferen private static LookupElement createLookupElement(PsiMethod method) { final LookupElementBuilder builder = LookupElementBuilder.create(method, method.getName()) - .setIcon(method.getIcon(Iconable.ICON_FLAG_VISIBILITY)) - .setPresentableText(method.getName()); + .withIcon(method.getIcon(Iconable.ICON_FLAG_VISIBILITY)) + .withPresentableText(method.getName()); final PsiClass containingClass = method.getContainingClass(); return containingClass != null - ? builder.setTailText(" (" + containingClass.getQualifiedName() + ')') + ? builder.withTailText(" (" + containingClass.getQualifiedName() + ')') : builder; } } diff --git a/plugins/android/src/org/jetbrains/android/dom/converters/StyleItemNameConverter.java b/plugins/android/src/org/jetbrains/android/dom/converters/StyleItemNameConverter.java index ba4bf7aea82d..5f191265cdb0 100644 --- a/plugins/android/src/org/jetbrains/android/dom/converters/StyleItemNameConverter.java +++ b/plugins/android/src/org/jetbrains/android/dom/converters/StyleItemNameConverter.java @@ -62,7 +62,7 @@ public class StyleItemNameConverter extends ResolvingConverter { return null; } final String attributeName = s.substring(prefix.length()); - return LookupElementBuilder.create(s).addLookupString(attributeName); + return LookupElementBuilder.create(s).withLookupString(attributeName); } @Override diff --git a/plugins/ant/src/com/intellij/lang/ant/dom/AntDomPropertyReference.java b/plugins/ant/src/com/intellij/lang/ant/dom/AntDomPropertyReference.java index 969546d0af3a..c8868762de92 100644 --- a/plugins/ant/src/com/intellij/lang/ant/dom/AntDomPropertyReference.java +++ b/plugins/ant/src/com/intellij/lang/ant/dom/AntDomPropertyReference.java @@ -91,7 +91,7 @@ public class AntDomPropertyReference extends PsiPolyVariantReferenceBase getFetchSpecs(Project project, VirtualFile root, String remoteName) throws VcsException { ArrayList rc = new ArrayList(); final File rootFile = VfsUtil.virtualToIoFile(root); - @NonNls final File remotesFile = new File(rootFile, ".git" + File.separator + "remotes" + File.separator + remoteName); + @NonNls final File remotesFile = new File(rootFile, GitUtil.DOT_GIT + File.separator + "remotes" + File.separator + remoteName); // TODO try branches file? if (remotesFile.exists() && !remotesFile.isDirectory()) { // try remotes file diff --git a/plugins/git4idea/src/git4idea/GitUtil.java b/plugins/git4idea/src/git4idea/GitUtil.java index db0de52d46dd..41db3cd4f414 100644 --- a/plugins/git4idea/src/git4idea/GitUtil.java +++ b/plugins/git4idea/src/git4idea/GitUtil.java @@ -57,10 +57,6 @@ import java.util.*; * Git utility/helper methods */ public class GitUtil { - /** - * The logger instance - */ - private final static Logger LOG = Logger.getInstance("#git4idea.GitUtil"); /** * Comparator for virtual files by name */ @@ -86,6 +82,9 @@ public class GitUtil { * The UTF8 charset */ public static final Charset UTF8_CHARSET = Charset.forName(UTF8_ENCODING); + public static final String DOT_GIT = ".git"; + + private final static Logger LOG = Logger.getInstance(GitUtil.class); /** * A private constructor to suppress instance creation @@ -96,7 +95,7 @@ public class GitUtil { @Nullable public static VirtualFile findGitDir(@NotNull VirtualFile rootDir) { - VirtualFile child = rootDir.findChild(".git"); + VirtualFile child = rootDir.findChild(DOT_GIT); if (child == null) { return null; } @@ -281,7 +280,7 @@ public class GitUtil { for (VirtualFile root : roots) { VirtualFile f = root; do { - if (f.findFileByRelativePath(".git") != null) { + if (f.findFileByRelativePath(DOT_GIT) != null) { rc.add(f); break; } @@ -320,13 +319,13 @@ public class GitUtil { } public static boolean isGitRoot(final File file) { - return file != null && file.exists() && file.isDirectory() && new File(file, ".git").exists(); + return file != null && file.exists() && file.isDirectory() && new File(file, DOT_GIT).exists(); } @Nullable public static VirtualFile getGitRootOrNull(final File file) { File root = file; - while (root != null && (!root.exists() || !root.isDirectory() || !new File(root, ".git").exists())) { + while (root != null && (!root.exists() || !root.isDirectory() || !new File(root, DOT_GIT).exists())) { root = root.getParentFile(); } return root == null ? null : LocalFileSystem.getInstance().findFileByIoFile(root); @@ -362,7 +361,7 @@ public class GitUtil { } VirtualFile root = file; while (root != null) { - if (root.findFileByRelativePath(".git") != null) { + if (root.findFileByRelativePath(DOT_GIT) != null) { return root; } root = root.getParent(); diff --git a/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java b/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java index 1f3fc88dd2a2..0f4237443533 100644 --- a/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java +++ b/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java @@ -41,6 +41,7 @@ import com.intellij.vcsUtil.VcsFileUtil; import com.intellij.vcsUtil.VcsUtil; import git4idea.GitUtil; import git4idea.commands.GitCommand; +import git4idea.repo.GitRepositoryFiles; import git4idea.util.GitFileUtils; import git4idea.commands.GitSimpleHandler; import git4idea.config.GitConfigUtil; @@ -103,8 +104,8 @@ public class GitCheckinEnvironment implements CheckinEnvironment { public String getDefaultMessageFor(FilePath[] filesToCheckin) { StringBuilder rc = new StringBuilder(); for (VirtualFile root : GitUtil.gitRoots(Arrays.asList(filesToCheckin))) { - VirtualFile mergeMsg = root.findFileByRelativePath(".git/MERGE_MSG"); - VirtualFile squashMsg = root.findFileByRelativePath(".git/SQUASH_MSG"); + VirtualFile mergeMsg = root.findFileByRelativePath(GitRepositoryFiles.GIT_MERGE_MSG); + VirtualFile squashMsg = root.findFileByRelativePath(GitRepositoryFiles.GIT_SQUASH_MSG); if (mergeMsg != null || squashMsg != null) { try { String encoding = GitConfigUtil.getCommitEncoding(myProject, root); diff --git a/plugins/git4idea/src/git4idea/checkout/GitCloneDialog.java b/plugins/git4idea/src/git4idea/checkout/GitCloneDialog.java index 219f0c2c1361..0658f0a65759 100644 --- a/plugins/git4idea/src/git4idea/checkout/GitCloneDialog.java +++ b/plugins/git4idea/src/git4idea/checkout/GitCloneDialog.java @@ -23,6 +23,7 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.DocumentAdapter; import com.intellij.ui.EditorComboBox; import com.intellij.util.ArrayUtil; +import git4idea.GitUtil; import git4idea.commands.GitCommand; import git4idea.commands.GitLineHandlerPasswordRequestAware; import git4idea.commands.GitTask; @@ -300,13 +301,11 @@ public class GitCloneDialog extends DialogWrapper { */ private static String defaultDirectoryName(final String url) { String nonSystemName; - //noinspection HardCodedStringLiteral - if (url.endsWith("/.git") || url.endsWith(File.separator + ".git")) { + if (url.endsWith("/" + GitUtil.DOT_GIT) || url.endsWith(File.separator + GitUtil.DOT_GIT)) { nonSystemName = url.substring(0, url.length() - 5); } else { - //noinspection HardCodedStringLiteral - if (url.endsWith(".git")) { + if (url.endsWith(GitUtil.DOT_GIT)) { nonSystemName = url.substring(0, url.length() - 4); } else { diff --git a/plugins/git4idea/src/git4idea/history/browser/LowLevelAccessImpl.java b/plugins/git4idea/src/git4idea/history/browser/LowLevelAccessImpl.java index 8f8ea572719f..45e11a63095a 100644 --- a/plugins/git4idea/src/git4idea/history/browser/LowLevelAccessImpl.java +++ b/plugins/git4idea/src/git4idea/history/browser/LowLevelAccessImpl.java @@ -15,41 +15,30 @@ */ package git4idea.history.browser; -import com.intellij.notification.Notification; -import com.intellij.notification.NotificationListener; -import com.intellij.notification.NotificationType; -import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Getter; -import com.intellij.openapi.util.Key; import com.intellij.openapi.vcs.FilePathImpl; import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vcs.history.VcsRevisionNumber; -import com.intellij.openapi.vcs.merge.MergeDialogCustomizer; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.ArrayUtil; import com.intellij.util.AsynchConsumer; -import git4idea.*; +import git4idea.GitBranch; +import git4idea.GitTag; +import git4idea.GitUtil; import git4idea.branch.GitBranchesCollection; -import git4idea.commands.Git; -import git4idea.commands.GitCommand; -import git4idea.commands.GitLineHandler; -import git4idea.commands.GitLineHandlerAdapter; import git4idea.config.GitConfigUtil; import git4idea.history.GitHistoryUtils; import git4idea.history.wholeTree.AbstractHash; import git4idea.history.wholeTree.CommitHashPlusParents; -import git4idea.merge.GitConflictResolver; import git4idea.repo.GitRepository; import git4idea.repo.GitRepositoryImpl; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import javax.swing.event.HyperlinkEvent; import java.io.File; import java.util.*; -import java.util.concurrent.atomic.AtomicBoolean; public class LowLevelAccessImpl implements LowLevelAccess { private final static Logger LOG = Logger.getInstance("#git4idea.history.browser.LowLevelAccessImpl"); @@ -117,7 +106,7 @@ public class LowLevelAccessImpl implements LowLevelAccess { final CachedRefs refs = new CachedRefs(); GitRepository repository = GitUtil.getRepositoryManager(myProject).getRepositoryForRoot(myRoot); if (repository == null) { - final File child = new File(myRoot.getPath(), ".git"); + final File child = new File(myRoot.getPath(), GitUtil.DOT_GIT); if (! child.exists()) { throw new VcsException("No git repository in " + myRoot.getPath()); } diff --git a/plugins/git4idea/src/git4idea/history/wholeTree/UsersFilterAction.java b/plugins/git4idea/src/git4idea/history/wholeTree/UsersFilterAction.java index 2da8b5dac27a..74d3123d8b85 100644 --- a/plugins/git4idea/src/git4idea/history/wholeTree/UsersFilterAction.java +++ b/plugins/git4idea/src/git4idea/history/wholeTree/UsersFilterAction.java @@ -170,7 +170,7 @@ public class UsersFilterAction extends BasePopupAction { if (list != null) { for (String completionVariant : list) { final LookupElementBuilder element = LookupElementBuilder.create(completionVariant); - result.addElement(element.addLookupString(completionVariant.toLowerCase())); + result.addElement(element.withLookupString(completionVariant.toLowerCase())); } } } diff --git a/plugins/git4idea/src/git4idea/jgit/GitHttpAdapter.java b/plugins/git4idea/src/git4idea/jgit/GitHttpAdapter.java index 823987234255..928bafa7ea86 100644 --- a/plugins/git4idea/src/git4idea/jgit/GitHttpAdapter.java +++ b/plugins/git4idea/src/git4idea/jgit/GitHttpAdapter.java @@ -23,6 +23,7 @@ import com.intellij.ide.passwordSafe.impl.PasswordSafeProvider; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import git4idea.GitBranch; +import git4idea.GitUtil; import git4idea.GitVcs; import git4idea.push.GitSimplePushResult; import git4idea.remote.GitRememberedInputs; @@ -362,7 +363,7 @@ public final class GitHttpAdapter { if (url.endsWith("/")) { url = url.substring(0, url.length() - 1); } - return url + ".git"; + return url + GitUtil.DOT_GIT; } private static void log(@NotNull GitHttpRemoteCommand command, @NotNull Project project) { @@ -387,7 +388,7 @@ public final class GitHttpAdapter { if (!(cause instanceof NoRemoteRepositoryException) && !(cause.getCause() instanceof NoRemoteRepositoryException)) { return false; } - return !url.toLowerCase().endsWith(".git"); + return !url.toLowerCase().endsWith(GitUtil.DOT_GIT); } private static boolean isTransportExceptionForHttp(@NotNull JGitInternalException e, @NotNull String url) { @@ -499,7 +500,7 @@ public final class GitHttpAdapter { @NotNull private static Repository convert(@NotNull GitRepository repository) throws IOException { FileRepositoryBuilder builder = new FileRepositoryBuilder(); - return builder.setGitDir(new File(repository.getRoot().getPath(), ".git")) + return builder.setGitDir(new File(repository.getRoot().getPath(), GitUtil.DOT_GIT)) .readEnvironment() // scan environment GIT_* variables .findGitDir() // scan up the file system tree .build(); diff --git a/plugins/git4idea/src/git4idea/merge/GitMergeUtil.java b/plugins/git4idea/src/git4idea/merge/GitMergeUtil.java index 86e9bef33299..b13ef7bf68b3 100644 --- a/plugins/git4idea/src/git4idea/merge/GitMergeUtil.java +++ b/plugins/git4idea/src/git4idea/merge/GitMergeUtil.java @@ -29,13 +29,15 @@ import com.intellij.openapi.vcs.update.FileGroup; import com.intellij.openapi.vcs.update.UpdateInfoTree; import com.intellij.openapi.vcs.update.UpdatedFiles; import com.intellij.openapi.vfs.LocalFileSystem; -import com.intellij.openapi.vfs.VfsUtil; +import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.ui.UIUtil; import git4idea.GitRevisionNumber; +import git4idea.GitUtil; import git4idea.GitVcs; import git4idea.actions.GitRepositoryAction; import git4idea.i18n.GitBundle; +import git4idea.repo.GitRepositoryFiles; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -186,8 +188,8 @@ public class GitMergeUtil { */ @Nullable private static File getMergeHead(@NotNull VirtualFile root) { - File gitDir = new File(VfsUtil.virtualToIoFile(root), ".git"); - File f = new File(gitDir, "MERGE_HEAD"); + File gitDir = new File(VfsUtilCore.virtualToIoFile(root), GitUtil.DOT_GIT); + File f = new File(gitDir, GitRepositoryFiles.MERGE_HEAD); if (f.exists()) { return f; } diff --git a/plugins/git4idea/src/git4idea/merge/GitMerger.java b/plugins/git4idea/src/git4idea/merge/GitMerger.java index ff1e372aa414..9bf920aa8734 100644 --- a/plugins/git4idea/src/git4idea/merge/GitMerger.java +++ b/plugins/git4idea/src/git4idea/merge/GitMerger.java @@ -18,12 +18,14 @@ package git4idea.merge; import com.intellij.openapi.project.Project; import com.intellij.openapi.vcs.ProjectLevelVcsManager; import com.intellij.openapi.vcs.VcsException; -import com.intellij.openapi.vfs.VfsUtil; +import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import git4idea.GitBranch; +import git4idea.GitUtil; import git4idea.GitVcs; import git4idea.commands.GitCommand; import git4idea.commands.GitSimpleHandler; +import git4idea.repo.GitRepositoryFiles; import java.io.File; import java.util.Collection; @@ -64,8 +66,8 @@ public class GitMerger { GitSimpleHandler handler = new GitSimpleHandler(myProject, root, GitCommand.COMMIT); handler.setNoSSH(true); - File gitDir = new File(VfsUtil.virtualToIoFile(root), ".git"); - File messageFile = new File(gitDir, "MERGE_MSG"); + File gitDir = new File(VfsUtilCore.virtualToIoFile(root), GitUtil.DOT_GIT); + File messageFile = new File(gitDir, GitRepositoryFiles.MERGE_MSG); if (!messageFile.exists()) { final GitBranch branch = GitBranch.current(myProject, root); final String branchName = branch != null ? branch.getName() : ""; diff --git a/plugins/git4idea/src/git4idea/merge/MergeChangeCollector.java b/plugins/git4idea/src/git4idea/merge/MergeChangeCollector.java index 84e169624db4..fbd99cf2ad6d 100644 --- a/plugins/git4idea/src/git4idea/merge/MergeChangeCollector.java +++ b/plugins/git4idea/src/git4idea/merge/MergeChangeCollector.java @@ -27,6 +27,7 @@ import git4idea.GitUtil; import git4idea.GitVcs; import git4idea.commands.GitCommand; import git4idea.commands.GitSimpleHandler; +import git4idea.repo.GitRepositoryFiles; import git4idea.util.StringScanner; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -119,7 +120,7 @@ public class MergeChangeCollector { // should be available. In case of --no-commit option, the MERGE_HEAD might contain // multiple heads separated by newline. The changes are collected separately for each head // and they are merged using TreeSet class (that also sorts the changes). - File mergeHeadsFile = new File(root, ".git/MERGE_HEAD"); + File mergeHeadsFile = new File(root, GitRepositoryFiles.GIT_MERGE_HEAD); try { if (mergeHeadsFile.exists()) { String mergeHeads = new String(FileUtil.loadFileText(mergeHeadsFile, GitUtil.UTF8_ENCODING)); diff --git a/plugins/git4idea/src/git4idea/push/GitCommitsByBranch.java b/plugins/git4idea/src/git4idea/push/GitCommitsByBranch.java index 1b533eab6b8d..7133f4dba8eb 100644 --- a/plugins/git4idea/src/git4idea/push/GitCommitsByBranch.java +++ b/plugins/git4idea/src/git4idea/push/GitCommitsByBranch.java @@ -39,7 +39,12 @@ final class GitCommitsByBranch { } boolean isEmpty() { - return myCommitsByBranch.isEmpty(); + for (GitPushBranchInfo info : myCommitsByBranch.values()) { + if (!info.isEmpty()) { + return false; + } + } + return true; } int commitsNumber() { diff --git a/plugins/git4idea/src/git4idea/push/GitPushBranchInfo.java b/plugins/git4idea/src/git4idea/push/GitPushBranchInfo.java index 999ed738d292..d784183dc964 100644 --- a/plugins/git4idea/src/git4idea/push/GitPushBranchInfo.java +++ b/plugins/git4idea/src/git4idea/push/GitPushBranchInfo.java @@ -74,4 +74,9 @@ final class GitPushBranchInfo { public GitBranch getSourceBranch() { return mySourceBranch; } + + boolean isEmpty() { + return myCommits.isEmpty(); + } + } diff --git a/plugins/git4idea/src/git4idea/push/GitPushLog.java b/plugins/git4idea/src/git4idea/push/GitPushLog.java index 1524ebc2aeeb..6e3b118e71c0 100644 --- a/plugins/git4idea/src/git4idea/push/GitPushLog.java +++ b/plugins/git4idea/src/git4idea/push/GitPushLog.java @@ -167,6 +167,7 @@ class GitPushLog extends JPanel implements TypeSafeDataProvider { myTree.setModel(myTreeModel); // TODO: why doesn't it repaint otherwise? TreeUtil.expandAll(myTree); selectFirstCommit(); + collapseEmptyRepoNodes(commits); myTreeWasConstructed = true; } finally { @@ -194,23 +195,66 @@ class GitPushLog extends JPanel implements TypeSafeDataProvider { myTree.setSelectionPath(new TreePath(node.getPath())); } + private void collapseEmptyRepoNodes(GitCommitsByRepoAndBranch commits) { + Enumeration enumeration = myRootNode.breadthFirstEnumeration(); + while (enumeration.hasMoreElements()) { + DefaultMutableTreeNode node = (DefaultMutableTreeNode) enumeration.nextElement(); + Object userObject = node.getUserObject(); + if (userObject == null) { + // root object => seeking further + } + else if (userObject instanceof GitRepository) { + if (commits.get((GitRepository)userObject).isEmpty()) { + myTree.collapsePath(new TreePath(node.getPath())); + } + } + else { + // we're looking to the breadthFirstEnumeration => all repository nodes have already been enumerated + // checking for null + return; + } + } + } + private void createNodes(@NotNull GitCommitsByRepoAndBranch commits) { - for (GitRepository repository : GitUtil.sortRepositories(commits.getRepositories())) { + for (GitRepository repository : sortRepositories(commits)) { GitCommitsByBranch commitsByBranch = commits.get(repository); createRepoNode(repository, commitsByBranch, myRootNode); } } + @NotNull + private static List sortRepositories(@NotNull final GitCommitsByRepoAndBranch commits) { + List repos = new ArrayList(commits.getRepositories()); + Collections.sort(repos, new Comparator() { + @Override public int compare(GitRepository r1, GitRepository r2) { + // empty repositories - to the end + if (commits.get(r1).isEmpty() && !commits.get(r2).isEmpty()) { + return 1; + } + if (commits.get(r2).isEmpty() && !commits.get(r1).isEmpty()) { + return -1; + } + return r1.getPresentableUrl().compareTo(r2.getPresentableUrl()); + } + }); + return repos; + } + /** * Creates the node with subnodes for a repository and adds it to the rootNode. * If there is only one repo in the project, doesn't create a node for the repository, and adds subnodes directly to the rootNode. */ - private void createRepoNode(@NotNull GitRepository repository, @NotNull GitCommitsByBranch commitsByBranch, @NotNull DefaultMutableTreeNode rootNode) { + private void createRepoNode(@NotNull GitRepository repository, @NotNull GitCommitsByBranch commitsByBranch, + @NotNull DefaultMutableTreeNode rootNode) { DefaultMutableTreeNode parentNode; if (GitUtil.justOneGitRepository(myProject)) { parentNode = rootNode; } else { parentNode = new CheckedTreeNode(repository); + if (commitsByBranch.isEmpty()) { + ((CheckedTreeNode)parentNode).setChecked(false); + } rootNode.add(parentNode); } @@ -302,7 +346,7 @@ class GitPushLog extends JPanel implements TypeSafeDataProvider { private static class MyTreeCellRenderer extends CheckboxTree.CheckboxTreeCellRenderer { @Override - public void customizeRenderer(final JTree tree, final Object value, final boolean selected, final boolean expanded, final boolean leaf, final int row, final boolean hasFocus) { + public void customizeRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { Object userObject; if (value instanceof CheckedTreeNode) { userObject = ((CheckedTreeNode)value).getUserObject(); diff --git a/plugins/git4idea/src/git4idea/rebase/GitRebaseUtils.java b/plugins/git4idea/src/git4idea/rebase/GitRebaseUtils.java index 6afa4b40bc0c..a7065892996c 100644 --- a/plugins/git4idea/src/git4idea/rebase/GitRebaseUtils.java +++ b/plugins/git4idea/src/git4idea/rebase/GitRebaseUtils.java @@ -17,10 +17,11 @@ package git4idea.rebase; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.io.FileUtil; -import com.intellij.openapi.vfs.VfsUtil; +import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import git4idea.GitRevisionNumber; import git4idea.GitUtil; +import git4idea.repo.GitRepositoryFiles; import org.jetbrains.annotations.Nullable; import java.io.BufferedReader; @@ -62,12 +63,12 @@ public class GitRebaseUtils { */ @Nullable private static File getRebaseDir(VirtualFile root) { - File gitDir = new File(VfsUtil.virtualToIoFile(root), ".git"); - File f = new File(gitDir, "rebase-apply"); + File gitDir = new File(VfsUtilCore.virtualToIoFile(root), GitUtil.DOT_GIT); + File f = new File(gitDir, GitRepositoryFiles.REBASE_APPLY); if (f.exists()) { return f; } - f = new File(gitDir, "rebase-merge"); + f = new File(gitDir, GitRepositoryFiles.REBASE_MERGE); if (f.exists()) { return f; } diff --git a/plugins/git4idea/src/git4idea/repo/GitRepositoryFiles.java b/plugins/git4idea/src/git4idea/repo/GitRepositoryFiles.java index d4f68bb512f4..f6456ce267a0 100644 --- a/plugins/git4idea/src/git4idea/repo/GitRepositoryFiles.java +++ b/plugins/git4idea/src/git4idea/repo/GitRepositoryFiles.java @@ -22,6 +22,8 @@ import org.jetbrains.annotations.NotNull; import java.util.Arrays; import java.util.Collection; +import static git4idea.GitUtil.DOT_GIT; + /** * Stores paths to Git service files (from .git/ directory) that are used by IDEA, and provides test-methods to check if a file * matches once of them. @@ -30,9 +32,28 @@ import java.util.Collection; */ public class GitRepositoryFiles { - public static final String REFS_HEADS = "/refs/heads"; - public static final String REFS_REMOTES = "/refs/remotes"; - public static final String INFO = "/info"; + public static final String COMMIT_EDITMSG = "COMMIT_EDITMSG"; + public static final String CONFIG = "config"; + public static final String HEAD = "HEAD"; + public static final String INDEX = "index"; + public static final String INFO = "info"; + public static final String INFO_EXCLUDE = INFO + "/exclude"; + public static final String MERGE_HEAD = "MERGE_HEAD"; + public static final String MERGE_MSG = "MERGE_MSG"; + public static final String REBASE_APPLY = "rebase-apply"; + public static final String REBASE_MERGE = "rebase-merge"; + public static final String PACKED_REFS = "packed-refs"; + public static final String REFS_HEADS = "refs/heads"; + public static final String REFS_REMOTES = "refs/remotes"; + public static final String SQUASH_MSG = "SQUASH_MSG"; + + public static final String GIT_HEAD = DOT_GIT + slash(HEAD); + public static final String GIT_REFS_REMOTES = DOT_GIT + slash(REFS_REMOTES); + public static final String GIT_PACKED_REFS = DOT_GIT + slash(PACKED_REFS); + public static final String GIT_MERGE_HEAD = DOT_GIT + slash(MERGE_HEAD); + public static final String GIT_MERGE_MSG = DOT_GIT + slash(MERGE_MSG); + public static final String GIT_SQUASH_MSG = DOT_GIT + slash(SQUASH_MSG); + private final String myConfigFilePath; private final String myHeadFilePath; private final String myIndexFilePath; @@ -54,17 +75,22 @@ public class GitRepositoryFiles { // add .git/ and .git/refs/heads to the VFS // save paths of the files, that we will watch String gitDirPath = GitFileUtils.stripFileProtocolPrefix(gitDir.getPath()); - myConfigFilePath = gitDirPath + "/config"; - myHeadFilePath = gitDirPath + "/HEAD"; - myIndexFilePath = gitDirPath + "/index"; - myMergeHeadPath = gitDirPath + "/MERGE_HEAD"; - myCommitMessagePath = gitDirPath + "/COMMIT_EDITMSG"; - myRebaseApplyPath = gitDirPath + "/rebase-apply"; - myRebaseMergePath = gitDirPath + "/rebase-merge"; - myPackedRefsPath = gitDirPath + "/packed-refs"; - myRefsHeadsDirPath = gitDirPath + REFS_HEADS; - myRefsRemotesDirPath = gitDirPath + REFS_REMOTES; - myExcludePath = gitDirPath + INFO + "/exclude"; + myConfigFilePath = gitDirPath + slash(CONFIG); + myHeadFilePath = gitDirPath + slash(HEAD); + myIndexFilePath = gitDirPath + slash(INDEX); + myMergeHeadPath = gitDirPath + slash(MERGE_HEAD); + myCommitMessagePath = gitDirPath + slash(COMMIT_EDITMSG); + myRebaseApplyPath = gitDirPath + slash(REBASE_APPLY); + myRebaseMergePath = gitDirPath + slash(REBASE_MERGE); + myPackedRefsPath = gitDirPath + slash(PACKED_REFS); + myRefsHeadsDirPath = gitDirPath + slash(REFS_HEADS); + myRefsRemotesDirPath = gitDirPath + slash(REFS_REMOTES); + myExcludePath = gitDirPath + slash(INFO_EXCLUDE); + } + + @NotNull + private static String slash(@NotNull String s) { + return "/" + s; } /** @@ -72,7 +98,7 @@ public class GitRepositoryFiles { */ @NotNull static Collection getSubDirRelativePaths() { - return Arrays.asList(REFS_HEADS, REFS_REMOTES, INFO); + return Arrays.asList(slash(REFS_HEADS), slash(REFS_REMOTES), slash(INFO)); } @NotNull diff --git a/plugins/git4idea/src/git4idea/repo/GitRepositoryManagerImpl.java b/plugins/git4idea/src/git4idea/repo/GitRepositoryManagerImpl.java index 362b4c7a74d2..e0ee250f464e 100644 --- a/plugins/git4idea/src/git4idea/repo/GitRepositoryManagerImpl.java +++ b/plugins/git4idea/src/git4idea/repo/GitRepositoryManagerImpl.java @@ -198,7 +198,7 @@ public class GitRepositoryManagerImpl extends AbstractProjectComponent implement } private static boolean gitRootOK(@NotNull VirtualFile root) { - VirtualFile gitDir = root.findChild(".git"); + VirtualFile gitDir = root.findChild(GitUtil.DOT_GIT); return gitDir != null && gitDir.exists(); } diff --git a/plugins/git4idea/src/git4idea/roots/GitRootChecker.java b/plugins/git4idea/src/git4idea/roots/GitRootChecker.java index ec5e97cf4efe..9377f717a67f 100644 --- a/plugins/git4idea/src/git4idea/roots/GitRootChecker.java +++ b/plugins/git4idea/src/git4idea/roots/GitRootChecker.java @@ -19,6 +19,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.vcs.VcsDirectoryMapping; import com.intellij.openapi.vcs.VcsRootChecker; import com.intellij.openapi.vcs.VcsRootError; +import git4idea.GitUtil; import git4idea.PlatformFacade; import org.jetbrains.annotations.NotNull; @@ -69,6 +70,6 @@ public class GitRootChecker implements VcsRootChecker { if (mapping.isDefaultMapping()) { return myProjectMappingIsInvalid; } - return !new File(mapping.getDirectory(), ".git").exists(); + return !new File(mapping.getDirectory(), GitUtil.DOT_GIT).exists(); } } diff --git a/plugins/git4idea/src/git4idea/roots/GitRootDetector.java b/plugins/git4idea/src/git4idea/roots/GitRootDetector.java index affb467d060a..be64b8f810ea 100644 --- a/plugins/git4idea/src/git4idea/roots/GitRootDetector.java +++ b/plugins/git4idea/src/git4idea/roots/GitRootDetector.java @@ -18,6 +18,7 @@ package git4idea.roots; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Computable; import com.intellij.openapi.vfs.VirtualFile; +import git4idea.GitUtil; import git4idea.PlatformFacade; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -138,7 +139,7 @@ public class GitRootDetector { } private static boolean hasGitDir(@NotNull VirtualFile dir) { - VirtualFile gitDir = dir.findChild(".git"); + VirtualFile gitDir = dir.findChild(GitUtil.DOT_GIT); return gitDir != null && gitDir.exists(); } diff --git a/plugins/git4idea/src/git4idea/roots/GitRootScanner.java b/plugins/git4idea/src/git4idea/roots/GitRootScanner.java index 2634a44b8727..02cebd2fce56 100644 --- a/plugins/git4idea/src/git4idea/roots/GitRootScanner.java +++ b/plugins/git4idea/src/git4idea/roots/GitRootScanner.java @@ -30,6 +30,7 @@ import com.intellij.openapi.vfs.VirtualFileManager; import com.intellij.openapi.vfs.newvfs.BulkFileListener; import com.intellij.openapi.vfs.newvfs.events.VFileEvent; import com.intellij.util.messages.MessageBus; +import git4idea.GitUtil; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -79,7 +80,7 @@ public class GitRootScanner implements BulkFileListener, ModuleRootListener, Dis public void after(@NotNull List events) { for (VFileEvent event : events) { VirtualFile file = event.getFile(); - if (file != null && file.getName().equalsIgnoreCase(".git") && file.isDirectory()) { + if (file != null && file.getName().equalsIgnoreCase(GitUtil.DOT_GIT) && file.isDirectory()) { scanIfReady(); } } diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java b/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java index d306f0b6e297..68ddeee657bf 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java +++ b/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java @@ -1,3 +1,18 @@ +/* + * 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 org.jetbrains.plugins.github; import com.intellij.notification.Notification; @@ -285,7 +300,7 @@ public class GithubShareAction extends DumbAwareAction { } for (VirtualFile file : changeListManager.getUnversionedFiles()) { - if (file.getPath().contains(".idea")) { + if (file.getPath().contains(Project.DIRECTORY_STORE_FOLDER)) { continue; } if (readmeFile != null && readmeFile.equals(file)) { diff --git a/plugins/groovy/resources/org/jetbrains/plugins/groovy/images/dynamicProperty_13.png b/plugins/groovy/resources/org/jetbrains/plugins/groovy/images/dynamicProperty_13.png new file mode 100644 index 000000000000..20064e198aaa Binary files /dev/null and b/plugins/groovy/resources/org/jetbrains/plugins/groovy/images/dynamicProperty_13.png differ diff --git a/plugins/groovy/src/META-INF/plugin.xml b/plugins/groovy/src/META-INF/plugin.xml index df1c77c38197..f71a9c20989f 100644 --- a/plugins/groovy/src/META-INF/plugin.xml +++ b/plugins/groovy/src/META-INF/plugin.xml @@ -636,7 +636,7 @@ level="WARNING" implementationClass="org.jetbrains.plugins.groovy.codeInspection.confusing.GroovyPointlessBooleanInspection"/> 0) element = file.findElementAt(offset - 1); while (element != null) { - if (myOwner.equals(element.getParent())) return element instanceof GrStatement ? (GrStatement) element : null; + if (myOwner.equals(element.getParent())) return element instanceof GrStatement ? (GrStatement)element : null; element = element.getParent(); } return null; diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovyAssignabilityCheckInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovyAssignabilityCheckInspection.java index ff68bf774825..f93e5f8511bd 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovyAssignabilityCheckInspection.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovyAssignabilityCheckInspection.java @@ -39,7 +39,6 @@ import org.jetbrains.plugins.groovy.extensions.GroovyNamedArgumentProvider; import org.jetbrains.plugins.groovy.extensions.NamedArgumentDescriptor; import org.jetbrains.plugins.groovy.findUsages.LiteralConstructorReference; import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes; -import org.jetbrains.plugins.groovy.lang.psi.GroovyFile; import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement; import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult; import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrListOrMap; @@ -61,8 +60,8 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.*; import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement; import org.jetbrains.plugins.groovy.lang.psi.controlFlow.Instruction; import org.jetbrains.plugins.groovy.lang.psi.impl.GrClosureType; -import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil; import org.jetbrains.plugins.groovy.lang.psi.impl.signatures.GrClosureSignatureUtil; +import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.GrReferenceResolveUtil; import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil; import org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames; import org.jetbrains.plugins.groovy.lang.psi.util.GroovyConstantExpressionEvaluator; @@ -117,7 +116,7 @@ public class GroovyAssignabilityCheckInspection extends BaseInspection { private static class MyVisitor extends BaseInspectionVisitor { private void checkAssignability(@NotNull PsiType expectedType, @NotNull GrExpression expression) { - if (PsiUtil.isRawClassMemberAccess(expression)) return; //GRVY-2197 + if (PsiUtil.isRawClassMemberAccess(expression)) return; if (checkForImplicitEnumAssigning(expectedType, expression, expression)) return; final PsiType rType = expression.getType(); if (rType == null || rType == PsiType.VOID) return; @@ -523,7 +522,7 @@ public class GroovyAssignabilityCheckInspection extends BaseInspection { GrExpression namedArgumentExpression = namedArgument.getExpression(); if (namedArgumentExpression == null) continue; - if (PsiUtil.isRawClassMemberAccess(namedArgumentExpression)) continue; //GRVY-2197 + if (PsiUtil.isRawClassMemberAccess(namedArgumentExpression)) continue; PsiType expressionType = namedArgumentExpression.getType(); if (expressionType == null) continue; @@ -748,8 +747,8 @@ public class GroovyAssignabilityCheckInspection extends BaseInspection { return true; } else { - final GrExpression qual = expression.getQualifierExpression(); - if (qual != null) return isListAssignment(qual); + final GrExpression qualifier = expression.getQualifierExpression(); + if (qualifier != null) return isListAssignment(qualifier); } } return false; @@ -760,27 +759,6 @@ public class GroovyAssignabilityCheckInspection extends BaseInspection { if (place.getParent() instanceof GrIndexProperty) { return place.getType(); } - final GrExpression rtQualifier = PsiImplUtil.getRuntimeQualifier(place); - if (rtQualifier != null) { - return rtQualifier.getType(); - } - - PsiClass containingClass = null; - final GrMember member = PsiTreeUtil.getParentOfType(place, GrMember.class); - if (member == null) { - final PsiFile file = place.getContainingFile(); - assert file instanceof GroovyFile && ((GroovyFile)file).isScript(); - containingClass = ((GroovyFile)file).getScriptClass(); - } - else if (member instanceof GrMethod) { - if (!member.hasModifierProperty(PsiModifier.STATIC)) { - containingClass = member.getContainingClass(); - } - } - - if (containingClass != null) { - return JavaPsiFacade.getElementFactory(place.getProject()).createType(containingClass); - } - return null; + return GrReferenceResolveUtil.getQualifierType(place); } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/confusing/GroovyPointlessArithmeticInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/confusing/GroovyPointlessArithmeticInspection.java index 2a8ce1c58f8d..1cc931eed071 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/confusing/GroovyPointlessArithmeticInspection.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/confusing/GroovyPointlessArithmeticInspection.java @@ -19,6 +19,7 @@ import com.intellij.codeInspection.ProblemDescriptor; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiElement; import com.intellij.psi.tree.IElementType; +import com.intellij.psi.tree.TokenSet; import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -26,12 +27,11 @@ import org.jetbrains.plugins.groovy.codeInspection.BaseInspection; import org.jetbrains.plugins.groovy.codeInspection.BaseInspectionVisitor; import org.jetbrains.plugins.groovy.codeInspection.GroovyFix; import org.jetbrains.plugins.groovy.codeInspection.GroovyInspectionBundle; -import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes; import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrBinaryExpression; import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression; +import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil; -import java.util.HashSet; -import java.util.Set; +import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.*; public class GroovyPointlessArithmeticInspection extends BaseInspection { @@ -46,7 +46,7 @@ public class GroovyPointlessArithmeticInspection extends BaseInspection { } public boolean isEnabledByDefault() { - return true; + return false; } public BaseInspectionVisitor buildVisitor() { @@ -58,90 +58,88 @@ public class GroovyPointlessArithmeticInspection extends BaseInspection { } private static String calculateReplacementExpression(GrExpression expression) { - final GrBinaryExpression exp = (GrBinaryExpression) expression; + final GrBinaryExpression exp = (GrBinaryExpression)expression; final IElementType sign = exp.getOperationTokenType(); final GrExpression lhs = exp.getLeftOperand(); final GrExpression rhs = exp.getRightOperand(); assert rhs != null; - if (GroovyTokenTypes.mPLUS.equals(sign)) { + if (mPLUS == sign) { if (isZero(lhs)) { return rhs.getText(); - } else { + } + else { return lhs.getText(); } - } else if (GroovyTokenTypes.mMINUS.equals(sign)) { + } + + if (mMINUS == sign) { return lhs.getText(); - } else if (GroovyTokenTypes.mSTAR.equals(sign)) { + } + + if (mSTAR == sign) { if (isOne(lhs)) { return rhs.getText(); - } else if (isOne(rhs)) { + } + else if (isOne(rhs)) { return lhs.getText(); - } else { + } + else { return "0"; } - } else if (GroovyTokenTypes.mDIV.equals(sign)) { - return lhs.getText(); - } else { - return ""; } + + if (mDIV == sign) { + return lhs.getText(); + } + + return ""; } public GroovyFix buildFix(PsiElement location) { return new PointlessArithmeticFix(); } - private class PointlessArithmeticFix extends GroovyFix { - + private static class PointlessArithmeticFix extends GroovyFix { @NotNull public String getName() { return "Simplify"; } - public void doFix(Project project, ProblemDescriptor descriptor) - throws IncorrectOperationException { - final GrExpression expression = (GrExpression) descriptor - .getPsiElement(); - final String newExpression = - calculateReplacementExpression(expression); + public void doFix(Project project, ProblemDescriptor descriptor) throws IncorrectOperationException { + final GrExpression expression = (GrExpression) descriptor.getPsiElement(); + final String newExpression = calculateReplacementExpression(expression); replaceExpression(expression, newExpression); } } - private class PointlessArithmeticVisitor extends BaseInspectionVisitor { + private static class PointlessArithmeticVisitor extends BaseInspectionVisitor { - private final Set arithmeticTokens = - new HashSet(4); - - { - arithmeticTokens.add(GroovyTokenTypes.mPLUS); - arithmeticTokens.add(GroovyTokenTypes.mMINUS); - arithmeticTokens.add(GroovyTokenTypes.mSTAR); - arithmeticTokens.add(GroovyTokenTypes.mDIV); - } + private final TokenSet arithmeticTokens = TokenSet.create(mPLUS, mMINUS, mSTAR, mDIV); public void visitBinaryExpression(@NotNull GrBinaryExpression expression) { super.visitBinaryExpression(expression); final GrExpression rhs = expression.getRightOperand(); - if (rhs == null) { - return; - } + if (rhs == null) return; + final IElementType sign = expression.getOperationTokenType(); - if (!arithmeticTokens.contains(sign)) { - return; - } + if (!arithmeticTokens.contains(sign)) return; + final GrExpression lhs = expression.getLeftOperand(); - assert sign != null; final boolean isPointless; - if (sign.equals(GroovyTokenTypes.mPLUS)) { + if (sign.equals(mPLUS)) { isPointless = additionExpressionIsPointless(lhs, rhs); - } else if (sign.equals(GroovyTokenTypes.mMINUS)) { + } + else if (sign.equals(mMINUS)) { isPointless = subtractionExpressionIsPointless(rhs); - } else if (sign.equals(GroovyTokenTypes.mSTAR)) { + } + else if (sign.equals(mSTAR)) { isPointless = multiplyExpressionIsPointless(lhs, rhs); - } else if (sign.equals(GroovyTokenTypes.mDIV)) { + } + else if (sign.equals(mDIV)) { isPointless = divideExpressionIsPointless(rhs); - } else { + } + else { isPointless = false; } if (!isPointless) { @@ -174,25 +172,35 @@ public class GroovyPointlessArithmeticInspection extends BaseInspection { * @noinspection FloatingPointEquality */ private static boolean isZero(GrExpression expression) { - @NonNls final String text = expression.getText(); + final PsiElement inner = PsiUtil.skipParentheses(expression, false); + if (inner == null) return false; + + @NonNls final String text = inner.getText(); return "0".equals(text) || - "0x0".equals(text) || - "0X0".equals(text) || - "0.0".equals(text) || - "0L".equals(text) || - "0l".equals(text); + "0x0".equals(text) || + "0X0".equals(text) || + "0.0".equals(text) || + "0L".equals(text) || + "0l".equals(text) || + "0b0".equals(text) || + "0B0".equals(text); } /** * @noinspection FloatingPointEquality */ private static boolean isOne(GrExpression expression) { - @NonNls final String text = expression.getText(); + final PsiElement inner = PsiUtil.skipParentheses(expression, false); + if (inner == null) return false; + + @NonNls final String text = inner.getText(); return "1".equals(text) || - "0x1".equals(text) || - "0X1".equals(text) || - "1.0".equals(text) || - "1L".equals(text) || - "1l".equals(text); + "0x1".equals(text) || + "0X1".equals(text) || + "1.0".equals(text) || + "1L".equals(text) || + "1l".equals(text) || + "0b0".equals(text) || + "0B0".equals(text); } } \ No newline at end of file diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyBlock.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyBlock.java index d49a367b02dc..ce333f8aab46 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyBlock.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyBlock.java @@ -18,6 +18,7 @@ package org.jetbrains.plugins.groovy.formatter; import com.intellij.formatting.*; import com.intellij.lang.ASTNode; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.TextRange; import com.intellij.psi.PsiComment; import com.intellij.psi.PsiElement; @@ -55,6 +56,8 @@ import java.util.List; * @author ilyas */ public class GroovyBlock implements Block, GroovyElementTypes, ASTBlock { + private static final Logger LOG = Logger.getInstance(GroovyBlock.class); + final protected ASTNode myNode; protected Alignment myAlignment = null; final protected Indent myIndent; @@ -107,7 +110,12 @@ public class GroovyBlock implements Block, GroovyElementTypes, ASTBlock { @Override public List getSubBlocks() { if (mySubBlocks == null) { - mySubBlocks = new GroovyBlockGenerator(this).generateSubBlocks(); + try { + mySubBlocks = new GroovyBlockGenerator(this).generateSubBlocks(); + } + catch (RuntimeException e) { + LOG.error(myNode.getPsi().getContainingFile().getText(), e); + } } return mySubBlocks; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/highlighter/GroovySlashyStringLexer.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/highlighter/GroovySlashyStringLexer.java index 5b8d006184ef..e959000f032b 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/highlighter/GroovySlashyStringLexer.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/highlighter/GroovySlashyStringLexer.java @@ -38,7 +38,7 @@ public class GroovySlashyStringLexer extends LexerBase { @Override public void start(CharSequence buffer, int startOffset, int endOffset, int initialState) { - assert buffer.length() >= endOffset : "buffer Length: " + buffer.length() + ", endOffset: " + endOffset; + assert buffer.length() >= endOffset : "buffer Length: " + buffer.length() + ", endOffset: " + endOffset + "buffer: " + buffer; myBuffer = buffer; myEnd = startOffset; diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/control/ExpandBooleanIntention.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/control/ExpandBooleanIntention.java index 049f66254cbc..c5d29526625b 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/control/ExpandBooleanIntention.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/control/ExpandBooleanIntention.java @@ -37,30 +37,23 @@ public class ExpandBooleanIntention extends Intention { return new ExpandBooleanPredicate(); } - public void processIntention(@NotNull PsiElement element, Project project, Editor editor) - throws IncorrectOperationException { - final GrStatement containingStatement = (GrStatement) element; + public void processIntention(@NotNull PsiElement element, Project project, Editor editor) throws IncorrectOperationException { + final GrStatement containingStatement = (GrStatement)element; if (ExpandBooleanPredicate.isBooleanAssignment(containingStatement)) { - - final GrAssignmentExpression assignmentExpression = - (GrAssignmentExpression) containingStatement; + final GrAssignmentExpression assignmentExpression = (GrAssignmentExpression)containingStatement; final GrExpression rhs = assignmentExpression.getRValue(); assert rhs != null; final String rhsText = rhs.getText(); final GrExpression lhs = assignmentExpression.getLValue(); final String lhsText = lhs.getText(); - @NonNls final String statement = - "if(" + rhsText + "){" + lhsText + " = true;}else{" + - lhsText + - " = false;}"; + @NonNls final String statement = "if(" + rhsText + "){\n" + lhsText + " = true\n}else{\n" + lhsText + " = false\n}"; IntentionUtils.replaceStatement(statement, containingStatement); - } else if (ExpandBooleanPredicate.isBooleanReturn(containingStatement)) { - final GrReturnStatement returnStatement = - (GrReturnStatement) containingStatement; + } + else if (ExpandBooleanPredicate.isBooleanReturn(containingStatement)) { + final GrReturnStatement returnStatement = (GrReturnStatement)containingStatement; final GrExpression returnValue = returnStatement.getReturnValue(); final String valueText = returnValue.getText(); - @NonNls final String statement = - "if(" + valueText + "){return true;}else{return false;}"; + @NonNls final String statement = "if(" + valueText + "){\nreturn true\n}else{\nreturn false\n}"; IntentionUtils.replaceStatement(statement, containingStatement); } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionContributor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionContributor.java index 280c5b08decc..22b90249dd41 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionContributor.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionContributor.java @@ -281,7 +281,7 @@ public class GroovyCompletionContributor extends CompletionContributor { protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) { - result.addElement(LookupElementBuilder.create("if").setBold().setInsertHandler(new InsertHandler() { + result.addElement(LookupElementBuilder.create("if").bold().withInsertHandler(new InsertHandler() { @Override public void handleInsert(InsertionContext context, LookupElement item) { if (context.getCompletionChar() != ' ') { @@ -290,7 +290,7 @@ public class GroovyCompletionContributor extends CompletionContributor { if (context.getCompletionChar() == '(') { context.setAddCompletionChar(false); } - } + } })); } }); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionData.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionData.java index e6f364fbaf38..267924e51aca 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionData.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionData.java @@ -207,7 +207,7 @@ public class GroovyCompletionData { } private static LookupElement keyword(final String keyword, @NotNull TailType tail) { - LookupElementBuilder element = LookupElementBuilder.create(keyword).setBold(); + LookupElementBuilder element = LookupElementBuilder.create(keyword).bold(); return tail != TailType.NONE ? TailTypeDecorator.withTail(element, tail) : element; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionUtil.java index 0a73b7ffad43..82048e78511f 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionUtil.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionUtil.java @@ -267,7 +267,7 @@ public class GroovyCompletionUtil { } final PsiSubstitutor substitutor = resolveResult.getSubstitutor(); - LookupElementBuilder builder = LookupElementBuilder.create(resolveResult, importedName).setPresentableText(importedName); + LookupElementBuilder builder = LookupElementBuilder.create(resolveResult, importedName).withPresentableText(importedName); return setupLookupBuilder(element, substitutor, builder); } @@ -275,15 +275,15 @@ public class GroovyCompletionUtil { if (o instanceof LookupElement) return (LookupElement)o; if (o instanceof PsiNamedElement) return generateLookupElement((PsiNamedElement)o); if (o instanceof PsiElement) return setupLookupBuilder((PsiElement)o, PsiSubstitutor.EMPTY, LookupElementBuilder.create(o, ((PsiElement)o).getText())); - return LookupElementBuilder.create(o, o.toString()).setItemTextUnderlined(true); + return LookupElementBuilder.create(o, o.toString()).withItemTextUnderlined(true); } private static LookupElementBuilder generateLookupElement(PsiNamedElement element) { return setupLookupBuilder(element, PsiSubstitutor.EMPTY, LookupElementBuilder.create(element)); } private static LookupElementBuilder setupLookupBuilder(PsiElement element, PsiSubstitutor substitutor, LookupElementBuilder builder) { - builder = builder.setIcon(element.getIcon(Iconable.ICON_FLAG_VISIBILITY | Iconable.ICON_FLAG_READ_STATUS)) - .setInsertHandler(GroovyInsertHandler.INSTANCE); + builder = builder.withIcon(element.getIcon(Iconable.ICON_FLAG_VISIBILITY | Iconable.ICON_FLAG_READ_STATUS)) + .withInsertHandler(GroovyInsertHandler.INSTANCE); builder = setTailText(element, builder, substitutor); builder = setTypeText(element, builder, substitutor); return builder; @@ -291,8 +291,8 @@ public class GroovyCompletionUtil { private static LookupElementBuilder setTailText(PsiElement element, LookupElementBuilder builder, PsiSubstitutor substitutor) { if (element instanceof PsiMethod) { - builder = builder.setTailText(PsiFormatUtil.formatMethod((PsiMethod)element, substitutor, PsiFormatUtilBase.SHOW_PARAMETERS, - PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_TYPE)); + builder = builder.withTailText(PsiFormatUtil.formatMethod((PsiMethod)element, substitutor, PsiFormatUtilBase.SHOW_PARAMETERS, + PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_TYPE)); } else if (element instanceof PsiClass) { String tailText = getPackageText((PsiClass)element); @@ -304,7 +304,7 @@ public class GroovyCompletionUtil { } }, "," + (showSpaceAfterComma(psiClass) ? " " : "")) + ">" + tailText; } - builder = builder.setTailText(tailText, true); + builder = builder.withTailText(tailText, true); } return builder; } @@ -331,7 +331,7 @@ public class GroovyCompletionUtil { else if (element instanceof PsiMethod) { type = substitutor.substitute(((PsiMethod)element).getReturnType()); } - return type != null ? builder.setTypeText(type.getPresentableText()) : builder; + return type != null ? builder.withTypeText(type.getPresentableText()) : builder; } public static boolean hasConstructorParameters(@NotNull PsiClass clazz, @NotNull GroovyPsiElement place) { diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyDocCompletionProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyDocCompletionProvider.java index c010d8216641..9ea37ad44345 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyDocCompletionProvider.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyDocCompletionProvider.java @@ -78,7 +78,7 @@ public class GroovyDocCompletionProvider extends CompletionProvider entry : map.entrySet()) { LookupElementBuilder lookup = LookupElementBuilder.create(entry.getValue(), entry.getKey()) - .setInsertHandler(NamedArgumentInsertHandler.INSTANCE) - .setTailText(":"); + .withInsertHandler(NamedArgumentInsertHandler.INSTANCE) + .withTailText(":"); if (entry.getValue().getPriority() == Priority.UNLIKELY) { - lookup.setItemTextForeground(DefaultHighlighter.MAP_KEY_COLOR); + lookup.withItemTextForeground(DefaultHighlighter.MAP_KEY_COLOR); } else { - lookup = lookup.setIcon(GroovyIcons.DYNAMIC); + lookup = lookup.withIcon(GroovyIcons.DYNAMIC); } result.addElement(lookup); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/editor/template/expressions/ChooseTypeExpression.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/editor/template/expressions/ChooseTypeExpression.java index 9ea283edb642..e6a41ecbf374 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/editor/template/expressions/ChooseTypeExpression.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/editor/template/expressions/ChooseTypeExpression.java @@ -64,7 +64,7 @@ public class ChooseTypeExpression extends Expression { } if (forGroovy) { - result.add(LookupElementBuilder.create(GrModifier.DEF).setBold()); + result.add(LookupElementBuilder.create(GrModifier.DEF).bold()); } return result.toArray(new LookupElement[result.size()]); @@ -74,7 +74,7 @@ public class ChooseTypeExpression extends Expression { String text = type.getCanonicalText(); String unboxed = PsiTypesUtil.unboxIfPossible(text); if (unboxed != null && !unboxed.equals(text)) { - result.add(LookupElementBuilder.create(unboxed).setBold()); + result.add(LookupElementBuilder.create(unboxed).bold()); } else { result.add(PsiTypeLookupItem.createLookupItem(type, null)); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/path/GrIndexProperty.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/path/GrIndexProperty.java index 41af564fabff..0f22cc194d08 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/path/GrIndexProperty.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/path/GrIndexProperty.java @@ -17,6 +17,7 @@ package org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path; import org.jetbrains.annotations.NotNull; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression; /** @@ -25,4 +26,8 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpres public interface GrIndexProperty extends GrExpression, GrCallExpression { @NotNull GrExpression getInvokedExpression(); + + @Override + @NotNull + GrArgumentList getArgumentList(); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java index 4b7a6dccc7cd..b87583cd5d3d 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java @@ -605,9 +605,13 @@ public class GroovyPsiElementFactoryImpl extends GroovyPsiElementFactory { @Override public GrStatement createStatementFromText(String text, @Nullable PsiElement context) { - PsiFile file = createGroovyFile(text, false, context); - LOG.assertTrue(((GroovyFileBase) file).getTopStatements()[0] instanceof GrStatement, text); - return (GrStatement) ((GroovyFileBase) file).getTopStatements()[0]; + try { + PsiFile file = createGroovyFile(text, false, context); + return (GrStatement)((GroovyFileBase)file).getTopStatements()[0]; + } + catch (RuntimeException e) { + throw new IncorrectOperationException(text); + } } public GrBlockStatement createBlockStatement(@NonNls GrStatement... statements) { diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/CompleteReferenceExpression.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/CompleteReferenceExpression.java index 906948b0d212..420b266d5889 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/CompleteReferenceExpression.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/CompleteReferenceExpression.java @@ -149,9 +149,9 @@ public class CompleteReferenceExpression { @NotNull public static LookupElementBuilder createPropertyLookupElement(@NotNull String name, @Nullable PsiType type) { - LookupElementBuilder res = LookupElementBuilder.create(name).setIcon(GroovyIcons.PROPERTY); + LookupElementBuilder res = LookupElementBuilder.create(name).withIcon(GroovyIcons.PROPERTY); if (type != null) { - res = res.setTypeText(type.getPresentableText()); + res = res.withTypeText(type.getPresentableText()); } return res; } @@ -190,9 +190,9 @@ public class CompleteReferenceExpression { LookupElementBuilder builder = LookupElementBuilder.create(generatePropertyResolveResult(propName, accessor, propType, resolveResult), propName) - .setIcon(GroovyIcons.PROPERTY); + .withIcon(GroovyIcons.PROPERTY); if (substituted != null) { - builder = builder.setTypeText(substituted.getPresentableText()); + builder = builder.withTypeText(substituted.getPresentableText()); } return builder; } @@ -440,7 +440,7 @@ public class CompleteReferenceExpression { private void processPropertyFromField(GrField field, GroovyResolveResult resolveResult) { if (field.getGetters().length != 0 || field.getSetter() != null || !myPropertyNames.add(field.getName())) return; - myConsumer.consume(((LookupElementBuilder)GroovyCompletionUtil.createCompletionVariant(resolveResult)).setIcon(GroovyIcons.PROPERTY)); + myConsumer.consume(((LookupElementBuilder)GroovyCompletionUtil.createCompletionVariant(resolveResult)).withIcon(GroovyIcons.PROPERTY)); } private void processProperty(PsiMethod method, GroovyResolveResult resolveResult) { @@ -474,7 +474,7 @@ public class CompleteReferenceExpression { if (myPropertyNames.add(name)) { LookupElementBuilder builder = LookupElementBuilder .create(generatePropertyResolveResult(name, listenerMethod, null, null), name) - .setIcon(GroovyIcons.PROPERTY); + .withIcon(GroovyIcons.PROPERTY); myConsumer.consume(builder); } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrReferenceExpressionImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrReferenceExpressionImpl.java index 6c54eeebb8d3..292af48c7f15 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrReferenceExpressionImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrReferenceExpressionImpl.java @@ -249,9 +249,7 @@ public class GrReferenceExpressionImpl extends GrReferenceElementImpl shapeResults = resolveByShape(allVariants, upToArgument); if (!genericsMatter && !allVariants && shapeResults.first) { - for (GroovyResolveResult candidate : shapeResults.second) { - assert candidate.getElement().isValid(); - } + assertAllAreValid(shapeResults.second); return shapeResults.second; } @@ -328,12 +326,17 @@ public class GrReferenceExpressionImpl extends GrReferenceElementImpl { @Nullable public PsiType fun(GrReferenceExpressionImpl refExpr) { @@ -602,14 +589,10 @@ public class GrReferenceExpressionImpl extends GrReferenceElementImpl 0) { - inputStream.readFully(data, offset, available); - offset += available; - } + readAsMuchAsAvailable(inputStream, data, length); int skipped = inputStream.skipBytes(origLength - length); if (skipped > 0) { @@ -121,6 +116,20 @@ public class SocketServer { return data; } + private static void readAsMuchAsAvailable(DataInputStream inputStream, byte[] data, int maxLength) throws IOException { + int offset = 0; + int available; + while ((available = inputStream.available()) > 0) { + if (available + offset > maxLength) { + // read no more than maxLength + inputStream.readFully(data, offset, maxLength - offset); + return; + } + inputStream.readFully(data, offset, available); + offset += available; + } + } + protected static void sendDataBlock(DataOutputStream out, byte[] data) throws IOException { out.writeInt(data.length); out.write(data); diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/repositories/MavenRepositoryConverter.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/repositories/MavenRepositoryConverter.java index 91c8f99c8e9c..342ebe39951a 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/repositories/MavenRepositoryConverter.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/repositories/MavenRepositoryConverter.java @@ -55,8 +55,8 @@ public abstract class MavenRepositoryConverter extends ResolvingConverter() { @@ -343,12 +343,12 @@ public class MavenPropertyPsiReference extends MavenPsiReference { MavenRunnerSettings runnerSettings = MavenRunner.getInstance(myProject).getSettings(); for (String prop : runnerSettings.getMavenProperties().keySet()) { if (!isResultAlreadyContains(result, prop)) { - result.add(LookupElementBuilder.create(prop).setIcon(PlatformIcons.PROPERTY_ICON)); + result.add(LookupElementBuilder.create(prop).withIcon(PlatformIcons.PROPERTY_ICON)); } } for (String prop : MavenUtil.getPropertiesFromMavenOpts().keySet()) { if (!isResultAlreadyContains(result, prop)) { - result.add(LookupElementBuilder.create(prop).setIcon(PlatformIcons.PROPERTY_ICON)); + result.add(LookupElementBuilder.create(prop).withIcon(PlatformIcons.PROPERTY_ICON)); } } } @@ -404,8 +404,8 @@ public class MavenPropertyPsiReference extends MavenPsiReference { private static LookupElement createLookupElement(@NotNull Object element, @NotNull String name, @Nullable Icon icon) { return LookupElementBuilder.create(element, name) - .setIcon(icon) - .setPresentableText(name); + .withIcon(icon) + .withPresentableText(name); } @Nullable diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerParametersConfigurable.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerParametersConfigurable.java index 04d5990f0d19..ade900ed3fe1 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerParametersConfigurable.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerParametersConfigurable.java @@ -109,7 +109,7 @@ public abstract class MavenRunnerParametersConfigurable implements Configurable, cachedElements = new ArrayList(goals.size()); for (String goal : goals) { - cachedElements.add(LookupElementBuilder.create(goal).setIcon(MavenIcons.PHASE_ICON)); + cachedElements.add(LookupElementBuilder.create(goal).withIcon(MavenIcons.PHASE_ICON)); } myCachedElements = cachedElements; diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenModuleImporter.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenModuleImporter.java index 6b362534ad9f..af2a3127887d 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenModuleImporter.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenModuleImporter.java @@ -140,6 +140,8 @@ public class MavenModuleImporter { private void configLanguageLevel() { final LanguageLevel level = LanguageLevel.parse(myMavenProject.getSourceLevel()); - myRootModelAdapter.setLanguageLevel(level); + if (level != null) { + myRootModelAdapter.setLanguageLevel(level); + } } } diff --git a/plugins/properties/src/com/intellij/lang/properties/references/PropertyReferenceBase.java b/plugins/properties/src/com/intellij/lang/properties/references/PropertyReferenceBase.java index 7168200d35c0..2897e5805370 100644 --- a/plugins/properties/src/com/intellij/lang/properties/references/PropertyReferenceBase.java +++ b/plugins/properties/src/com/intellij/lang/properties/references/PropertyReferenceBase.java @@ -270,12 +270,12 @@ public abstract class PropertyReferenceBase implements PsiPolyVariantReference, return ContainerUtil.mapNotNull(variants, new NullableFunction() { @Override public LookupElement fun(Object o) { - if (o instanceof String) return LookupElementBuilder.create((String)o).setIcon(PlatformIcons.PROPERTY_ICON); + if (o instanceof String) return LookupElementBuilder.create((String)o).withIcon(PlatformIcons.PROPERTY_ICON); IProperty property = (IProperty)o; String key = property.getKey(); if (key == null) return null; - return LookupElementBuilder.create(property, key).setRenderer(LOOKUP_ELEMENT_RENDERER); + return LookupElementBuilder.create(property, key).withRenderer(LOOKUP_ELEMENT_RENDERER); } }).toArray(); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/MarkLocallyDeletedTreeConflictResolvedAction.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/MarkLocallyDeletedTreeConflictResolvedAction.java index ca8390dbfa23..a76cdad08642 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/MarkLocallyDeletedTreeConflictResolvedAction.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/MarkLocallyDeletedTreeConflictResolvedAction.java @@ -122,7 +122,12 @@ public class MarkLocallyDeletedTreeConflictResolvedAction extends AnAction { final List missingFiles = e.getData(ChangesListView.LOCALLY_DELETED_CHANGES); - if (missingFiles == null || missingFiles.size() != 1) { + if (missingFiles == null || missingFiles.isEmpty()) { + myPath = null; + myEnabled = false; + return; + } + /*if (missingFiles == null || missingFiles.size() != 1) { final Change[] changes = e.getData(VcsDataKeys.CHANGES); if (changes == null || changes.length != 1 || changes[0].getAfterRevision() != null) { myPath = null; @@ -136,7 +141,7 @@ public class MarkLocallyDeletedTreeConflictResolvedAction extends AnAction { myPath = null; } return; - } + } */ final LocallyDeletedChange change = missingFiles.get(0); myEnabled = change instanceof SvnLocallyDeletedChange && ((SvnLocallyDeletedChange) change).getConflictState().isTree(); diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/ActivateTaskDialog.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/ActivateTaskDialog.java index 8228c0998cf3..7713c2848108 100644 --- a/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/ActivateTaskDialog.java +++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/ActivateTaskDialog.java @@ -323,9 +323,9 @@ public class ActivateTaskDialog extends DialogWrapper { public LookupElementBuilder createLookupBuilder(@NotNull final Task task) { LookupElementBuilder builder = super.createLookupBuilder(task); - builder = builder.addLookupString(task.getSummary()); + builder = builder.withLookupString(task.getSummary()); if (task.isClosed()) { - builder = builder.setStrikeout(); + builder = builder.strikeout(); } return builder; diff --git a/xml/impl/src/com/intellij/codeInsight/completion/XmlCompletionContributor.java b/xml/impl/src/com/intellij/codeInsight/completion/XmlCompletionContributor.java index 8cd06b130a29..1642487e0f49 100644 --- a/xml/impl/src/com/intellij/codeInsight/completion/XmlCompletionContributor.java +++ b/xml/impl/src/com/intellij/codeInsight/completion/XmlCompletionContributor.java @@ -181,9 +181,10 @@ public class XmlCompletionContributor extends CompletionContributor { final String namespace, final String tailText, @Nullable String namespacePrefix) { LookupElementBuilder builder = - LookupElementBuilder.create(Pair.create(name, namespace), name).setInsertHandler(new ExtendedTagInsertHandler(name, namespace, namespacePrefix)); + LookupElementBuilder.create(Pair.create(name, namespace), name).withInsertHandler( + new ExtendedTagInsertHandler(name, namespace, namespacePrefix)); if (!StringUtil.isEmpty(namespace)) { - builder = builder.setTypeText(tailText, true); + builder = builder.withTypeText(tailText, true); } return builder; } diff --git a/xml/impl/src/com/intellij/codeInsight/completion/XmlSmartCompletionProvider.java b/xml/impl/src/com/intellij/codeInsight/completion/XmlSmartCompletionProvider.java index 392bea39e0c0..5321d8513506 100644 --- a/xml/impl/src/com/intellij/codeInsight/completion/XmlSmartCompletionProvider.java +++ b/xml/impl/src/com/intellij/codeInsight/completion/XmlSmartCompletionProvider.java @@ -70,13 +70,13 @@ public class XmlSmartCompletionProvider { insertHandler = new ExtendedTagInsertHandler(name, ((XmlElementDescriptorImpl)descriptor).getNamespace(), null); } } - result.addElement(createLookupElement(descriptor).setInsertHandler(insertHandler)); + result.addElement(createLookupElement(descriptor).withInsertHandler(insertHandler)); } public static LookupElementBuilder createLookupElement(@NotNull XmlElementDescriptor descriptor) { LookupElementBuilder builder = LookupElementBuilder.create(descriptor.getName()); if (descriptor instanceof XmlElementDescriptorImpl) { - builder = builder.setTypeText(((XmlElementDescriptorImpl)descriptor).getNamespace(), true); + builder = builder.withTypeText(((XmlElementDescriptorImpl)descriptor).getNamespace(), true); } return builder; } diff --git a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/encoding/XmlEncodingReference.java b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/encoding/XmlEncodingReference.java index 5de454c9b173..59d987996ffa 100644 --- a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/encoding/XmlEncodingReference.java +++ b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/encoding/XmlEncodingReference.java @@ -92,7 +92,7 @@ public class XmlEncodingReference implements PsiReference, EmptyResolveMessagePr Charset[] charsets = CharsetToolkit.getAvailableCharsets(); List suggestions = new ArrayList(charsets.length); for (Charset charset : charsets) { - suggestions.add(LookupElementBuilder.create(charset.name()).setCaseSensitive(false)); + suggestions.add(LookupElementBuilder.create(charset.name()).withCaseSensitivity(false)); } return suggestions.toArray(new LookupElement[suggestions.size()]); } diff --git a/xml/impl/src/com/intellij/psi/impl/source/xml/TagNameReference.java b/xml/impl/src/com/intellij/psi/impl/source/xml/TagNameReference.java index c9a8f8941545..56bc30e580bd 100644 --- a/xml/impl/src/com/intellij/psi/impl/source/xml/TagNameReference.java +++ b/xml/impl/src/com/intellij/psi/impl/source/xml/TagNameReference.java @@ -222,13 +222,13 @@ public class TagNameReference implements PsiReference { LookupElementBuilder lookupElement = LookupElementBuilder.create(qname); final int separator = qname.indexOf(':'); if (separator > 0) { - lookupElement = lookupElement.addLookupString(qname.substring(separator + 1)); + lookupElement = lookupElement.withLookupString(qname.substring(separator + 1)); } String ns = nsInfo.get(i); if (StringUtil.isNotEmpty(ns)) { - lookupElement = lookupElement.setTypeText(ns, true); + lookupElement = lookupElement.withTypeText(ns, true); } - elements.add(lookupElement.setInsertHandler(XmlTagInsertHandler.INSTANCE)); + elements.add(lookupElement.withInsertHandler(XmlTagInsertHandler.INSTANCE)); } return elements.toArray(new LookupElement[elements.size()]); } diff --git a/xml/impl/src/com/intellij/psi/impl/source/xml/XmlAttributeImpl.java b/xml/impl/src/com/intellij/psi/impl/source/xml/XmlAttributeImpl.java index cd80276b75f7..de8bd97d61a2 100644 --- a/xml/impl/src/com/intellij/psi/impl/source/xml/XmlAttributeImpl.java +++ b/xml/impl/src/com/intellij/psi/impl/source/xml/XmlAttributeImpl.java @@ -469,13 +469,13 @@ public class XmlAttributeImpl extends XmlElementImpl implements XmlAttribute { } LookupElementBuilder element = LookupElementBuilder.create(name); if (descriptor instanceof PsiPresentableMetaData) { - element = element.setIcon(((PsiPresentableMetaData)descriptor).getIcon()); + element = element.withIcon(((PsiPresentableMetaData)descriptor).getIcon()); } final int separator = name.indexOf(':'); if (separator > 0) { - element = element.addLookupString(name.substring(separator + 1)); + element = element.withLookupString(name.substring(separator + 1)); } - variants.add(element.setCaseSensitive(caseSensitive).setInsertHandler(XmlAttributeInsertHandler.INSTANCE)); + variants.add(element.withCaseSensitivity(caseSensitive).withInsertHandler(XmlAttributeInsertHandler.INSTANCE)); } } } diff --git a/xml/impl/src/com/intellij/xml/util/AnchorReference.java b/xml/impl/src/com/intellij/xml/util/AnchorReference.java index c95a026da4af..6c5138c802b3 100644 --- a/xml/impl/src/com/intellij/xml/util/AnchorReference.java +++ b/xml/impl/src/com/intellij/xml/util/AnchorReference.java @@ -189,7 +189,7 @@ class AnchorReference implements PsiReference, EmptyResolveMessageProvider { String[] variants = idMap.keySet().toArray(new String[idMap.size()]); LookupElement[] elements = new LookupElement[variants.length]; for (int i = 0, variantsLength = variants.length; i < variantsLength; i++) { - elements[i] = LookupElementBuilder.create(variants[i]).setCaseSensitive(true); + elements[i] = LookupElementBuilder.create(variants[i]).withCaseSensitivity(true); } return elements; } diff --git a/xml/impl/src/com/intellij/xml/util/UserColorLookup.java b/xml/impl/src/com/intellij/xml/util/UserColorLookup.java index 29c431f04c7f..ebab2d6148c1 100644 --- a/xml/impl/src/com/intellij/xml/util/UserColorLookup.java +++ b/xml/impl/src/com/intellij/xml/util/UserColorLookup.java @@ -39,12 +39,13 @@ public class UserColorLookup extends LookupElementDecorator { private static final String COLOR_STRING = XmlBundle.message("choose.color.in.color.lookup"); public UserColorLookup() { - super(PrioritizedLookupElement.withPriority(LookupElementBuilder.create(COLOR_STRING).setInsertHandler(new InsertHandler() { - @Override - public void handleInsert(InsertionContext context, LookupElement item) { - handleUserSelection(context); - } - }), LookupValueWithPriority.HIGH)); + super(PrioritizedLookupElement.withPriority(LookupElementBuilder.create(COLOR_STRING).withInsertHandler( + new InsertHandler() { + @Override + public void handleInsert(InsertionContext context, LookupElement item) { + handleUserSelection(context); + } + }), LookupValueWithPriority.HIGH)); } private static void handleUserSelection(InsertionContext context) { diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RncCompletionData.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RncCompletionData.java index 35fff7ece61f..c83739307839 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RncCompletionData.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RncCompletionData.java @@ -100,7 +100,7 @@ public class RncCompletionData extends CompletionData { public Object[] get(PsiElement context, CompletionContext completionContext) { return ContainerUtil.map2Array(doGetKeywords(context), LookupElement.class, new Function() { public LookupElement fun(String s) { - return TailTypeDecorator.withTail(LookupElementBuilder.create(s).setBold(), TailType.SPACE); + return TailTypeDecorator.withTail(LookupElementBuilder.create(s).bold(), TailType.SPACE); } }); }